Skip to content

build: add Taskfile #118

build: add Taskfile

build: add Taskfile #118

Workflow file for this run

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: |
lib
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: |
./bashdep.sh
poetry install --all-extras --sync
- 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: |
lib
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: |
poetry run codespell \
`git ls-files "*.md" "*.yaml" "*.yml" "*.py" "*.sh"`
poetry run isort --check `git ls-files "*.py"`
poetry run ruff check `git ls-files "*.py"`
poetry run yamllint `git ls-files "*.yaml" "*.yml"`
poetry run mdformat --wrap 79 --number --check `git ls-files "*.md"`
poetry run shellcheck `git ls-files "*.sh"`
test:
runs-on: ubuntu-24.04
needs: [build]
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Restore tests
uses: actions/cache@v4
with:
path: |
lib
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 python files
run: tox -r -e py39
- name: Test shell files
run: lib/bashunit --parallel --simple tests/**/*.sh
dist:
runs-on: ubuntu-24.04
needs: [build]
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Restore tests
uses: actions/cache@v4
with:
path: |
Taskfile.yaml
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]
# Only triggered for the `master` branch
if: github.ref == 'refs/heads/master'
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