Skip to content

Syntax fix in ci file #18

Syntax fix in ci file

Syntax fix in ci file #18

Workflow file for this run

name: CI
on:
push:
branches: ["main"]
tags:
- "v*"
pull_request:
branches: ["main"]
jobs:
build-and-test:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
# Get code
- name: Checkout repository
uses: actions/checkout@v4
# Set up Python
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.11"
# Cache pip dependencies
- name: Cache pip
uses: actions/cache@v4
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('backend/requirements.txt') }}
restore-keys: |
${{ runner.os }}-pip
# Install dependencies
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r backend/requirements.txt
# Lint with Ruff
- name: Lint with Ruff
run: |
ruff check backend/app backend/tests
# Ruff formatting check
- name: Ruff format check
run: |
ruff format --check backend/app backend/tests
# Run tests
- name: Run tests
run: |
pytest backend/tests/
# Log in to Github Container Registry
- name: Log in to GHCR
if: github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/v')
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
# Semantic Docker image tagging (relesae-grade)
- name: Docker metadata
id: meta
uses: docker/metadata-action@v5
with:
images: ghcr.io/${{ github.repository_owner }}/eventrelay
tags: |
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
type=sha
# Build and push docker image (for main only)
- name: Build and push Docker image
uses: docker/build-push-action@v5
if: github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/v')
with:
context: backend
file: backend/Dockerfile
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}