From 81f33964062e2401c29457b402e43b1518d7d758 Mon Sep 17 00:00:00 2001 From: Kir Kolyshkin Date: Tue, 22 Oct 2024 12:06:25 -0700 Subject: [PATCH 1/4] ci/gha: bump github actions to latest versions Bump - actions/checkout v2 -> v4 - actions/setup-go v2 -> v5 Signed-off-by: Kir Kolyshkin --- .github/workflows/main.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 0e480f96..d63e9083 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -11,10 +11,10 @@ jobs: build: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - name: Set up Go - uses: actions/setup-go@v2 + uses: actions/setup-go@v5 with: go-version: 1.17 @@ -30,13 +30,13 @@ jobs: # on macOS, which helps catch missing build tags. runs-on: macos-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - name: Set up Go - uses: actions/setup-go@v2 + uses: actions/setup-go@v5 with: go-version: 1.17 - + - name: Build run: go build ./... From 0dcaba4e955b7b7a5a3d48a5c54d1d5c9430d8e5 Mon Sep 17 00:00:00 2001 From: Kir Kolyshkin Date: Tue, 22 Oct 2024 12:19:28 -0700 Subject: [PATCH 2/4] ci/gha: add build step Make sure CI builds everything that is (or will be) there to build. In particular, this ensures that cmd/ipset-test is buildable. Signed-off-by: Kir Kolyshkin --- .github/workflows/main.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index d63e9083..2db94916 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -22,6 +22,9 @@ jobs: run: ./.github/scripts/modprobe.sh shell: bash + - name: Build + run: go build ./... + - name: Test run: sudo -E env PATH=$PATH go test -v ./ ./nl From 768583ec60c989302c4e344529df5a854bf1d931 Mon Sep 17 00:00:00 2001 From: Kir Kolyshkin Date: Tue, 22 Oct 2024 12:11:37 -0700 Subject: [PATCH 3/4] ci/gha: use go test -exec sudo Running "sudo go test" results in a different environment, so go has to recompile everything again. Use "go test -exec sudo" so test would compile as current user (so that go build cache is reused), then run as root. The arguments added to sudo are: -n: do not ask for password --preserve-env CI,PATH: preserve these environment variables Signed-off-by: Kir Kolyshkin --- .github/workflows/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 2db94916..57c943e7 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -26,7 +26,7 @@ jobs: run: go build ./... - name: Test - run: sudo -E env PATH=$PATH go test -v ./ ./nl + run: go test -exec 'sudo --preserve-env=CI,PATH -n' -v ./ ./nl build-macos: # netlink is Linux-only, but this ensures that netlink builds without error From 2d3ce5c227bbdb04d617bbbc1af54538291f9c96 Mon Sep 17 00:00:00 2001 From: Kir Kolyshkin Date: Tue, 22 Oct 2024 12:25:53 -0700 Subject: [PATCH 4/4] ci/gha: test on different Go and Ubuntu versions Add test matrix to run tests on latest Go and different Ubuntu versions Signed-off-by: Kir Kolyshkin --- .github/workflows/main.yml | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 57c943e7..8e9aa805 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -9,6 +9,11 @@ on: jobs: build: + strategy: + fail-fast: false + matrix: + os: [ubuntu-20.04, ubuntu-24.04] + go-version: [1.17.x, 1.22.x, 1.23.x] runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 @@ -16,7 +21,7 @@ jobs: - name: Set up Go uses: actions/setup-go@v5 with: - go-version: 1.17 + go-version: ${{ matrix.go-version }} - name: Kernel Modules run: ./.github/scripts/modprobe.sh