docs: adapt README.md from country-template #110
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Extension-Template | |
on: | |
push: | |
branches: [master] | |
pull_request: | |
types: [assigned, opened, reopened, synchronize, ready_for_review] | |
workflow_dispatch: | |
jobs: | |
build: | |
runs-on: ubuntu-22.04 | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Cache tests | |
uses: actions/cache@v4 | |
with: | |
path: | | |
Makefile | |
openfisca_extension_template/tests | |
poetry.lock | |
pyproject.toml | |
key: tests-${{ github.sha }} | |
- name: Cache build | |
id: cache-build | |
uses: actions/cache@v4 | |
with: | |
path: dist | |
key: build-${{ hashFiles('poetry.lock') }}-${{ github.sha }} | |
- name: Install Poetry | |
run: pipx install poetry | |
- name: Set up Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: 3.9.20 | |
cache: 'poetry' | |
- name: Install dependencies | |
run: make install | |
- name: Build package | |
if: steps.cache-build.outputs.cache-hit != 'true' | |
run: poetry build | |
lint: | |
runs-on: ubuntu-24.04 | |
needs: [build] | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Restore tests | |
uses: actions/cache@v4 | |
with: | |
path: | | |
Makefile | |
openfisca_extension_template/tests | |
poetry.lock | |
pyproject.toml | |
key: tests-${{ github.sha }} | |
- name: Install Poetry | |
run: pipx install poetry | |
- name: Set up Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: 3.9.20 | |
cache: 'poetry' | |
- name: Lint files | |
run: make lint | |
test: | |
runs-on: ubuntu-24.04 | |
needs: [build] | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Restore tests | |
uses: actions/cache@v4 | |
with: | |
path: | | |
Makefile | |
openfisca_extension_template/tests | |
poetry.lock | |
pyproject.toml | |
key: tests-${{ github.sha }} | |
- name: Install Tox | |
run: pipx install tox | |
- name: Set up Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: 3.9.20 | |
- name: Test files | |
run: tox -r -e py39 | |
dist: | |
runs-on: ubuntu-24.04 | |
needs: [build] | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Restore tests | |
uses: actions/cache@v4 | |
with: | |
path: | | |
Makefile | |
openfisca_extension_template/tests | |
poetry.lock | |
pyproject.toml | |
key: tests-${{ github.sha }} | |
- name: Install Tox | |
run: pipx install tox | |
- name: Set up Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: 3.9.20 | |
- name: Check built package | |
run: tox -r -e dist | |
check-version-and-changelog: | |
runs-on: ubuntu-22.04 | |
needs: [lint, test, dist] # Last job to run | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 # Fetch all the tags | |
- name: Install Poetry | |
run: pipx install poetry | |
- 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. | |
check-for-functional-changes: | |
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@v4 | |
with: | |
fetch-depth: 0 # Fetch all the tags | |
- id: stop-early | |
run: if "./.github/has-functional-changes.sh" ; then echo "::set-output name=status::success" ; fi | |
deploy: | |
runs-on: ubuntu-22.04 | |
needs: [check-for-functional-changes] | |
if: needs.check-for-functional-changes.outputs.status == 'success' | |
env: | |
PYPI_USERNAME: __token__ | |
PYPI_PASSWORD: ${{ secrets.PYPI_TOKEN_OPENFISCA_BOT }} | |
steps: | |
- 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@v4 | |
with: | |
path: dist | |
key: build-${{ hashFiles('poetry.lock') }}-${{ github.sha }} | |
- name: Upload dist to PyPi | |
run: poetry publish --username $PYPI_USERNAME --password $PYPI_PASSWORD | |
- name: Publish a git tag | |
run: | | |
git tag $(poetry version --short) | |
git push --tags # update the repository version |