From edb5c74bcd360e81fd5808e6db4c2a96f25ec769 Mon Sep 17 00:00:00 2001 From: Jeremy Lewi Date: Fri, 24 May 2024 18:38:46 -0700 Subject: [PATCH 1/8] Enable all unittests in CI * A lot of unittests aren't running on CI because the GHA currently * Runs all tests but only on windows and a bunch of tests have the build tag !windows * On docker ubuntu only the tests with the dag docker ubuntu run * The fix is to update the GHA that runs `make test` to run on all OSS * This rule doesn't use any build tags so it will run all tests. * Fix #587 --- .github/workflows/ci.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e4b9f5e9d..16400efd0 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -64,11 +64,12 @@ jobs: TAGS="test_with_docker" make test/coverage make test/coverage/func if: ${{ matrix.os == 'ubuntu-latest' }} + # make test should run on all os's because + # on windows only a subset of the tests run. - name: Test run: | Set-Timezone -Id "UTC" -PassThru - make test - if: ${{ matrix.os == 'windows-latest' }} + make test - name: Upload coverage uses: actions/upload-artifact@v4 if: ${{github.actor != 'dependabot[bot]' && matrix.os == 'ubuntu-latest'}} From 57c40134bc676028d1c4e46390e1a607bf27fc76 Mon Sep 17 00:00:00 2001 From: Jeremy Lewi Date: Fri, 24 May 2024 18:46:15 -0700 Subject: [PATCH 2/8] Fix the tests. --- .github/workflows/ci.yml | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 16400efd0..edb855b91 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -57,19 +57,27 @@ jobs: run: | go build -o runme main.go ./runme --version + - name: Test All + run: | + export SHELL=/bin/bash + export TZ=UTC + make test + if: ${{ matrix.os == 'ubuntu-latest' }} - name: Test run: | export SHELL=/bin/bash export TZ=UTC TAGS="test_with_docker" make test/coverage make test/coverage/func - if: ${{ matrix.os == 'ubuntu-latest' }} + if: ${{ matrix.os == 'ubuntu-latest' }} # make test should run on all os's because # on windows only a subset of the tests run. - name: Test + # N.B. Set-Timezone is a windows command run: | Set-Timezone -Id "UTC" -PassThru - make test + make test + if: ${{ matrix.os == 'windows-latest' }} - name: Upload coverage uses: actions/upload-artifact@v4 if: ${{github.actor != 'dependabot[bot]' && matrix.os == 'ubuntu-latest'}} From 44e8f550f1a1ac8a206fc5de82fab39caf99a17f Mon Sep 17 00:00:00 2001 From: Jeremy Lewi Date: Fri, 24 May 2024 18:50:21 -0700 Subject: [PATCH 3/8] Skip flaky test. --- internal/runner/service_test.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/internal/runner/service_test.go b/internal/runner/service_test.go index 9a1c312fd..c10a76fcc 100644 --- a/internal/runner/service_test.go +++ b/internal/runner/service_test.go @@ -347,6 +347,9 @@ func Test_runnerService(t *testing.T) { }) t.Run("Input", func(t *testing.T) { + if os.Getenv("RUN_FLAKY") == "" { + t.Skip("skipping flaky test") + } t.Parallel() stream, err := client.Execute(context.Background()) From 1317fdcb20b15f48e51fd7f11084b12ac2870c0f Mon Sep 17 00:00:00 2001 From: Jeremy Lewi Date: Fri, 24 May 2024 18:51:41 -0700 Subject: [PATCH 4/8] Fix lint. --- .github/workflows/ci.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index edb855b91..5b56756b6 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -61,7 +61,7 @@ jobs: run: | export SHELL=/bin/bash export TZ=UTC - make test + make test if: ${{ matrix.os == 'ubuntu-latest' }} - name: Test run: | @@ -69,15 +69,15 @@ jobs: export TZ=UTC TAGS="test_with_docker" make test/coverage make test/coverage/func - if: ${{ matrix.os == 'ubuntu-latest' }} + if: ${{ matrix.os == 'ubuntu-latest' }} # make test should run on all os's because # on windows only a subset of the tests run. - name: Test - # N.B. Set-Timezone is a windows command + # N.B. Set-Timezone is a windows command run: | Set-Timezone -Id "UTC" -PassThru make test - if: ${{ matrix.os == 'windows-latest' }} + if: ${{ matrix.os == 'windows-latest' }} - name: Upload coverage uses: actions/upload-artifact@v4 if: ${{github.actor != 'dependabot[bot]' && matrix.os == 'ubuntu-latest'}} From 9a1b898a613ac0f70903e89345cc8b198e5b1cfe Mon Sep 17 00:00:00 2001 From: Jeremy Lewi Date: Fri, 24 May 2024 19:05:33 -0700 Subject: [PATCH 5/8] Disable sonar step in forks. --- .github/workflows/ci.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 5b56756b6..39e0d0ac1 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -134,6 +134,10 @@ jobs: - name: SonarCloud Scan uses: SonarSource/sonarcloud-github-action@v2.1.1 + # Skip this test if the PR is created from a fork. + # If its created from a fork the PR won't be able to fetch the secrets so + # the step will fail. + if: github.event.pull_request.head.repo.full_name == github.repository env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} From 4ba685c4398b0c5a22b5b33c94b8fe92288d2930 Mon Sep 17 00:00:00 2001 From: Jeremy Lewi Date: Fri, 31 May 2024 15:44:41 -0700 Subject: [PATCH 6/8] Revert changes to ci.yaml because that's not the problem --- .github/workflows/ci.yml | 9 --------- 1 file changed, 9 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 39e0d0ac1..88a0aa56d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -57,12 +57,6 @@ jobs: run: | go build -o runme main.go ./runme --version - - name: Test All - run: | - export SHELL=/bin/bash - export TZ=UTC - make test - if: ${{ matrix.os == 'ubuntu-latest' }} - name: Test run: | export SHELL=/bin/bash @@ -70,10 +64,7 @@ jobs: TAGS="test_with_docker" make test/coverage make test/coverage/func if: ${{ matrix.os == 'ubuntu-latest' }} - # make test should run on all os's because - # on windows only a subset of the tests run. - name: Test - # N.B. Set-Timezone is a windows command run: | Set-Timezone -Id "UTC" -PassThru make test From f1653634ef4af3cadd5c1f5ae4a043707669ea09 Mon Sep 17 00:00:00 2001 From: Jeremy Lewi Date: Sat, 1 Jun 2024 18:53:46 -0700 Subject: [PATCH 7/8] Update internal/runner/service_test.go Co-authored-by: Adam Babik --- internal/runner/service_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/runner/service_test.go b/internal/runner/service_test.go index eb33c20c3..fd1bad618 100644 --- a/internal/runner/service_test.go +++ b/internal/runner/service_test.go @@ -347,7 +347,7 @@ func Test_runnerService(t *testing.T) { }) t.Run("Input", func(t *testing.T) { - if os.Getenv("RUN_FLAKY") == "" { + if skip, err := strconv.ParseBool(os.Getenv("SKIP_FLAKY")); err == nil && skip { t.Skip("skipping flaky test") } t.Parallel() From d4e0bdeb567feb097617978e19f3b37042b403ef Mon Sep 17 00:00:00 2001 From: Sebastian Tiedtke Date: Mon, 3 Jun 2024 10:03:03 -0400 Subject: [PATCH 8/8] Add import --- internal/runner/service_test.go | 1 + 1 file changed, 1 insertion(+) diff --git a/internal/runner/service_test.go b/internal/runner/service_test.go index fd1bad618..f7514a4dc 100644 --- a/internal/runner/service_test.go +++ b/internal/runner/service_test.go @@ -11,6 +11,7 @@ import ( "os" "os/exec" "runtime" + "strconv" "strings" "syscall" "testing"