From 2e40a871ad248e50f558199651b754ed08e15adb Mon Sep 17 00:00:00 2001 From: "Silvio J. Gutierrez" Date: Sun, 1 Feb 2026 22:55:24 +0000 Subject: [PATCH 1/2] Add multi-version Go testing to CI using nix Test against Go 1.17 through 1.22 using a matrix strategy with nix. The shell.nix accepts a goPackage argument and maps versions to different nixpkgs pins: - pkgsCurrent (8c5066250910): go_1_21, go_1_22 - pkgs2305 (nixos-23.05): go_1_18, go_1_19, go_1_20 - pkgs2205 (nixos-22.05): go_1_17 Adds a "ci" rollup job that can be used as a single required check in branch protection rules. Co-Authored-By: Claude Opus 4.5 --- .github/workflows/ci.yml | 26 +++++++++++++++++++++----- shell.nix | 30 ++++++++++++++++++++++++++---- 2 files changed, 47 insertions(+), 9 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c3b6205..6e12644 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -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 @@ -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 diff --git a/shell.nix b/shell.nix index 152eeee..889200c 100644 --- a/shell.nix +++ b/shell.nix @@ -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 = '' From e8c98b0399494899d34716b2f5478c98cea128a2 Mon Sep 17 00:00:00 2001 From: "Silvio J. Gutierrez" Date: Sun, 1 Feb 2026 23:16:33 +0000 Subject: [PATCH 2/2] Update Go version requirements to 1.17 - Update README to reflect Go 1.17 minimum requirement - Lower go.mod version to 1.17 to match CI matrix Co-Authored-By: Claude Opus 4.5 --- README.md | 2 +- go.mod | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index b768e7c..0bc03ab 100644 --- a/README.md +++ b/README.md @@ -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 ----- diff --git a/go.mod b/go.mod index a634d43..4ccc694 100644 --- a/go.mod +++ b/go.mod @@ -1,3 +1,3 @@ module github.com/ajg/form -go 1.21 +go 1.17