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/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 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 = ''