Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 21 additions & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ on:
jobs:
test:
runs-on: ubuntu-latest
strategy:
matrix:
go-pkg: ['go_1_17', 'go_1_18', 'go_1_19', 'go_1_20', 'go_1_21', 'go_1_22']
steps:
- uses: actions/checkout@v4

Expand All @@ -17,16 +20,29 @@ jobs:
- name: Restore and cache Nix store
uses: nix-community/cache-nix-action@v6.1.3
with:
primary-key: nix-${{ runner.os }}-${{ hashFiles('shell.nix') }}
primary-key: nix-${{ runner.os }}-${{ matrix.go-pkg }}-${{ hashFiles('shell.nix') }}

- name: Format check
run: nix-shell --run "test -z \$(gofmt -l .)"
run: nix-shell --argstr goPackage "${{ matrix.go-pkg }}" --run "test -z \$(gofmt -l .)"

- name: Build
run: nix-shell --run "go build ./..."
run: nix-shell --argstr goPackage "${{ matrix.go-pkg }}" --run "go build ./..."

- name: Test
run: nix-shell --run "go test -v -cover ./..."
run: nix-shell --argstr goPackage "${{ matrix.go-pkg }}" --run "go test -v -cover ./..."

- name: Vet
run: nix-shell --run "go vet ./..."
run: nix-shell --argstr goPackage "${{ matrix.go-pkg }}" --run "go vet ./..."

# Rollup job for branch protection - only require this single check
ci:
runs-on: ubuntu-latest
needs: test
if: always()
steps:
- name: Check all matrix jobs passed
run: |
if [[ "${{ needs.test.result }}" != "success" ]]; then
echo "Matrix jobs failed"
exit 1
fi
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ The implementation is in usable shape and is fairly well tested with its accompa
Dependencies
------------

The only requirement is [Go 1.2](http://golang.org/doc/go1.2) or later.
The only requirement is [Go 1.17](http://golang.org/doc/go1.17) or later.

Usage
-----
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module github.com/ajg/form

go 1.21
go 1.17
30 changes: 26 additions & 4 deletions shell.nix
Original file line number Diff line number Diff line change
@@ -1,10 +1,32 @@
{ goPackage ? "go" }:

let
pkgs = import (fetchTarball
# Current nixpkgs (has go_1_21, go_1_22)
pkgsCurrent = import (fetchTarball
"https://github.com/NixOS/nixpkgs/archive/8c5066250910.tar.gz") { };

in pkgs.mkShell {
buildInputs = with pkgs; [
go
# nixpkgs 23.05 - has go_1_18, go_1_19, go_1_20
pkgs2305 = import (fetchTarball
"https://github.com/NixOS/nixpkgs/archive/nixos-23.05.tar.gz") { };

# nixpkgs 22.05 - has go_1_17
pkgs2205 = import (fetchTarball
"https://github.com/NixOS/nixpkgs/archive/nixos-22.05.tar.gz") { };

# Map Go packages to their source
goFromPkgs = {
go = pkgsCurrent.go;
go_1_17 = pkgs2205.go_1_17;
go_1_18 = pkgs2305.go_1_18;
go_1_19 = pkgs2305.go_1_19;
go_1_20 = pkgs2305.go_1_20;
go_1_21 = pkgsCurrent.go_1_21;
go_1_22 = pkgsCurrent.go_1_22;
};

in pkgsCurrent.mkShell {
buildInputs = [
goFromPkgs.${goPackage}
];

shellHook = ''
Expand Down