chore: update requirements management #43
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: "Build" | |
on: | |
push: | |
branches: | |
- main | |
- maintenance/* | |
tags: | |
- "v*.*.*" | |
pull_request: | |
branches: | |
- main | |
- maintenance/* | |
types: [opened, synchronize, reopened, ready_for_review] | |
paths-ignore: | |
- "**.png" | |
- "**.gif" | |
- "**.svg" | |
- "**.jpeg" | |
workflow_dispatch: | |
concurrency: | |
group: ${{ github.ref }}-${{ github.workflow }}-checks | |
cancel-in-progress: true | |
env: | |
PIP_CONFIG_FILE: /dev/null | |
jobs: | |
root_checks: | |
name: Root checks | |
timeout-minutes: 10 | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout current branch | |
uses: actions/checkout@v3 | |
- name: Ensure remote mk targets are present | |
run: | | |
make init-mk | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: Install Tools with asdf | |
uses: asdf-vm/actions/install@v2.2.0 | |
- name: Run pre-commit checks | |
run: | | |
poetry install --only=dev | |
source .venv/bin/activate | |
pre-commit run -a | |
# We only check docs for now | |
- uses: dorny/paths-filter@v2 | |
id: filter | |
with: | |
filters: | | |
can_apply: | |
- '**/*.md' | |
- name: Lint Docs | |
if: steps.filter.outputs.can_apply == 'true' | |
uses: DavidAnson/markdownlint-cli2-action@v9 | |
with: | |
globs: | | |
**/*.md | |
- name: Check if requirements*.txt are up to date with poetry.lock | |
run: | | |
if ! test -f "requirements.txt" || ! test -f "requirements_dev.txt"; then | |
echo "[ERROR] Either requirements.txt or requirements_dev.txt (or both) does not exist" | |
echo "[ERROR] Make sure to run 'make generate-requirements-files' with remote make targets >= mk-0.7.0" | |
exit 1 | |
fi | |
make generate-requirements-files | |
changes_count=$(git status --porcelain --untracked-files requirements.txt requirements_dev.txt | wc -l) | |
if [[ "$changes_count" -ne 0 ]] ; then | |
echo "You failed to keep requirements files synchronized with poetry.lock" | |
git status --porcelain --untracked-files requirements.txt | |
git diff requirements.txt requirements_dev.txt | |
echo | |
exit 1 | |
else | |
echo "Nothing to say, requirements*.txt files seem OK" | |
fi | |
build-python: | |
name: Build python artifacts | |
runs-on: ubuntu-latest | |
needs: root_checks | |
timeout-minutes: 20 | |
strategy: | |
matrix: | |
python_version: | |
- 3.8 | |
- 3.9 | |
- "3.10" | |
- 3.11 | |
steps: | |
- name: Checkout current branch | |
uses: actions/checkout@v3 | |
- name: Inject slug/short variables | |
uses: rlespinasse/github-slug-action@v4.x | |
- name: Setup Python | |
uses: actions/setup-python@v4 | |
with: | |
python-version: ${{ matrix.python_version }} | |
- name: Ensure remote mk targets are present | |
run: | | |
make init-mk | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: Get poetry version from .tool-versions | |
id: get-poetry-version | |
run: | | |
echo "POETRY_VERSION=$(grep poetry .tool-versions | cut -d " " -f2)" >> "${GITHUB_OUTPUT}" | |
- name: Install poetry ${{ steps.get-poetry-version.outputs.POETRY_VERSION }} | |
uses: abatilo/actions-poetry@v2 | |
with: | |
poetry-version: ${{ steps.get-poetry-version.outputs.POETRY_VERSION }} | |
- name: Prepare venv | |
run: | | |
poetry install | |
- name: Run linters | |
run: | | |
echo "Activate venv" | |
eval "$(make echo-venv-activate-cmd)" | |
echo "Run linters" | |
make lint | |
- name: Run unit tests | |
run: | | |
echo "Activate venv" | |
eval "$(make echo-venv-activate-cmd)" | |
echo "Run unit tests" | |
make unit-tests | |
- name: Setup BATS | |
uses: mig4/setup-bats@v1.2.0 | |
with: | |
bats-version: 1.5.0 | |
- name: Run integration tests | |
run: | | |
echo "Activate venv" | |
source .venv/bin/activate | |
echo "Run integration tests" | |
make integration-tests | |
- name: Check that we can build a package | |
run: | | |
poetry build | |
ls dist | |
release: | |
name: Release | |
runs-on: ubuntu-latest | |
needs: build-python | |
timeout-minutes: 20 | |
steps: | |
- name: Checkout current branch | |
uses: actions/checkout@v3 | |
- name: Inject slug/short variables | |
uses: rlespinasse/github-slug-action@v4.x | |
- name: Do we need to release? | |
run: | | |
NEED_RELEASE= | |
if [[ "$GITHUB_REF_SLUG" == v* ]]; then | |
NEED_RELEASE=yes | |
fi | |
echo "NEED_RELEASE=${NEED_RELEASE}" >> "${GITHUB_ENV}" | |
- name: Setup Python | |
if: "${{ env.NEED_RELEASE == 'yes' }}" | |
uses: actions/setup-python@v4 | |
with: | |
python-version: "3.10" | |
- name: Ensure remote mk targets are present | |
if: "${{ env.NEED_RELEASE == 'yes' }}" | |
run: | | |
make init-mk | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: Get poetry version from .tool-versions | |
id: get-poetry-version | |
if: "${{ env.NEED_RELEASE == 'yes' }}" | |
run: | | |
echo "POETRY_VERSION=$(grep poetry .tool-versions | cut -d " " -f2)" >> "${GITHUB_OUTPUT}" | |
- name: Install poetry ${{ steps.get-poetry-version.outputs.POETRY_VERSION }} | |
if: "${{ env.NEED_RELEASE == 'yes' }}" | |
uses: abatilo/actions-poetry@v2 | |
with: | |
poetry-version: ${{ steps.get-poetry-version.outputs.POETRY_VERSION }} | |
- name: Prepare venv | |
if: "${{ env.NEED_RELEASE == 'yes' }}" | |
run: | | |
poetry install | |
- name: Publish python artifact | |
if: "${{ env.NEED_RELEASE == 'yes' }}" | |
run: | | |
echo "Publish artifacts" | |
poetry config pypi-token.pypi ${{ secrets.PYPI_TOKEN }} | |
poetry self add "poetry-dynamic-versioning[plugin]" | |
poetry build | |
poetry publish | |
- name: Login to DockerHub | |
uses: docker/login-action@v1 | |
if: "${{ env.NEED_RELEASE == 'yes' }}" | |
with: | |
username: ${{ secrets.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_TOKEN }} | |
- name: Docker build | |
if: "${{ env.NEED_RELEASE == 'yes' }}" | |
run: | | |
make docker-build APP_VERSION="${GITHUB_REF_SLUG:1}" | |
echo "Checking built image" | |
docker image ls | |
- name: Push docker images | |
if: "${{ env.NEED_RELEASE == 'yes' }}" | |
run: | | |
make docker-push docker-push-latest |