Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate actions to work with uv instead of rye, use commit for lint a… #23

Merged
merged 1 commit into from
Sep 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ EOF
ADD https://astral.sh/uv/install.sh uv-installer.sh

# Run the installer then remove it
RUN sh uv-installer.sh
RUN sh uv-installer.sh && rm uv-installer.sh

# Devcontainer image
FROM mcr.microsoft.com/vscode/devcontainers/base:bookworm
Expand Down
31 changes: 0 additions & 31 deletions .github/actions/extract-python-version/action.yml

This file was deleted.

53 changes: 0 additions & 53 deletions .github/actions/setup-python-with-uv/action.yml

This file was deleted.

110 changes: 60 additions & 50 deletions .github/workflows/code.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,79 +7,89 @@ jobs:
lint:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- uses: actions/checkout@v4

- name: Setup Python with uv
uses: ./.github/actions/setup-python-with-uv
- name: "Install uv"
uses: astral-sh/setup-uv@v2
with:
enable-cache: true
cache-dependency-glob: "uv.lock"

- name: "Set up Python"
uses: actions/setup-python@v5
with:
python-version-file: ".python-version"

- name: Lint
run: uv run ruff check --output-format=github .
- name: "Install the project"
run: uv sync --frozen --all-extras --dev

- name: "Pre-commit"
run: uv run pre-commit run --show-diff-on-failure --color=always --all-files
env:
SKIP: "update-version,ruff-format,hadolint"
shell: bash

format:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- uses: actions/checkout@v4

- name: Setup Python with uv
uses: ./.github/actions/setup-python-with-uv
- name: "Install uv"
uses: astral-sh/setup-uv@v2
with:
enable-cache: true
cache-dependency-glob: "uv.lock"

- name: Format
- name: "Set up Python"
uses: actions/setup-python@v5
with:
python-version-file: ".python-version"

- name: "Install the project"
run: uv sync --frozen --all-extras --dev

- name: "Format"
run: uv run ruff format . --check --diff

tests:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ['3.11', '3.12']
python-version:
- 3.11
- 3.12
include:
- python-version: "3.13.0-rc.2"
continue-on-error: true
steps:
- name: Checkout
uses: actions/checkout@v4
- uses: actions/checkout@v4

- name: Setup Python ${{ matrix.python-version }} with uv
uses: ./.github/actions/setup-python-with-uv
- name: "Install uv"
uses: astral-sh/setup-uv@v2
with:
python-version: ${{ matrix.python-version }}
enable-cache: true
cache-dependency-glob: "uv.lock"

- name: Run Pytest if directory exists
run: uv run pytest --cov=src --cov-report=xml --junitxml=junit.xml

- name: Upload test results to Codecov
if: ${{ !env.ACT }}
uses: codecov/test-results-action@v1
with:
fail_ci_if_error: true
file: junit.xml
flags: ${{ matrix.python-version }}
name: ${{ github.repository }}
token: ${{ secrets.CODECOV_TOKEN }}

- name: Upload Coverage files
uses: actions/upload-artifact@v3
- name: "Set up Python ${{ matrix.python-version }}"
uses: actions/setup-python@v5
with:
name: coverage-xml
path: coverage.xml
python-version: ${{ matrix.python-version }}

coverage:
runs-on: ubuntu-latest
needs: tests
if: ${{ always() && ! cancelled() }}
- name: "Install the project"
run: uv sync --frozen --all-extras --dev

steps:
- name: Download coverage.xml
uses: actions/download-artifact@v3
with:
name: coverage-xml
path: .
- name: "Run tests with coverage"
env:
COVERAGE_FILE: .coverage.${{ runner.os }}-py${{ matrix.python-version }}-without-deps
CONTEXT: ${{ runner.os }}-py${{ matrix.python-version }}-without-deps
run: uv run coverage run -m pytest --durations=10

- name: Upload Coverage to Codecov
- run: uv run coverage combine
- run: uv run coverage xml

- name: "Upload coverage to CodeCov"
uses: codecov/codecov-action@v4
if: ${{ !env.ACT }}
with:
fail_ci_if_error: true
file: coverage.xml
flags: unittests
name: ${{ github.repository }}
token: ${{ secrets.CODECOV_TOKEN }}

env_vars: PYTHON,OS
25 changes: 10 additions & 15 deletions .github/workflows/containers.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,16 @@ name: Container CI

on:
push:
branches: [ main ]
branches: [main]
pull_request:
branches: [ main ]
branches: [main]

jobs:
lint-container:
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v4
- uses: actions/checkout@v4

- name: Lint Dockerfile
uses: hadolint/hadolint-action@v3.1.0
Expand All @@ -27,15 +26,14 @@ jobs:
if: ${{ success() }}

steps:
- name: Checkout
uses: actions/checkout@v4
- uses: actions/checkout@v4

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Extract Python Version
id: extract-python-version
uses: ./.github/actions/extract-python-version
- name: Get version
id: python
run: echo "version=$(cat .python-version)" >> "$GITHUB_OUTPUT"

- name: Build
uses: docker/build-push-action@v6
Expand All @@ -46,7 +44,7 @@ jobs:
tags: ${{ github.repository }}:latest
build-args: |
REPOSITORY=${{ github.repository }}
PYTHON_VERSION=${{ steps.extract-python-version.outputs.python-version }}
PYTHON_VERSION=${{ steps.python.outputs.version }}

- name: Test Image
run: |
Expand All @@ -56,8 +54,7 @@ jobs:
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v4
- uses: actions/checkout@v4

- name: Lint Dockerfile
uses: hadolint/hadolint-action@v3.1.0
Expand All @@ -71,8 +68,7 @@ jobs:
if: ${{ success() }}

steps:
- name: Checkout
uses: actions/checkout@v4
- uses: actions/checkout@v4

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
Expand All @@ -84,4 +80,3 @@ jobs:
load: true
file: ./.devcontainer/Dockerfile
tags: ${{ github.repository }}:latest

12 changes: 4 additions & 8 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,7 @@ jobs:
packages: write

steps:
- name: Checkout the repository
uses: actions/checkout@v4
- uses: actions/checkout@v4

- name: Set up QEMU to build multi-platform images
uses: docker/setup-qemu-action@v3
Expand All @@ -54,13 +53,10 @@ jobs:
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Compute Environment
id: extract_version
- name: Compute Environment Variables
run: |
VERSION=$(grep -Po '(?<=^__version__ = ")[^"]*' src/dns_synchub/__about__.py)
echo "VERSION=$VERSION" >> "$GITHUB_ENV"
PYTHON_VERSION=$(cat .python-version)
echo "PYTHON_VERSION=$PYTHON_VERSION" >> "$GITHUB_ENV"
echo "VERSION=$(grep -Po '(?<=^__version__ = ")[^"]*' src/dns_synchub/__about__.py)" >> "$GITHUB_ENV"
echo "PYTHON_VERSION=$(cat .python-version)" >> "$GITHUB_ENV"
shell: bash

- name: Extract metadata (tags, labels) for Docker
Expand Down
17 changes: 10 additions & 7 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
default_stages: [commit]
repos:
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.6.4
rev: v0.6.5
hooks:
- id: ruff
name: Ruff linter
Expand All @@ -11,8 +11,9 @@ repos:
- id: ruff-format
name: Ruff format
types_or: [python, pyi]

- repo: https://github.com/executablebooks/mdformat
rev: 0.7.13
rev: 0.7.17
hooks:
- id: mdformat
additional_dependencies:
Expand All @@ -32,26 +33,28 @@ repos:
hooks:
- id: update-version
name: Update Version
entry: scripts/versioning.py
entry: uv run scripts/versioning.py
language: python
pass_filenames: false
stages: [commit]
files: ^pyproject\.toml$

- id: mypy
name: mypy
name: mypy static type checker
language: system
types: [python]
entry: uv run mypy --strict
entry: uv run mypy
pass_filenames: false

- id: pyupgrade
name: Pyupgrade
entry: pyupgrade --py311-plus
entry: uv run pyupgrade --py311-plus
types: [python]
language: system

- id: deptry
name: Deptry
entry: deptry src tests
entry: uv run deptry src tests
types: [python]
language: system
pass_filenames: false
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

All notable changes to this project will be documented in this file.

## [Unreleased]
## \[Unreleased\]

### Added

Expand Down
Loading
Loading