Skip to content

Commit d08bac9

Browse files
committed
Swap to my more modern nixified setups
1 parent 8bb7c0a commit d08bac9

5 files changed

Lines changed: 85 additions & 95 deletions

File tree

.github/workflows/main.yml

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -11,37 +11,35 @@ jobs:
1111
test:
1212
strategy:
1313
matrix:
14-
go: ['1.24', '1.25']
14+
go: ['go124', 'go125']
1515
os: [ubuntu, macos]
1616
runs-on: ${{ matrix.os }}-latest
17-
name: test (go${{ matrix.go }}-${{ matrix.os }})
17+
name: test (${{ matrix.go }}-${{ matrix.os }})
1818
steps:
1919
- uses: actions/checkout@v6
20-
- uses: actions/setup-go@v6
21-
with:
22-
go-version: ${{ matrix.go }}
23-
- run: go mod download
24-
- run: go build -v
25-
- run: make test
20+
- uses: DeterminateSystems/nix-installer-action@main
21+
- uses: DeterminateSystems/magic-nix-cache-action@main
22+
- run: nix develop .#${{ matrix.go }} --command go mod download
23+
- run: nix develop .#${{ matrix.go }} --command go build -v
24+
- run: nix develop .#${{ matrix.go }} --command just test
2625

2726
test-race:
2827
strategy:
2928
matrix:
30-
go: ['1.24', '1.25']
29+
go: ['go124', 'go125']
3130
os: [ubuntu, macos]
3231
runs-on: ${{ matrix.os }}-latest
33-
name: test-race (go${{ matrix.go }}-${{ matrix.os }})
32+
name: test-race (${{ matrix.go }}-${{ matrix.os }})
3433
steps:
3534
- uses: actions/checkout@v6
36-
- uses: actions/setup-go@v6
37-
with:
38-
go-version: ${{ matrix.go }}
39-
- run: make test-race
35+
- uses: DeterminateSystems/nix-installer-action@main
36+
- uses: DeterminateSystems/magic-nix-cache-action@main
37+
- run: nix develop .#${{ matrix.go }} --command just test-race
4038

4139
lint:
4240
runs-on: ubuntu-latest
4341
steps:
4442
- uses: actions/checkout@v6
45-
- uses: golangci/golangci-lint-action@v7
46-
with:
47-
version: v2.0.2
43+
- uses: DeterminateSystems/nix-installer-action@main
44+
- uses: DeterminateSystems/magic-nix-cache-action@main
45+
- run: nix develop .#go125 --command just lint

Justfile

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
TEST_FLAGS := "--rerun-fails=5 --packages=./... --format testname"
2+
3+
default:
4+
@just --list
5+
6+
# Format Go code
7+
fmt: fmt-go
8+
9+
# Format Go code with golangci-lint
10+
fmt-go:
11+
golangci-lint fmt
12+
13+
# Run linter
14+
lint:
15+
golangci-lint run --show-stats
16+
17+
# Start documentation server
18+
docs:
19+
go doc -http
20+
21+
# Run tests
22+
test:
23+
GOEXPERIMENT=synctest gotestsum {{ TEST_FLAGS }}
24+
25+
# Run tests with race detector
26+
test-race:
27+
GOEXPERIMENT=synctest gotestsum {{ TEST_FLAGS }} -- -race
28+
29+
# Run tests in watch mode
30+
test-watch:
31+
GOEXPERIMENT=synctest gotestsum --watch {{ TEST_FLAGS }}
32+
33+
# Update benchmark results
34+
update-benchmarks:
35+
go -C benchmarks/ test -v -bench=. -count=10 | tee compare.txt
36+
go run golang.org/x/perf/cmd/benchstat@latest -col /mod compare.txt | tee benchmarks.txt
37+
echo >> benchmarks.txt
38+
go test -v . -run=xxx -bench=. | tee -a benchmarks.txt
39+
rm compare.txt

Makefile

Lines changed: 0 additions & 60 deletions
This file was deleted.

flake.lock

Lines changed: 6 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

flake.nix

Lines changed: 25 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,28 +9,41 @@
99
};
1010

1111
outputs =
12-
{ nixpkgs, flake-utils, matt, ... }:
12+
{
13+
nixpkgs,
14+
flake-utils,
15+
matt,
16+
...
17+
}:
1318
flake-utils.lib.eachDefaultSystem (
1419
system:
1520
let
1621
pkgs = import nixpkgs {
1722
inherit system;
1823
overlays = [ matt.overlays.default ];
1924
};
25+
26+
# Common dev tools for all shells
27+
devTools = with pkgs; [
28+
just
29+
gopls
30+
golangci-lint
31+
gotestsum
32+
];
33+
34+
mkGoShell =
35+
goPackage:
36+
pkgs.mkShell {
37+
packages = [ goPackage ] ++ devTools;
38+
};
2039
in
2140
{
22-
devShells.default = pkgs.mkShell {
23-
packages = with pkgs; [
24-
go-bin_1_25
25-
gopls
26-
just
27-
gnumake
28-
];
41+
# Default shell uses Go 1.25
42+
devShells.default = mkGoShell pkgs.go-bin_1_25;
2943

30-
shellHook = ''
31-
export PATH="$PWD/bin:$PATH"
32-
'';
33-
};
44+
# Explicit shells for each Go version
45+
devShells.go124 = mkGoShell pkgs.go_1_24;
46+
devShells.go125 = mkGoShell pkgs.go-bin_1_25;
3447
}
3548
);
3649
}

0 commit comments

Comments
 (0)