Skip to content

Commit 986eb2f

Browse files
committed
Add CI
Run checks and upload builds when pushing to main. Also use a cache (seems somewhat functional, reduces time from 5 to 3 minutes, though I would expect it to be ~1 minute if everything was cached).
1 parent 27c6caf commit 986eb2f

1 file changed

Lines changed: 61 additions & 0 deletions

File tree

.github/workflows/check.yml

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
name: Build and test
2+
on: [pull_request, push]
3+
4+
jobs:
5+
run:
6+
runs-on: ubuntu-latest
7+
8+
steps:
9+
- uses: actions/checkout@v6
10+
- uses: nixbuild/nix-quick-install-action@v34
11+
with:
12+
nix_conf: |
13+
keep-env-derivations = true
14+
keep-outputs = true
15+
16+
- name: Restore and save Nix store
17+
uses: nix-community/cache-nix-action@v7
18+
with:
19+
primary-key: nix-${{ runner.os }}-${{ hashFiles('flake.nix', 'flake.lock') }}
20+
restore-prefixes-first-match: nix-${{ runner.os }}-
21+
purge: true
22+
# purge all versions of the cache
23+
purge-prefixes: build-${{ runner.os }}-
24+
# created more than 10 seconds ago relative to the start of the `Post Restore` phase
25+
purge-created: PT10S
26+
# except the version with the `primary-key`, if it exists
27+
purge-primary-key: never
28+
# and collect garbage in the Nix store until it reaches this size in bytes
29+
gc-max-store-size: 0
30+
31+
- name: Check
32+
run: |
33+
nix flake check -L
34+
35+
- name: Package
36+
if: github.event_name != 'pull_request' && github.ref == 'refs/heads/main'
37+
run: |
38+
commit_short="$(git rev-parse --short HEAD)"
39+
date="$(date -I)"
40+
41+
# Create package
42+
nix build .#mingw-release -L
43+
cp result/smoldr.zip "smoldr_${date}_${GITHUB_RUN_ID}_${commit_short}.zip"
44+
45+
# Create agility SDK package
46+
nix build .#mingw-agility-release -L
47+
cp result/smoldr.zip "smoldr-agility_${date}_${GITHUB_RUN_ID}_${commit_short}.zip"
48+
49+
- uses: actions/upload-artifact@v7
50+
if: github.event_name != 'pull_request' && github.ref == 'refs/heads/main'
51+
with:
52+
path: smoldr_*.zip
53+
if-no-files-found: error
54+
archive: false
55+
56+
- uses: actions/upload-artifact@v7
57+
if: github.event_name != 'pull_request' && github.ref == 'refs/heads/main'
58+
with:
59+
path: smoldr-agility_*.zip
60+
if-no-files-found: error
61+
archive: false

0 commit comments

Comments
 (0)