Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into peteski22/dependency/…
Browse files Browse the repository at this point in the history
…swap-armon-go-metrics-to-hashicorp-go-metrics
  • Loading branch information
Peter Wilson committed Jan 24, 2024
2 parents 68a93c7 + b85365e commit 8efb40e
Show file tree
Hide file tree
Showing 501 changed files with 13,622 additions and 5,238 deletions.
32 changes: 32 additions & 0 deletions .github/actions/install-external-tools/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Copyright (c) HashiCorp, Inc.
# SPDX-License-Identifier: BUSL-1.1

---
name: Install external tools for CI
description: Install external tools CI

# When possible, prefer installing pre-built external tools for speed. This allows us to avoid
# downloading modules and compiling external tools on CI runners.

runs:
using: composite
steps:
- uses: ./.github/actions/set-up-buf
with:
version: v1.25.0 # This should match the version in tools/tool.sh
- uses: ./.github/actions/set-up-gofumpt
- uses: ./.github/actions/set-up-gotestsum
- uses: ./.github/actions/set-up-misspell
- uses: ./.github/actions/set-up-staticcheck
# We assume that the Go toolchain will be managed by the caller workflow so we don't set one
# up here.
- run: go install google.golang.org/protobuf/cmd/protoc-gen-go@latest
shell: bash
- run: go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@latest
shell: bash
- run: go install github.com/favadi/protoc-go-inject-tag@latest
shell: bash
- run: go install golang.org/x/tools/cmd/goimports@latest
shell: bash
- run: go install github.com/golangci/revgrep/cmd/revgrep@latest
shell: bash
63 changes: 63 additions & 0 deletions .github/actions/set-up-buf/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
# Copyright (c) HashiCorp, Inc.
# SPDX-License-Identifier: BUSL-1.1

---
name: Set up buf from Github releases
description: Set up buf from Github releases

inputs:
destination:
description: "Where to install the buf binary (default: $HOME/bin/buf)"
type: boolean
default: "$HOME/bin/buf"
version:
description: "The version to install (default: latest)"
type: string
default: Latest

outputs:
destination:
description: Where the installed buf binary is
value: ${{ steps.install.outputs.destination }}
destination-dir:
description: The directory where the installed buf binary is
value: ${{ steps.install.outputs.destination-dir }}
version:
description: The installed version of buf
value: ${{ steps.install.outputs.version }}

runs:
using: composite
steps:
- id: install
shell: bash
env:
GH_TOKEN: ${{ github.token }}
run: |
VERSION=$(gh release list -R bufbuild/buf --exclude-drafts --exclude-pre-releases | grep ${{ inputs.version }} | cut -f1)
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
mkdir -p $(dirname ${{ inputs.destination }})
DESTINATION="$(readlink -f "${{ inputs.destination }}")"
echo "destination=$DESTINATION" >> "$GITHUB_OUTPUT"
DESTINATION_DIR="$(dirname "$DESTINATION")"
echo "$DESTINATION_DIR" >> "$GITHUB_PATH"
echo "destination-dir=$DESTINATION_DIR" >> "$GITHUB_OUTPUT"
ARCH="$(echo "$RUNNER_ARCH" | tr '[:upper:]' '[:lower:]')"
OS="$RUNNER_OS"
if [ "$ARCH" = "x64" ]; then
export ARCH="x86_64"
fi
if [ "$ARCH" = "arm64" ] && [ "$OS" = "Linux" ]; then
export ARCH="aarch64"
fi
if [ "$OS" = "macOS" ]; then
export OS="Darwin"
fi
mkdir -p tmp
gh release download "$VERSION" -p "buf-${OS}-${ARCH}.tar.gz" -O tmp/buf.tgz -R bufbuild/buf
pushd tmp && tar -xvf buf.tgz && popd
mv tmp/buf/bin/buf "$DESTINATION"
rm -rf tmp
24 changes: 15 additions & 9 deletions .github/actions/set-up-go/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ inputs:
description: "Whether or not to restore the Go module cache on a cache hit"
type: boolean
default: false
go-version:
description: "Override .go-version"
type: string
default: ""

outputs:
cache-key:
Expand All @@ -22,15 +26,20 @@ outputs:
description: "The GOMODCACHE path"
value: ${{ steps.metadata.outputs.cache-path }}
go-version:
description: "The version of Go in the .go-version file"
description: "The version of Go used"
value: ${{ steps.go-version.outputs.go-version }}

runs:
using: composite
steps:
- id: go-version
shell: bash
run: echo "go-version=$(cat ./.go-version)" >> "$GITHUB_OUTPUT"
run: |
if [ "${{ inputs.go-version }}" = "" ]; then
echo "go-version=$(cat ./.go-version)" >> "$GITHUB_OUTPUT"
else
echo "go-version=${{ inputs.go-version }}" >> "$GITHUB_OUTPUT"
fi
- uses: actions/setup-go@fac708d6674e30b6ba41289acaab6d4b75aa0753 # v4.0.1
with:
go-version: ${{ steps.go-version.outputs.go-version }}
Expand Down Expand Up @@ -63,12 +72,9 @@ runs:
- if: steps.cache-modules.outputs.cache-hit != 'true'
name: Download go modules
shell: bash
env:
GOPRIVATE: github.com/hashicorp/*
run: |
git config --global url."https://${{ inputs.github-token }}@github.com".insteadOf https://github.com
for mod in $(find . -type f -name go.mod); do
pushd "$(dirname $mod)"
go list ./...
go list -test ./...
go mod download
popd
done
make go-mod-download
du -h -d 1 ${{ steps.metadata.outputs.cache-path }}
58 changes: 58 additions & 0 deletions .github/actions/set-up-gofumpt/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
# Copyright (c) HashiCorp, Inc.
# SPDX-License-Identifier: BUSL-1.1

---
name: Set up gofumpt from Github releases
description: Set up gofumpt from Github releases

inputs:
destination:
description: "Where to install the gofumpt binary (default: $HOME/bin/gofumpt)"
type: boolean
default: "$HOME/bin/gofumpt"
version:
description: "The version to install (default: latest)"
type: string
default: Latest

outputs:
destination:
description: Where the installed gofumpt binary is
value: ${{ steps.install.outputs.destination }}
destination-dir:
description: The directory where the installed gofumpt binary is
value: ${{ steps.install.outputs.destination-dir }}
version:
description: The installed version of gofumpt
value: ${{ steps.install.outputs.version }}

runs:
using: composite
steps:
- id: install
shell: bash
env:
GH_TOKEN: ${{ github.token }}
run: |
VERSION=$(gh release list -R mvdan/gofumpt --exclude-drafts --exclude-pre-releases | grep ${{ inputs.version }} | cut -f1)
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
mkdir -p $(dirname ${{ inputs.destination }})
DESTINATION="$(readlink -f "${{ inputs.destination }}")"
echo "destination=$DESTINATION" >> "$GITHUB_OUTPUT"
DESTINATION_DIR="$(dirname "$DESTINATION")"
echo "$DESTINATION_DIR" >> "$GITHUB_PATH"
echo "destination-dir=$DESTINATION_DIR" >> "$GITHUB_OUTPUT"
ARCH="$(echo "$RUNNER_ARCH" | tr '[:upper:]' '[:lower:]')"
OS="$(echo "$RUNNER_OS" | tr '[:upper:]' '[:lower:]')"
if [ "$ARCH" = "x64" ]; then
export ARCH="amd64"
fi
if [ "$OS" = "macos" ]; then
export OS="darwin"
fi
gh release download "$VERSION" -p "gofumpt_*_${OS}_${ARCH}" -O gofumpt -R mvdan/gofumpt
chmod +x gofumpt
mv gofumpt "$DESTINATION"
20 changes: 11 additions & 9 deletions .github/actions/set-up-gotestsum/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ inputs:
destination:
description: "Where to install the gotestsum binary (default: $HOME/bin/gotestsum)"
type: boolean
default: "$HOME/bin"
default: "$HOME/bin/gotestsum"
version:
description: "The version to install (default: latest)"
type: string
Expand All @@ -34,22 +34,24 @@ runs:
env:
GH_TOKEN: ${{ github.token }}
run: |
VERSION=$(gh release list -R gotestyourself/gotestsum --exclude-drafts --exclude-pre-releases | grep Latest | cut -f1)
VERSION=$(gh release list -R gotestyourself/gotestsum --exclude-drafts --exclude-pre-releases | grep ${{ inputs.version }} | cut -f1)
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
mkdir -p "$HOME/bin"
DESTINATION="$(readlink -f "$HOME/bin")"
echo "destination=$DESTINATION" >> "GITHUB_OUTPUT"
mkdir -p $(dirname ${{ inputs.destination }})
DESTINATION="$(readlink -f "${{ inputs.destination }}")"
echo "destination=$DESTINATION" >> "$GITHUB_OUTPUT"
DESTINATION_DIR="$(dirname "$DESTINATION")"
echo "$DESTINATION_DIR" >> "$GITHUB_PATH"
echo "destination-dir=$DESTINATION_DIR" >> "GITHUB_OUTPUT"
echo "destination-dir=$DESTINATION_DIR" >> "$GITHUB_OUTPUT"
OS="$(echo "$RUNNER_OS" | tr '[:upper:]' '[:lower:]')"
ARCH="$(echo "$RUNNER_ARCH" | tr '[:upper:]' '[:lower:]')"
if [ "$ARCH" = "x64" ]; then
export ARCH="amd64"
fi
gh release download "$VERSION" -p "*${OS}_${ARCH}.tar.gz" -O gotestsum.tgz -R gotestyourself/gotestsum
tar -xvf gotestsum.tgz
mv gotestsum "${DESTINATION_DIR}/gotestsum"
mkdir -p tmp
gh release download "$VERSION" -p "*${OS}_${ARCH}.tar.gz" -O tmp/gotestsum.tgz -R gotestyourself/gotestsum
pushd tmp && tar -xvf gotestsum.tgz && popd
mv tmp/gotestsum "$DESTINATION"
rm -rf tmp
60 changes: 60 additions & 0 deletions .github/actions/set-up-misspell/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
# Copyright (c) HashiCorp, Inc.
# SPDX-License-Identifier: BUSL-1.1

---
name: Set up misspell from Github releases
description: Set up misspell from Github releases

inputs:
destination:
description: "Where to install the misspell binary (default: $HOME/bin/misspell)"
type: boolean
default: "$HOME/bin/misspell"
version:
description: "The version to install (default: latest)"
type: string
default: Latest

outputs:
destination:
description: Where the installed misspell binary is
value: ${{ steps.install.outputs.destination }}
destination-dir:
description: The directory where the installed misspell binary is
value: ${{ steps.install.outputs.destination-dir }}
version:
description: The installed version of misspell
value: ${{ steps.install.outputs.version }}

runs:
using: composite
steps:
- id: install
shell: bash
env:
GH_TOKEN: ${{ github.token }}
run: |
VERSION=$(gh release list -R golangci/misspell --exclude-drafts --exclude-pre-releases | grep ${{ inputs.version }} | cut -f1)
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
mkdir -p $(dirname ${{ inputs.destination }})
DESTINATION="$(readlink -f "${{ inputs.destination }}")"
echo "destination=$DESTINATION" >> "$GITHUB_OUTPUT"
DESTINATION_DIR="$(dirname "$DESTINATION")"
echo "$DESTINATION_DIR" >> "$GITHUB_PATH"
echo "destination-dir=$DESTINATION_DIR" >> "$GITHUB_OUTPUT"
ARCH="$(echo "$RUNNER_ARCH" | tr '[:upper:]' '[:lower:]')"
OS="$(echo "$RUNNER_OS" | tr '[:upper:]' '[:lower:]')"
if [ "$ARCH" = "x64" ]; then
export ARCH="64bit"
fi
if [ "$OS" = "macos" ]; then
export OS="mac"
fi
mkdir -p tmp
gh release download "$VERSION" -p "misspell_*_${OS}_${ARCH}.tar.gz" -O tmp/misspell.tgz -R golangci/misspell
pushd tmp && tar -xvf misspell.tgz && popd
mv tmp/misspell "$DESTINATION"
rm -rf tmp
60 changes: 60 additions & 0 deletions .github/actions/set-up-staticcheck/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
# Copyright (c) HashiCorp, Inc.
# SPDX-License-Identifier: BUSL-1.1

---
name: Set up staticcheck from Github releases
description: Set up staticcheck from Github releases

inputs:
destination:
description: "Where to install the staticcheck binary (default: $HOME/bin/staticcheck)"
type: boolean
default: "$HOME/bin/staticcheck"
version:
description: "The version to install (default: latest)"
type: string
default: Latest

outputs:
destination:
description: Where the installed staticcheck binary is
value: ${{ steps.install.outputs.destination }}
destination-dir:
description: The directory where the installed staticcheck binary is
value: ${{ steps.install.outputs.destination-dir }}
version:
description: The installed version of staticcheck
value: ${{ steps.install.outputs.version }}

runs:
using: composite
steps:
- id: install
shell: bash
env:
GH_TOKEN: ${{ github.token }}
run: |
VERSION=$(gh release list -R dominikh/go-tools --exclude-drafts --exclude-pre-releases | grep ${{ inputs.version }} | cut -d " " -f2)
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
mkdir -p $(dirname ${{ inputs.destination }})
DESTINATION="$(readlink -f "${{ inputs.destination }}")"
echo "destination=$DESTINATION" >> "$GITHUB_OUTPUT"
DESTINATION_DIR="$(dirname "$DESTINATION")"
echo "$DESTINATION_DIR" >> "$GITHUB_PATH"
echo "destination-dir=$DESTINATION_DIR" >> "$GITHUB_OUTPUT"
ARCH="$(echo "$RUNNER_ARCH" | tr '[:upper:]' '[:lower:]')"
OS="$(echo "$RUNNER_OS" | tr '[:upper:]' '[:lower:]')"
if [ "$ARCH" = "x64" ]; then
export ARCH="amd64"
fi
if [ "$OS" = "macos" ]; then
export OS="darwin"
fi
mkdir -p tmp
gh release download "$VERSION" -p "staticcheck_${OS}_${ARCH}.tar.gz" -O tmp/staticcheck.tgz -R dominikh/go-tools
pushd tmp && tar -xvf staticcheck.tgz && popd
mv tmp/staticcheck/staticcheck "$DESTINATION"
rm -rf tmp
2 changes: 1 addition & 1 deletion .github/workflows/actionlint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
actionlint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
- name: "Check workflow files"
uses: docker://docker.mirror.hashicorp.services/rhysd/actionlint@sha256:93834930f56ca380be3e9a3377670d7aa5921be251b9c774891a39b3629b83b8
with:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/build-vault-ce.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,12 @@ jobs:
runs-on: custom-linux-xl-vault-latest
name: Vault ${{ inputs.goos }} ${{ inputs.goarch }} v${{ inputs.vault-version }}
steps:
- uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
- uses: ./.github/actions/set-up-go
with:
github-token: ${{ secrets.ELEVATED_GITHUB_TOKEN }}
- name: Restore UI from cache
uses: actions/cache@88522ab9f39a2ea568f7027eddc7d8d8bc9d59c8 # v3.3.1
uses: actions/cache@13aacd865c20de90d75de3b17ebe84f7a17d57d2 # v4.0.0
with:
# Restore the UI asset from the UI build workflow. Never use a partial restore key.
enableCrossOsArchive: true
Expand Down
Loading

0 comments on commit 8efb40e

Please sign in to comment.