-
Notifications
You must be signed in to change notification settings - Fork 0
242 lines (213 loc) · 8.13 KB
/
Copy pathtemplate.yaml
File metadata and controls
242 lines (213 loc) · 8.13 KB
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
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
name: "Template"
on:
workflow_dispatch:
inputs:
debug_enabled:
description: "Run the workflow with tmate.io debugging enabled"
required: true
type: boolean
default: false
force_run:
description: "Force execution even if already successful for this commit"
required: false
type: boolean
default: false
pull_request:
types: [opened, reopened, synchronize]
paths-ignore:
- "**/*.md"
- "*"
- "!flake.nix"
- "!flake.lock"
- "!pyproject.toml"
- "!justfile"
- "!packages/*/uv.lock"
- "!packages/*/pyproject.toml"
push:
branches:
- "main"
- "beta"
paths-ignore:
- "**/*.md"
- "*"
- "!flake.nix"
- "!flake.lock"
- "!pyproject.toml"
- "!justfile"
- "!packages/*/uv.lock"
- "!packages/*/pyproject.toml"
concurrency:
group: template-${{ github.event_name == 'pull_request' && github.event.pull_request.number || github.ref_name }}
cancel-in-progress: true
defaults:
run:
shell: bash
permissions:
contents: read
actions: write
jobs:
set-variables:
runs-on: ubuntu-latest
outputs:
debug: ${{ steps.set-variables.outputs.debug }}
skip_ci: ${{ steps.set-variables.outputs.skip_ci }}
checkout_ref: ${{ steps.set-variables.outputs.checkout_ref }}
checkout_rev: ${{ steps.set-variables.outputs.checkout_rev }}
steps:
- name: Set action variables
id: set-variables
env:
PR_HEAD_REF: ${{ github.event.pull_request.head.ref }}
run: |
DEBUG="false"
SKIP_CI="false"
if [[ "${{ github.event_name }}" == "workflow_dispatch" ]]; then
DEBUG="${{ inputs.debug_enabled }}"
fi
if [[ "${{ github.event_name }}" == "pull_request" ]]; then
if ${{ contains(github.event.pull_request.labels.*.name, 'skip-ci') }}; then
SKIP_CI="true"
fi
if ${{ contains(github.event.pull_request.labels.*.name, 'actions-debug') }}; then
DEBUG="true"
fi
CHECKOUT_REF="$PR_HEAD_REF"
CHECKOUT_REV="${{ github.event.pull_request.head.sha }}"
else
CHECKOUT_REF="${{ github.ref_name }}"
CHECKOUT_REV="${{ github.sha }}"
fi
echo "DEBUG=$DEBUG"
echo "SKIP_CI=$SKIP_CI"
echo "CHECKOUT_REF=$CHECKOUT_REF"
echo "CHECKOUT_REV=$CHECKOUT_REV"
{
echo "debug=$DEBUG"
echo "skip_ci=$SKIP_CI"
echo "checkout_ref=$CHECKOUT_REF"
echo "checkout_rev=$CHECKOUT_REV"
} >> "$GITHUB_OUTPUT"
test-omnix-template:
needs: [set-variables]
runs-on: ubuntu-latest
if: |
!cancelled() &&
needs.set-variables.outputs.skip_ci != 'true'
steps:
- name: Checkout repository
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
with:
fetch-depth: 0
- name: Check execution cache
id: cache
uses: ./.github/actions/cached-ci-job
with:
hash-sources: 'flake.nix flake.lock modules/**/*.nix .github/workflows/template.yaml .github/actions/setup-nix/action.yml .github/actions/cached-ci-job/action.yaml'
force-run: ${{ inputs.force_run || 'false' }}
- name: Setup Nix
if: steps.cache.outputs.should-run == 'true'
uses: ./.github/actions/setup-nix
with:
installer: full
system: x86_64-linux
enable-cachix: true
cachix-name: ${{ vars.CACHIX_CACHE_NAME }}
cachix-auth-token: ${{ secrets.CACHIX_AUTH_TOKEN }}
- name: Setup tmate debug session
if: steps.cache.outputs.should-run == 'true' && needs.set-variables.outputs.debug == 'true'
uses: mxschmitt/action-tmate@c0afd6f790e3a5564914980036ebf83216678101 # v3
- name: Install omnix
if: steps.cache.outputs.should-run == 'true'
run: nix --accept-flake-config profile install "github:juspay/omnix/v1.3.2"
- name: Test monorepo template initialization
if: steps.cache.outputs.should-run == 'true'
run: |
REPO_REF="github:sciexp/python-nix-template/${{ needs.set-variables.outputs.checkout_rev }}"
echo "Using repository reference: $REPO_REF"
pwd
rm -fr pnt-mono
nix --accept-flake-config run github:juspay/omnix/v1.3.2 -- init "$REPO_REF" -o pnt-mono --non-interactive --params '{
"package-name-kebab-case": "pnt-mono",
"package-name-snake-case": "pnt_mono",
"package-name-camel-case": "pntMono",
"repo-name": "pnt-mono",
"monorepo-package": true,
"git-org": "pnt-mono",
"author": "Pnt Mono",
"author-email": "mono@pnt.org",
"project-description": "Test monorepo template project",
"vscode": true,
"github-ci": true,
"docs": true,
"nix-template": true
}'
cd pnt-mono
git init
git config --local user.email "test@example.com"
git config --local user.name "Test User"
git commit --allow-empty -m "initial commit (empty)"
for pkg in packages/*/; do
if [ -f "$pkg/pyproject.toml" ]; then
echo "Locking $pkg"
(cd "$pkg" && nix run github:NixOS/nixpkgs/nixos-unstable#uv -- lock)
fi
done
git add .
nix flake check --accept-flake-config
nix develop --accept-flake-config -c just test-all
- name: Test single-package template initialization
if: steps.cache.outputs.should-run == 'true'
run: |
REPO_REF="github:sciexp/python-nix-template/${{ needs.set-variables.outputs.checkout_rev }}"
echo "Using repository reference: $REPO_REF"
pwd
rm -fr pnt-new
nix --accept-flake-config run github:juspay/omnix/v1.3.2 -- init "$REPO_REF" -o pnt-new --non-interactive --params '{
"package-name-kebab-case": "pnt-new",
"package-name-snake-case": "pnt_new",
"package-name-camel-case": "pntNew",
"repo-name": "pnt-new",
"monorepo-package": false,
"git-org": "pnt-new",
"author": "Pnt New",
"author-email": "new@pnt.org",
"project-description": "Test single-package template project",
"vscode": true,
"github-ci": true,
"docs": false,
"nix-template": false
}'
cd pnt-new
git init
git config --local user.email "test@example.com"
git config --local user.name "Test User"
git commit --allow-empty -m "initial commit (empty)"
for pkg in packages/*/; do
if [ -f "$pkg/pyproject.toml" ]; then
echo "Locking $pkg"
(cd "$pkg" && nix run github:NixOS/nixpkgs/nixos-unstable#uv -- lock)
fi
done
git add .
nix flake check --accept-flake-config
nix develop --accept-flake-config -c just test-all
- name: Create job result marker
if: success() && steps.cache.outputs.should-run == 'true' && steps.cache.outputs.cache-source == 'none'
shell: bash
run: |
mkdir -p "${{ steps.cache.outputs.cache-path }}"
cat > "${{ steps.cache.outputs.cache-path }}/marker" <<EOF
job: test-omnix-template
workflow: ${{ github.workflow }}
run_id: ${{ github.run_id }}
run_number: ${{ github.run_number }}
sha: ${{ needs.set-variables.outputs.checkout_rev }}
ref: ${{ needs.set-variables.outputs.checkout_ref }}
timestamp: $(date -u +%Y-%m-%dT%H:%M:%SZ)
EOF
- name: Save execution cache
if: success() && steps.cache.outputs.should-run == 'true' && steps.cache.outputs.cache-source == 'none'
uses: actions/cache/save@565629816435f6c0b50676926c9b05c254113c0c # ratchet:actions/cache/save@v4
with:
path: ${{ steps.cache.outputs.cache-path }}
key: ${{ steps.cache.outputs.cache-key }}