From 8a44a61a77a21d958e5e8432d40da8602bc468a6 Mon Sep 17 00:00:00 2001 From: Ammar Bandukwala Date: Fri, 9 Jun 2023 20:26:35 +0000 Subject: [PATCH 1/8] ci: increase parallelism for Windows tests --- .github/workflows/ci.yaml | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 9941112481f1c..64ed977fc81b5 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -218,8 +218,16 @@ jobs: echo "cover=false" >> $GITHUB_OUTPUT fi + parallelism=8 + if [ "${{ matrix.os }}" == "windows-2019" ]; then + # Windows appears more I/O bound, so we increase parallelism + # to make better use of CPU. + parallelism=16 + fi + export TS_DEBUG_DISCO=true - gotestsum --junitfile="gotests.xml" --jsonfile="gotests.json" --packages="./..." -- -parallel=8 -timeout=7m -short -failfast $COVERAGE_FLAGS + gotestsum --junitfile="gotests.xml" --jsonfile="gotests.json" \ + --packages="./..." -- -parallel=$parallelism -short -failfast $COVERAGE_FLAGS - name: Print test stats if: success() || failure() From e5bd9e25b62ccb3a0afa1bc9487d4520b31141a3 Mon Sep 17 00:00:00 2001 From: Ammar Bandukwala Date: Fri, 9 Jun 2023 20:27:58 +0000 Subject: [PATCH 2/8] fixup! ci: increase parallelism for Windows tests --- .github/workflows/ci.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 64ed977fc81b5..1a009a6136b05 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -218,16 +218,16 @@ jobs: echo "cover=false" >> $GITHUB_OUTPUT fi - parallelism=8 + PARALLEL_FLAG="" if [ "${{ matrix.os }}" == "windows-2019" ]; then # Windows appears more I/O bound, so we increase parallelism # to make better use of CPU. - parallelism=16 + PARALLEL_FLAG="-parallel=16" fi export TS_DEBUG_DISCO=true gotestsum --junitfile="gotests.xml" --jsonfile="gotests.json" \ - --packages="./..." -- -parallel=$parallelism -short -failfast $COVERAGE_FLAGS + --packages="./..." -- $PARALLEL_FLAG -short -failfast $COVERAGE_FLAGS - name: Print test stats if: success() || failure() From f36d72c6925d6dbedbccf2f17ef1aeb7f31467d3 Mon Sep 17 00:00:00 2001 From: Ammar Bandukwala Date: Fri, 9 Jun 2023 20:36:40 +0000 Subject: [PATCH 3/8] Improve caching --- .github/actions/setup-go/action.yaml | 13 +++++++++++++ .github/workflows/ci.yaml | 2 ++ 2 files changed, 15 insertions(+) diff --git a/.github/actions/setup-go/action.yaml b/.github/actions/setup-go/action.yaml index e54bcf36a9e29..0803dacba1c67 100644 --- a/.github/actions/setup-go/action.yaml +++ b/.github/actions/setup-go/action.yaml @@ -4,6 +4,10 @@ description: | runs: using: "composite" steps: + - shell: bash + run: | + # Aids in debugging + go env - uses: buildjet/setup-go@v4 with: cache: true @@ -13,3 +17,12 @@ runs: with: repo: gotestyourself/gotestsum tag: v1.9.0 + + - uses: buildjet/cache@v3 + with: + # This cache includes $GOCACHE, which is used for + # test caching. + path: ~/.cache + key: buildjet-gocache-${{ hashFiles('**/*.go') }} + restore-keys: | + buildjet-gocache- diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 1a009a6136b05..a02fa6d849b56 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -218,6 +218,8 @@ jobs: echo "cover=false" >> $GITHUB_OUTPUT fi + # By default Go will use the number of logical CPUs, which + # is a fine default. PARALLEL_FLAG="" if [ "${{ matrix.os }}" == "windows-2019" ]; then # Windows appears more I/O bound, so we increase parallelism From 0294442ef7bf97448ddef49df33f58d154094335 Mon Sep 17 00:00:00 2001 From: Ammar Bandukwala Date: Fri, 9 Jun 2023 20:45:15 +0000 Subject: [PATCH 4/8] Simplify caching --- .github/actions/setup-go/action.yaml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/actions/setup-go/action.yaml b/.github/actions/setup-go/action.yaml index 0803dacba1c67..557bc3341c89b 100644 --- a/.github/actions/setup-go/action.yaml +++ b/.github/actions/setup-go/action.yaml @@ -20,9 +20,9 @@ runs: - uses: buildjet/cache@v3 with: - # This cache includes $GOCACHE, which is used for - # test caching. - path: ~/.cache - key: buildjet-gocache-${{ hashFiles('**/*.go') }} + path: | + ~/.cache/go-build + ~/go/pkg + key: go-${{ hashFiles('**/*.go', 'go.**') }} restore-keys: | - buildjet-gocache- + go- From 2ecccbb98e162087a8cc96664cb8e6fac155dbae Mon Sep 17 00:00:00 2001 From: Ammar Bandukwala Date: Fri, 9 Jun 2023 20:58:38 +0000 Subject: [PATCH 5/8] Update caches --- .github/actions/setup-go/action.yaml | 30 +++++++++++++++++----------- 1 file changed, 18 insertions(+), 12 deletions(-) diff --git a/.github/actions/setup-go/action.yaml b/.github/actions/setup-go/action.yaml index 557bc3341c89b..486e89772f375 100644 --- a/.github/actions/setup-go/action.yaml +++ b/.github/actions/setup-go/action.yaml @@ -4,25 +4,31 @@ description: | runs: using: "composite" steps: - - shell: bash - run: | - # Aids in debugging - go env - uses: buildjet/setup-go@v4 with: cache: true go-version: "1.20.5" - - name: Install gotestsum - uses: jaxxstorm/action-install-gh-release@v1.10.0 - with: - repo: gotestyourself/gotestsum - tag: v1.9.0 - uses: buildjet/cache@v3 with: + # ~/go/pkg is the same across operating systems. path: | - ~/.cache/go-build ~/go/pkg - key: go-${{ hashFiles('**/*.go', 'go.**') }} + ~/.cache/go-build + ~/AppData/Local/go-build + ~/Library/Caches/go-build + key: go-${{ runner.os }}-${{ hashFiles('**/*.go', 'go.**') }} restore-keys: | - go- + go-${{ runner.os }} + + - name: Install gotestsum + uses: jaxxstorm/action-install-gh-release@v1.10.0 + with: + repo: gotestyourself/gotestsum + tag: v1.9.0 + + # It isn't necessary that we ever do this, but it helps + # separate the "setup" from the "run" times. + - name: go mod download + shell: bash + run: go mod download From 4c252e7cfc76b3b1c2b25b69f528af116404c008 Mon Sep 17 00:00:00 2001 From: Ammar Bandukwala Date: Fri, 9 Jun 2023 21:13:07 +0000 Subject: [PATCH 6/8] Further improve --- .github/actions/setup-go/action.yaml | 12 ++++++++---- .github/workflows/ci.yaml | 7 ------- 2 files changed, 8 insertions(+), 11 deletions(-) diff --git a/.github/actions/setup-go/action.yaml b/.github/actions/setup-go/action.yaml index 486e89772f375..698154a839688 100644 --- a/.github/actions/setup-go/action.yaml +++ b/.github/actions/setup-go/action.yaml @@ -17,10 +17,14 @@ runs: ~/.cache/go-build ~/AppData/Local/go-build ~/Library/Caches/go-build - key: go-${{ runner.os }}-${{ hashFiles('**/*.go', 'go.**') }} + # Job name must be included in the key for effective + # test cache reuse. + key: go-${{ runner.os }}-${{ github.job }}-${{ hashFiles('**/*.go', 'go.**') }} restore-keys: | - go-${{ runner.os }} - + go-${{ runner.os }}-${{ github.job }}- + go-${{ runner.os }}- + go- + - name: Install gotestsum uses: jaxxstorm/action-install-gh-release@v1.10.0 with: @@ -31,4 +35,4 @@ runs: # separate the "setup" from the "run" times. - name: go mod download shell: bash - run: go mod download + run: go mod download -x diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index a02fa6d849b56..52fbd149bca71 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -238,13 +238,6 @@ jobs: # so we need to print the test stats to the log. go run ./scripts/ci-report/main.go gotests.json | tee gotests_stats.json - - uses: actions/upload-artifact@v3 - if: success() || failure() - with: - name: gotests-${{ matrix.os }}.xml - path: ./gotests.xml - retention-days: 30 - - uses: ./.github/actions/upload-datadog if: always() with: From bd5a452e6cd652771776260ffedce192eb1444dc Mon Sep 17 00:00:00 2001 From: Ammar Bandukwala Date: Fri, 9 Jun 2023 21:18:56 +0000 Subject: [PATCH 7/8] fixup! Further improve --- .github/actions/setup-go/action.yaml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/actions/setup-go/action.yaml b/.github/actions/setup-go/action.yaml index 698154a839688..f286334855134 100644 --- a/.github/actions/setup-go/action.yaml +++ b/.github/actions/setup-go/action.yaml @@ -9,7 +9,8 @@ runs: cache: true go-version: "1.20.5" - - uses: buildjet/cache@v3 + - name: Cache go + uses: buildjet/cache@v3 with: # ~/go/pkg is the same across operating systems. path: | From 26857bb2b99a6eb9d699cd322afda58d98adc28c Mon Sep 17 00:00:00 2001 From: Ammar Bandukwala Date: Fri, 9 Jun 2023 21:23:22 +0000 Subject: [PATCH 8/8] Enable test caching for postgres --- Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 920c6b6816980..00af3932877c3 100644 --- a/Makefile +++ b/Makefile @@ -610,6 +610,7 @@ test: test-clean # When updating -timeout for this test, keep in sync with # test-go-postgres (.github/workflows/coder.yaml). +# Do add coverage flags so that test caching works. test-postgres: test-clean test-postgres-docker # The postgres test is prone to failure, so we limit parallelism for # more consistent execution. @@ -617,8 +618,7 @@ test-postgres: test-clean test-postgres-docker --junitfile="gotests.xml" \ --jsonfile="gotests.json" \ --packages="./..." -- \ - -covermode=atomic -coverprofile="gotests.coverage" -timeout=20m \ - -coverpkg=./... \ + -timeout=20m \ -failfast .PHONY: test-postgres