Skip to content

Commit

Permalink
Merge branch 'master' into add-poetry
Browse files Browse the repository at this point in the history
  • Loading branch information
bonjourmauko committed Oct 16, 2024
2 parents 29ea784 + c2cd78d commit 53a2be7
Show file tree
Hide file tree
Showing 15 changed files with 941 additions and 1,255 deletions.
16 changes: 16 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
root = true

[*]
charset = utf-8
end_of_line = lf
indent_size = 2
indent_style = space
insert_final_newline = true
trim_trailing_whitespace = true

[Makefile]
indent_size = 4
indent_style = tab

[*.{py,pyi,rst,toml}]
indent_size = 4
63 changes: 32 additions & 31 deletions .github/workflows/workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,22 +9,25 @@ on:

jobs:
build:
runs-on: ubuntu-20.04
runs-on: ubuntu-22.04

steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Install Poetry
run: pipx install poetry

- name: Set up Python
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: 3.7.12 # Patch version must be specified to avoid any cache confusion, since the cache key depends on the full Python version. Any potentiel difference in patches between jobs will lead to a cache not found error.
# Patch version must be specified to avoid any cache confusion, since
# the cache key depends on the full Python version. Any potential
# difference in patches between jobs will lead to a cache not found error.
python-version: 3.9.20

- name: Cache tests
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: |
Makefile
Expand All @@ -35,7 +38,7 @@ jobs:

- name: Cache build
id: cache-build
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: dist
key: build-${{ hashFiles('poetry.lock') }}-${{ github.sha }}
Expand All @@ -45,20 +48,20 @@ jobs:
run: poetry build

lint:
runs-on: ubuntu-20.04
runs-on: ubuntu-24.04
needs: [build]

steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Install Poetry
run: pipx install poetry

- name: Set up Python
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: 3.7.12 # Patch version must be specified to avoid any cache confusion, since the cache key depends on the full Python version. Any potentiel difference in patches between jobs will lead to a cache not found error.
python-version: 3.9.20
cache: poetry
cache-dependency-path: poetry.lock

Expand All @@ -69,20 +72,20 @@ jobs:
run: make lint

test:
runs-on: ubuntu-20.04
runs-on: ubuntu-22.04
needs: [build]

steps:
- name: Install Tox
run: pipx install tox

- name: Set up Python
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: 3.7.12 # Patch version must be specified to avoid any cache confusion, since the cache key depends on the full Python version. Any potentiel difference in patches between jobs will lead to a cache not found error.
python-version: 3.9.20

- name: Restore tests
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: |
Makefile
Expand All @@ -92,20 +95,20 @@ jobs:
key: tests-${{ github.sha }}

- name: Restore build
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: dist
key: build-${{ hashFiles('poetry.lock') }}-${{ github.sha }}

- name: Run the test suite
run: tox
run: tox -r -e py39

check-version-and-changelog:
runs-on: ubuntu-20.04
runs-on: ubuntu-22.04
needs: [lint, test] # Last job to run

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
fetch-depth: 0 # Fetch all the tags

Expand All @@ -115,47 +118,45 @@ jobs:
- name: Check version number has been properly updated
run: ./.github/is-version-number-acceptable.sh

# GitHub Actions does not have a halt job option, to stop from deploying if no functional changes were found.
# We build a separate job to substitute the halt option.
# The `deploy` job is dependent on the output of the `check-for-functional-changes`job.
# GitHub Actions does not have a halt job option, to stop from deploying if
# no functional changes were found. We build a separate job to substitute the
# halt option. The `deploy` job is dependent on the output of the
# `check-for-functional-changes`job.
check-for-functional-changes:
runs-on: ubuntu-20.04
runs-on: ubuntu-22.04
needs: [check-version-and-changelog]
if: github.ref == 'refs/heads/master' # Only triggered for the `master` branch

outputs:
status: ${{ steps.stop-early.outputs.status }}

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
fetch-depth: 0 # Fetch all the tags

- name: Install Poetry
run: pipx install poetry

- id: stop-early
run: if "./.github/has-functional-changes.sh" ; then echo "::set-output name=status::success" ; fi

deploy:
runs-on: ubuntu-20.04
runs-on: ubuntu-22.04
needs: [check-for-functional-changes]
if: needs.check-for-functional-changes.outputs.status == 'success'

env:
PYPI_USERNAME: openfisca-bot
PYPI_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
PYPI_USERNAME: __token__
PYPI_PASSWORD: ${{ secrets.PYPI_TOKEN_OPENFISCA_BOT }}

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
fetch-depth: 0 # Fetch all the tags

- name: Install Poetry
run: pipx install poetry

- name: Restore build
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: dist
key: build-${{ hashFiles('poetry.lock') }}-${{ github.sha }}
Expand Down
28 changes: 28 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,34 @@
- Uses `poetry` to ensure deterministic builds
- Uses `tox` to test builds in isolation

### 1.3.15 - [#57](https://github.com/openfisca/extension-template/pull/57)

* Crash fix.
* Details:
- Add pyproject.toml
- Fix variables not being loaded
- Upgrade country-template to latest

### 1.3.14 - [#55](https://github.com/openfisca/extension-template/pull/55)

* Technical improvement.
* Details:
- Use PyPi token for authentication on CI `deploy` job
- Allows for Python package upload since the 2FA enforcement on PyPi

### 1.3.13 - [#53](https://github.com/openfisca/extension-template/pull/53)

* Minor change.
* Details:
- Improve format with isort & pyupgrade
- This to help transition to py3.8 and np1.21+

### 1.3.12 - [#52](https://github.com/openfisca/extension-template/pull/52)

* Minor change.
* Details:
- Add .editorconfig for consistency of editor settings across packages

### 1.3.11 - [#51](https://github.com/openfisca/extension-template/pull/51)

* Technical Changes
Expand Down
3 changes: 2 additions & 1 deletion MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
recursive-include openfisca_extension_template *
graft openfisca_extension_template
global-exclude *~ *.py[cod] *.so
35 changes: 20 additions & 15 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,33 +1,38 @@
all: test

uninstall:
pip freeze | grep -v "^-e" | sed "s/@.*//" | xargs pip uninstall -y
@pip freeze | grep -v "^-e" | sed "s/@.*//" | xargs pip uninstall -y

clean:
rm -rf build dist
find . -name '*.pyc' -exec rm \{\} \;
@rm -rf build dist
@find . -name '*.pyc' -exec rm \{\} \;
@find . -type d -name '__pycache__' -exec rm -r {} +

install:
@# Install OpenFisca-Extension-Template for development.
@# The editable version of OpenFisca-Extension-Template allows contributors
@# to test as they code.
pip install --upgrade pip
poetry install --sync

check-syntax-errors:
python -m compileall -q .
@pip install --upgrade pip
@poetry install --sync

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

lint: clean check-syntax-errors
lint: clean
@# Do not analyse .gitignored files.
@# `make` needs `$$` to output `$`. Ref: http://stackoverflow.com/questions/2382764.
poetry run flake8 `git ls-files | grep "\.py$$"`
poetry run pylint `git ls-files | grep "\.py$$"`
poetry run yamllint `git ls-files | grep "\.yaml$$"`
@poetry run ruff check `git ls-files | grep "\.py$$"`
@poetry run isort --check `git ls-files | grep "\.py$$"`
@poetry run black --check `git ls-files | grep "\.py$$"`

test: clean check-syntax-errors
openfisca test openfisca_extension_template/tests --country-package openfisca_country_template --extensions openfisca_extension_template
test: clean lint
@PYTEST_ADDOPTS="--import-mode importlib" \
openfisca test \
--country-package=openfisca_country_template \
--extensions=openfisca_extension_template \
openfisca_extension_template/tests
7 changes: 4 additions & 3 deletions openfisca_extension_template/__init__.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
"""
This package defines a country package extension.
"""This package defines a country package extension.
Extensions allow you to define new variables or parameters for a tax and
benefit system, while keeping their code separated from the main country
package.
They are for instance used to code local taxes and benefits.
See https://openfisca.org/doc/contribute/extensions.html
See:
https://openfisca.org/doc/contribute/extensions.html
"""
42 changes: 0 additions & 42 deletions openfisca_extension_template/local_benefit.py

This file was deleted.

Empty file.
Loading

0 comments on commit 53a2be7

Please sign in to comment.