forked from tahoe-lafs/tahoe-lafs
-
Notifications
You must be signed in to change notification settings - Fork 4
159 lines (146 loc) · 5.31 KB
/
nix.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
158
159
name: Nix
on:
push:
branches:
- main
paths:
- '.github/workflows/nix.yml'
- 'flake.*'
- 'setup.cfg'
- '*.nix'
- '*.py'
- '*.ini'
pull_request:
paths:
- '.github/workflows/nix.yml'
- 'flake.*'
- 'setup.cfg'
- '*.nix'
- '*.py'
- '*.ini'
jobs:
check:
runs-on: ubuntu-22.04
outputs:
NIXPKGS: ${{ steps.prep.outputs.NIXPKGS }}
NIX_PATH: ${{ steps.prep.outputs.NIX_PATH }}
env:
nixpkgs: nixos-24_11
steps:
- name: Checkout
id: checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
fetch-tags: true
- name: Install nix
id: install_nix
uses: nixbuild/nix-quick-install-action@v28
- name: Show the flake
id: show
run: |
nix flake show
- name: Check the flake
id: check
env:
# FIXME: Our python39 package depends on some broken zope
NIXPKGS_ALLOW_BROKEN: 1
run: |
echo FIXME: nix flake check --impure
- name: Restore and cache Nix store for nixpkgs-${{ env.nixpkgs }}
uses: nix-community/cache-nix-action@v5
with:
# restore and save a cache using this key
primary-key: nixpkgs-${{ env.nixpkgs }}-${{ hashFiles('flake.*', '*.nix') }}
# if there's no cache hit, restore a cache by this prefix
restore-prefixes-first-match: nixpkgs-${{ env.nixpkgs }}-
# collect garbage until Nix store size (in bytes) is at most this number
# before trying to save a new cache
gc-max-store-size-linux: 1073741824
# do purge caches
purge: true
# purge all versions of the cache
purge-prefixes: nixpkgs-${{ env.nixpkgs }}-
# created more than 0 seconds ago relative to the start of the `Post Restore` phase
purge-created: 0
# except the version with the `primary-key`, if it exists
purge-primary-key: never
- name: Prepare environment
id: prep
run: |
# Get the reference to the nixpkgs pinned in the flake - dirty way
NIXPKGS=$(nix flake metadata | grep -E '[^\w]+nixpkgs-${{ matrix.nixpkgs }}[^\w]+:' | cut -d' ' -f2 | cut -d'?' -f1)
NIX_PATH=nixpkgs=https://github.com/NixOS/nixpkgs/archive/${NIXPKGS##*/}.tar.gz
# Pass those variables to the next steps and jobs
echo NIXPKGS=$NIXPKGS | tee -a $GITHUB_ENV >> $GITHUB_OUTPUT
echo NIX_PATH=$NIX_PATH | tee -a $GITHUB_ENV >> $GITHUB_OUTPUT
- name: Generate version
# The Nix package doesn't know how to do this part, unfortunately.
run: |
nix-shell \
-p 'python3.withPackages (ps: [ ps.setuptools ])' \
--run 'python setup.py update_version'
packaging:
runs-on: ubuntu-22.04
needs: check
env:
NIXPKGS: ${{ needs.check.outputs.NIXPKGS }}
NIX_PATH: ${{ needs.check.outputs.NIX_PATH }}
strategy:
fail-fast: false
matrix:
python-version:
- 310
- 311
nixpkgs:
- nixos-24_11
steps:
- name: Checkout
id: checkout
uses: actions/checkout@v4
- name: Install nix
id: install_nix
uses: nixbuild/nix-quick-install-action@v28
- name: Restore and cache Nix store for nixpkgs-${{ matrix.nixpkgs }}
uses: nix-community/cache-nix-action@v5
with:
# restore and save a cache using this key
primary-key: python${{ matrix.python-version }}-nixpkgs-${{ matrix.nixpkgs }}-${{ hashFiles('flake.*', '*.nix') }}
# if there's no cache hit, restore a cache by this prefix
restore-prefixes-first-match: nixpkgs-${{ matrix.nixpkgs }}-
# collect garbage until Nix store size (in bytes) is at most this number
# before trying to save a new cache
gc-max-store-size-linux: 1073741824
# do purge caches
purge: true
# purge all versions of the cache
purge-prefixes: python${{ matrix.python-version }}-nixpkgs-${{ matrix.nixpkgs }}-
# created more than 0 seconds ago relative to the start of the `Post Restore` phase
purge-created: 0
# except the version with the `primary-key`, if it exists
purge-primary-key: never
- name: Build package
env:
# CircleCI build environment looks like it has a zillion and a half cores.
# Don't let Nix autodetect this high core count because it blows up memory
# usage and fails the test run. Pick a number of cores that suits the build
# environment we're paying for (the free one!).
DEPENDENCY_CORES: 3
run: |
nix build \
--verbose \
--print-build-logs \
--cores "$DEPENDENCY_CORES" \
--override-input nixpkgs "$NIXPKGS" \
.#python${{ matrix.python-version }}-tahoe-lafs
- name: Unit test
env:
# Once dependencies are built, we can allow some more concurrency for our own
# test suite.
UNITTEST_CORES: 8
run: |
nix run \
--override-input nixpkgs "$NIXPKGS" \
.#python${{ matrix.python-version }}-unittest -- \
--jobs $UNITTEST_CORES \
allmydata