Training upgrade #124
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: Country-Template | |
on: | |
push: | |
branches: [ main ] | |
pull_request: | |
types: [ assigned, opened, reopened, synchronize, ready_for_review ] | |
workflow_dispatch: | |
jobs: | |
build: | |
runs-on: ubuntu-20.04 | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v2 | |
- name: Set up Python | |
uses: actions/setup-python@v2 | |
with: | |
python-version: 3.9.9 # 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. | |
- name: Cache build | |
id: restore-build | |
uses: actions/cache@v2 | |
with: | |
path: ${{ env.pythonLocation }} | |
key: build-${{ env.pythonLocation }}-${{ hashFiles('setup.py') }}-${{ github.sha }} # Cache the entire build Python environment | |
restore-keys: | | |
build-${{ env.pythonLocation }}-${{ hashFiles('setup.py') }} | |
build-${{ env.pythonLocation }}- | |
- name: Build package | |
run: make build | |
- name: Cache release | |
id: restore-release | |
uses: actions/cache@v2 | |
with: | |
path: dist | |
key: release-${{ env.pythonLocation }}-${{ hashFiles('setup.py') }}-${{ github.sha }} | |
lint-files: | |
runs-on: ubuntu-20.04 | |
needs: [ build ] | |
steps: | |
- uses: actions/checkout@v2 | |
with: | |
fetch-depth: 0 # Fetch all the tags | |
- name: Set up Python | |
uses: actions/setup-python@v2 | |
with: | |
python-version: 3.9.9 | |
- name: Cache build | |
id: restore-build | |
uses: actions/cache@v2 | |
with: | |
path: ${{ env.pythonLocation }} | |
key: build-${{ env.pythonLocation }}-${{ hashFiles('setup.py') }}-${{ github.sha }} | |
- run: make check-syntax-errors | |
- run: make check-style | |
- name: Lint Python files | |
run: "${GITHUB_WORKSPACE}/.github/lint-changed-python-files.sh" | |
- name: Lint YAML tests | |
run: "${GITHUB_WORKSPACE}/.github/lint-changed-yaml-tests.sh" | |
test-yaml: | |
runs-on: ubuntu-20.04 | |
needs: [ build ] | |
steps: | |
- uses: actions/checkout@v2 | |
- name: Set up Python | |
uses: actions/setup-python@v2 | |
with: | |
python-version: 3.9.9 | |
- name: Cache build | |
id: restore-build | |
uses: actions/cache@v2 | |
with: | |
path: ${{ env.pythonLocation }} | |
key: build-${{ env.pythonLocation }}-${{ hashFiles('setup.py') }}-${{ github.sha }} | |
- run: openfisca test --country-package openfisca_country_template openfisca_country_template/tests | |
test-api: | |
runs-on: ubuntu-20.04 | |
needs: [ build ] | |
steps: | |
- uses: actions/checkout@v2 | |
- name: Set up Python | |
uses: actions/setup-python@v2 | |
with: | |
python-version: 3.9.9 | |
- name: Cache build | |
id: restore-build | |
uses: actions/cache@v2 | |
with: | |
path: ${{ env.pythonLocation }} | |
key: build-${{ env.pythonLocation }}-${{ hashFiles('setup.py') }}-${{ github.sha }} | |
- name: Test the Web API | |
run: "${GITHUB_WORKSPACE}/.github/test-api.sh" | |
check-version-and-changelog: | |
runs-on: ubuntu-20.04 | |
needs: [ lint-files, test-yaml, test-api ] # Last job to run | |
steps: | |
- uses: actions/checkout@v2 | |
with: | |
fetch-depth: 0 # Fetch all the tags | |
- name: Set up Python | |
uses: actions/setup-python@v2 | |
with: | |
python-version: 3.9.9 | |
- name: Check version number has been properly updated | |
run: "${GITHUB_WORKSPACE}/.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-20.04 | |
if: github.ref == 'refs/heads/main' # Only triggered for the `main` branch | |
needs: [ check-version-and-changelog ] | |
outputs: | |
status: ${{ steps.stop-early.outputs.status }} | |
steps: | |
- uses: actions/checkout@v2 | |
with: | |
fetch-depth: 0 # Fetch all the tags | |
- name: Set up Python | |
uses: actions/setup-python@v2 | |
with: | |
python-version: 3.9.9 | |
- id: stop-early | |
run: if "${GITHUB_WORKSPACE}/.github/has-functional-changes.sh" ; then echo "::set-output name=status::success" ; fi | |
deploy: | |
runs-on: ubuntu-20.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 }} | |
steps: | |
- uses: actions/checkout@v2 | |
with: | |
fetch-depth: 0 # Fetch all the tags | |
- name: Set up Python | |
uses: actions/setup-python@v2 | |
with: | |
python-version: 3.9.9 | |
- name: Cache build | |
id: restore-build | |
uses: actions/cache@v2 | |
with: | |
path: ${{ env.pythonLocation }} | |
key: build-${{ env.pythonLocation }}-${{ hashFiles('setup.py') }}-${{ github.sha }} | |
- name: Cache release | |
id: restore-release | |
uses: actions/cache@v2 | |
with: | |
path: dist | |
key: release-${{ env.pythonLocation }}-${{ hashFiles('setup.py') }}-${{ github.sha }} | |
- name: Upload a Python package to PyPi | |
run: twine upload dist/* --username $PYPI_USERNAME --password $PYPI_PASSWORD | |
- name: Publish a git tag | |
run: "${GITHUB_WORKSPACE}/.github/publish-git-tag.sh" |