From 0629649aa9b163c831d196da9f1eedc75b79a4ae Mon Sep 17 00:00:00 2001 From: Rishabh Agarwal Date: Wed, 29 Jul 2026 07:56:45 +0000 Subject: [PATCH 01/17] Remove static sleep and incorrect code from zrp_laser_bias_current_test --- .../zrp_laser_bias_current_test.go | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/feature/platform/transceiver/tests/zrp_laser_bias_current_test/zrp_laser_bias_current_test.go b/feature/platform/transceiver/tests/zrp_laser_bias_current_test/zrp_laser_bias_current_test.go index d2c7d5decae..abef05f3e36 100644 --- a/feature/platform/transceiver/tests/zrp_laser_bias_current_test/zrp_laser_bias_current_test.go +++ b/feature/platform/transceiver/tests/zrp_laser_bias_current_test/zrp_laser_bias_current_test.go @@ -51,8 +51,8 @@ func TestMain(m *testing.M) { func verifyLaserBiasValue(t *testing.T, laserBiasValue float64) { t.Helper() - if laserBiasValue <= 0 && laserBiasValue >= 131 { - t.Errorf("The laser bias value is not between 0 and 131") + if laserBiasValue < 0.0 || laserBiasValue > 131.0 { + t.Errorf("The laser bias value %f is not between 0 and 131", laserBiasValue) } } @@ -67,7 +67,7 @@ func verifyLaserBiasCurrentAll(t *testing.T, p1Stream *samplestream.SampleStream } laserBiasInstant := laserBiasVal.GetInstant() if reflect.TypeOf(laserBiasInstant).Kind() != reflect.Float64 { - t.Fatalf("Return value is not type string") + t.Fatalf("Return value is not type float64") } t.Logf("laserBias Instant value: %f", laserBiasInstant) if deviations.MissingZROpticalChannelTunableParametersTelemetry(dut1) { @@ -81,7 +81,7 @@ func verifyLaserBiasCurrentAll(t *testing.T, p1Stream *samplestream.SampleStream t.Logf("laserBias Max value: %f", laserBiasMax) laserBiasAvg := laserBiasVal.GetAvg() verifyLaserBiasValue(t, laserBiasAvg) - t.Logf("laserBias Avg value: %f", laserBiasMin) + t.Logf("laserBias Avg value: %f", laserBiasAvg) if laserBiasAvg >= laserBiasMin && laserBiasAvg <= laserBiasMax { t.Logf("The average %f is between the maximum and minimum values", laserBiasAvg) } else { @@ -144,8 +144,8 @@ func TestZRLaserBiasCurrentStateInterfaceFlap(t *testing.T) { // Wait 120 sec cooling-off period gnmi.Await(t, dut1, gnmi.OC().Interface(dp1.Name()).OperStatus().State(), intUpdateTime, oc.Interface_OperStatus_DOWN) t.Logf("%v operational status is: %v", dp1.Name(), gnmi.Get(t, dut1, gnmi.OC().Interface(dp1.Name()).OperStatus().State())) - t.Log("Wait to update telemetry") - time.Sleep(80 * time.Second) + t.Log("Wait for laser bias current to update to 0.0") + gnmi.Await(t, dut1, component.OpticalChannel().LaserBiasCurrent().Instant().State(), 2*time.Minute, 0.0) verifyLaserBiasCurrentAll(t, p1Stream, dut1) // Enable interface cfgplugins.ToggleInterface(t, dut1, dp1.Name(), true) From cdff8ecc5f5517291b77a351c2a866953548f177 Mon Sep 17 00:00:00 2001 From: Rishabh Agarwal Date: Wed, 29 Jul 2026 16:01:10 +0000 Subject: [PATCH 02/17] Skip cleaning cache and avoid .pb.go files in fmt --- .github/workflows/go.yml | 31 +++++++++++-------------------- 1 file changed, 11 insertions(+), 20 deletions(-) diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml index a1ca9259f9e..3b2e1904f7d 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/go.yml @@ -86,36 +86,27 @@ jobs: - name: Install libpcap-dev run: sudo apt-get -y install libpcap-dev - # === THIS IS THE ONLY CHANGE === - - name: Clean Go build cache before analysis - run: go clean -cache - # =============================== - - name: Go vet run: GOGC=30 go vet ./... - name: Gofmt run: | - # gofmt always returns true, so we use grep '^' which returns - # true on non-empty output, but will otherwise passthrough all - # output lines. - if gofmt -d -s . | grep '^'; then + # Use find to exclude generated pb.go files which take too long to parse + unformatted=$(find . -name "*.go" -type f | grep -v "pb.go$" | xargs gofmt -d -s) + if [ -n "$unformatted" ]; then + echo "$unformatted" exit 1 fi - name: Get goimports run: go install golang.org/x/tools/cmd/goimports@latest - name: Goimports run: | - # goimports always returns true, so we use grep '^' which returns - # true on non-empty output, but will otherwise passthrough all - # output lines. - # - # goimports does not support "gofmt -s" so both goimports and gofmt are - # required. - find . -name "*.go" | egrep -v "pb.go$" | while read l; do - if goimports -d $l | grep '^'; then - exit 1; - fi; - done + # goimports does not support "gofmt -s" so both goimports and gofmt are required. + unformatted=$(find . -name "*.go" -type f | grep -v "pb.go$" | xargs goimports -l) + if [ -n "$unformatted" ]; then + echo "The following files have goimports formatting errors:" + echo "$unformatted" + exit 1 + fi - name: Get revive run: go install github.com/mgechev/revive@v1.3.4 - name: Run revive From 57638313d1d1937655cd01fd08c3fdd4a1c4253c Mon Sep 17 00:00:00 2001 From: Rishabh Agarwal Date: Thu, 30 Jul 2026 03:20:54 +0000 Subject: [PATCH 03/17] AI attempt 2 --- .github/workflows/go.yml | 59 ++++++++++++++++++++++++++++++---------- 1 file changed, 45 insertions(+), 14 deletions(-) diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml index 3b2e1904f7d..390e76650bf 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/go.yml @@ -23,10 +23,6 @@ jobs: with: go-version-file: 'go.mod' cache: true - - name: Move cache - run: | - sudo mv "${HOME}/.cache" /mnt/cache - ln -s /mnt/cache "${HOME}/.cache" # Dependency for Go module github.com/google/gopacket - name: Install libpcap-dev run: sudo apt-get -y install libpcap-dev @@ -49,10 +45,6 @@ jobs: with: go-version-file: 'go.mod' cache: true - - name: Move cache - run: | - sudo mv "${HOME}/.cache" /mnt/cache - ln -s /mnt/cache "${HOME}/.cache" # Dependency for Go module github.com/google/gopacket - name: Install libpcap-dev run: sudo apt-get -y install libpcap-dev @@ -63,8 +55,8 @@ jobs: with: path-to-profile: profile.cov - static_analysis: - name: Static Analysis + fast_analysis: + name: Fast Analysis runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 @@ -78,10 +70,6 @@ jobs: with: go-version-file: 'go.mod' cache: true - - name: Move cache - run: | - sudo mv "${HOME}/.cache" /mnt/cache - ln -s /mnt/cache "${HOME}/.cache" # Dependency for Go module github.com/google/gopacket - name: Install libpcap-dev run: sudo apt-get -y install libpcap-dev @@ -111,6 +99,49 @@ jobs: run: go install github.com/mgechev/revive@v1.3.4 - name: Run revive run: revive ./... + + - name: Get changed Go directories + id: changed-dirs + if: github.event_name == 'pull_request' + uses: tj-actions/changed-files@v44 + with: + files: | + **/*.go + dir_names: true + + - name: Get staticcheck + if: github.event_name == 'pull_request' && steps.changed-dirs.outputs.any_changed == 'true' + run: go install honnef.co/go/tools/cmd/staticcheck@latest + + - name: Run staticcheck on changed packages + if: github.event_name == 'pull_request' && steps.changed-dirs.outputs.any_changed == 'true' + run: | + for dir in ${{ steps.changed-dirs.outputs.all_changed_files }}; do + echo "Running staticcheck on ./$dir/..." + GOGC=30 staticcheck "./$dir/..." + done + + deep_analysis: + name: Deep Analysis (Staticcheck) + # Only run on cron schedule or push to main, NOT on pull requests + if: github.event_name != 'pull_request' + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Free additional disk space + run: | + sudo rm -rf /usr/share/dotnet + sudo rm -rf /usr/local/lib/android + sudo rm -rf /opt/hostedtoolcache/CodeQL + - name: Set up Go + uses: actions/setup-go@v5 + with: + go-version-file: 'go.mod' + cache: true + # Dependency for Go module github.com/google/gopacket + - name: Install libpcap-dev + run: sudo apt-get -y install libpcap-dev + - name: Get staticcheck run: go install honnef.co/go/tools/cmd/staticcheck@latest - name: Run staticcheck From b064ad530ee865022f2530c652da59684033c7e2 Mon Sep 17 00:00:00 2001 From: Rishabh Agarwal Date: Thu, 30 Jul 2026 06:15:15 +0000 Subject: [PATCH 04/17] using third-party action instead of our own --- .github/workflows/go.yml | 53 ++++------------------------------------ 1 file changed, 5 insertions(+), 48 deletions(-) diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml index 390e76650bf..0b6ba86455a 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/go.yml @@ -55,8 +55,8 @@ jobs: with: path-to-profile: profile.cov - fast_analysis: - name: Fast Analysis + static_analysis: + name: Static Analysis runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 @@ -99,50 +99,7 @@ jobs: run: go install github.com/mgechev/revive@v1.3.4 - name: Run revive run: revive ./... - - - name: Get changed Go directories - id: changed-dirs - if: github.event_name == 'pull_request' - uses: tj-actions/changed-files@v44 - with: - files: | - **/*.go - dir_names: true - - - name: Get staticcheck - if: github.event_name == 'pull_request' && steps.changed-dirs.outputs.any_changed == 'true' - run: go install honnef.co/go/tools/cmd/staticcheck@latest - - - name: Run staticcheck on changed packages - if: github.event_name == 'pull_request' && steps.changed-dirs.outputs.any_changed == 'true' - run: | - for dir in ${{ steps.changed-dirs.outputs.all_changed_files }}; do - echo "Running staticcheck on ./$dir/..." - GOGC=30 staticcheck "./$dir/..." - done - - deep_analysis: - name: Deep Analysis (Staticcheck) - # Only run on cron schedule or push to main, NOT on pull requests - if: github.event_name != 'pull_request' - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - name: Free additional disk space - run: | - sudo rm -rf /usr/share/dotnet - sudo rm -rf /usr/local/lib/android - sudo rm -rf /opt/hostedtoolcache/CodeQL - - name: Set up Go - uses: actions/setup-go@v5 + - uses: dominikh/staticcheck-action@v1.3.1 with: - go-version-file: 'go.mod' - cache: true - # Dependency for Go module github.com/google/gopacket - - name: Install libpcap-dev - run: sudo apt-get -y install libpcap-dev - - - name: Get staticcheck - run: go install honnef.co/go/tools/cmd/staticcheck@latest - - name: Run staticcheck - run: GOGC=30 staticcheck ./... + version: "latest" + install-go: false From 80d47f01e2ec7f3d3cbe526ef2cbbbafcf1ad36a Mon Sep 17 00:00:00 2001 From: Rishabh Agarwal Date: Thu, 30 Jul 2026 08:11:17 +0000 Subject: [PATCH 05/17] Introduce failure in zrp --- .../zrp_laser_bias_current_test.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/feature/platform/transceiver/tests/zrp_laser_bias_current_test/zrp_laser_bias_current_test.go b/feature/platform/transceiver/tests/zrp_laser_bias_current_test/zrp_laser_bias_current_test.go index abef05f3e36..5d76c6fb58b 100644 --- a/feature/platform/transceiver/tests/zrp_laser_bias_current_test/zrp_laser_bias_current_test.go +++ b/feature/platform/transceiver/tests/zrp_laser_bias_current_test/zrp_laser_bias_current_test.go @@ -155,6 +155,14 @@ func TestZRLaserBiasCurrentStateInterfaceFlap(t *testing.T) { verifyLaserBiasCurrentAll(t, p1Stream, dut1) } +func dummyStaticcheckTest() { + x := 1 + // SA4000: identical expressions on the left and right side of the '==' operator + if x == x { + _ = x + } +} + func TestZRLaserBiasCurrentStateTransceiverOnOff(t *testing.T) { dut1 := ondatra.DUT(t, "dut") if !deviations.TransceiverConfigEnableUnsupported(dut1) { From e5597b40aa75a6b4d1de1b1f74226530083d699b Mon Sep 17 00:00:00 2001 From: Rishabh Agarwal Date: Thu, 30 Jul 2026 08:26:41 +0000 Subject: [PATCH 06/17] Fix FMT issues --- .../zrp_laser_bias_current_test.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/feature/platform/transceiver/tests/zrp_laser_bias_current_test/zrp_laser_bias_current_test.go b/feature/platform/transceiver/tests/zrp_laser_bias_current_test/zrp_laser_bias_current_test.go index 5d76c6fb58b..ad074e4233c 100644 --- a/feature/platform/transceiver/tests/zrp_laser_bias_current_test/zrp_laser_bias_current_test.go +++ b/feature/platform/transceiver/tests/zrp_laser_bias_current_test/zrp_laser_bias_current_test.go @@ -156,11 +156,11 @@ func TestZRLaserBiasCurrentStateInterfaceFlap(t *testing.T) { } func dummyStaticcheckTest() { - x := 1 - // SA4000: identical expressions on the left and right side of the '==' operator - if x == x { - _ = x - } + x := 1 + // SA4000: identical expressions on the left and right side of the '==' operator + if x == x { + _ = x + } } func TestZRLaserBiasCurrentStateTransceiverOnOff(t *testing.T) { From 2d28a7b6cf0458d04d62ce1a981b29d76cdb7aac Mon Sep 17 00:00:00 2001 From: Rishabh Agarwal Date: Fri, 31 Jul 2026 05:16:34 +0000 Subject: [PATCH 07/17] Experimenting with arm64 runners --- .github/workflows/go.yml | 57 +++++++++++++------ .../zrp_laser_bias_current_test.go | 8 --- 2 files changed, 39 insertions(+), 26 deletions(-) diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml index 0b6ba86455a..9dfaf632b78 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/go.yml @@ -8,7 +8,7 @@ on: - cron: "0 0 * * *" jobs: build: - runs-on: ubuntu-latest + runs-on: ubuntu-latest-arm64 steps: - uses: actions/checkout@v4 # Go & staticcheck build cache require a lot of disk space. Reclaim extra @@ -23,6 +23,10 @@ jobs: with: go-version-file: 'go.mod' cache: true + - name: Move cache + run: | + sudo mv "${HOME}/.cache" /mnt/cache + ln -s /mnt/cache "${HOME}/.cache" # Dependency for Go module github.com/google/gopacket - name: Install libpcap-dev run: sudo apt-get -y install libpcap-dev @@ -30,7 +34,7 @@ jobs: run: go build -v ./... test: - runs-on: ubuntu-latest + runs-on: ubuntu-latest-arm64 steps: - uses: actions/checkout@v4 # Go & staticcheck build cache require a lot of disk space. Reclaim extra @@ -45,6 +49,10 @@ jobs: with: go-version-file: 'go.mod' cache: true + - name: Move cache + run: | + sudo mv "${HOME}/.cache" /mnt/cache + ln -s /mnt/cache "${HOME}/.cache" # Dependency for Go module github.com/google/gopacket - name: Install libpcap-dev run: sudo apt-get -y install libpcap-dev @@ -57,7 +65,7 @@ jobs: static_analysis: name: Static Analysis - runs-on: ubuntu-latest + runs-on: ubuntu-latest-arm64 steps: - uses: actions/checkout@v4 - name: Free additional disk space @@ -70,36 +78,49 @@ jobs: with: go-version-file: 'go.mod' cache: true + - name: Move cache + run: | + sudo mv "${HOME}/.cache" /mnt/cache + ln -s /mnt/cache "${HOME}/.cache" # Dependency for Go module github.com/google/gopacket - name: Install libpcap-dev run: sudo apt-get -y install libpcap-dev + # === THIS IS THE ONLY CHANGE === + - name: Clean Go build cache before analysis + run: go clean -cache + # =============================== + - name: Go vet run: GOGC=30 go vet ./... - name: Gofmt run: | - # Use find to exclude generated pb.go files which take too long to parse - unformatted=$(find . -name "*.go" -type f | grep -v "pb.go$" | xargs gofmt -d -s) - if [ -n "$unformatted" ]; then - echo "$unformatted" + # gofmt always returns true, so we use grep '^' which returns + # true on non-empty output, but will otherwise passthrough all + # output lines. + if gofmt -d -s . | grep '^'; then exit 1 fi - name: Get goimports run: go install golang.org/x/tools/cmd/goimports@latest - name: Goimports run: | - # goimports does not support "gofmt -s" so both goimports and gofmt are required. - unformatted=$(find . -name "*.go" -type f | grep -v "pb.go$" | xargs goimports -l) - if [ -n "$unformatted" ]; then - echo "The following files have goimports formatting errors:" - echo "$unformatted" - exit 1 - fi + # goimports always returns true, so we use grep '^' which returns + # true on non-empty output, but will otherwise passthrough all + # output lines. + # + # goimports does not support "gofmt -s" so both goimports and gofmt are + # required. + find . -name "*.go" | egrep -v "pb.go$" | while read l; do + if goimports -d $l | grep '^'; then + exit 1; + fi; + done - name: Get revive run: go install github.com/mgechev/revive@v1.3.4 - name: Run revive run: revive ./... - - uses: dominikh/staticcheck-action@v1.3.1 - with: - version: "latest" - install-go: false + - name: Get staticcheck + run: go install honnef.co/go/tools/cmd/staticcheck@latest + - name: Run staticcheck + run: GOGC=30 staticcheck ./... diff --git a/feature/platform/transceiver/tests/zrp_laser_bias_current_test/zrp_laser_bias_current_test.go b/feature/platform/transceiver/tests/zrp_laser_bias_current_test/zrp_laser_bias_current_test.go index ad074e4233c..abef05f3e36 100644 --- a/feature/platform/transceiver/tests/zrp_laser_bias_current_test/zrp_laser_bias_current_test.go +++ b/feature/platform/transceiver/tests/zrp_laser_bias_current_test/zrp_laser_bias_current_test.go @@ -155,14 +155,6 @@ func TestZRLaserBiasCurrentStateInterfaceFlap(t *testing.T) { verifyLaserBiasCurrentAll(t, p1Stream, dut1) } -func dummyStaticcheckTest() { - x := 1 - // SA4000: identical expressions on the left and right side of the '==' operator - if x == x { - _ = x - } -} - func TestZRLaserBiasCurrentStateTransceiverOnOff(t *testing.T) { dut1 := ondatra.DUT(t, "dut") if !deviations.TransceiverConfigEnableUnsupported(dut1) { From 0992920848cd2657e56c919ab3a2adc6330e1ed8 Mon Sep 17 00:00:00 2001 From: Rishabh Agarwal Date: Fri, 31 Jul 2026 05:21:49 +0000 Subject: [PATCH 08/17] Address Zirmor issues --- .github/workflows/go.yml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml index 9dfaf632b78..8c031bed2fb 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/go.yml @@ -10,7 +10,7 @@ jobs: build: runs-on: ubuntu-latest-arm64 steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4 # Go & staticcheck build cache require a lot of disk space. Reclaim extra # space for the container by removing unnecessary tooling. - name: Free additional disk space @@ -19,7 +19,7 @@ jobs: sudo rm -rf /usr/local/lib/android sudo rm -rf /opt/hostedtoolcache/CodeQL - name: Set up Go - uses: actions/setup-go@v5 + uses: actions/setup-go@40f1582b2485089dde7abd97c1529aa768e1baff # v5 with: go-version-file: 'go.mod' cache: true @@ -36,7 +36,7 @@ jobs: test: runs-on: ubuntu-latest-arm64 steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4 # Go & staticcheck build cache require a lot of disk space. Reclaim extra # space for the container by removing unnecessary tooling. - name: Free additional disk space @@ -45,7 +45,7 @@ jobs: sudo rm -rf /usr/local/lib/android sudo rm -rf /opt/hostedtoolcache/CodeQL - name: Set up Go - uses: actions/setup-go@v5 + uses: actions/setup-go@40f1582b2485089dde7abd97c1529aa768e1baff # v5 with: go-version-file: 'go.mod' cache: true @@ -67,14 +67,14 @@ jobs: name: Static Analysis runs-on: ubuntu-latest-arm64 steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4 - name: Free additional disk space run: | sudo rm -rf /usr/share/dotnet sudo rm -rf /usr/local/lib/android sudo rm -rf /opt/hostedtoolcache/CodeQL - name: Set up Go - uses: actions/setup-go@v5 + uses: actions/setup-go@40f1582b2485089dde7abd97c1529aa768e1baff # v5 with: go-version-file: 'go.mod' cache: true From 2e3c70ce7531f1b57f0a3daaa0c980199bb84964 Mon Sep 17 00:00:00 2001 From: Rishabh Agarwal Date: Fri, 31 Jul 2026 05:24:47 +0000 Subject: [PATCH 09/17] Add permissions to go.yml --- .github/workflows/go.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml index 8c031bed2fb..c3b15cf7aad 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/go.yml @@ -6,6 +6,9 @@ on: pull_request: schedule: - cron: "0 0 * * *" +permissions: + contents: read + jobs: build: runs-on: ubuntu-latest-arm64 From 4cc170cc285bca22a651cf7a73207251a4375021 Mon Sep 17 00:00:00 2001 From: Rishabh Agarwal Date: Fri, 31 Jul 2026 05:28:07 +0000 Subject: [PATCH 10/17] Pin Runner version for Arm64 --- .github/workflows/go.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml index c3b15cf7aad..95bc5343478 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/go.yml @@ -11,7 +11,7 @@ permissions: jobs: build: - runs-on: ubuntu-latest-arm64 + runs-on: ubuntu-24.04-arm steps: - uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4 # Go & staticcheck build cache require a lot of disk space. Reclaim extra @@ -37,7 +37,7 @@ jobs: run: go build -v ./... test: - runs-on: ubuntu-latest-arm64 + runs-on: ubuntu-24.04-arm steps: - uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4 # Go & staticcheck build cache require a lot of disk space. Reclaim extra @@ -68,7 +68,7 @@ jobs: static_analysis: name: Static Analysis - runs-on: ubuntu-latest-arm64 + runs-on: ubuntu-24.04-arm steps: - uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4 - name: Free additional disk space From 2460848e46cb189a8ae9296c55c02bfcbdf98c40 Mon Sep 17 00:00:00 2001 From: Rishabh Agarwal Date: Fri, 31 Jul 2026 06:23:14 +0000 Subject: [PATCH 11/17] Add cache envs --- .github/workflows/go.yml | 36 +++++++++++++++++------------------- 1 file changed, 17 insertions(+), 19 deletions(-) diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml index 95bc5343478..abe7b8336e1 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/go.yml @@ -9,6 +9,10 @@ on: permissions: contents: read +env: + XDG_CACHE_HOME: /mnt/cache + GOMODCACHE: /mnt/cache/go-mod + jobs: build: runs-on: ubuntu-24.04-arm @@ -16,20 +20,19 @@ jobs: - uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4 # Go & staticcheck build cache require a lot of disk space. Reclaim extra # space for the container by removing unnecessary tooling. - - name: Free additional disk space + - name: Free additional disk space and prepare cache directory run: | sudo rm -rf /usr/share/dotnet sudo rm -rf /usr/local/lib/android sudo rm -rf /opt/hostedtoolcache/CodeQL + sudo mkdir -p /mnt/cache + sudo chown -R $USER:$USER /mnt/cache - name: Set up Go uses: actions/setup-go@40f1582b2485089dde7abd97c1529aa768e1baff # v5 with: go-version-file: 'go.mod' cache: true - - name: Move cache - run: | - sudo mv "${HOME}/.cache" /mnt/cache - ln -s /mnt/cache "${HOME}/.cache" + # Cache location is managed by XDG_CACHE_HOME env variable # Dependency for Go module github.com/google/gopacket - name: Install libpcap-dev run: sudo apt-get -y install libpcap-dev @@ -42,20 +45,19 @@ jobs: - uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4 # Go & staticcheck build cache require a lot of disk space. Reclaim extra # space for the container by removing unnecessary tooling. - - name: Free additional disk space + - name: Free additional disk space and prepare cache directory run: | sudo rm -rf /usr/share/dotnet sudo rm -rf /usr/local/lib/android sudo rm -rf /opt/hostedtoolcache/CodeQL + sudo mkdir -p /mnt/cache + sudo chown -R $USER:$USER /mnt/cache - name: Set up Go uses: actions/setup-go@40f1582b2485089dde7abd97c1529aa768e1baff # v5 with: go-version-file: 'go.mod' cache: true - - name: Move cache - run: | - sudo mv "${HOME}/.cache" /mnt/cache - ln -s /mnt/cache "${HOME}/.cache" + # Cache location is managed by XDG_CACHE_HOME env variable # Dependency for Go module github.com/google/gopacket - name: Install libpcap-dev run: sudo apt-get -y install libpcap-dev @@ -71,28 +73,24 @@ jobs: runs-on: ubuntu-24.04-arm steps: - uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4 - - name: Free additional disk space + - name: Free additional disk space and prepare cache directory run: | sudo rm -rf /usr/share/dotnet sudo rm -rf /usr/local/lib/android sudo rm -rf /opt/hostedtoolcache/CodeQL + sudo mkdir -p /mnt/cache + sudo chown -R $USER:$USER /mnt/cache - name: Set up Go uses: actions/setup-go@40f1582b2485089dde7abd97c1529aa768e1baff # v5 with: go-version-file: 'go.mod' cache: true - - name: Move cache - run: | - sudo mv "${HOME}/.cache" /mnt/cache - ln -s /mnt/cache "${HOME}/.cache" + # Cache location is managed by XDG_CACHE_HOME env variable # Dependency for Go module github.com/google/gopacket - name: Install libpcap-dev run: sudo apt-get -y install libpcap-dev - # === THIS IS THE ONLY CHANGE === - - name: Clean Go build cache before analysis - run: go clean -cache - # =============================== + # Removed counter-productive go clean -cache - name: Go vet run: GOGC=30 go vet ./... From 31e08d962587d1c826898240c1b0873091215a66 Mon Sep 17 00:00:00 2001 From: Rishabh Agarwal Date: Fri, 31 Jul 2026 07:01:17 +0000 Subject: [PATCH 12/17] Remove GOGC=30 --- .github/workflows/go.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml index abe7b8336e1..75edbf2688b 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/go.yml @@ -93,7 +93,7 @@ jobs: # Removed counter-productive go clean -cache - name: Go vet - run: GOGC=30 go vet ./... + run: go vet ./... - name: Gofmt run: | # gofmt always returns true, so we use grep '^' which returns @@ -124,4 +124,4 @@ jobs: - name: Get staticcheck run: go install honnef.co/go/tools/cmd/staticcheck@latest - name: Run staticcheck - run: GOGC=30 staticcheck ./... + run: staticcheck ./... From 32da65fa0e3e04bfedc27476c9ded650812f392f Mon Sep 17 00:00:00 2001 From: Rishabh Agarwal Date: Fri, 31 Jul 2026 07:32:14 +0000 Subject: [PATCH 13/17] Print cache size after static check --- .github/workflows/go.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml index 75edbf2688b..04aa9147171 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/go.yml @@ -125,3 +125,7 @@ jobs: run: go install honnef.co/go/tools/cmd/staticcheck@latest - name: Run staticcheck run: staticcheck ./... + - name: Print cache sizes + run: | + echo "=== Cache Sizes ===" + sudo du -sh /mnt/cache/* || true From 13d6d54362f6ba237bda40300a3e608d6c8dc9b4 Mon Sep 17 00:00:00 2001 From: Rishabh Agarwal Date: Fri, 31 Jul 2026 08:35:32 +0000 Subject: [PATCH 14/17] Store the cache - /mnt/cache/staticcheck --- .github/workflows/go.yml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml index 04aa9147171..90c7809d299 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/go.yml @@ -123,6 +123,13 @@ jobs: run: revive ./... - name: Get staticcheck run: go install honnef.co/go/tools/cmd/staticcheck@latest + - name: Cache staticcheck + uses: actions/cache@v4 + with: + path: /mnt/cache/staticcheck + key: ${{ runner.os }}-staticcheck-${{ github.sha }} + restore-keys: | + ${{ runner.os }}-staticcheck- - name: Run staticcheck run: staticcheck ./... - name: Print cache sizes From 7ca635689770205f4958f6494b92c343df5f9afc Mon Sep 17 00:00:00 2001 From: Rishabh Agarwal Date: Fri, 31 Jul 2026 09:57:46 +0000 Subject: [PATCH 15/17] Create a separate experimental action --- .github/workflows/go-experimental-arm.yml | 139 ++++++++++++++++++++++ .github/workflows/go.yml | 72 +++++------ 2 files changed, 169 insertions(+), 42 deletions(-) create mode 100644 .github/workflows/go-experimental-arm.yml diff --git a/.github/workflows/go-experimental-arm.yml b/.github/workflows/go-experimental-arm.yml new file mode 100644 index 00000000000..127ac6d198e --- /dev/null +++ b/.github/workflows/go-experimental-arm.yml @@ -0,0 +1,139 @@ +name: Go (ARM64 Experimental) + +# NOTE: This is an experimental workflow running on ARM64 infrastructure to +# evaluate execution speed and GitHub caching. +# DO NOT add this check as a required status check for branch protection. +# If this workflow fails, it should NOT block merges to main. + +on: + push: + branches: [ main ] + pull_request: + schedule: + - cron: "0 0 * * *" +permissions: + contents: read + +env: + XDG_CACHE_HOME: /mnt/cache + GOMODCACHE: /mnt/cache/go-mod + +jobs: + build: + runs-on: ubuntu-24.04-arm + steps: + - uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4 + # Go & staticcheck build cache require a lot of disk space. Reclaim extra + # space for the container by removing unnecessary tooling. + - name: Free additional disk space and prepare cache directory + run: | + sudo rm -rf /usr/share/dotnet + sudo rm -rf /usr/local/lib/android + sudo rm -rf /opt/hostedtoolcache/CodeQL + sudo mkdir -p /mnt/cache + sudo chown -R $USER:$USER /mnt/cache + - name: Set up Go + uses: actions/setup-go@40f1582b2485089dde7abd97c1529aa768e1baff # v5 + with: + go-version-file: 'go.mod' + cache: true + # Cache location is managed by XDG_CACHE_HOME env variable + # Dependency for Go module github.com/google/gopacket + - name: Install libpcap-dev + run: sudo apt-get -y install libpcap-dev + - name: Build + run: go build -v ./... + + test: + runs-on: ubuntu-24.04-arm + steps: + - uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4 + # Go & staticcheck build cache require a lot of disk space. Reclaim extra + # space for the container by removing unnecessary tooling. + - name: Free additional disk space and prepare cache directory + run: | + sudo rm -rf /usr/share/dotnet + sudo rm -rf /usr/local/lib/android + sudo rm -rf /opt/hostedtoolcache/CodeQL + sudo mkdir -p /mnt/cache + sudo chown -R $USER:$USER /mnt/cache + - name: Set up Go + uses: actions/setup-go@40f1582b2485089dde7abd97c1529aa768e1baff # v5 + with: + go-version-file: 'go.mod' + cache: true + # Cache location is managed by XDG_CACHE_HOME env variable + # Dependency for Go module github.com/google/gopacket + - name: Install libpcap-dev + run: sudo apt-get -y install libpcap-dev + - run: go test -v -coverprofile=profile.cov $(go list ./... | grep -v /.*test.*) + - name: Send coverage + continue-on-error: true + uses: shogo82148/actions-goveralls@7b1bd2871942af030d707d6574e5f684f9891fb2 + with: + path-to-profile: profile.cov + + static_analysis: + name: Static Analysis + runs-on: ubuntu-24.04-arm + steps: + - uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4 + - name: Free additional disk space and prepare cache directory + run: | + sudo rm -rf /usr/share/dotnet + sudo rm -rf /usr/local/lib/android + sudo rm -rf /opt/hostedtoolcache/CodeQL + sudo mkdir -p /mnt/cache + sudo chown -R $USER:$USER /mnt/cache + - name: Set up Go + uses: actions/setup-go@40f1582b2485089dde7abd97c1529aa768e1baff # v5 + with: + go-version-file: 'go.mod' + cache: true + # Cache location is managed by XDG_CACHE_HOME env variable + # Dependency for Go module github.com/google/gopacket + - name: Install libpcap-dev + run: sudo apt-get -y install libpcap-dev + + # Removed counter-productive go clean -cache + + - name: Go vet + run: go vet ./... + - name: Gofmt + run: | + # gofmt always returns true, so we use grep '^' which returns + # true on non-empty output, but will otherwise passthrough all + # output lines. + if gofmt -d -s . | grep '^'; then + exit 1 + fi + - name: Get goimports + run: go install golang.org/x/tools/cmd/goimports@latest + - name: Goimports + run: | + # goimports always returns true, so we use grep '^' which returns + # true on non-empty output, but will otherwise passthrough all + # output lines. + # + # goimports does not support "gofmt -s" so both goimports and gofmt are + # required. + find . -name "*.go" | egrep -v "pb.go$" | while read l; do + if goimports -d $l | grep '^'; then + exit 1; + fi; + done + - name: Get revive + run: go install github.com/mgechev/revive@v1.3.4 + - name: Run revive + run: revive ./... + - name: Get staticcheck + run: go install honnef.co/go/tools/cmd/staticcheck@latest + - name: Cache staticcheck + uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4 + with: + path: /mnt/cache/staticcheck + key: ${{ runner.os }}-staticcheck-${{ github.sha }} + restore-keys: | + ${{ runner.os }}-staticcheck- + - name: Run staticcheck + run: staticcheck ./... \ No newline at end of file diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml index 90c7809d299..a1ca9259f9e 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/go.yml @@ -6,33 +6,27 @@ on: pull_request: schedule: - cron: "0 0 * * *" -permissions: - contents: read - -env: - XDG_CACHE_HOME: /mnt/cache - GOMODCACHE: /mnt/cache/go-mod - jobs: build: - runs-on: ubuntu-24.04-arm + runs-on: ubuntu-latest steps: - - uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4 + - uses: actions/checkout@v4 # Go & staticcheck build cache require a lot of disk space. Reclaim extra # space for the container by removing unnecessary tooling. - - name: Free additional disk space and prepare cache directory + - name: Free additional disk space run: | sudo rm -rf /usr/share/dotnet sudo rm -rf /usr/local/lib/android sudo rm -rf /opt/hostedtoolcache/CodeQL - sudo mkdir -p /mnt/cache - sudo chown -R $USER:$USER /mnt/cache - name: Set up Go - uses: actions/setup-go@40f1582b2485089dde7abd97c1529aa768e1baff # v5 + uses: actions/setup-go@v5 with: go-version-file: 'go.mod' cache: true - # Cache location is managed by XDG_CACHE_HOME env variable + - name: Move cache + run: | + sudo mv "${HOME}/.cache" /mnt/cache + ln -s /mnt/cache "${HOME}/.cache" # Dependency for Go module github.com/google/gopacket - name: Install libpcap-dev run: sudo apt-get -y install libpcap-dev @@ -40,24 +34,25 @@ jobs: run: go build -v ./... test: - runs-on: ubuntu-24.04-arm + runs-on: ubuntu-latest steps: - - uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4 + - uses: actions/checkout@v4 # Go & staticcheck build cache require a lot of disk space. Reclaim extra # space for the container by removing unnecessary tooling. - - name: Free additional disk space and prepare cache directory + - name: Free additional disk space run: | sudo rm -rf /usr/share/dotnet sudo rm -rf /usr/local/lib/android sudo rm -rf /opt/hostedtoolcache/CodeQL - sudo mkdir -p /mnt/cache - sudo chown -R $USER:$USER /mnt/cache - name: Set up Go - uses: actions/setup-go@40f1582b2485089dde7abd97c1529aa768e1baff # v5 + uses: actions/setup-go@v5 with: go-version-file: 'go.mod' cache: true - # Cache location is managed by XDG_CACHE_HOME env variable + - name: Move cache + run: | + sudo mv "${HOME}/.cache" /mnt/cache + ln -s /mnt/cache "${HOME}/.cache" # Dependency for Go module github.com/google/gopacket - name: Install libpcap-dev run: sudo apt-get -y install libpcap-dev @@ -70,30 +65,34 @@ jobs: static_analysis: name: Static Analysis - runs-on: ubuntu-24.04-arm + runs-on: ubuntu-latest steps: - - uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4 - - name: Free additional disk space and prepare cache directory + - uses: actions/checkout@v4 + - name: Free additional disk space run: | sudo rm -rf /usr/share/dotnet sudo rm -rf /usr/local/lib/android sudo rm -rf /opt/hostedtoolcache/CodeQL - sudo mkdir -p /mnt/cache - sudo chown -R $USER:$USER /mnt/cache - name: Set up Go - uses: actions/setup-go@40f1582b2485089dde7abd97c1529aa768e1baff # v5 + uses: actions/setup-go@v5 with: go-version-file: 'go.mod' cache: true - # Cache location is managed by XDG_CACHE_HOME env variable + - name: Move cache + run: | + sudo mv "${HOME}/.cache" /mnt/cache + ln -s /mnt/cache "${HOME}/.cache" # Dependency for Go module github.com/google/gopacket - name: Install libpcap-dev run: sudo apt-get -y install libpcap-dev - # Removed counter-productive go clean -cache + # === THIS IS THE ONLY CHANGE === + - name: Clean Go build cache before analysis + run: go clean -cache + # =============================== - name: Go vet - run: go vet ./... + run: GOGC=30 go vet ./... - name: Gofmt run: | # gofmt always returns true, so we use grep '^' which returns @@ -123,16 +122,5 @@ jobs: run: revive ./... - name: Get staticcheck run: go install honnef.co/go/tools/cmd/staticcheck@latest - - name: Cache staticcheck - uses: actions/cache@v4 - with: - path: /mnt/cache/staticcheck - key: ${{ runner.os }}-staticcheck-${{ github.sha }} - restore-keys: | - ${{ runner.os }}-staticcheck- - name: Run staticcheck - run: staticcheck ./... - - name: Print cache sizes - run: | - echo "=== Cache Sizes ===" - sudo du -sh /mnt/cache/* || true + run: GOGC=30 staticcheck ./... From 6e5f5c6072366c7f29705c78be93a4ebd3d6ab9b Mon Sep 17 00:00:00 2001 From: Rishabh Agarwal Date: Mon, 3 Aug 2026 07:45:25 +0000 Subject: [PATCH 16/17] Add names to avoid matching with the required check --- .github/workflows/go-experimental-arm.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/go-experimental-arm.yml b/.github/workflows/go-experimental-arm.yml index 127ac6d198e..de22ffdd18e 100644 --- a/.github/workflows/go-experimental-arm.yml +++ b/.github/workflows/go-experimental-arm.yml @@ -20,6 +20,7 @@ env: jobs: build: + name: Build (ARM64) runs-on: ubuntu-24.04-arm steps: - uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4 @@ -45,6 +46,7 @@ jobs: run: go build -v ./... test: + name: Test (ARM64) runs-on: ubuntu-24.04-arm steps: - uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4 @@ -74,7 +76,7 @@ jobs: path-to-profile: profile.cov static_analysis: - name: Static Analysis + name: Static Analysis (ARM64) runs-on: ubuntu-24.04-arm steps: - uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4 From 6bde135b6676e42f6f9503d357973e3de880c8ec Mon Sep 17 00:00:00 2001 From: Rishabh Agarwal Date: Tue, 4 Aug 2026 07:23:47 +0000 Subject: [PATCH 17/17] Use correct cache key --- .github/workflows/go-experimental-arm.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/go-experimental-arm.yml b/.github/workflows/go-experimental-arm.yml index de22ffdd18e..95e20e39333 100644 --- a/.github/workflows/go-experimental-arm.yml +++ b/.github/workflows/go-experimental-arm.yml @@ -134,7 +134,7 @@ jobs: uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4 with: path: /mnt/cache/staticcheck - key: ${{ runner.os }}-staticcheck-${{ github.sha }} + key: ${{ runner.os }}-staticcheck-${{ hashFiles('**/go.sum') }} restore-keys: | ${{ runner.os }}-staticcheck- - name: Run staticcheck