mirror of
https://github.com/copier-org/copier.git
synced 2025-05-05 15:32:54 +00:00
152 lines
4.2 KiB
YAML
152 lines
4.2 KiB
YAML
name: CI
|
|
|
|
on:
|
|
pull_request:
|
|
push:
|
|
branches: [master]
|
|
tags: ["*"]
|
|
workflow_dispatch:
|
|
inputs:
|
|
pytest_addopts:
|
|
description:
|
|
Extra options for pytest; use -vv for full details; see
|
|
https://docs.pytest.org/en/latest/example/simple.html#how-to-change-command-line-options-defaults
|
|
required: false
|
|
|
|
env:
|
|
LANG: "en_US.utf-8"
|
|
LC_ALL: "en_US.utf-8"
|
|
PRE_COMMIT_HOME: ${{ github.workspace }}/.cache/pre-commit
|
|
PYTEST_ADDOPTS: ${{ github.event.inputs.pytest_addopts }}
|
|
PYTHONIOENCODING: "UTF-8"
|
|
# renovate: datasource=pypi depName=uv
|
|
UV_VERSION: "0.6.13"
|
|
|
|
jobs:
|
|
build:
|
|
strategy:
|
|
fail-fast: false
|
|
matrix:
|
|
os:
|
|
- macos-latest
|
|
- ubuntu-latest
|
|
- windows-latest
|
|
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"]
|
|
runs-on: ${{ matrix.os }}
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
with:
|
|
fetch-depth: 0 # Needs all tags to compute dynamic version
|
|
- name: Install uv
|
|
uses: astral-sh/setup-uv@v5
|
|
with:
|
|
version: ${{ env.UV_VERSION }}
|
|
enable-cache: "true"
|
|
cache-suffix: ${{ matrix.python-version }}
|
|
- name: Set up Python ${{ matrix.python-version }}
|
|
uses: actions/setup-python@v5
|
|
with:
|
|
python-version: ${{ matrix.python-version }}
|
|
- name: Install dependencies
|
|
run: uv sync --frozen
|
|
- name: Run pytest
|
|
run: uv run poe test --cov=./ --cov-report=xml -ra .
|
|
- name: Upload coverage to Codecov
|
|
continue-on-error: true
|
|
uses: codecov/codecov-action@v5
|
|
env:
|
|
OS: ${{ matrix.os }}
|
|
PYTHON: ${{ matrix.python-version }}
|
|
with:
|
|
env_vars: OS,PYTHON
|
|
fail_ci_if_error: true
|
|
file: ./coverage.xml
|
|
flags: unittests
|
|
name: copier
|
|
token: ${{ secrets.CODECOV_TOKEN }}
|
|
|
|
flake-check:
|
|
strategy:
|
|
fail-fast: false
|
|
matrix:
|
|
os:
|
|
- macos-latest
|
|
- ubuntu-latest
|
|
runs-on: ${{ matrix.os }}
|
|
permissions:
|
|
contents: write # Allow pushing back pre-commit changes
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
|
|
# Install Nix
|
|
- uses: cachix/install-nix-action@v31
|
|
with:
|
|
nix_path: nixpkgs=channel:nixos-unstable
|
|
# Set up Cachix
|
|
- uses: cachix/cachix-action@v16
|
|
with:
|
|
authToken: ${{ secrets.CACHIX_AUTH_TOKEN }}
|
|
extraPullNames: devenv
|
|
name: copier
|
|
pushFilter: (-source$|nixpkgs\.tar\.gz$)
|
|
# Install devenv
|
|
- run: nix-env -iA devenv -f '<nixpkgs>'
|
|
|
|
# Cache for uv venv when using direnv
|
|
- uses: actions/cache@v4
|
|
with:
|
|
path: |
|
|
.cache
|
|
.devenv
|
|
.direnv
|
|
# prettier-ignore
|
|
key:
|
|
direnv-
|
|
${{ runner.os }}-
|
|
${{ runner.arch }}-
|
|
${{ hashFiles('pyproject.toml', '*.lock', '*.nix') }}
|
|
|
|
# Check direnv works as expected
|
|
- uses: JRMurr/direnv-nix-action@v4.2.0
|
|
with:
|
|
install-nix: "false"
|
|
cache-store: "false"
|
|
- run: uv run copier --version
|
|
|
|
# Run tests
|
|
- run: devenv test
|
|
|
|
publish:
|
|
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')
|
|
needs:
|
|
- build
|
|
- flake-check
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
with:
|
|
fetch-depth: 0 # Needs all tags to compute dynamic version
|
|
- name: Install uv
|
|
uses: astral-sh/setup-uv@v5
|
|
with:
|
|
version: ${{ env.UV_VERSION }}
|
|
enable-cache: "true"
|
|
cache-suffix: "3.13"
|
|
- name: Set up Python
|
|
uses: actions/setup-python@v5
|
|
with:
|
|
python-version: "3.13"
|
|
- name: Build dist
|
|
run: uv build
|
|
- name: Publish distribution 📦 to Test PyPI
|
|
uses: pypa/gh-action-pypi-publish@master
|
|
with:
|
|
user: __token__
|
|
password: ${{ secrets.test_pypi_token_copier }}
|
|
repository_url: https://test.pypi.org/legacy/
|
|
- name: Publish distribution 📦 to PyPI
|
|
uses: pypa/gh-action-pypi-publish@master
|
|
with:
|
|
user: __token__
|
|
password: ${{ secrets.pypi_token_copier }}
|