use common taskfiles #173
Workflow file for this run
This file contains hidden or 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: ci | |
| on: | |
| push: | |
| branches: | |
| - main | |
| release: | |
| pull_request: | |
| env: | |
| POETRY_HOME: /opt/poetry | |
| POETRY_CACHE: /opt/poetry_cache | |
| POETRY_VERSION: 1.7.1 | |
| jobs: | |
| lint_and_test: | |
| runs-on: ubuntu-latest | |
| strategy: | |
| matrix: | |
| python-version: ['3.8', '3.9', '3.10', '3.11', '3.12'] | |
| steps: | |
| - run: echo "🎉 The job was automatically triggered by a ${{ github.event_name }} event. Selected python version is ${{ matrix.python-version }}." | |
| - run: echo "🐧 This job is now running on a ${{ runner.os }} server hosted by GitHub!" | |
| - run: echo "🔎 The name of your branch is ${{ github.ref }} and your repository is ${{ github.repository }}." | |
| - name: Check out repository code | |
| uses: actions/checkout@v3 | |
| - name: Install Task | |
| uses: arduino/setup-task@v2 | |
| with: | |
| version: 3.x | |
| repo-token: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Install the latest version of uv | |
| uses: astral-sh/setup-uv@v5 | |
| with: | |
| version: "latest" | |
| python-version: ${{ matrix.python-version }} | |
| - name: Install | |
| run: | | |
| task install | |
| - name: Run lint | |
| run: | | |
| if [ "${{ matrix.python-version }}" = "3.8" ]; then | |
| # As we have mypy issues with 3.8 => let's skip | |
| export LINT_MYPY=0 | |
| fi | |
| task lint | |
| env: | |
| FIX: 0 | |
| - name: Run tests | |
| run: | | |
| task test | |
| - name: Run doc | |
| if: matrix.python-version == '3.12' | |
| run: | | |
| task doc | |
| - name: Check modified files | |
| if: matrix.python-version == '3.12' | |
| run: | | |
| task no-dirty | |
| - name: Clean | |
| if: matrix.python-version == '3.12' | |
| run: | | |
| task clean | |
| - name: Check modified files (after clean) | |
| if: matrix.python-version == '3.12' | |
| run: | | |
| task no-dirty | |
| publish_pypi: | |
| runs-on: ubuntu-latest | |
| needs: lint_and_test | |
| if: github.event_name == 'release' && github.event.action == 'created' | |
| steps: | |
| - name: Check out repository code | |
| uses: actions/checkout@v3 | |
| - name: Install Task | |
| uses: arduino/setup-task@v2 | |
| with: | |
| version: 3.x | |
| repo-token: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Install the latest version of uv | |
| uses: astral-sh/setup-uv@v5 | |
| with: | |
| version: "latest" | |
| python-version: 3.12 | |
| - name: Install | |
| run: | | |
| task install | |
| - name: Override BASEURL in README.md | |
| env: | |
| BASEURL: https://github.com/fabien-marty/jinja-tree/blob/main/ | |
| run: | | |
| task doc | |
| - name: Publish on Pypi | |
| run: | | |
| VERSION=$(echo "${{ github.event.release.tag_name }}" | sed -e 's/^v//') | |
| echo "VERSION: $VERSION" | |
| uvx --from=toml-cli toml set --toml-path=pyproject.toml project.version "$VERSION" | |
| task publish | |
| env: | |
| UV_PUBLISH_TOKEN: ${{ secrets.PYPI_TOKEN }} | |
| test_docker: | |
| runs-on: ubuntu-latest | |
| needs: lint_and_test | |
| if: github.event_name != 'release' | |
| steps: | |
| - name: Check out repository code | |
| uses: actions/checkout@v4 | |
| - name: Build and push Docker image | |
| uses: docker/build-push-action@v5 | |
| with: | |
| push: false | |
| publish_docker: | |
| runs-on: ubuntu-latest | |
| if: github.event_name == 'release' && github.event.action == 'created' | |
| env: | |
| REGISTRY: ghcr.io | |
| IMAGE_NAME: ${{ github.repository }} | |
| permissions: | |
| contents: read | |
| packages: write | |
| steps: | |
| - name: Check out repository code | |
| uses: actions/checkout@v4 | |
| - name: Log in to the Container registry | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ${{ env.REGISTRY }} | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Extract metadata (tags, labels) for Docker | |
| id: meta | |
| uses: docker/metadata-action@v5 | |
| with: | |
| images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} | |
| - name: Build and push Docker image | |
| uses: docker/build-push-action@v5 | |
| with: | |
| push: true | |
| tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest | |
| labels: ${{ steps.meta.outputs.labels }} | |
| mergify-ci-status: # this is a special job for mergify | |
| runs-on: ubuntu-24.04 | |
| needs: ["lint_and_test", "test_docker"] | |
| steps: | |
| - name: Status | |
| run: | | |
| echo "OK" |