[MNT] move doctests + add dependency #1
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: Build CI Images | |
| on: | |
| push: | |
| branches: | |
| - main | |
| - dev | |
| paths: | |
| - 'pyproject.toml' | |
| - 'docs/requirements.txt' | |
| - '.github/docker/Dockerfile' | |
| - '.github/workflows/build-ci-image.yml' | |
| workflow_dispatch: | |
| inputs: | |
| python_versions: | |
| description: 'Python versions to build (comma-separated, e.g., "3.11,3.12" or "all")' | |
| required: false | |
| default: 'all' | |
| env: | |
| REGISTRY: ghcr.io | |
| IMAGE_NAME: simonblanke/hyperactive-ci | |
| jobs: | |
| build-and-push: | |
| name: Build Python ${{ matrix.python-version }} | |
| runs-on: ubuntu-latest | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| python-version: ["3.10", "3.11", "3.12", "3.13", "3.14"] | |
| permissions: | |
| contents: read | |
| packages: write | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Check if version should be built | |
| id: should-build | |
| run: | | |
| INPUT="${{ github.event.inputs.python_versions }}" | |
| VERSION="${{ matrix.python-version }}" | |
| if [ -z "$INPUT" ] || [ "$INPUT" = "all" ]; then | |
| echo "build=true" >> $GITHUB_OUTPUT | |
| elif echo "$INPUT" | grep -q "$VERSION"; then | |
| echo "build=true" >> $GITHUB_OUTPUT | |
| else | |
| echo "build=false" >> $GITHUB_OUTPUT | |
| fi | |
| - name: Set up Docker Buildx | |
| if: steps.should-build.outputs.build == 'true' | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Log in to Container Registry | |
| if: steps.should-build.outputs.build == 'true' | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ${{ env.REGISTRY }} | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Extract metadata | |
| if: steps.should-build.outputs.build == 'true' | |
| id: meta | |
| uses: docker/metadata-action@v5 | |
| with: | |
| images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} | |
| tags: | | |
| type=raw,value=py${{ matrix.python-version }} | |
| type=raw,value=py${{ matrix.python-version }}-{{date 'YYYYMMDD'}} | |
| - name: Build and push Docker image | |
| if: steps.should-build.outputs.build == 'true' | |
| uses: docker/build-push-action@v5 | |
| with: | |
| context: . | |
| file: .github/docker/Dockerfile | |
| push: true | |
| tags: ${{ steps.meta.outputs.tags }} | |
| labels: ${{ steps.meta.outputs.labels }} | |
| build-args: | | |
| PYTHON_VERSION=${{ matrix.python-version }} | |
| cache-from: type=gha | |
| cache-to: type=gha,mode=max | |
| - name: Skip message | |
| if: steps.should-build.outputs.build != 'true' | |
| run: echo "Skipping Python ${{ matrix.python-version }} (not in requested versions)" | |
| summary: | |
| name: Build Summary | |
| needs: build-and-push | |
| runs-on: ubuntu-latest | |
| if: always() | |
| steps: | |
| - name: Summary | |
| run: | | |
| echo "## CI Image Build Summary" >> $GITHUB_STEP_SUMMARY | |
| echo "" >> $GITHUB_STEP_SUMMARY | |
| echo "Images pushed to: \`${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}\`" >> $GITHUB_STEP_SUMMARY | |
| echo "" >> $GITHUB_STEP_SUMMARY | |
| echo "Available tags:" >> $GITHUB_STEP_SUMMARY | |
| echo "- \`py3.10\`, \`py3.11\`, \`py3.12\`, \`py3.13\`, \`py3.14\`" >> $GITHUB_STEP_SUMMARY | |
| echo "" >> $GITHUB_STEP_SUMMARY | |
| echo "Usage in workflows:" >> $GITHUB_STEP_SUMMARY | |
| echo "\`\`\`yaml" >> $GITHUB_STEP_SUMMARY | |
| echo "jobs:" >> $GITHUB_STEP_SUMMARY | |
| echo " test:" >> $GITHUB_STEP_SUMMARY | |
| echo " runs-on: ubuntu-latest" >> $GITHUB_STEP_SUMMARY | |
| echo " container:" >> $GITHUB_STEP_SUMMARY | |
| echo " image: ghcr.io/simonblanke/hyperactive-ci:py3.11" >> $GITHUB_STEP_SUMMARY | |
| echo "\`\`\`" >> $GITHUB_STEP_SUMMARY |