-
-
Notifications
You must be signed in to change notification settings - Fork 454
157 lines (141 loc) · 4.33 KB
/
ci.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
name: CI
on:
pull_request:
merge_group:
push:
branches:
- "master"
concurrency:
group: ${{ github.repository }}-${{ github.workflow }}
cancel-in-progress: false
jobs:
nix-matrix:
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
steps:
- uses: actions/checkout@v4
- uses: cachix/install-nix-action@v30
- id: set-matrix
name: Generate Nix Matrix
run: |
set -euo pipefail
matrix="$(nix eval --json '.#githubActions.matrix')"
echo "matrix=${matrix}" >> "$GITHUB_OUTPUT"
nix-build:
needs: nix-matrix
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
max-parallel: 10
matrix: ${{ fromJSON(needs.nix-matrix.outputs.matrix) }}
steps:
- uses: actions/checkout@v4
- uses: cachix/install-nix-action@v30
- uses: cachix/cachix-action@v15
with:
name: poetry2nix
authToken: ${{ secrets.POETRY2NIX_CACHIX_AUTH_TOKEN }}
- run: nix build -L ".#${{ matrix.attr }}" --keep-going
nix-build-shell:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os:
- ubuntu-latest
- macos-13
- macos-14
steps:
- uses: actions/checkout@v4
- uses: cachix/install-nix-action@v30
- uses: cachix/cachix-action@v15
with:
name: poetry2nix
authToken: ${{ secrets.POETRY2NIX_CACHIX_AUTH_TOKEN }}
- 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-13
- macos-14
steps:
- uses: actions/checkout@v4
- uses: cachix/install-nix-action@v30
- uses: cachix/cachix-action@v15
with:
name: poetry2nix
authToken: ${{ secrets.POETRY2NIX_CACHIX_AUTH_TOKEN }}
- run: nix flake show --all-systems
test-template:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os:
- ubuntu-latest
- macos-13
- macos-14
steps:
- uses: actions/checkout@v4
- uses: cachix/install-nix-action@v30
- uses: cachix/cachix-action@v15
with:
name: poetry2nix
authToken: ${{ secrets.POETRY2NIX_CACHIX_AUTH_TOKEN }}
- name: create flake template test directory
run: echo "TESTDIR=$(mktemp -d)" >> "$GITHUB_ENV"
- name: initialize flake from poetry2nix template
working-directory: ${{ env.TESTDIR }}
run: nix flake init --template "$GITHUB_WORKSPACE"
- name: force flake to our poetry2nix version
working-directory: ${{ env.TESTDIR }}
run: nix flake lock --override-input poetry2nix "$GITHUB_WORKSPACE"
- name: generate poetry.lock
working-directory: ${{ env.TESTDIR }}
run: nix develop '.#poetry' -c poetry lock --no-update
- name: create a minimal python package
working-directory: ${{ env.TESTDIR }}
run: |
touch README.md
mkdir poetry2nix_template_test
touch poetry2nix_template_test/__init__.py
- 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
- test-template
- nix-flake-show
steps:
- run: exit 0
release:
if: github.ref == 'refs/heads/master'
needs: collect
name: "Release"
runs-on: "ubuntu-latest"
permissions:
contents: write
pull-requests: read
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