Skip to content

fix(Branch CI): Install dev dependencies #3

fix(Branch CI): Install dev dependencies

fix(Branch CI): Install dev dependencies #3

Workflow file for this run

# Workflow that runs on pushes to non-default branches
name: Non-Default Branch CI (Python)
on:
push:
branches-ignore: ["main"]
# Specify concurrency such that only one workflow can run at a time
# * Different workflow files are not affected
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
# Registry for storing Container images
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
# Ensure the GitHub token can remove packages
permissions:
packages: write
jobs:
lint-typecheck:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Setup uv
uses: astral-sh/setup-uv@v3
with:
enable-cache: true
cache-dependency-glob: "pyproject.toml"
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version-file: "pyproject.toml"
- name: Install editable package and required dependencies
run: uv sync --extra=dev
- name: Lint package
run: uv run ruff check --output-format=github .
- name: Typecheck package
run: uv run mypy .
test-unit:
runs-on: ubuntu-latest
needs: lint-typecheck
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Setup uv
uses: astral-sh/setup-uv@v3
with:
enable-cache: true
cache-dependency-glob: "pyproject.toml"
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version-file: "pyproject.toml"
- name: Install editable package and required dependencies
run: uv sync --extras=dev
# Run unittests
# * Produce JUnit XML report
- name: Run unit tests
run: uv run xmlrunner discover -s src/nwp_consumer -p "test_*.py" --output-file ut-report.xml
# Create test summary to be visualised on the job summary screen on GitHub
# * Runs even if previous steps fail
- name: Create test summary
uses: test-summary/action@v2
with:
paths: "*t-report.xml"
show: "fail, skip"
if: always()
# Define a job that builds the documentation
# * Surfaces the documentation as an artifact
build-docs:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Setup uv
uses: astral-sh/setup-uv@v3
with:
enable-cache: true
cache-dependency-glob: "pyproject.toml"
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version-file: "pyproject.toml"
- name: Install editable package and required dependencies
run: uv sync --extras=docs
- name: Build documentation
run: uv run pydoctor
- name: Upload documentation
uses: actions/upload-artifact@v4
with:
name: docs
path: docs
# * Builds and pushes an OCI Container image to the registry defined in the environment variables
# * Only runs if test job passes
build-container:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
needs: ["lint-typecheck", "test-unit"]
steps:
# Do a non-shallow clone of the repo to ensure tags are present
# * This allows setuptools-git-versioning to automatically set the version
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Buildx
uses: docker/setup-buildx-action@v2
- name: Log in to the Container registry
uses: docker/login-action@65b78e6e13532edd9afa3aa52ac7964289d1a9c1
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
# Tag the built image according to the event type
# The event is a branch commit, so use the commit sha
- name: Extract metadata (tags, labels) for Container
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=ref,event=branch
# Build and push the Container image to the registry
# * Creates a multiplatform-aware image
# * Pulls build cache from the registry
- name: Build and push container image
uses: docker/build-push-action@v4
with:
context: .
file: Containerfile
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
platforms: linux/amd64,linux/arm64
cache-from: type=registry,ref=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:buildcache