name: CI
on:
push:
branches: [main, develop]
pull_request:
branches: [main, develop]
permissions:
contents: read
packages: write
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
jobs:
build-image:
name: Build Docker Image
runs-on: ubuntu-latest
outputs:
image: ${{ steps.image.outputs.image }}
digest: ${{ steps.build.outputs.digest }}
steps:
- uses: actions/checkout@v4
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to Container Registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=ref,event=branch
type=ref,event=pr
type=sha,prefix=sha-
type=raw,value=latest,enable={{is_default_branch}}
- name: Build and push Docker image
id: build
uses: docker/build-push-action@v6
with:
context: .
platforms: linux/amd64,linux/arm64
push: true
platforms: linux/amd64,linux/arm64
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
build-args: |
BUILD_ENV=ci
cache-from: type=gha
cache-to: type=gha,mode=max
- name: Output image
id: image
run: echo "image=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}@${{ steps.build.outputs.digest }}" >> $GITHUB_OUTPUT
lint:
name: Lint
runs-on: ubuntu-latest
needs: [build-image]
container:
image: ${{ needs.build-image.outputs.image }}
options: --user root
steps:
- name: Run ruff linting
run: cd /app && uv run ruff check jira_mcp
- name: Run ruff formatting check
run: cd /app && uv run ruff format --check jira_mcp
type-check:
name: Type Check
runs-on: ubuntu-latest
needs: [build-image]
container:
image: ${{ needs.build-image.outputs.image }}
options: --user root
steps:
- name: Run mypy
run: cd /app && uv run mypy jira_mcp
test:
name: Test
runs-on: ubuntu-latest
needs: [build-image]
container:
image: ${{ needs.build-image.outputs.image }}
options: --user root
steps:
- name: Run unit tests
run: cd /app && uv run pytest tests/unit -v --tb=short
- name: Run integration tests
run: cd /app && uv run pytest tests/integration -v --tb=short
- name: Generate test coverage
run: |
cd /app
uv run coverage run -m pytest
uv run coverage report --show-missing
uv run coverage xml
# TODO: Fix codecov upload in container environment
# - name: Upload coverage to Codecov
# uses: codecov/codecov-action@v4
# with:
# file: /app/coverage.xml
# fail_ci_if_error: false
# token: ${{ secrets.CODECOV_TOKEN }}
security:
name: Security Scan
runs-on: ubuntu-latest
needs: [build-image]
container:
image: ${{ needs.build-image.outputs.image }}
options: --user root
steps:
- name: Run safety check
run: cd /app && uv run safety check
- name: Run bandit security scan
run: cd /app && uv run bandit -r jira_mcp
build:
name: Build Package
runs-on: ubuntu-latest
needs: [build-image, lint, type-check, test, security]
container:
image: ${{ needs.build-image.outputs.image }}
options: --user root
steps:
- name: Build package
run: cd /app && uv run python -m build
- name: Upload build artifacts
uses: actions/upload-artifact@v4
with:
name: dist
path: /app/dist/