diff --git a/.github/workflows/build-check.yml b/.github/workflows/build-check.yml index 9b27b337b..4d4e0c5eb 100644 --- a/.github/workflows/build-check.yml +++ b/.github/workflows/build-check.yml @@ -33,25 +33,17 @@ jobs: with: go-version: "${{ steps.get-go-version.outputs.go-version }}" cache: false - - name: Determine go cache key - id: go-cache-key - run: | - echo "key=${{ runner.os }}-go-${{ hashFiles('**/go.sum', './Makefile', './tools/tools.go') }}" >> "$GITHUB_OUTPUT" - name: Determine Go cache paths id: go-cache-paths run: | - echo "go-build=$(go env GOCACHE)" >> "$GITHUB_OUTPUT" echo "go-mod=$(go env GOMODCACHE)" >> "$GITHUB_OUTPUT" - echo "go-bin=$(go env GOPATH)/bin" >> "$GITHUB_OUTPUT" - name: Set up Go modules cache uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0 with: path: | - ${{ steps.go-cache-paths.outputs.go-build }} ${{ steps.go-cache-paths.outputs.go-mod }} - ${{ steps.go-cache-paths.outputs.go-bin }} - key: ${{ steps.go-cache-key.outputs.key }} + key: go-mod-${{ hashFiles('**/go.sum') }} restore-keys: | - ${{ runner.os }}-go + go-mod - name: Build Boundary run: make build-no-ui diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index d58f17636..81d6ed1fa 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -59,21 +59,20 @@ jobs: - name: Determine Go cache paths id: go-cache-paths run: | - echo "go-build=$(go env GOCACHE)" >> "$GITHUB_OUTPUT" echo "go-mod=$(go env GOMODCACHE)" >> "$GITHUB_OUTPUT" - name: Set up Go modules cache uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0 with: path: | - ${{ steps.go-cache-paths.outputs.go-build }} ${{ steps.go-cache-paths.outputs.go-mod }} - key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} + key: go-mod-${{ hashFiles('**/go.sum') }} restore-keys: | - ${{ runner.os }}-go- + go-mod - name: Determine product edition id: get-product-edition # Run make edition twice to ensure that extra go output isn't included run: | + go mod download make edition echo "product-edition=$(make edition)" >> "$GITHUB_OUTPUT" - name: Determine minor product version @@ -150,17 +149,15 @@ jobs: - name: Determine Go cache paths id: go-cache-paths run: | - echo "go-build=$(go env GOCACHE)" >> "$GITHUB_OUTPUT" echo "go-mod=$(go env GOMODCACHE)" >> "$GITHUB_OUTPUT" - name: Set up Go modules cache uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0 with: path: | - ${{ steps.go-cache-paths.outputs.go-build }} ${{ steps.go-cache-paths.outputs.go-mod }} - key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}-${{ matrix.goarch }} + key: go-mod-${{ hashFiles('**/go.sum') }} restore-keys: | - ${{ runner.os }}-go- + go-mod - name: Set up Git run: git config --global url."https://${{ secrets.ELEVATED_GITHUB_TOKEN }}:@github.com".insteadOf "https://github.com" - name: Determine SHA @@ -226,11 +223,19 @@ jobs: uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0 with: path: | - ${{ steps.go-cache-paths.outputs.go-build }} ${{ steps.go-cache-paths.outputs.go-mod }} - key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}-${{ matrix.goarch }} + key: go-mod-${{ hashFiles('**/go.sum') }} restore-keys: | - ${{ runner.os }}-go- + go-mod + # Adding go build cache here since this build is used for tests + - name: Set up Go build cache + uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0 + with: + path: | + ${{ steps.go-cache-paths.outputs.go-build }} + key: go-build-${{ needs.product-metadata.outputs.go-version }}-${{ runner.os }}-${{ matrix.goarch }}-${{ hashFiles('**/go.sum') }} + restore-keys: | + go-build-${{ needs.product-metadata.outputs.go-version }}-${{ runner.os }}-${{ matrix.goarch }}- - name: Determine SHA id: set-sha run: echo "sha=$(head -n1 internal/ui/VERSION | cut -d ' ' -f1)" >> "$GITHUB_OUTPUT" @@ -320,17 +325,15 @@ jobs: - name: Determine Go cache paths id: go-cache-paths run: | - echo "go-build=$(go env GOCACHE)" >> "$GITHUB_OUTPUT" echo "go-mod=$(go env GOMODCACHE)" >> "$GITHUB_OUTPUT" - name: Set up Go modules cache uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0 with: path: | - ${{ steps.go-cache-paths.outputs.go-build }} ${{ steps.go-cache-paths.outputs.go-mod }} - key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} + key: go-mod-${{ hashFiles('**/go.sum') }} restore-keys: | - ${{ runner.os }}-go- + go-mod - name: Determine SHA id: set-sha run: echo "sha=$(head -n1 internal/ui/VERSION | cut -d ' ' -f1)" >> "$GITHUB_OUTPUT" diff --git a/.github/workflows/enos-run.yml b/.github/workflows/enos-run.yml index 560a9b105..61876f93f 100644 --- a/.github/workflows/enos-run.yml +++ b/.github/workflows/enos-run.yml @@ -22,10 +22,8 @@ on: jobs: setup: outputs: - cache-go-build: ${{ steps.go-cache-paths.outputs.go-build }} cache-go-mod: ${{ steps.go-cache-paths.outputs.go-mod }} - cache-go-bin: ${{ steps.go-cache-paths.outputs.go-bin }} - go-cache-key: ${{ steps.go-cache-key.outputs.key }} + go-mod-cache-key: ${{ steps.go-mod-cache-key.outputs.key }} runs-on: ${{ fromJSON(vars.RUNNER) }} steps: - uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 @@ -36,30 +34,25 @@ jobs: with: go-version: ${{ inputs.go-version }} cache: false - - name: Determine go cache key - id: go-cache-key - run: | - echo "key=${{ runner.os }}-go-${{ hashFiles('**/go.sum', './Makefile', './tools/tools.go') }}" >> "$GITHUB_OUTPUT" - name: Determine Go cache paths id: go-cache-paths run: | - echo "go-build=$(go env GOCACHE)" >> "$GITHUB_OUTPUT" echo "go-mod=$(go env GOMODCACHE)" >> "$GITHUB_OUTPUT" - echo "go-bin=$(go env GOPATH)/bin" >> "$GITHUB_OUTPUT" + - name: Determine Go modules cache key + id: go-mod-cache-key + run: | + echo "key=go-mod-${{ hashFiles('**/go.sum') }}" >> "$GITHUB_OUTPUT" - name: Set up Go modules cache uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0 with: path: | - ${{ steps.go-cache-paths.outputs.go-build }} ${{ steps.go-cache-paths.outputs.go-mod }} - ${{ steps.go-cache-paths.outputs.go-bin }} - key: ${{ steps.go-cache-key.outputs.key }} + key: ${{ steps.go-mod-cache-key.outputs.key }} restore-keys: | - ${{ runner.os }}-go - - name: Install Tools + go-mod + - name: Download Go modules run: | go mod download - make tools enos: name: test needs: @@ -114,13 +107,10 @@ jobs: uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0 with: path: | - ${{ needs.setup.outputs.cache-go-build }} ${{ needs.setup.outputs.cache-go-mod }} - ${{ needs.setup.outputs.cache-go-bin }} - key: ${{ needs.setup.outputs.go-cache-key }} + key: ${{ needs.setup.outputs.go-mod-cache-key }} restore-keys: | - ${{ runner.os }}-go - fail-on-cache-miss: false + go-mod - name: Downloads Go modules if cache miss if: steps.go-mod-cache.outputs.cache-hit != 'true' run: | @@ -179,11 +169,21 @@ jobs: uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0 with: path: /tmp/test-deps - key: enos-test-deps-password-store-1.7.4-vault-1.12.2 + key: enos-bats-cli-ui-deps-jq-1.6-password-store-1.7.4-vault-1.12.2 - name: Debug dep-cache run: | mkdir -p /tmp/test-deps ls -la /tmp/test-deps + - name: Download jq + if: steps.dep-cache.outputs.cache-hit != 'true' + # NOTE: if you update the jq version make sure to update the dep cache key + run: | + mkdir -p /tmp/test-deps + wget https://github.com/stedolan/jq/releases/download/jq-1.6/jq-linux64 -O /tmp/test-deps/jq-bin + - name: Install jq + run: | + chmod +x /tmp/test-deps/jq-bin + sudo cp /tmp/test-deps/jq-bin /usr/local/bin/jq - name: Download and unzip pass for Boundary keyring if: steps.dep-cache.outputs.cache-hit != 'true' # NOTE: if you update the password store version make sure to update the dep cache key diff --git a/.github/workflows/fuzz.yml b/.github/workflows/fuzz.yml index d867df3a8..f005c3d90 100644 --- a/.github/workflows/fuzz.yml +++ b/.github/workflows/fuzz.yml @@ -33,7 +33,7 @@ jobs: fuzz-grants-parse: name: Fuzz grants.Parse runs-on: ubuntu-latest - steps: + steps: - uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 - name: Determine Go version id: get-go-version @@ -45,6 +45,7 @@ jobs: - uses: actions/setup-go@44694675825211faa026b3c33043df3e48a5fa00 # v6.0.0 with: go-version: "${{ steps.get-go-version.outputs.go-version }}" + cache: false - shell: bash run: go test ./internal/perms -fuzz=FuzzParse -fuzztime=30s - name: Upload fuzz failure seed corpus as run artifact diff --git a/.github/workflows/linting.yml b/.github/workflows/linting.yml index 8ea0a50f3..8c5f3a686 100644 --- a/.github/workflows/linting.yml +++ b/.github/workflows/linting.yml @@ -27,6 +27,19 @@ jobs: uses: actions/setup-go@44694675825211faa026b3c33043df3e48a5fa00 # v6.0.0 with: go-version: "${{ steps.get-go-version.outputs.go-version }}" + cache: false + - name: Determine Go cache paths + id: go-cache-paths + run: | + echo "go-mod=$(go env GOMODCACHE)" >> "$GITHUB_OUTPUT" + - name: Set up Go modules cache + uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0 + with: + path: | + ${{ steps.go-cache-paths.outputs.go-mod }} + key: go-mod-${{ hashFiles('**/go.sum') }} + restore-keys: | + go-mod - name: Install Dependencies # if we really need to we can update this to run `make tools` # later but its just not necessary to only run linters diff --git a/.github/workflows/make-gen-delta.yml b/.github/workflows/make-gen-delta.yml index 3c6a66b02..5ad712886 100644 --- a/.github/workflows/make-gen-delta.yml +++ b/.github/workflows/make-gen-delta.yml @@ -26,11 +26,36 @@ jobs: uses: actions/setup-go@44694675825211faa026b3c33043df3e48a5fa00 # v6.0.0 with: go-version: "${{ steps.get-go-version.outputs.go-version }}" + cache: false + - name: Determine Go cache paths + id: go-cache-paths + run: | + echo "go-mod=$(go env GOMODCACHE)" >> "$GITHUB_OUTPUT" + echo "go-bin=$(go env GOPATH)/bin" >> "$GITHUB_OUTPUT" + - name: Set up Go modules cache + uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0 + with: + path: | + ${{ steps.go-cache-paths.outputs.go-mod }} + key: go-mod-${{ hashFiles('**/go.sum') }} + restore-keys: | + go-mod + - name: Set up Go tools cache + id: go-tools-cache + uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0 + with: + path: | + ${{ steps.go-cache-paths.outputs.go-bin }} + key: go-tools-${{ steps.get-go-version.outputs.go-version }}-${{ hashFiles('**/go.sum', './Makefile', './tools/tools.go') }} + restore-keys: | + go-tools-${{ steps.get-go-version.outputs.go-version }} - name: Running go mod tidy run: | go mod tidy - name: Install Dependencies + if: steps.go-tools-cache.outputs.cache-hit != 'true' run: | + go mod download make tools - name: Running make gen run: | diff --git a/.github/workflows/test-cli-ui_oss.yml b/.github/workflows/test-cli-ui_oss.yml index e3a2899bd..4dbdc9c98 100644 --- a/.github/workflows/test-cli-ui_oss.yml +++ b/.github/workflows/test-cli-ui_oss.yml @@ -33,7 +33,7 @@ jobs: id: dep-cache uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0 with: - path: /tmp/bats-cli-ui-deps + path: /tmp/test-deps key: enos-bats-cli-ui-deps-jq-1.6-password-store-1.7.4-vault-1.12.2 - name: Set up Node for Bats install uses: actions/setup-node@2028fbc5c25fe9cf00d9f06a71cc4710d4507903 # v6.0.0 @@ -46,32 +46,32 @@ jobs: if: steps.dep-cache.outputs.cache-hit != 'true' # NOTE: if you update the jq version make sure to update the dep cache key run: | - mkdir -p /tmp/bats-cli-ui-deps - wget https://github.com/stedolan/jq/releases/download/jq-1.6/jq-linux64 -O /tmp/bats-cli-ui-deps/jq-bin + mkdir -p /tmp/test-deps + wget https://github.com/stedolan/jq/releases/download/jq-1.6/jq-linux64 -O /tmp/test-deps/jq-bin - name: Install jq for Bats CLI UI tests run: | - chmod +x /tmp/bats-cli-ui-deps/jq-bin - sudo cp /tmp/bats-cli-ui-deps/jq-bin /usr/local/bin/jq + chmod +x /tmp/test-deps/jq-bin + sudo cp /tmp/test-deps/jq-bin /usr/local/bin/jq - name: Download and unzip pass for Boundary keyring if: steps.dep-cache.outputs.cache-hit != 'true' # NOTE: if you update the password store version make sure to update the dep cache key run: | - mkdir -p /tmp/bats-cli-ui-deps/pass - wget https://github.com/zx2c4/password-store/archive/refs/tags/1.7.4.tar.gz -O /tmp/bats-cli-ui-deps/pass/pass.tar.gz - cd /tmp/bats-cli-ui-deps/pass + mkdir -p /tmp/test-deps/pass + wget https://github.com/zx2c4/password-store/archive/refs/tags/1.7.4.tar.gz -O /tmp/test-deps/pass/pass.tar.gz + cd /tmp/test-deps/pass tar -xvf pass.tar.gz - name: Install pass for Boundary keyring run: | - cd /tmp/bats-cli-ui-deps/pass/password-store-1.7.4 + cd /tmp/test-deps/pass/password-store-1.7.4 sudo make install pass init ${{ secrets.ENOS_GPG_UID }} - name: Download Vault AMD64 binary for integration testing if: steps.dep-cache.outputs.cache-hit != 'true' run: | - wget https://releases.hashicorp.com/vault/1.12.2/vault_1.12.2_linux_amd64.zip -O /tmp/bats-cli-ui-deps/vault.zip + wget https://releases.hashicorp.com/vault/1.12.2/vault_1.12.2_linux_amd64.zip -O /tmp/test-deps/vault.zip - name: Install Vault run: | - unzip /tmp/bats-cli-ui-deps/vault.zip -d /usr/local/bin + unzip /tmp/test-deps/vault.zip -d /usr/local/bin - name: Download Linux AMD64 Boundary bundle uses: actions/download-artifact@018cc2cf5baa6db3ef3c5f8a56943fffe632ef53 # v6.0.0 with: @@ -83,8 +83,6 @@ jobs: rm /tmp/${{ inputs.artifact-name }} - name: Versions run: | - echo "go version:" - go version echo "bats version:" bats --version echo "jq version:" diff --git a/.github/workflows/test-race.yml b/.github/workflows/test-race.yml index b1704e8fe..ade28233d 100644 --- a/.github/workflows/test-race.yml +++ b/.github/workflows/test-race.yml @@ -17,10 +17,10 @@ jobs: setup: outputs: go-version: ${{ steps.get-go-version.outputs.go-version }} - cache-go-build: ${{ steps.go-cache-paths.outputs.go-build }} cache-go-mod: ${{ steps.go-cache-paths.outputs.go-mod }} cache-go-bin: ${{ steps.go-cache-paths.outputs.go-bin }} - go-cache-key: ${{ steps.go-cache-key.outputs.key }} + go-mod-cache-key: ${{ steps.go-mod-cache-key.outputs.key }} + go-tools-cache-key: ${{ steps.go-tools-cache-key.outputs.key }} plugin-cache-path: ${{ steps.plugin-cache-paths.outputs.path }} plugin-cache-key: ${{ steps.plugin-cache-key.outputs.key }} runs-on: ${{ fromJSON(vars.RUNNER) }} @@ -40,35 +40,48 @@ jobs: with: go-version: "${{ steps.get-go-version.outputs.go-version }}" cache: false - - name: Determine go cache key - id: go-cache-key - run: | - echo "key=${{ runner.os }}-go-${{ hashFiles('**/go.sum', './Makefile', './tools/tools.go') }}" >> "$GITHUB_OUTPUT" - name: Determine Go cache paths id: go-cache-paths run: | - echo "go-build=$(go env GOCACHE)" >> "$GITHUB_OUTPUT" echo "go-mod=$(go env GOMODCACHE)" >> "$GITHUB_OUTPUT" echo "go-bin=$(go env GOPATH)/bin" >> "$GITHUB_OUTPUT" + - name: Determine Go modules cache key + id: go-mod-cache-key + run: | + echo "key=go-mod-${{ hashFiles('**/go.sum') }}" >> "$GITHUB_OUTPUT" - name: Set up Go modules cache uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0 with: path: | - ${{ steps.go-cache-paths.outputs.go-build }} ${{ steps.go-cache-paths.outputs.go-mod }} - ${{ steps.go-cache-paths.outputs.go-bin }} - key: ${{ steps.go-cache-key.outputs.key }} + key: ${{ steps.go-mod-cache-key.outputs.key }} restore-keys: | - ${{ runner.os }}-go - - name: Install Tools + go-mod + - name: Determine Go tools cache key + id: go-tools-cache-key + run: | + echo "key=go-tools-${{ steps.get-go-version.outputs.go-version }}-${{ hashFiles('**/go.sum', './Makefile', './tools/tools.go') }}" >> "$GITHUB_OUTPUT" + - name: Set up Go tools cache + id: go-tools-cache + uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0 + with: + path: | + ${{ steps.go-cache-paths.outputs.go-bin }} + key: ${{ steps.go-tools-cache-key.outputs.key }} + restore-keys: | + go-tools-${{ steps.get-go-version.outputs.go-version }} + - name: Go mod download run: | go mod download + - name: Install Tools + if: steps.go-tools-cache.outputs.cache-hit != 'true' + run: | make tools - name: Determine plugin cache key id: plugin-cache-key run: | - echo "key=${{ runner.os }}-plugins-${{ hashFiles('plugins/**/*.go', 'plugins/**/go.sum', './Makefile', './scripts/plugins.sh') }}" >> "$GITHUB_OUTPUT" - - name: Determin plugin cache path + echo "key=plugins-${{ runner.os }}-${{ hashFiles('plugins/**/*.go', 'plugins/**/go.sum', './Makefile', './scripts/plugins.sh') }}" >> "$GITHUB_OUTPUT" + - name: Determine plugin cache path id: plugin-cache-paths run: | echo "path=plugins/**/assets/*.gz" >> "$GITHUB_OUTPUT" @@ -80,7 +93,7 @@ jobs: ${{ steps.plugin-cache-paths.outputs.path }} key: ${{ steps.plugin-cache-key.outputs.key }} restore-keys: | - ${{ runner.os }}-plugin + plugins-${{ runner.os }} - name: Build Plugins if: steps.plugin-cache.outputs.cache-hit != 'true' run: | @@ -103,12 +116,10 @@ jobs: uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0 with: path: | - ${{ needs.setup.outputs.cache-go-build }} ${{ needs.setup.outputs.cache-go-mod }} - ${{ needs.setup.outputs.cache-go-bin }} - key: ${{ needs.setup.outputs.go-cache-key }} + key: ${{ needs.setup.outputs.go-mod-cache-key }} restore-keys: | - ${{ runner.os }}-go + go-mod fail-on-cache-miss: false - name: Test ${{ matrix.module }} Module run: | @@ -132,26 +143,28 @@ jobs: go-version: "${{ needs.setup.outputs.go-version }}" cache: false - name: Set up Go modules cache - id: go-cache uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0 with: path: | - ${{ needs.setup.outputs.cache-go-build }} ${{ needs.setup.outputs.cache-go-mod }} - ${{ needs.setup.outputs.cache-go-bin }} - key: ${{ needs.setup.outputs.go-cache-key }} + key: ${{ needs.setup.outputs.go-mod-cache-key }} restore-keys: | - ${{ runner.os }}-go + go-mod fail-on-cache-miss: false - - name: Install tools if tparse doesn't exist + - name: Set up Go tools cache + id: go-tools-cache + uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0 + with: + path: | + ${{ needs.setup.outputs.cache-go-bin }} + key: ${{ needs.setup.outputs.go-tools-cache-key }} + restore-keys: | + go-tools-${{ needs.setup.outputs.go-version }} + - name: Install tools + if: steps.go-tools-cache.outputs.cache-hit != 'true' run: | - if command -v tparse &> /dev/null; then - echo "tparse exists" - else - echo "tparse doesn't exist" - go mod download - make tools - fi + go mod download + make tools - name: Set up plugin cache id: plugin-cache uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0 @@ -160,7 +173,7 @@ jobs: ${{ needs.setup.outputs.plugin-cache-path }} key: ${{ needs.setup.outputs.plugin-cache-key }} restore-keys: | - ${{ runner.os }}-plugin + plugins-${{ runner.os }} - name: GH fix for localhost resolution if: github.repository == 'hashicorp/boundary' run: | diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index bfb35df97..1d6146b10 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -17,10 +17,10 @@ jobs: setup: outputs: go-version: ${{ steps.get-go-version.outputs.go-version }} - cache-go-build: ${{ steps.go-cache-paths.outputs.go-build }} cache-go-mod: ${{ steps.go-cache-paths.outputs.go-mod }} cache-go-bin: ${{ steps.go-cache-paths.outputs.go-bin }} - go-cache-key: ${{ steps.go-cache-key.outputs.key }} + go-mod-cache-key: ${{ steps.go-mod-cache-key.outputs.key }} + go-tools-cache-key: ${{ steps.go-tools-cache-key.outputs.key }} plugin-cache-path: ${{ steps.plugin-cache-paths.outputs.path }} plugin-cache-key: ${{ steps.plugin-cache-key.outputs.key }} runs-on: ${{ fromJSON(vars.RUNNER) }} @@ -40,35 +40,48 @@ jobs: with: go-version: "${{ steps.get-go-version.outputs.go-version }}" cache: false - - name: Determine go cache key - id: go-cache-key - run: | - echo "key=${{ runner.os }}-go-${{ hashFiles('**/go.sum', './Makefile', './tools/tools.go') }}" >> "$GITHUB_OUTPUT" - name: Determine Go cache paths id: go-cache-paths run: | - echo "go-build=$(go env GOCACHE)" >> "$GITHUB_OUTPUT" echo "go-mod=$(go env GOMODCACHE)" >> "$GITHUB_OUTPUT" echo "go-bin=$(go env GOPATH)/bin" >> "$GITHUB_OUTPUT" + - name: Determine Go modules cache key + id: go-mod-cache-key + run: | + echo "key=go-mod-${{ hashFiles('**/go.sum') }}" >> "$GITHUB_OUTPUT" - name: Set up Go modules cache uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0 with: path: | - ${{ steps.go-cache-paths.outputs.go-build }} ${{ steps.go-cache-paths.outputs.go-mod }} - ${{ steps.go-cache-paths.outputs.go-bin }} - key: ${{ steps.go-cache-key.outputs.key }} + key: ${{ steps.go-mod-cache-key.outputs.key }} restore-keys: | - ${{ runner.os }}-go - - name: Install Tools + go-mod + - name: Determine Go tools cache key + id: go-tools-cache-key + run: | + echo "key=go-tools-${{ steps.get-go-version.outputs.go-version }}-${{ hashFiles('**/go.sum', './Makefile', './tools/tools.go') }}" >> "$GITHUB_OUTPUT" + - name: Set up Go tools cache + id: go-tools-cache + uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0 + with: + path: | + ${{ steps.go-cache-paths.outputs.go-bin }} + key: ${{ steps.go-tools-cache-key.outputs.key }} + restore-keys: | + go-tools-${{ steps.get-go-version.outputs.go-version }} + - name: Go mod download run: | go mod download + - name: Install Tools + if: steps.go-tools-cache.outputs.cache-hit != 'true' + run: | make tools - name: Determine plugin cache key id: plugin-cache-key run: | - echo "key=${{ runner.os }}-plugins-${{ hashFiles('plugins/**/*.go', 'plugins/**/go.sum', './Makefile', './scripts/plugins.sh') }}" >> "$GITHUB_OUTPUT" - - name: Determin plugin cache path + echo "key=plugins-${{ runner.os }}-${{ hashFiles('plugins/**/*.go', 'plugins/**/go.sum', './Makefile', './scripts/plugins.sh') }}" >> "$GITHUB_OUTPUT" + - name: Determine plugin cache path id: plugin-cache-paths run: | echo "path=plugins/**/assets/*.gz" >> "$GITHUB_OUTPUT" @@ -80,7 +93,7 @@ jobs: ${{ steps.plugin-cache-paths.outputs.path }} key: ${{ steps.plugin-cache-key.outputs.key }} restore-keys: | - ${{ runner.os }}-plugin + plugins-${{ runner.os }} - name: Build Plugins if: steps.plugin-cache.outputs.cache-hit != 'true' run: | @@ -103,12 +116,10 @@ jobs: uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0 with: path: | - ${{ needs.setup.outputs.cache-go-build }} ${{ needs.setup.outputs.cache-go-mod }} - ${{ needs.setup.outputs.cache-go-bin }} - key: ${{ needs.setup.outputs.go-cache-key }} + key: ${{ needs.setup.outputs.go-mod-cache-key }} restore-keys: | - ${{ runner.os }}-go + go-mod fail-on-cache-miss: false - name: Test ${{ matrix.module }} Module run: | @@ -132,26 +143,28 @@ jobs: go-version: "${{ needs.setup.outputs.go-version }}" cache: false - name: Set up Go modules cache - id: go-cache uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0 with: path: | - ${{ needs.setup.outputs.cache-go-build }} ${{ needs.setup.outputs.cache-go-mod }} - ${{ needs.setup.outputs.cache-go-bin }} - key: ${{ needs.setup.outputs.go-cache-key }} + key: ${{ needs.setup.outputs.go-mod-cache-key }} restore-keys: | - ${{ runner.os }}-go + go-mod fail-on-cache-miss: false - - name: Install tools if tparse doesn't exist + - name: Set up Go tools cache + id: go-tools-cache + uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0 + with: + path: | + ${{ needs.setup.outputs.cache-go-bin }} + key: ${{ needs.setup.outputs.go-tools-cache-key }} + restore-keys: | + go-tools-${{ needs.setup.outputs.go-version }} + - name: Install tools + if: steps.go-tools-cache.outputs.cache-hit != 'true' run: | - if command -v tparse &> /dev/null; then - echo "tparse exists" - else - echo "tparse doesn't exist" - go mod download - make tools - fi + go mod download + make tools - name: Set up plugin cache id: plugin-cache uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0 @@ -160,7 +173,7 @@ jobs: ${{ needs.setup.outputs.plugin-cache-path }} key: ${{ needs.setup.outputs.plugin-cache-key }} restore-keys: | - ${{ runner.os }}-plugin + plugins-${{ runner.os }} - name: GH fix for localhost resolution if: github.repository == 'hashicorp/boundary' run: |