-
Notifications
You must be signed in to change notification settings - Fork 17
107 lines (104 loc) · 4.44 KB
/
nix-rebuild.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
name: rebuilds
on: [pull_request]
jobs:
# Calculate changed derivations
get-changed-derivs:
name: Get changed derivations
runs-on: ubuntu-latest
steps:
# Install Nix on the runner
- uses: cachix/install-nix-action@v25
with:
nix_path: nixpkgs=channel:nixos-unstable
# Pull from the cachix cache
- uses: cachix/cachix-action@v15
with:
name: nix-qchem
# Checkout of the current head in the working dir
- uses: actions/checkout@v4
# Get PR target branch checkout
- uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.base.ref }}
repository: ${{ github.event.pull_request.base.repo.full_name }}
path: pr_base
# Get a checkout of this PR
- uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.ref }}
repository: ${{ github.event.pull_request.head.repo.full_name }}
path: pr_head
- name: Calculate changed derivations and upload as artifacts
run: nix eval --impure --expr 'import ./.github/workflows/changedPaths.nix ./pr_head ./pr_base' --json | tee chDerivs.json
# Upload JSON of the changed derivations
- uses: actions/upload-artifact@v4
with:
name: Changed-Derivations-${{ github.event.number }}
path: chDerivs.json
retention-days: 1
# Rebuild changed derivations for the pinned snapshot
rebuild-head:
name: Changed derivations HEAD (pinned nixpkgs)
needs: get-changed-derivs
runs-on: ubuntu-latest
steps:
# Install Nix on the runner
- uses: cachix/install-nix-action@v25
with:
nix_path: nixpkgs=channel:nixos-unstable
- name: Magic Nix Cache
uses: DeterminateSystems/magic-nix-cache-action@v6
# Pull from the cachix cache
- uses: cachix/cachix-action@v15
with:
name: nix-qchem
# Checkout of the current head in the working dir
- uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha }}
# Get changed derivations as artifact from previous step
- uses: actions/download-artifact@v4
with:
name: Changed-Derivations-${{ github.event.number }}
- name: Rebuild python3 packages
run: |
if [ -n "$(jq '.python3[]' chDerivs.json)" ]; then
nix build --extra-substituters https://nix-qchem.cachix.org --print-build-logs -f release.nix $(for p in $(jq '.python3[]' chDerivs.json | tr -d "\""); do echo "qchem.python3.${p}"; done)
fi
- name: Rebuild all top-level packages
run: |
if [ -n "$(jq '.topLevel[]' chDerivs.json)" ]; then
nix build --extra-substituters https://nix-qchem.cachix.org --print-build-logs -f release.nix $(for p in $(jq 'del(.topLevel[] | select(. == "release-barrier")) | .topLevel[]' chDerivs.json | tr -d "\""); do echo "qchem.${p}"; done)
fi
# Rebuild changed derivations as if merged
rebuild-merge:
name: Changed Derivations Merge (pinned nixpkgs)
needs: get-changed-derivs
runs-on: ubuntu-latest
steps:
# Install Nix on the runner
- uses: cachix/install-nix-action@v25
with:
nix_path: nixpkgs=channel:nixos-unstable
- name: Magic Nix Cache
uses: DeterminateSystems/magic-nix-cache-action@v6
# Pull from the cachix cache
- uses: cachix/cachix-action@v15
with:
name: nix-qchem
# Checkout merge commit as if PR would already be merged
- uses: actions/checkout@v4
# Get changed derivations as artifact from previous step
- uses: actions/download-artifact@v4
with:
name: Changed-Derivations-${{ github.event.number }}
- name: Rebuild all changed python3 packages
run: |
if [ -n "$(jq '.python3[]' chDerivs.json)" ]; then
nix build --extra-substituters https://nix-qchem.cachix.org --print-build-logs -f release.nix $(for p in $(jq '.python3[]' chDerivs.json | tr -d "\""); do echo "qchem.python3.${p}"; done)
fi
- name: Rebuild all changed top-level packages
run: |
if [ -n "$(jq '.topLevel[]' chDerivs.json)" ]; then
nix build --extra-substituters https://nix-qchem.cachix.org --print-build-logs -f release.nix $(for p in $(jq 'del(.topLevel[] | select(. == "release-barrier")) | .topLevel[]' chDerivs.json | tr -d "\""); do echo "qchem.${p}"; done)
fi