poetry2nix/.github/workflows/ci.yml

155 lines
4.5 KiB
YAML
Raw Normal View History

2020-04-08 16:39:06 +12:00
name: CI
on:
pull_request:
2023-07-10 07:20:29 -05:00
merge_group:
push:
branches:
- "master"
2020-04-08 16:39:06 +12:00
2022-12-18 11:37:07 -05:00
concurrency:
2024-05-02 09:56:25 -04:00
group: ${{ github.repository }}-${{ github.head_ref || github.sha }}-${{ github.workflow }}
cancel-in-progress: true
2022-12-18 11:37:07 -05:00
2020-04-08 16:39:06 +12:00
jobs:
nix-matrix:
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
steps:
2023-10-02 02:00:47 +00:00
- uses: actions/checkout@v4
2024-03-08 07:23:08 +00:00
- uses: cachix/install-nix-action@v26
- id: set-matrix
name: Generate Nix Matrix
2021-12-30 07:23:53 -05:00
run: |
set -euo pipefail
matrix="$(nix eval --json '.#githubActions.matrix')"
echo "matrix=${matrix}" >> "$GITHUB_OUTPUT"
nix-build:
needs: nix-matrix
runs-on: ${{ matrix.os }}
2020-04-08 16:39:06 +12:00
strategy:
fail-fast: false
max-parallel: 10
matrix: ${{ fromJSON(needs.nix-matrix.outputs.matrix) }}
2020-04-08 16:39:06 +12:00
steps:
2023-10-02 02:00:47 +00:00
- uses: actions/checkout@v4
2024-03-08 07:23:08 +00:00
- uses: cachix/install-nix-action@v26
- uses: cachix/cachix-action@v14
with:
name: poetry2nix
signingKey: "VhaWuN3IyJVpWg+aZvTocVB+W8ziZKKRGLKR53Pkld3YRZxYOUfXZf0fvqF+LkqVW0eA60trVd5vsqNONpX9Hw=="
2023-10-25 04:52:18 -04:00
- run: nix build -L ".#${{ matrix.attr }}" --keep-going
2023-10-28 06:12:01 -04:00
nix-build-shell:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os:
- ubuntu-latest
- macos-latest
steps:
- uses: actions/checkout@v4
2024-03-08 07:23:08 +00:00
- uses: cachix/install-nix-action@v26
- uses: cachix/cachix-action@v14
2023-10-28 06:12:01 -04:00
with:
name: poetry2nix
signingKey: "VhaWuN3IyJVpWg+aZvTocVB+W8ziZKKRGLKR53Pkld3YRZxYOUfXZf0fvqF+LkqVW0eA60trVd5vsqNONpX9Hw=="
- name: compute system from nixpkgs
run: |
echo "NIXPKGS_SYSTEM=$(nix eval --raw 'nixpkgs#system')" >> "$GITHUB_ENV"
- run: nix build -L ".#devShells.${NIXPKGS_SYSTEM}.default" --keep-going
nix-flake-show:
# ensure flake-exposed endpoints (apps, packages, devShells) are of correct types
# (something like apps.${SYSTEM}.<app> can be hard to get right)
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os:
- ubuntu-latest
- macos-latest
steps:
- uses: actions/checkout@v4
2024-03-08 07:23:08 +00:00
- uses: cachix/install-nix-action@v26
- uses: cachix/cachix-action@v14
with:
name: poetry2nix
signingKey: "VhaWuN3IyJVpWg+aZvTocVB+W8ziZKKRGLKR53Pkld3YRZxYOUfXZf0fvqF+LkqVW0eA60trVd5vsqNONpX9Hw=="
- run: nix flake show --all-systems
2023-10-26 06:27:56 -04:00
test-template:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os:
- ubuntu-latest
- macos-latest
steps:
- uses: actions/checkout@v4
2024-03-08 07:23:08 +00:00
- uses: cachix/install-nix-action@v26
- uses: cachix/cachix-action@v14
2023-10-26 06:27:56 -04:00
with:
name: poetry2nix
signingKey: "VhaWuN3IyJVpWg+aZvTocVB+W8ziZKKRGLKR53Pkld3YRZxYOUfXZf0fvqF+LkqVW0eA60trVd5vsqNONpX9Hw=="
- name: create flake template test directory
run: echo "TESTDIR=$(mktemp -d)" >> "$GITHUB_ENV"
- name: initialize flake from poetry2nix template
working-directory: ${{ env.TESTDIR }}
2023-10-26 06:32:20 -04:00
run: nix flake init --template "$GITHUB_WORKSPACE"
2023-10-26 06:27:56 -04:00
- name: force flake to our poetry2nix version
working-directory: ${{ env.TESTDIR }}
run: nix flake lock --override-input poetry2nix "$GITHUB_WORKSPACE"
2023-10-26 06:27:56 -04:00
- name: generate poetry.lock
working-directory: ${{ env.TESTDIR }}
run: nix develop -c poetry lock --no-update
2023-10-26 06:38:38 -04:00
- name: create a minimal python package
working-directory: ${{ env.TESTDIR }}
run: |
2023-10-26 06:41:32 -04:00
touch README.md
2023-10-26 06:38:38 -04:00
mkdir poetry2nix_template_test
touch poetry2nix_template_test/__init__.py
2023-10-26 06:27:56 -04:00
- name: build the flake
working-directory: ${{ env.TESTDIR }}
run: nix build --keep-going -L --show-trace
collect:
runs-on: ubuntu-latest
needs:
- nix-build
- nix-build-shell
2023-10-26 06:27:56 -04:00
- test-template
- nix-flake-show
steps:
- run: exit 0
release:
if: github.ref == 'refs/heads/master'
needs: collect
name: "Release"
runs-on: "ubuntu-latest"
2024-05-02 09:56:25 -04:00
concurrency:
group: ${{ github.repository }}-${{ github.workflow }}
cancel-in-progress: false
steps:
- uses: actions/checkout@v4
- name: "Generate tag"
id: tag
run: echo tag=$(./tools/auto_version.py) >> "$GITHUB_OUTPUT"
- uses: "marvinpinto/action-automatic-releases@latest"
with:
repo_token: "${{ secrets.GITHUB_TOKEN }}"
automatic_release_tag: "${{ steps.tag.outputs.tag }}"
prerelease: false