-
Notifications
You must be signed in to change notification settings - Fork 0
207 lines (172 loc) · 7.52 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
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
name: "CI"
on:
pull_request:
push:
branches:
- "main"
schedule:
- cron: '20 2 * * *'
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
test-javascript:
name: "JavaScript Tests"
runs-on: ${{ matrix.os }}
strategy:
matrix:
os:
- "ubuntu-latest"
- "ghcr.io/cirruslabs/macos-sonoma-xcode:latest"
steps:
- name: "Checkout"
uses: "actions/checkout@v4"
- name: "Install Nix"
uses: "cachix/install-nix-action@v27"
- name: "Cache Dependencies"
id: cache
uses: "actions/cache@8070854e57d983bdd2887b0a708ad985f77398ab"
env:
GITHUB_ACTIONS_RUNNER_FORCED_NODE_VERSION: node20
with:
key: npm-${{ matrix.os }}-${{ hashFiles('package-lock.json') }}
path: ./node_modules
restore-keys: |
npm-feature-${{ matrix.os }}-${{ hashFiles('package-lock.json') }}
npm-feature-${{ matrix.os }}-
npm-feature-
npm-
- name: "Install Dependencies"
if: steps.cache.outputs.cache-hit != 'true'
run: nix develop --accept-flake-config --command npm ci
- name: "Check Format"
run: nix develop --accept-flake-config --command npm run format:check
- name: "Test"
run: nix develop --accept-flake-config --command npm run ci-test
test-minimal-action:
name: "Minimal - Github Action Test"
runs-on: ${{ matrix.os }}
strategy:
matrix:
os:
- "ubuntu-latest"
- "ghcr.io/cirruslabs/macos-sonoma-xcode:latest"
steps:
- name: "Checkout"
uses: "actions/checkout@v4"
- name: "Install Nix"
uses: "cachix/install-nix-action@v27"
- name: "Test Local Action"
uses: "./"
with:
github-access-token: "${{ secrets.MANAGED_MANAGED_FLOXBOT_GITHUB_ACCESS_TOKEN_REPO_SCOPE }}"
- name: "Test: nix --version"
run: |
nix --version
test-all-action:
name: "All - Github Action Test"
runs-on: ${{ matrix.os }}
strategy:
matrix:
os:
- "ubuntu-latest"
- "ghcr.io/cirruslabs/macos-sonoma-xcode:latest"
steps:
- name: "Checkout"
uses: "actions/checkout@v4"
- name: "Setup Tailscale"
if: ${{ runner.os == 'Linux' }}
uses: "tailscale/github-action@v2"
with:
args: "--timeout 30s --login-server ${{ vars.MANAGED_TAILSCALE_URL }}"
tags: tag:ci
authkey: "${{ secrets.MANAGED_TAILSCALE_AUTH_KEY }}"
- name: "Install Nix"
uses: "cachix/install-nix-action@v27"
with:
nix_path: nixpkgs=channel:nixos-unstable
- name: "Test Local Action"
uses: "./"
with:
github-access-token: "${{ secrets.MANAGED_FLOXBOT_GITHUB_ACCESS_TOKEN_REPO_SCOPE }}"
substituter: "${{ vars.MANAGED_CACHE_PUBLIC_S3_BUCKET }}"
substituter-key: "${{ secrets.MANAGED_CACHE_PUBLIC_SECRET_KEY }}"
aws-access-key-id: "${{ secrets.MANAGED_CACHE_PUBLIC_AWS_ACCESS_KEY_ID }}"
aws-secret-access-key: "${{ secrets.MANAGED_CACHE_PUBLIC_AWS_SECRET_ACCESS_KEY }}"
ssh-key: "${{ secrets.MANAGED_FLOXBOT_SSH_KEY }}"
remote-builders: "${{ runner.os == 'Linux' && vars.MANAGED_REMOTE_BUILDERS || '' }}"
- name: "Test Remote Builders"
if: ${{ runner.os == 'Linux' }} # tailscale Action does not work on MacOS
run: |
export NIX_PATH="nixpkgs=flake:nixpkgs"
export NIX_CONFIG="experimental-features = nix-command flakes"
RAND=$RANDOM
nix build --accept-flake-config -vv -L --impure --expr '(with import <nixpkgs> { system = "x86_64-linux"; }; runCommand "foo-'"$RAND"'" {} "uname -mo > $out")'
nix build --accept-flake-config -vv -L --impure --expr '(with import <nixpkgs> { system = "aarch64-linux"; }; runCommand "foo-'"$RAND"'" {} "uname -mo > $out")'
nix build --accept-flake-config -vv -L --impure --expr '(with import <nixpkgs> { system = "x86_64-darwin"; }; runCommand "foo-'"$RAND"'" {} "uname -mo > $out")'
nix build --accept-flake-config -vv -L --impure --expr '(with import <nixpkgs> { system = "aarch64-darwin"; }; runCommand "foo-'"$RAND"'" {} "uname -mo > $out")'
cd example
nix build --accept-flake-config --no-write-lock-file
test-nix-action:
name: "Nix - test integration with Nix"
runs-on: ${{ matrix.os }}
strategy:
matrix:
os:
- "ubuntu-latest"
- "ghcr.io/cirruslabs/macos-sonoma-xcode:latest"
steps:
- name: "Checkout"
uses: "actions/checkout@v4"
- name: "Setup Tailscale"
if: ${{ runner.os == 'Linux' }}
uses: "tailscale/github-action@v2"
with:
args: "--timeout 30s --login-server ${{ vars.MANAGED_TAILSCALE_URL }}"
tags: tag:ci
authkey: "${{ secrets.MANAGED_TAILSCALE_AUTH_KEY }}"
- name: "Install Nix"
uses: "cachix/install-nix-action@v27"
with:
nix_path: nixpkgs=channel:nixos-unstable
- name: "Test Local Action"
uses: "./"
with:
github-access-token: "${{ secrets.MANAGED_FLOXBOT_GITHUB_ACCESS_TOKEN_REPO_SCOPE }}"
substituter: "${{ vars.MANAGED_CACHE_PUBLIC_S3_BUCKET }}"
substituter-key: "${{ secrets.MANAGED_CACHE_PUBLIC_SECRET_KEY }}"
aws-access-key-id: "${{ secrets.MANAGED_CACHE_PUBLIC_AWS_ACCESS_KEY_ID }}"
aws-secret-access-key: "${{ secrets.MANAGED_CACHE_PUBLIC_AWS_SECRET_ACCESS_KEY }}"
ssh-key: "${{ secrets.MANAGED_FLOXBOT_SSH_KEY }}"
remote-builders: "${{ runner.os == 'Linux' && vars.MANAGED_REMOTE_BUILDERS || '' }}"
- name: "Test Remote Builders"
if: ${{ runner.os == 'Linux' }}
run: |
export NIX_CONFIG="experimental-features = nix-command flakes"
RAND=$RANDOM
nix build --accept-flake-config -L --impure --expr '(with import <nixpkgs> { system = "x86_64-linux"; }; runCommand "foo-'"$RAND"'" {} "uname -mo > $out")'
nix build --accept-flake-config -L --impure --expr '(with import <nixpkgs> { system = "aarch64-linux"; }; runCommand "foo-'"$RAND"'" {} "uname -mo > $out")'
nix build --accept-flake-config -L --impure --expr '(with import <nixpkgs> { system = "x86_64-darwin"; }; runCommand "foo-'"$RAND"'" {} "uname -mo > $out")'
nix build --accept-flake-config -L --impure --expr '(with import <nixpkgs> { system = "aarch64-darwin"; }; runCommand "foo-'"$RAND"'" {} "uname -mo > $out")'
cd example
nix build --accept-flake-config --no-write-lock-file
report-failure:
name: "Report Failure"
runs-on: "ubuntu-latest"
if: ${{ failure() && github.ref == 'refs/heads/main' && (github.event_name == 'push' || github.event_name == 'schedule') }}
needs:
- "test-javascript"
- "test-minimal-action"
- "test-all-action"
- "test-nix-action"
steps:
- name: "Slack Notification"
uses: "rtCamp/action-slack-notify@v2"
env:
SLACK_TITLE: "Something broke CI for flox/configure-nix-action on main"
SLACK_FOOTER: "Thank you for caring"
SLACK_WEBHOOK: "${{ secrets.MANAGED_SLACK_WEBHOOK }}"
SLACK_USERNAME: "GitHub"
SLACK_ICON_EMOJI: ":poop:"
SLACK_COLOR: "#ff2800" # ferrari red -> https://encycolorpedia.com/ff2800
SLACK_LINK_NAMES: true