From a26fd503d6c1be80262ebdb9b5a7abbb04fe638c Mon Sep 17 00:00:00 2001 From: Ammar Bandukwala Date: Sat, 10 Jun 2023 17:19:26 +0000 Subject: [PATCH 01/25] ci: cache Go only once --- .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 f286334855134..f27a837f7738b 100644 --- a/.github/actions/setup-go/action.yaml +++ b/.github/actions/setup-go/action.yaml @@ -6,7 +6,8 @@ runs: steps: - uses: buildjet/setup-go@v4 with: - cache: true + # We do our own caching for implementation clarity. + cache: false go-version: "1.20.5" - name: Cache go From 0c2c580fed7dd89dbab7f55176e901c197329552 Mon Sep 17 00:00:00 2001 From: Ammar Bandukwala Date: Sat, 10 Jun 2023 17:33:22 +0000 Subject: [PATCH 02/25] Simplify --- .github/workflows/ci.yaml | 23 ++++++++--------------- 1 file changed, 8 insertions(+), 15 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 4ee4fddb1e072..e99660db4e24b 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -158,16 +158,14 @@ jobs: - name: Install sqlc run: | curl -sSL https://github.com/kyleconroy/sqlc/releases/download/v1.17.2/sqlc_1.17.2_linux_amd64.tar.gz | sudo tar -C /usr/bin -xz sqlc - - name: Install protoc-gen-go - run: go install google.golang.org/protobuf/cmd/protoc-gen-go@v1.30 - - name: Install protoc-gen-go-drpc - run: go install storj.io/drpc/cmd/protoc-gen-go-drpc@v0.0.33 - - name: Install goimports - run: go install golang.org/x/tools/cmd/goimports@latest - - name: Install yq - run: go run github.com/mikefarah/yq/v4@v4.30.6 - - name: Install mockgen - run: go install github.com/golang/mock/mockgen@v1.6.0 + + - name: go install tools + run: | + go install google.golang.org/protobuf/cmd/protoc-gen-go@v1.30 \ + storj.io/drpc/cmd/protoc-gen-go-drpc@v0.0.33 \ + golang.org/x/tools/cmd/goimports@latest \ + github.com/mikefarah/yq/v4@v4.30.6 \ + github.com/golang/mock/mockgen@v1.6.0 - name: Install Protoc run: | @@ -349,11 +347,6 @@ jobs: - uses: ./.github/actions/setup-go - - uses: hashicorp/setup-terraform@v2 - with: - terraform_version: 1.1.9 - terraform_wrapper: false - - name: Run Tests run: | gotestsum --junitfile="gotests.xml" -- -race ./... From d2909e8f7a4854bcc103b77a9493f54cf0b7c09b Mon Sep 17 00:00:00 2001 From: Ammar Bandukwala Date: Sat, 10 Jun 2023 17:46:15 +0000 Subject: [PATCH 03/25] Cache toolchain --- .github/actions/setup-go/action.yaml | 23 ++++++++++++++++++----- .github/workflows/ci.yaml | 10 +++++----- 2 files changed, 23 insertions(+), 10 deletions(-) diff --git a/.github/actions/setup-go/action.yaml b/.github/actions/setup-go/action.yaml index f27a837f7738b..cff1205084315 100644 --- a/.github/actions/setup-go/action.yaml +++ b/.github/actions/setup-go/action.yaml @@ -1,14 +1,27 @@ name: "Setup Go" description: | Sets up the Go environment for tests, builds, etc. +inputs: + version: + description: "The Go version to use." + default: "1.20.5" runs: using: "composite" steps: + - name: Cache go toolchain + uses: buildjet/cache@v3 + with: + path: | + ${{ env.RUNNER_TOOL_CACHE }}/go/${{ inputs.version }} + key: gotoolchain-${{ runner.os }}-${{ inputs.version }} + restore-keys: | + gotoolchain-${{ runner.os }}- + - uses: buildjet/setup-go@v4 with: # We do our own caching for implementation clarity. cache: false - go-version: "1.20.5" + go-version: ${{ inputs.version }} - name: Cache go uses: buildjet/cache@v3 @@ -21,11 +34,11 @@ runs: ~/Library/Caches/go-build # Job name must be included in the key for effective # test cache reuse. - key: go-${{ runner.os }}-${{ github.job }}-${{ hashFiles('**/*.go', 'go.**') }} + key: gocache-${{ runner.os }}-${{ github.job }}-${{ hashFiles('**/*.go', 'go.**') }} restore-keys: | - go-${{ runner.os }}-${{ github.job }}- - go-${{ runner.os }}- - go- + gocache-${{ runner.os }}-${{ github.job }}- + gocache-${{ runner.os }}- + gocache- - name: Install gotestsum uses: jaxxstorm/action-install-gh-release@v1.10.0 diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index e99660db4e24b..15c25375124e9 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -161,11 +161,11 @@ jobs: - name: go install tools run: | - go install google.golang.org/protobuf/cmd/protoc-gen-go@v1.30 \ - storj.io/drpc/cmd/protoc-gen-go-drpc@v0.0.33 \ - golang.org/x/tools/cmd/goimports@latest \ - github.com/mikefarah/yq/v4@v4.30.6 \ - github.com/golang/mock/mockgen@v1.6.0 + go install google.golang.org/protobuf/cmd/protoc-gen-go@v1.30 + go install storj.io/drpc/cmd/protoc-gen-go-drpc@v0.0.33 + go install golang.org/x/tools/cmd/goimports@latest + go install github.com/mikefarah/yq/v4@v4.30.6 + go install github.com/golang/mock/mockgen@v1.6.0 - name: Install Protoc run: | From ece4e2a3862d7aaea8d981da2661e088d234284c Mon Sep 17 00:00:00 2001 From: Ammar Bandukwala Date: Sat, 10 Jun 2023 17:50:59 +0000 Subject: [PATCH 04/25] Dump env --- .github/actions/setup-go/action.yaml | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/.github/actions/setup-go/action.yaml b/.github/actions/setup-go/action.yaml index cff1205084315..9f3d2eba77f5b 100644 --- a/.github/actions/setup-go/action.yaml +++ b/.github/actions/setup-go/action.yaml @@ -8,6 +8,11 @@ inputs: runs: using: "composite" steps: + - name: dump env + shell: bash + run: | + env + - name: Cache go toolchain uses: buildjet/cache@v3 with: @@ -41,10 +46,8 @@ runs: gocache- - name: Install gotestsum - uses: jaxxstorm/action-install-gh-release@v1.10.0 - with: - repo: gotestyourself/gotestsum - tag: v1.9.0 + shell: bash + run: go install gotest.tools/gotestsum@latest # It isn't necessary that we ever do this, but it helps # separate the "setup" from the "run" times. From 2eeb2ae83ece51613a9d7adff03213d130f6c618 Mon Sep 17 00:00:00 2001 From: Ammar Bandukwala Date: Sat, 10 Jun 2023 17:54:29 +0000 Subject: [PATCH 05/25] Cache Go toolchain --- .github/actions/setup-go/action.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/actions/setup-go/action.yaml b/.github/actions/setup-go/action.yaml index 9f3d2eba77f5b..f2f9d35b07c07 100644 --- a/.github/actions/setup-go/action.yaml +++ b/.github/actions/setup-go/action.yaml @@ -17,7 +17,7 @@ runs: uses: buildjet/cache@v3 with: path: | - ${{ env.RUNNER_TOOL_CACHE }}/go/${{ inputs.version }} + ${{ env.AGENT_TOOLSDIRECTORY }}/go/${{ inputs.version }} key: gotoolchain-${{ runner.os }}-${{ inputs.version }} restore-keys: | gotoolchain-${{ runner.os }}- From 1004b9a930145e5cee2a549ded3e2ddad29e0d26 Mon Sep 17 00:00:00 2001 From: Ammar Bandukwala Date: Sat, 10 Jun 2023 18:00:26 +0000 Subject: [PATCH 06/25] Use right cache? --- .github/actions/setup-go/action.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/actions/setup-go/action.yaml b/.github/actions/setup-go/action.yaml index f2f9d35b07c07..7499cf3c3ccb7 100644 --- a/.github/actions/setup-go/action.yaml +++ b/.github/actions/setup-go/action.yaml @@ -17,7 +17,7 @@ runs: uses: buildjet/cache@v3 with: path: | - ${{ env.AGENT_TOOLSDIRECTORY }}/go/${{ inputs.version }} + ${{ runner.tool_cache }}/go/${{ inputs.version }} key: gotoolchain-${{ runner.os }}-${{ inputs.version }} restore-keys: | gotoolchain-${{ runner.os }}- From 9f90b78c6881fc747e510f8a84007b075d86c47c Mon Sep 17 00:00:00 2001 From: Ammar Bandukwala Date: Sat, 10 Jun 2023 18:00:43 +0000 Subject: [PATCH 07/25] mhm --- .github/workflows/ci.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 15c25375124e9..8acf234355805 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -558,7 +558,7 @@ jobs: required: runs-on: ubuntu-latest - needs: [gen, test-go, test-go-pg, test-go-race, test-js] + needs: [gen, fmt, lint, test-go, test-go-pg, test-go-race, test-js] # Allow this job to run even if the needed jobs fail, are skipped or # cancelled. if: always() From 1c36a078095a1b7af650ec131cb0068235868718 Mon Sep 17 00:00:00 2001 From: Ammar Bandukwala Date: Sat, 10 Jun 2023 18:04:07 +0000 Subject: [PATCH 08/25] Skip datadog on skip --- .github/workflows/ci.yaml | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 8acf234355805..6170016eea235 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -266,7 +266,7 @@ jobs: go run ./scripts/ci-report/main.go gotests.json | tee gotests_stats.json - uses: ./.github/actions/upload-datadog - if: always() + if: success() || failure() with: api-key: ${{ secrets.DATADOG_API_KEY }} @@ -313,15 +313,8 @@ 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-postgres.xml - path: ./gotests.xml - retention-days: 30 - - uses: ./.github/actions/upload-datadog - if: always() + if: success() || failure() with: api-key: ${{ secrets.DATADOG_API_KEY }} From de837ce58b6ec5f118883376e4e7137602b4d529 Mon Sep 17 00:00:00 2001 From: Ammar Bandukwala Date: Sat, 10 Jun 2023 18:10:19 +0000 Subject: [PATCH 09/25] no more dump env --- .github/actions/setup-go/action.yaml | 5 ----- 1 file changed, 5 deletions(-) diff --git a/.github/actions/setup-go/action.yaml b/.github/actions/setup-go/action.yaml index 7499cf3c3ccb7..5b36b6dcd51a4 100644 --- a/.github/actions/setup-go/action.yaml +++ b/.github/actions/setup-go/action.yaml @@ -8,11 +8,6 @@ inputs: runs: using: "composite" steps: - - name: dump env - shell: bash - run: | - env - - name: Cache go toolchain uses: buildjet/cache@v3 with: From f8df5c952d14ba01591d1ec4370cf704358f0352 Mon Sep 17 00:00:00 2001 From: Ammar Bandukwala Date: Sat, 10 Jun 2023 19:12:41 +0000 Subject: [PATCH 10/25] Simplify lint --- .github/workflows/ci.yaml | 23 +++++++++-------------- 1 file changed, 9 insertions(+), 14 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 6170016eea235..3e9852febda3b 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -100,11 +100,14 @@ jobs: - uses: ./.github/actions/setup-go + - uses: ./.github/actions/setup-node + # Check for any typos! - name: Check for typos uses: crate-ci/typos@v1.14.12 with: config: .github/workflows/typos.toml + - name: Fix the typos if: ${{ failure() }} run: | @@ -113,28 +116,20 @@ jobs: typos -c .github/workflows/typos.toml -w" # Check for Go linting errors! - - name: Lint Go - uses: golangci/golangci-lint-action@v3.5.0 - with: - version: v1.52.2 + - name: install golangci-lint + run: go install github.com/golangci/golangci-lint@v1.53.2 - - name: Lint shell scripts - uses: ludeeus/action-shellcheck@2.0.0 - env: - SHELLCHECK_OPTS: --external-sources - with: - ignore: node_modules + - name: make lint + run: | + make --output-sync -j lint - - uses: ./.github/actions/setup-node - - name: Lint TypeScript - run: yarn lint - working-directory: site # Make sure the Helm chart is linted! - name: Install helm uses: azure/setup-helm@v3 with: version: v3.9.2 + - name: Lint Helm chart run: | cd helm From 901853bb69a704114b52334581bf64206fcb0123 Mon Sep 17 00:00:00 2001 From: Ammar Bandukwala Date: Sat, 10 Jun 2023 19:15:30 +0000 Subject: [PATCH 11/25] fixup! Simplify lint --- .github/workflows/ci.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 3e9852febda3b..eb8908a422e02 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -117,7 +117,7 @@ jobs: # Check for Go linting errors! - name: install golangci-lint - run: go install github.com/golangci/golangci-lint@v1.53.2 + run: go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.53.2 - name: make lint run: | From 06f71682c3ab26f742a8d6459651f87c48769039 Mon Sep 17 00:00:00 2001 From: Ammar Bandukwala Date: Sat, 10 Jun 2023 19:21:58 +0000 Subject: [PATCH 12/25] make fmt --- .github/workflows/ci.yaml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index eb8908a422e02..5a17c026774a1 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -123,7 +123,6 @@ jobs: run: | make --output-sync -j lint - # Make sure the Helm chart is linted! - name: Install helm uses: azure/setup-helm@v3 From 0b268563323a199e18ea018667b3d031642eb980 Mon Sep 17 00:00:00 2001 From: Ammar Bandukwala Date: Sat, 10 Jun 2023 19:37:31 +0000 Subject: [PATCH 13/25] improve lint --- .github/workflows/ci.yaml | 23 ++++++----------------- .golangci.yaml | 1 - Makefile | 17 ++++++++++++++++- enterprise/cli/root_internal_test.go | 3 ++- 4 files changed, 24 insertions(+), 20 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 5a17c026774a1..5f73df05d943e 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -93,7 +93,8 @@ jobs: echo "${{ toJSON(steps.filter )}}" lint: - runs-on: ${{ github.repository_owner == 'coder' && 'buildjet-8vcpu-ubuntu-2204' || 'ubuntu-latest' }} + # golangci-lint is heavily parallelizable. + runs-on: ${{ github.repository_owner == 'coder' && 'buildjet-32vcpu-ubuntu-2204' || 'ubuntu-latest' }} steps: - name: Checkout uses: actions/checkout@v3 @@ -102,7 +103,7 @@ jobs: - uses: ./.github/actions/setup-node - # Check for any typos! + # Check for any typos - name: Check for typos uses: crate-ci/typos@v1.14.12 with: @@ -115,28 +116,16 @@ jobs: cargo install typos-cli typos -c .github/workflows/typos.toml -w" - # Check for Go linting errors! - - name: install golangci-lint - run: go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.53.2 - - - name: make lint - run: | - make --output-sync -j lint - # Make sure the Helm chart is linted! + # Needed for helm chart linting - name: Install helm uses: azure/setup-helm@v3 with: version: v3.9.2 - - name: Lint Helm chart + - name: make lint run: | - cd helm - make lint - - # Ensure AGPL and Enterprise are separated! - - name: Check for AGPL code importing Enterprise... - run: ./scripts/check_enterprise_imports.sh + make --output-sync -j lint gen: timeout-minutes: 8 diff --git a/.golangci.yaml b/.golangci.yaml index f0d310193a457..3ebd36c026737 100644 --- a/.golangci.yaml +++ b/.golangci.yaml @@ -200,7 +200,6 @@ issues: max-same-issues: 0 run: - concurrency: 4 skip-dirs: - node_modules skip-files: diff --git a/Makefile b/Makefile index 00af3932877c3..e5fa8392e02c3 100644 --- a/Makefile +++ b/Makefile @@ -402,11 +402,17 @@ else endif .PHONY: fmt/shfmt -lint: lint/shellcheck lint/go +lint: lint/shellcheck lint/go lint/ts lint/helm lint/agpl .PHONY: lint +lint/ts: + cd site + yarn && yarn lint +.PHONY: lint/ts + lint/go: ./scripts/check_enterprise_imports.sh + go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.53.2 golangci-lint run .PHONY: lint/go @@ -416,6 +422,15 @@ lint/shellcheck: $(SHELL_SRC_FILES) shellcheck --external-sources $(SHELL_SRC_FILES) .PHONY: lint/shellcheck +lint/helm: + cd helm + make lint +.PHONY: lint/helm + +lint/agpl: + ./scripts/check_enterprise_imports.sh +.PHONY: lint/agpl + # all gen targets should be added here and to gen/mark-fresh gen: \ coderd/database/dump.sql \ diff --git a/enterprise/cli/root_internal_test.go b/enterprise/cli/root_internal_test.go index cc7b803698442..abaa9cc53d020 100644 --- a/enterprise/cli/root_internal_test.go +++ b/enterprise/cli/root_internal_test.go @@ -3,9 +3,10 @@ package cli import ( "testing" - "github.com/coder/coder/cli" "github.com/stretchr/testify/require" + "github.com/coder/coder/cli" + "github.com/coder/coder/cli/clibase" "github.com/coder/coder/cli/clitest" From 2cb78845234a67dda7c27abc10aed69a1e23d649 Mon Sep 17 00:00:00 2001 From: Ammar Bandukwala Date: Sat, 10 Jun 2023 19:45:23 +0000 Subject: [PATCH 14/25] fixup! improve lint --- .github/workflows/ci.yaml | 6 ++---- Makefile | 6 +----- 2 files changed, 3 insertions(+), 9 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 5f73df05d943e..199940242c4cd 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -93,8 +93,7 @@ jobs: echo "${{ toJSON(steps.filter )}}" lint: - # golangci-lint is heavily parallelizable. - runs-on: ${{ github.repository_owner == 'coder' && 'buildjet-32vcpu-ubuntu-2204' || 'ubuntu-latest' }} + runs-on: ${{ github.repository_owner == 'coder' && 'buildjet-8vcpu-ubuntu-2204' || 'ubuntu-latest' }} steps: - name: Checkout uses: actions/checkout@v3 @@ -116,7 +115,6 @@ jobs: cargo install typos-cli typos -c .github/workflows/typos.toml -w" - # Needed for helm chart linting - name: Install helm uses: azure/setup-helm@v3 @@ -125,7 +123,7 @@ jobs: - name: make lint run: | - make --output-sync -j lint + make --output-sync=line -j lint gen: timeout-minutes: 8 diff --git a/Makefile b/Makefile index e5fa8392e02c3..2c3d3672efc71 100644 --- a/Makefile +++ b/Makefile @@ -402,7 +402,7 @@ else endif .PHONY: fmt/shfmt -lint: lint/shellcheck lint/go lint/ts lint/helm lint/agpl +lint: lint/shellcheck lint/go lint/ts lint/helm .PHONY: lint lint/ts: @@ -427,10 +427,6 @@ lint/helm: make lint .PHONY: lint/helm -lint/agpl: - ./scripts/check_enterprise_imports.sh -.PHONY: lint/agpl - # all gen targets should be added here and to gen/mark-fresh gen: \ coderd/database/dump.sql \ From fe090853e1a759bbc9c67ff4c7e379e57f336e51 Mon Sep 17 00:00:00 2001 From: Ammar Bandukwala Date: Sat, 10 Jun 2023 19:54:17 +0000 Subject: [PATCH 15/25] Reduce thrashing --- .github/actions/setup-go/action.yaml | 27 +++++++++++++++++++++------ 1 file changed, 21 insertions(+), 6 deletions(-) diff --git a/.github/actions/setup-go/action.yaml b/.github/actions/setup-go/action.yaml index 5b36b6dcd51a4..264e6b89171b4 100644 --- a/.github/actions/setup-go/action.yaml +++ b/.github/actions/setup-go/action.yaml @@ -23,15 +23,30 @@ runs: cache: false go-version: ${{ inputs.version }} - - name: Cache go + - name: Get cache dirs + id: get_cache_dirs + shell: bash + run: | + echo "::set-output name=go-mod-cache::$(go env GOMODCACHE)" + echo "::set-output name=go-cache::$(go env GOCACHE)" + # We split up GOMODCACHE from GOCACHE because the latter must be invalidated + # on code change, but the former can be kept. + - name: Cache $GOMODCACHE + uses: buildjet/cache@v3 + with: + path: | + ${{ steps.get_cache_dirs.outputs.go-mod-cache }}} + key: gomodcache-${{ runner.os }}-${{ github.job }}-${{ hashFiles('**/go.sum') }} + restore-keys: | + gomodcache-${{ runner.os }}-${{ github.job }}- + gomodcache-${{ runner.os }}- + gomodcache- + + - name: Cache $GOCACHE uses: buildjet/cache@v3 with: - # ~/go/pkg is the same across operating systems. path: | - ~/go/pkg - ~/.cache/go-build - ~/AppData/Local/go-build - ~/Library/Caches/go-build + ${{ steps.get_cache_dirs.outputs.go-cache }}} # Job name must be included in the key for effective # test cache reuse. key: gocache-${{ runner.os }}-${{ github.job }}-${{ hashFiles('**/*.go', 'go.**') }} From cc8700040aca112a1bc5523411737a8da5ce89a8 Mon Sep 17 00:00:00 2001 From: Ammar Bandukwala Date: Sat, 10 Jun 2023 19:56:42 +0000 Subject: [PATCH 16/25] fixup! Reduce thrashing --- .github/actions/setup-go/action.yaml | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/.github/actions/setup-go/action.yaml b/.github/actions/setup-go/action.yaml index 264e6b89171b4..c084271d25f8c 100644 --- a/.github/actions/setup-go/action.yaml +++ b/.github/actions/setup-go/action.yaml @@ -36,11 +36,10 @@ runs: with: path: | ${{ steps.get_cache_dirs.outputs.go-mod-cache }}} - key: gomodcache-${{ runner.os }}-${{ github.job }}-${{ hashFiles('**/go.sum') }} + key: gomodcache-${{ runner.os }}-${{ hashFiles('**/go.sum') }}-${{ github.job }} restore-keys: | - gomodcache-${{ runner.os }}-${{ github.job }}- + gomodcache-${{ runner.os }}-${{ hashFiles('**/go.sum') }}- gomodcache-${{ runner.os }}- - gomodcache- - name: Cache $GOCACHE uses: buildjet/cache@v3 @@ -53,7 +52,6 @@ runs: restore-keys: | gocache-${{ runner.os }}-${{ github.job }}- gocache-${{ runner.os }}- - gocache- - name: Install gotestsum shell: bash From 2c7208ae1e263c3258c5d714f1c7475954f695e2 Mon Sep 17 00:00:00 2001 From: Ammar Bandukwala Date: Sat, 10 Jun 2023 20:03:06 +0000 Subject: [PATCH 17/25] fixup! Reduce thrashing --- .github/actions/setup-go/action.yaml | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/.github/actions/setup-go/action.yaml b/.github/actions/setup-go/action.yaml index c084271d25f8c..f9f9f04072fc0 100644 --- a/.github/actions/setup-go/action.yaml +++ b/.github/actions/setup-go/action.yaml @@ -27,15 +27,16 @@ runs: id: get_cache_dirs shell: bash run: | - echo "::set-output name=go-mod-cache::$(go env GOMODCACHE)" - echo "::set-output name=go-cache::$(go env GOCACHE)" + echo "go-mod-cache=$(go env GOMODCACHE)" >> $GITHUB_ENV + echo "go-cache=$(go env GOCACHE)" >> $GITHUB_ENV + # We split up GOMODCACHE from GOCACHE because the latter must be invalidated # on code change, but the former can be kept. - name: Cache $GOMODCACHE uses: buildjet/cache@v3 with: path: | - ${{ steps.get_cache_dirs.outputs.go-mod-cache }}} + ${{ env.GOMODCACHE }}} key: gomodcache-${{ runner.os }}-${{ hashFiles('**/go.sum') }}-${{ github.job }} restore-keys: | gomodcache-${{ runner.os }}-${{ hashFiles('**/go.sum') }}- @@ -45,7 +46,7 @@ runs: uses: buildjet/cache@v3 with: path: | - ${{ steps.get_cache_dirs.outputs.go-cache }}} + ${{ env.GOCACHE }}} # Job name must be included in the key for effective # test cache reuse. key: gocache-${{ runner.os }}-${{ github.job }}-${{ hashFiles('**/*.go', 'go.**') }} From 9676000fbaced72c31e8372f95d9c6acdb5ea543 Mon Sep 17 00:00:00 2001 From: Ammar Bandukwala Date: Sat, 10 Jun 2023 20:07:45 +0000 Subject: [PATCH 18/25] fixup! Reduce thrashing --- .github/actions/setup-go/action.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/actions/setup-go/action.yaml b/.github/actions/setup-go/action.yaml index f9f9f04072fc0..9360ef5785bd7 100644 --- a/.github/actions/setup-go/action.yaml +++ b/.github/actions/setup-go/action.yaml @@ -24,11 +24,11 @@ runs: go-version: ${{ inputs.version }} - name: Get cache dirs - id: get_cache_dirs shell: bash run: | - echo "go-mod-cache=$(go env GOMODCACHE)" >> $GITHUB_ENV - echo "go-cache=$(go env GOCACHE)" >> $GITHUB_ENV + set -x + echo "GOMODCACHE=$(go env GOMODCACHE)" >> $GITHUB_ENV + echo "GOCACHE=$(go env GOCACHE)" >> $GITHUB_ENV # We split up GOMODCACHE from GOCACHE because the latter must be invalidated # on code change, but the former can be kept. From 0453d7e9d4b8ebb75133fb48858dc76243c9c769 Mon Sep 17 00:00:00 2001 From: Ammar Bandukwala Date: Sat, 10 Jun 2023 20:27:54 +0000 Subject: [PATCH 19/25] fixup! Reduce thrashing --- .github/actions/setup-go/action.yaml | 2 +- .golangci.yaml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/actions/setup-go/action.yaml b/.github/actions/setup-go/action.yaml index 9360ef5785bd7..d8845ad771656 100644 --- a/.github/actions/setup-go/action.yaml +++ b/.github/actions/setup-go/action.yaml @@ -46,7 +46,7 @@ runs: uses: buildjet/cache@v3 with: path: | - ${{ env.GOCACHE }}} + ${{ env.GOCACHE }} # Job name must be included in the key for effective # test cache reuse. key: gocache-${{ runner.os }}-${{ github.job }}-${{ hashFiles('**/*.go', 'go.**') }} diff --git a/.golangci.yaml b/.golangci.yaml index 3ebd36c026737..7dc85c6968fbc 100644 --- a/.golangci.yaml +++ b/.golangci.yaml @@ -204,7 +204,7 @@ run: - node_modules skip-files: - scripts/rules.go - timeout: 5m + timeout: 10m # Over time, add more and more linters from # https://golangci-lint.run/usage/linters/ as the code improves. From 9865c3836992bc37ebb16fc07933f4f54edbce12 Mon Sep 17 00:00:00 2001 From: Ammar Bandukwala Date: Sat, 10 Jun 2023 20:37:02 +0000 Subject: [PATCH 20/25] golangcilint only new files --- .golangci.yaml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.golangci.yaml b/.golangci.yaml index 7dc85c6968fbc..3ae5ec566a30f 100644 --- a/.golangci.yaml +++ b/.golangci.yaml @@ -199,6 +199,9 @@ issues: max-issues-per-linter: 0 max-same-issues: 0 + new: true + new-from-rev: origin/main + run: skip-dirs: - node_modules From 45aaa1e040c9ddda2880d0a424c014e00930951f Mon Sep 17 00:00:00 2001 From: Ammar Bandukwala Date: Sat, 10 Jun 2023 20:43:26 +0000 Subject: [PATCH 21/25] cache golangci-lint --- .github/workflows/ci.yaml | 14 ++++++++++++++ .golangci.yaml | 3 --- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 199940242c4cd..fea289ad7e4d4 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -102,6 +102,20 @@ jobs: - uses: ./.github/actions/setup-node + - name: Get golangci-lint cache dir + run: | + dir=$(golangci-lint cache status | awk '/Dir/ { print $2 }') + echo "LINT_CACHE_DIR=$dir" >> $GITHUB_ENV + + - name: golangci-lint cache + uses: buildjet/cache@v3 + with: + path: | + ${{ env.LINT_CACHE_DIR }} + key: golangci-lint-${{ runner.os }}-${{ hashFiles('**/*.go') }} + restore-keys: | + golangci-lint-${{ runner.os }}- + # Check for any typos - name: Check for typos uses: crate-ci/typos@v1.14.12 diff --git a/.golangci.yaml b/.golangci.yaml index 3ae5ec566a30f..7dc85c6968fbc 100644 --- a/.golangci.yaml +++ b/.golangci.yaml @@ -199,9 +199,6 @@ issues: max-issues-per-linter: 0 max-same-issues: 0 - new: true - new-from-rev: origin/main - run: skip-dirs: - node_modules From 82320d51e9176e3d77f83bcd71da70c57989ca69 Mon Sep 17 00:00:00 2001 From: Ammar Bandukwala Date: Sat, 10 Jun 2023 20:44:50 +0000 Subject: [PATCH 22/25] fixup! cache golangci-lint --- .github/actions/setup-go/action.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/actions/setup-go/action.yaml b/.github/actions/setup-go/action.yaml index d8845ad771656..bc083ed4e2a94 100644 --- a/.github/actions/setup-go/action.yaml +++ b/.github/actions/setup-go/action.yaml @@ -36,7 +36,7 @@ runs: uses: buildjet/cache@v3 with: path: | - ${{ env.GOMODCACHE }}} + ${{ env.GOMODCACHE }} key: gomodcache-${{ runner.os }}-${{ hashFiles('**/go.sum') }}-${{ github.job }} restore-keys: | gomodcache-${{ runner.os }}-${{ hashFiles('**/go.sum') }}- From eb6a3ed7ddfec59143b005114fa752fb009b6b0d Mon Sep 17 00:00:00 2001 From: Ammar Bandukwala Date: Sat, 10 Jun 2023 20:48:51 +0000 Subject: [PATCH 23/25] fixup! cache golangci-lint --- .github/workflows/ci.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index fea289ad7e4d4..1a7e05b674ec0 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -104,6 +104,7 @@ jobs: - name: Get golangci-lint cache dir run: | + go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.53.2 dir=$(golangci-lint cache status | awk '/Dir/ { print $2 }') echo "LINT_CACHE_DIR=$dir" >> $GITHUB_ENV From 39c1fe5d26975f6fe801e241929c23eb6f745f3a Mon Sep 17 00:00:00 2001 From: Ammar Bandukwala Date: Sun, 11 Jun 2023 22:41:11 +0000 Subject: [PATCH 24/25] Respond to review comments --- .github/actions/setup-go/action.yaml | 3 +++ .github/workflows/ci.yaml | 4 +++- enterprise/cli/root_internal_test.go | 2 -- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/.github/actions/setup-go/action.yaml b/.github/actions/setup-go/action.yaml index bc083ed4e2a94..0698ff7174f0c 100644 --- a/.github/actions/setup-go/action.yaml +++ b/.github/actions/setup-go/action.yaml @@ -49,6 +49,9 @@ runs: ${{ env.GOCACHE }} # Job name must be included in the key for effective # test cache reuse. + # The key format is intentionally different than GOMODCACHE, because any + # time a Go file changes we invalidate this cache, whereas GOMODCACHE + # is only invalidated when go.sum changes. key: gocache-${{ runner.os }}-${{ github.job }}-${{ hashFiles('**/*.go', 'go.**') }} restore-keys: | gocache-${{ runner.os }}-${{ github.job }}- diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 1a7e05b674ec0..61e40ff1d794d 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -104,7 +104,7 @@ jobs: - name: Get golangci-lint cache dir run: | - go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.53.2 + go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.53.2 dir=$(golangci-lint cache status | awk '/Dir/ { print $2 }') echo "LINT_CACHE_DIR=$dir" >> $GITHUB_ENV @@ -555,6 +555,8 @@ jobs: - name: Ensure required checks run: | echo "Checking required checks" + echo "- fmt: ${{ needs.fmt.result }}" + echo "- lint: ${{ needs.lint.result }}" echo "- gen: ${{ needs.gen.result }}" echo "- test-go: ${{ needs.test-go.result }}" echo "- test-go-pg: ${{ needs.test-go-pg.result }}" diff --git a/enterprise/cli/root_internal_test.go b/enterprise/cli/root_internal_test.go index abaa9cc53d020..3b3c86bc8d011 100644 --- a/enterprise/cli/root_internal_test.go +++ b/enterprise/cli/root_internal_test.go @@ -6,9 +6,7 @@ import ( "github.com/stretchr/testify/require" "github.com/coder/coder/cli" - "github.com/coder/coder/cli/clibase" - "github.com/coder/coder/cli/clitest" ) From 6fcd675e680429cc64834f967fb934b8708dac9c Mon Sep 17 00:00:00 2001 From: Ammar Bandukwala Date: Mon, 12 Jun 2023 15:52:03 +0000 Subject: [PATCH 25/25] supercharge fmt --- .github/workflows/ci.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 36a176d58c1a3..e6b4e000ecae5 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -183,7 +183,7 @@ jobs: run: ./scripts/check_unstaged.sh fmt: - runs-on: ubuntu-latest + runs-on: ${{ github.repository_owner == 'coder' && 'buildjet-8vcpu-ubuntu-2204' || 'ubuntu-latest' }} timeout-minutes: 5 steps: - name: Checkout