Skip to content

Commit

Permalink
build: test built version (#158)
Browse files Browse the repository at this point in the history
* Technical Changes
* Details:
  - Run tests in absolute isolation
    - Uses `tox` to test builds in isolation
  • Loading branch information
bonjourmauko authored Oct 18, 2024
2 parents 3b3a980 + 3430b7f commit de83b9e
Show file tree
Hide file tree
Showing 6 changed files with 366 additions and 170 deletions.
44 changes: 27 additions & 17 deletions .github/workflows/validate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,29 +14,36 @@ jobs:
needs: [ build ]
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0 # Fetch all the tags

- name: Install Tox
run: pipx install tox

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: 3.9.12

- name: Restore build
uses: actions/cache@v4
with:
path: ${{ env.pythonLocation }}
key: build-${{ env.pythonLocation }}-${{ hashFiles('pyproject.toml') }}-${{ github.sha }}
- name: Lint files
run: tox -r -e lint

test-yaml:
runs-on: ubuntu-22.04
needs: [ build ]
steps:
- uses: actions/checkout@v4

- run: make check-syntax-errors
- name: Install Tox
run: pipx install tox

- name: Lint Python files
run: make check-style
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: 3.9.12

- name: Lint YAML tests
run: make check-yaml
- name: Test files
run: tox -r -e py39

test-yaml:
test-dist:
runs-on: ubuntu-22.04
needs: [ build ]
steps:
Expand All @@ -47,13 +54,16 @@ jobs:
with:
python-version: 3.9.12

- name: Restore build
- name: Restore built package
uses: actions/cache@v4
with:
path: ${{ env.pythonLocation }}
key: build-${{ env.pythonLocation }}-${{ hashFiles('pyproject.toml') }}-${{ github.sha }}
path: dist
key: release-${{ env.pythonLocation }}-${{ hashFiles('pyproject.toml') }}-${{ github.sha }}

- run: make test
- name: Test the built package
run: |
pip install twine
twine check dist/*
test-api:
runs-on: ubuntu-22.04
Expand Down
9 changes: 8 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# Changelog

### 7.1.7 [#158](https://github.com/openfisca/country-template/pull/158)

* Technical improvement.
* Details:
- Run tests in absolute isolation
- Uses `tox` to test builds in isolation

### 7.1.6 [#156](https://github.com/openfisca/country-template/pull/156)

* Minor change.
Expand Down Expand Up @@ -478,7 +485,7 @@ name: Housing tax

* Minor change.
* Details:
- Make boostrap script portable.
- Make bootstrap script portable.

## 3.2.0 - [#43](https://github.com/openfisca/country-template/pull/43)

Expand Down
104 changes: 70 additions & 34 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,36 +1,45 @@
> This file defines the rules to follow to contribute to your repository.
> The rules suggested here are what we generally use for OpenFisca country packages.
> You can of course edit them, and you should probably remove this block :)
> This file defines the rules to follow to contribute to your repository. The
> rules suggested here are what we generally use for OpenFisca country
> packages. You can of course edit them, and you should probably remove this
> block :)
Thank you for wanting to contribute to OpenFisca! :smiley:

TL;DR: [GitHub Flow](https://guides.github.com/introduction/flow/), [SemVer](http://semver.org/).

TL;DR: [GitHub Flow](https://guides.github.com/introduction/flow/),
[SemVer](http://semver.org/).

## Pull requests

We follow the [GitHub Flow](https://guides.github.com/introduction/flow/): all code contributions are submitted via a pull request towards the `main` branch.
We follow the [GitHub Flow](https://guides.github.com/introduction/flow/): all
code contributions are submitted via a pull request towards the `main` branch.

Opening a Pull Request means you want that code to be merged. If you want to only discuss it, send a link to your branch along with your questions through whichever communication channel you prefer.
Opening a Pull Request means you want that code to be merged. If you want to
only discuss it, send a link to your branch along with your questions through
whichever communication channel you prefer.

### Peer reviews

All pull requests must be reviewed by someone else than their original author.

> In case of a lack of available reviewers, one may review oneself, but only after at least 24 hours have passed without working on the code to review.
To help reviewers, make sure to add to your PR a **clear text explanation** of your changes.
> In case of a lack of available reviewers, one may review oneself, but only
> after at least 24 hours have passed without working on the code to review.
In case of breaking changes, you **must** give details about what features were deprecated.
To help reviewers, make sure to add to your PR a **clear text explanation** of
your changes.

> You must also provide guidelines to help users adapt their code to be compatible with the new version of the package.
In case of breaking changes, you **must** give details about what features were
deprecated.

> You must also provide guidelines to help users adapt their code to be
> compatible with the new version of the package.
## Advertising changes

### Version number

We follow the [semantic versioning](http://semver.org/) spec: any change impacts the version number, and the version number conveys API compatibility information **only**.
We follow the [semantic versioning](http://semver.org/) spec: any change
impacts the version number, and the version number conveys API compatibility
information **only**.

Examples:

Expand All @@ -48,51 +57,78 @@ Examples:

### Changelog

openfisca-country_template changes must be understood by users who don't necessarily work on the code. The Changelog must therefore be as explicit as possible.
openfisca-country_template changes must be understood by users who don't
necessarily work on the code. The Changelog must therefore be as explicit as
possible.

Each change must be documented with the following elements:

- On the first line appears as a title the version number, as well as a link towards the Pull Request introducing the change. The title level must match the incrementation level of the version.

- On the first line appears as a title the version number, as well as a link
towards the Pull Request introducing the change. The title level must match
the incrementation level of the version.

> For instance :
>
> # 13.0.0 - [#671](https://example.com/repository/pull/671)
>
> ## 13.2.0 - [#676](https://example.com/repository/pull/676)
>
> ### 13.1.5 - [#684](https://example.com/repository/pull/684)
- The second line indicates the type of the change. The possible types are:
- `Tax and benefit system evolution`: Calculation improvement, fix, or update. Impacts the users interested in calculations.
- `Technical improvement`: Performances improvement, installing process change, formula syntax change… Impacts the users who write legislation and/or deploy their own instance.
- `Crash fix`: Impact all reusers.
- `Minor change`: Refactoring, metadata… Has no impact on users.

- In the case of a `Tax and benefit system evolution`, the following elements must then be specified:
- The periods impacted by the change. To avoid any ambiguity, the start day and/or the end day of the impacted periods must be precised. For instance, `from 01/01/2017` is correct, but `from 2017` is not, as it is ambiguous: it is not clear wheter 2017 is included or not in the impacted period.
- The tax and benefit system areas impacted by the change. These areas are described by the relative paths to the modified files, without the `.py` extension.
- `Tax and benefit system evolution`: Calculation improvement, fix, or update.
Impacts the users interested in calculations.

- `Technical improvement`: Performances improvement, installing process change,
formula syntax change… Impacts the users who write legislation and/or deploy
their own instance.

- `Crash fix`: Impact all reusers.

- `Minor change`: Refactoring, metadata… Has no impact on users.

- In the case of a `Tax and benefit system evolution`, the following elements
must then be specified:

- The periods impacted by the change. To avoid any ambiguity, the start day
and/or the end day of the impacted periods must be precised. For instance,
`from 01/01/2017` is correct, but `from 2017` is not, as it is ambiguous:
it is not clear whether 2017 is included or not in the impacted period.
- The tax and benefit system areas impacted by the change. These areas are
described by the relative paths to the modified files, without the `.py`
extension.

> For instance :
>
> - Impacted periods: Until 31/12/2015.
> - Impacted areas: `benefits/healthcare/universal_coverage`
- Finally, for all cases except `Minor Change`, the changes must be explicited by details given from a user perspective: in which case was an error or a problem was noticed ? What is the new available feature ? Which new behaviour is adopted.
- Finally, for all cases except `Minor Change`, the changes must be described
in an explicit manner by details given from a user perspective: in which case
was an error or a problem was noticed ? What is the new available feature ?
Which new behaviour is adopted.

> For instance:
>
> * Details :
> - Details :
> - These variables now return a yearly amount (instead of monthly):
> - `middle_school_scholarship`
> - `high_school_scholarship`
> - _The previous monthly amounts were just yearly amounts artificially divided by 12_
> - _The previous monthly amounts were just yearly amounts artificially
> divided by 12_
>
> or :
>
> * Details :
> - Use OpenFisca-Core `12.0.0`
> - Change the syntax used to declare parameters:
> - Remove "fuzzy" attribute
> - Remove "end" attribute
> - All parameters are assumed to be valid until and end date is explicitely specified with an `<END>` tag
When a Pull Request contains several disctincts changes, several paragraphs may be added to the Changelog. To be properly formatted in Markdown, these paragraphs must be separated by `<!-- -->`.
> - Details :
>
> * Use OpenFisca-Core `12.0.0`
> * Change the syntax used to declare parameters:
> - Remove "fuzzy" attribute
> - Remove "end" attribute
> - All parameters are assumed to be valid until and end date is explicitly
> specified with an `<END>` tag
When a Pull Request contains several distinct changes, several paragraphs may
be added to the Changelog. To be properly formatted in Markdown, these
paragraphs must be separated by `<!-- -->`.
19 changes: 6 additions & 13 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ uninstall:
clean:
rm -rf build dist
find . -name '*.pyc' -exec rm \{\} \;
find . -type d -name '__pycache__' -exec rm -r {} +

deps:
pip install --upgrade pip build twine
Expand All @@ -24,29 +25,21 @@ build: clean deps
pip uninstall --yes openfisca-country-template
find dist -name "*.whl" -exec pip install --force-reinstall {}[dev] \;

check-syntax-errors:
python -m compileall -q .

format-style:
format:
@# Do not analyse .gitignored files.
@# `make` needs `$$` to output `$`. Ref: http://stackoverflow.com/questions/2382764.
ruff format `git ls-files | grep "\.py$$"`
isort `git ls-files | grep "\.py$$"`
black `git ls-files | grep "\.py$$"`
pyproject-fmt pyproject.toml

check-style:
lint:
@# Do not analyse .gitignored files.
@# `make` needs `$$` to output `$`. Ref: http://stackoverflow.com/questions/2382764.
ruff check `git ls-files | grep "\.py$$"`
isort --check `git ls-files | grep "\.py$$"`
black --check `git ls-files | grep "\.py$$"`

check-yaml:
@# Do not analyse .gitignored files.
@# `make` needs `$$` to output `$`. Ref: http://stackoverflow.com/questions/2382764.
ruff check `git ls-files | grep "\.py$$"`
yamllint `git ls-files | grep "\.yaml$$"`

test: clean check-syntax-errors check-style
test: clean
openfisca test --country-package openfisca_country_template openfisca_country_template/tests

serve-local: build
Expand Down
Loading

0 comments on commit de83b9e

Please sign in to comment.