Skip to content

Commit

Permalink
Merge pull request #239 from OliverCullimore/100-wiki
Browse files Browse the repository at this point in the history
Generate Councils.md from input.json & fix some integration tests
  • Loading branch information
robbrad authored Mar 2, 2023
2 parents 37dea68 + 0097b40 commit ad91d2c
Show file tree
Hide file tree
Showing 5 changed files with 292 additions and 98 deletions.
25 changes: 25 additions & 0 deletions .github/workflows/wiki.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,34 @@ on:

jobs:
deploy-wiki:
# Only run on main branch push (e.g. after pull request merge).
if: github.event_name == 'push'
runs-on: ubuntu-latest
environment: wiki
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: '3.10'

- name: Run image
uses: abatilo/[email protected]
with:
poetry-version: '1.2.1'

- name: Install
run: make install

- name: Update Councils.md from input.json
run: make update-wiki

- name: Commit and Push Wiki changes
run: |
git config --global user.name "Wiki GitHub Action"
git config --global user.email "[email protected]"
git add wiki
git commit -m "Update Councils.md from input.json"
git push
- name: Deploy Wiki Changes
uses: Andrew-Chen-Wang/github-wiki-action@v3
Expand All @@ -28,3 +52,4 @@ jobs:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GH_MAIL: ${{ secrets.YOUR_EMAIL }}
GH_NAME: ${{ github.repository_owner }}
EXCLUDED_FILES: "generate_wiki.py"
49 changes: 18 additions & 31 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
+ [Output JSON file](#output-json-file)
+ [Council schema](#council-schema)
+ [Feature file](#feature-file)
+ [Run command](#run-command)
* [Testing](#testing)
+ [Behave (Integration Testing)](#behave--integration-testing-)
- [Running the Behave tests](#running-the-behave-tests)
Expand Down Expand Up @@ -89,8 +88,8 @@ UKBCD has two mandatory parameters when it runs - the name of the parser (sans .
| Parameter | Prompt | Notes | kwargs.get |
|--------------|----------------------|------------------------------------------|--------------------------|
| UPRN | `-u` or `--uprn` | | `kwargs.get('uprn')` |
| House number | `-n` or `--number` | Sometimes call PAON | `kwargs.get('paon')` |
| Postcode | `-p` or `--postcode` | Needs to be wrapped in quotes on the CLI | `kwargs.get('postcode')` |
| House number | `-n` or `--number` | Sometimes called PAON | `kwargs.get('paon')` |
| Postcode | `-p` or `--postcode` | Needs to be wrapped in quotes on the CLI | `kwargs.get('postcode')` |

These parameters are useful if you're using something like the requests module and need to take additional user information into the request, such as:
```commandline
Expand Down Expand Up @@ -132,7 +131,6 @@ modified:
- [ ] [Output JSON file](#output-json-file)
- [ ] [Council Schema](#council-schema)
- [ ] [Feature file](#feature-file)
- [ ] [Wiki entry](#wiki-entry)

**Note:** from here on, anything containing`<council_name>` should be replaced with the scraper's name.

Expand All @@ -145,6 +143,17 @@ Each council should have a node that matches the scraper's name. The node should
URL is mandatory, but any additional parameters like UPRN or postcode should also be provided. Councils should be
listed in alphabetical order.

A "wiki_name" argument with the council's full name should also be provided.

A "wiki_note" argument should be used where non-standard instructions of just providing UPRN/Postcode/House Number
parameters are needed.

A "wiki_command_url_override" argument should be used where parts of the URL need to be replaced by the user to allow a
valid URL to be left for the integration tests.

A new [Wiki](https://github.com/robbrad/UKBinCollectionData/wiki/Councils) entry will be generated automatically from
this file's details.

**Note:** If you want the integration test to work you must supply real, working data (a business address is
recommended - the council's address is usually a good one).

Expand All @@ -153,9 +162,12 @@ recommended - the council's address is usually a good one).

```json
"CheshireEastCouncil": {
"uprn": "100012791226",
"url": "https://online.cheshireeast.gov.uk/MyCollectionDay/SearchByAjax/GetBartecJobList?uprn=100012791226&onelineaddress=3%20COBBLERS%20YARD,%20SK9%207DZ&_=1621149987573",
"uprn": "100012791226"
}
"wiki_name": "Cheshire East Council",
"wiki_command_url_override": "https://online.cheshireeast.gov.uk/MyCollectionDay/SearchByAjax/GetBartecJobList?uprn=XXXXXXXX&onelineaddress=XXXXXXXX&_=1621149987573",
"wiki_note": "Both the UPRN and a one-line address are passed in the URL, which needs to be wrapped in double quotes. The one-line address is made up of the house number, street name and postcode.\nUse the form [here](https://online.cheshireeast.gov.uk/mycollectionday/) to find them, then take the first line and post code and replace all spaces with `%20`."
},
```
</details>

Expand Down Expand Up @@ -264,31 +276,6 @@ If this is the case, you may need to add them to the bin_type `enum` manually (u
The council's name should be added to the feature file's example list. These names are alphabetically sorted, although
`council` should always remain on line 10. The name should be wrapped in pipes.

### Run command
| Type | File location |
|------|--------------------|
| Modify | `wiki/Councils.md` |

The project contains a [Wiki](https://github.com/robbrad/UKBinCollectionData/wiki/Councils) of all run commands for
each individual scraper to tell users how they can run the script on their CLI. These are also alphabetically sorted.
Instructions for your scraper should be added to Councils.md file.

<details>
<summary>Example</summary>

````markdown
---

### Cheshire East Council
```commandline
python collect_data.py CheshireEastCouncil "https://online.cheshireeast.gov.uk/MyCollectionDay/SearchByAjax/GetBartecJobList?uprn=XXXXXXXX&onelineaddress=XXXXXXXX&_=1621149987573"
```
Note:
Both the UPRN and a one-line address are passed in the URL, which needs to be wrapped in double quotes. The one-line address is made up of the house number, street name and postcode.
Use the form [here](https://online.cheshireeast.gov.uk/mycollectionday/) to find them, then take the first line and post code and replace all spaces with `%20`.
````
</details>


## Testing
### Behave (Integration Testing)
Expand Down
5 changes: 4 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.PHONY: install pre-build build black pycodestyle
.PHONY: install pre-build build black pycodestyle update-wiki

## @CI_actions Installs the checked out version of the code to your poetry managed venv
install:
Expand Down Expand Up @@ -28,3 +28,6 @@ integration-tests: ## runs tests for the project
unit-tests:
poetry run coverage run --omit "*/tests/*" -m pytest uk_bin_collection/tests --ignore=uk_bin_collection/tests/step_defs/
poetry run coverage xml

update-wiki:
poetry run python wiki/generate_wiki.py
Loading

0 comments on commit ad91d2c

Please sign in to comment.