-
Notifications
You must be signed in to change notification settings - Fork 352
155 lines (137 loc) · 5.03 KB
/
Copy pathcachix.yml
File metadata and controls
155 lines (137 loc) · 5.03 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
name: Populate Cachix
on:
push:
branches:
- main
paths:
- flake.nix
workflow_dispatch: {}
permissions:
contents: read
concurrency:
group: populate-cachix-${{ github.ref }}
cancel-in-progress: false
env:
CACHIX_CACHE_NAME: codex-desktop-linux
CARGO_TERM_COLOR: always
NIX_CONFIG: experimental-features = nix-command flakes
jobs:
detect-codex-dmg-hash:
name: Detect Codex DMG hash change
if: github.event_name != 'workflow_dispatch' || github.ref == 'refs/heads/main'
runs-on: ubuntu-latest
outputs:
changed: ${{ steps.codex-dmg-hash.outputs.changed }}
current: ${{ steps.codex-dmg-hash.outputs.current }}
steps:
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
with:
fetch-depth: 2
persist-credentials: false
- name: Compare Codex DMG hashes
id: codex-dmg-hash
env:
EVENT_NAME: ${{ github.event_name }}
BEFORE_SHA: ${{ github.event.before }}
run: |
set -euo pipefail
current_hash="$(
scripts/ci/update-nix-hashes.sh \
read-flake-hash "codexDmg = pkgs.fetchurl {" "hash = "
)"
previous_flake="$(mktemp)"
trap 'rm -f "$previous_flake"' EXIT
if [ "$EVENT_NAME" = "workflow_dispatch" ]; then
changed=true
previous_hash=manual-backfill
elif [ "$BEFORE_SHA" = "0000000000000000000000000000000000000000" ]; then
changed=true
previous_hash=missing
else
if ! git cat-file -e "$BEFORE_SHA:flake.nix" 2>/dev/null; then
git fetch --no-tags --depth=1 origin "$BEFORE_SHA"
fi
git show "$BEFORE_SHA:flake.nix" > "$previous_flake"
previous_hash="$(
FLAKE_FILE="$previous_flake" scripts/ci/update-nix-hashes.sh \
read-flake-hash "codexDmg = pkgs.fetchurl {" "hash = "
)"
if [ "$current_hash" = "$previous_hash" ]; then
changed=false
else
changed=true
fi
fi
{
echo "changed=$changed"
echo "current=$current_hash"
} >> "$GITHUB_OUTPUT"
{
echo "## Codex DMG hash"
echo
echo "- Previous: \`$previous_hash\`"
echo "- Current: \`$current_hash\`"
echo "- Populate Cachix: \`$changed\`"
} >> "$GITHUB_STEP_SUMMARY"
populate:
name: Build Nix flake outputs
needs: detect-codex-dmg-hash
if: needs.detect-codex-dmg-hash.outputs.changed == 'true'
runs-on: ubuntu-latest
timeout-minutes: 150
env:
CACHIX_AUTH_TOKEN: ${{ secrets.CACHIX_AUTH_TOKEN }}
steps:
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
with:
persist-credentials: false
- uses: cachix/install-nix-action@630ae543ea3a38a9a4166f03376c02c50f408342 # v31
- name: Configure Cachix for explicit uploads
uses: cachix/cachix-action@5f2d7c5294214f71b873db4b969586b980625e71 # v17
with:
name: ${{ env.CACHIX_CACHE_NAME }}
authToken: ${{ env.CACHIX_AUTH_TOKEN }}
skipPush: true
- name: Warn when Cachix push token is missing
if: env.CACHIX_AUTH_TOKEN == ''
run: |
cat <<'EOF' >> "$GITHUB_STEP_SUMMARY"
## Cachix
`CACHIX_AUTH_TOKEN` is not configured, so this run will build without pushing to Cachix.
Add a write token for the `codex-desktop-linux` Cachix cache as a repository secret to populate it automatically.
EOF
- name: Build, upload, and collect cacheable Nix outputs
run: |
set -euo pipefail
outputs=(
.#codex-desktop
.#codex-desktop-computer-use-ui
.#codex-desktop-remote-mobile-control
.#codex-desktop-computer-use-ui-remote-mobile-control
.#checks.x86_64-linux.watchdog-linux-features
.#installer
)
for output in "${outputs[@]}"; do
echo "Building $output"
store_paths_file="$RUNNER_TEMP/cachix-store-paths"
nix build "$output" \
--no-link \
--print-build-logs \
--print-out-paths > "$store_paths_file"
mapfile -t store_paths < "$store_paths_file"
if [ "${#store_paths[@]}" -eq 0 ]; then
echo "Nix did not return a store path for $output." >&2
exit 1
fi
if [ -n "$CACHIX_AUTH_TOKEN" ]; then
printf '%s\n' "${store_paths[@]}" | cachix push "$CACHIX_CACHE_NAME"
fi
nix store gc
done
{
echo "## Cachix population"
echo
echo "- Triggering Codex DMG hash: \`${{ needs.detect-codex-dmg-hash.outputs.current }}\`"
echo "- Cache: \`$CACHIX_CACHE_NAME\`"
printf -- '- Built and collected: `%s`\n' "${outputs[@]}"
} >> "$GITHUB_STEP_SUMMARY"