Add CI workflow for automated builds and tests in Github
- Adds a GitHub Actions workflow for linting, testing, and pushing to GHCR. - Uses uv for environment management and dependency installation. - Includes Ruff for linting and pytest for testing. - Uploads test coverage to Codecov. - Pushes the Docker image to GHCR on pushes to the master branch.
This commit is contained in:
parent
446b613816
commit
e865ebfee1
65
.github/workflows/ci.yml
vendored
Normal file
65
.github/workflows/ci.yml
vendored
Normal file
@ -0,0 +1,65 @@
|
||||
name: CI + Push to GHCR
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
|
||||
jobs:
|
||||
lint:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
- name: Install uv
|
||||
run: |
|
||||
curl -LsSf https://astral.sh/uv/install.sh | sh
|
||||
echo "$HOME/.cargo/bin" >> $GITHUB_PATH
|
||||
|
||||
- name: Lint with Ruff
|
||||
run: |
|
||||
uv venv .venv
|
||||
source .venv/bin/activate
|
||||
uv sync
|
||||
uv run ruff check
|
||||
uv run ruff format --check
|
||||
|
||||
test:
|
||||
runs-on: ubuntu-latest
|
||||
needs: lint
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
- name: Install uv
|
||||
run: |
|
||||
curl -LsSf https://astral.sh/uv/install.sh | sh
|
||||
echo "$HOME/.cargo/bin" >> $GITHUB_PATH
|
||||
|
||||
- name: Run tests
|
||||
run: |
|
||||
uv venv .venv
|
||||
source .venv/bin/activate
|
||||
uv sync
|
||||
uv run pytest -v --cov=. --cov-report=xml
|
||||
|
||||
- name: Upload to Codecov
|
||||
run: bash <(curl -s https://codecov.io/bash)
|
||||
|
||||
push_to_ghcr:
|
||||
runs-on: ubuntu-latest
|
||||
needs: test
|
||||
if: github.ref == 'refs/heads/master'
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
- name: Log in to GHCR
|
||||
run: echo "${{ secrets.REGISTRY_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin
|
||||
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v2
|
||||
|
||||
- name: Build and push to GHCR
|
||||
run: |
|
||||
docker buildx build --push \
|
||||
--tag ghcr.io/${{ github.repository_owner }}/subscleaner:latest \
|
||||
.
|
Loading…
x
Reference in New Issue
Block a user