build: test built version #73
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: Install Poetry | |
run: pipx install poetry | |
- name: Set up Python | |
uses: actions/setup-python@v5 | |
with: | |
# 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@v4 | |
with: | |
path: | | |
Makefile | |
openfisca_extension_template/tests | |
poetry.lock | |
tox.ini | |
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: 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: Install Poetry | |
run: pipx install poetry | |
- name: Set up Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: 3.9.20 | |
cache: poetry | |
cache-dependency-path: poetry.lock | |
- name: Install dependencies | |
run: make install | |
- name: Lint files | |
run: make lint | |
test: | |
runs-on: ubuntu-22.04 | |
needs: [build] | |
steps: | |
- name: Install Tox | |
run: pipx install tox | |
- name: Set up Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: 3.9.20 | |
- name: Restore tests | |
uses: actions/cache@v4 | |
with: | |
path: | | |
Makefile | |
openfisca_extension_template/tests | |
poetry.lock | |
tox.ini | |
key: tests-${{ github.sha }} | |
- name: Restore build | |
uses: actions/cache@v4 | |
with: | |
path: dist | |
key: build-${{ hashFiles('poetry.lock') }}-${{ github.sha }} | |
- name: Run the test suite | |
run: tox -r -e py39 | |
check-version-and-changelog: | |
runs-on: ubuntu-22.04 | |
needs: [lint, test] # 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 |