Introduce GitHub Actions CI Workflow (#19449)
* Migrate subset of CircleCI ci workflow to GitHub Actions Runs test-go and test-go-remote-docker with a static splitting of test packages * [skip actions] add comment to explain the purpose of test-generate-test-package-lists.sh and what to do if it fails * change trigger to push --------- Co-authored-by: Kuba Wieczorek <kuba.wieczorek@hashicorp.com>
This commit is contained in:
parent
d91d2ceaf8
commit
84238dee52
|
@ -0,0 +1,280 @@
|
|||
# This script is meant to be sourced into the shell running in a Github
|
||||
# workflow.
|
||||
|
||||
# This script is a temporary measure until we implement a dynamic test-splitting
|
||||
# solution. It distributes the entire set of test packages into 16 sublists,
|
||||
# which should roughly take an equal amount of time to complete.
|
||||
|
||||
test_packages=()
|
||||
|
||||
base="github.com/hashicorp/vault"
|
||||
|
||||
# Total time: 526
|
||||
test_packages[1]+=" $base/api"
|
||||
test_packages[1]+=" $base/command"
|
||||
test_packages[1]+=" $base/sdk/helper/keysutil"
|
||||
|
||||
# Total time: 1160
|
||||
test_packages[2]+=" $base/sdk/helper/ocsp"
|
||||
if [ "${ENTERPRISE:+x}" == "x" ] ; then
|
||||
test_packages[2]+=" $base/vault/external_tests/replication-perf"
|
||||
fi
|
||||
|
||||
# Total time: 1009
|
||||
test_packages[3]+=" $base/builtin/credential/approle"
|
||||
test_packages[3]+=" $base/command/agent/sink/file"
|
||||
test_packages[3]+=" $base/command/agent/template"
|
||||
test_packages[3]+=" $base/helper/random"
|
||||
test_packages[3]+=" $base/helper/storagepacker"
|
||||
test_packages[3]+=" $base/sdk/helper/certutil"
|
||||
if [ "${ENTERPRISE:+x}" == "x" ] ; then
|
||||
test_packages[3]+=" $base/vault/external_tests/entropy"
|
||||
fi
|
||||
test_packages[3]+=" $base/vault/external_tests/raft"
|
||||
|
||||
# Total time: 830
|
||||
test_packages[4]+=" $base/builtin/plugin"
|
||||
if [ "${ENTERPRISE:+x}" == "x" ] ; then
|
||||
test_packages[4]+=" $base/enthelpers/fsm"
|
||||
fi
|
||||
test_packages[4]+=" $base/http"
|
||||
test_packages[4]+=" $base/sdk/helper/pluginutil"
|
||||
test_packages[4]+=" $base/serviceregistration/kubernetes"
|
||||
test_packages[4]+=" $base/tools/godoctests/pkg/analyzer"
|
||||
if [ "${ENTERPRISE:+x}" == "x" ] ; then
|
||||
test_packages[4]+=" $base/vault/external_tests/apilock"
|
||||
test_packages[4]+=" $base/vault/external_tests/filteredpaths"
|
||||
test_packages[4]+=" $base/vault/external_tests/perfstandby"
|
||||
test_packages[4]+=" $base/vault/external_tests/replication-dr"
|
||||
fi
|
||||
|
||||
|
||||
# Total time: 258
|
||||
test_packages[5]+=" $base/builtin/credential/aws"
|
||||
test_packages[5]+=" $base/builtin/credential/cert"
|
||||
test_packages[5]+=" $base/builtin/logical/aws"
|
||||
if [ "${ENTERPRISE:+x}" == "x" ] ; then
|
||||
test_packages[5]+=" $base/enthelpers/logshipper"
|
||||
test_packages[5]+=" $base/enthelpers/merkle"
|
||||
fi
|
||||
test_packages[5]+=" $base/helper/hostutil"
|
||||
test_packages[5]+=" $base/helper/pgpkeys"
|
||||
test_packages[5]+=" $base/sdk/physical/inmem"
|
||||
test_packages[5]+=" $base/vault/activity"
|
||||
test_packages[5]+=" $base/vault/diagnose"
|
||||
test_packages[5]+=" $base/vault/external_tests/pprof"
|
||||
if [ "${ENTERPRISE:+x}" == "x" ] ; then
|
||||
test_packages[5]+=" $base/vault/external_tests/resolver"
|
||||
fi
|
||||
test_packages[5]+=" $base/vault/external_tests/response"
|
||||
if [ "${ENTERPRISE:+x}" == "x" ] ; then
|
||||
test_packages[5]+=" $base/vault/external_tests/seal"
|
||||
fi
|
||||
test_packages[5]+=" $base/vault/external_tests/sealmigration"
|
||||
if [ "${ENTERPRISE:+x}" == "x" ] ; then
|
||||
test_packages[5]+=" $base/vault/external_tests/transform"
|
||||
fi
|
||||
|
||||
# Total time: 588
|
||||
test_packages[6]+=" $base"
|
||||
test_packages[6]+=" $base/audit"
|
||||
test_packages[6]+=" $base/builtin/audit/file"
|
||||
test_packages[6]+=" $base/builtin/credential/github"
|
||||
test_packages[6]+=" $base/builtin/credential/okta"
|
||||
test_packages[6]+=" $base/builtin/logical/database/dbplugin"
|
||||
test_packages[6]+=" $base/command/agent/auth/cert"
|
||||
test_packages[6]+=" $base/command/agent/auth/jwt"
|
||||
test_packages[6]+=" $base/command/agent/auth/kerberos"
|
||||
test_packages[6]+=" $base/command/agent/auth/kubernetes"
|
||||
test_packages[6]+=" $base/command/agent/auth/token-file"
|
||||
test_packages[6]+=" $base/command/agent/cache"
|
||||
test_packages[6]+=" $base/command/agent/cache/cacheboltdb"
|
||||
test_packages[6]+=" $base/command/agent/cache/cachememdb"
|
||||
test_packages[6]+=" $base/command/agent/cache/keymanager"
|
||||
test_packages[6]+=" $base/command/agent/config"
|
||||
test_packages[6]+=" $base/command/config"
|
||||
test_packages[6]+=" $base/command/token"
|
||||
if [ "${ENTERPRISE:+x}" == "x" ] ; then
|
||||
test_packages[6]+=" $base/enthelpers/namespace"
|
||||
test_packages[6]+=" $base/enthelpers/replicatedpaths"
|
||||
test_packages[6]+=" $base/enthelpers/sealrewrap"
|
||||
fi
|
||||
test_packages[6]+=" $base/helper/builtinplugins"
|
||||
test_packages[6]+=" $base/helper/dhutil"
|
||||
test_packages[6]+=" $base/helper/fairshare"
|
||||
test_packages[6]+=" $base/helper/flag-kv"
|
||||
test_packages[6]+=" $base/helper/flag-slice"
|
||||
test_packages[6]+=" $base/helper/forwarding"
|
||||
test_packages[6]+=" $base/helper/logging"
|
||||
test_packages[6]+=" $base/helper/metricsutil"
|
||||
test_packages[6]+=" $base/helper/namespace"
|
||||
test_packages[6]+=" $base/helper/osutil"
|
||||
test_packages[6]+=" $base/helper/parseip"
|
||||
test_packages[6]+=" $base/helper/policies"
|
||||
test_packages[6]+=" $base/helper/testhelpers/logical"
|
||||
test_packages[6]+=" $base/helper/timeutil"
|
||||
test_packages[6]+=" $base/helper/useragent"
|
||||
test_packages[6]+=" $base/helper/versions"
|
||||
test_packages[6]+=" $base/internalshared/configutil"
|
||||
test_packages[6]+=" $base/internalshared/listenerutil"
|
||||
test_packages[6]+=" $base/physical/alicloudoss"
|
||||
test_packages[6]+=" $base/physical/gcs"
|
||||
test_packages[6]+=" $base/physical/manta"
|
||||
test_packages[6]+=" $base/physical/mssql"
|
||||
test_packages[6]+=" $base/physical/oci"
|
||||
test_packages[6]+=" $base/physical/s3"
|
||||
test_packages[6]+=" $base/physical/spanner"
|
||||
test_packages[6]+=" $base/physical/swift"
|
||||
test_packages[6]+=" $base/physical/zookeeper"
|
||||
test_packages[6]+=" $base/plugins/database/hana"
|
||||
test_packages[6]+=" $base/plugins/database/redshift"
|
||||
test_packages[6]+=" $base/sdk/database/dbplugin/v5"
|
||||
test_packages[6]+=" $base/sdk/database/helper/credsutil"
|
||||
test_packages[6]+=" $base/sdk/helper/authmetadata"
|
||||
test_packages[6]+=" $base/sdk/helper/compressutil"
|
||||
test_packages[6]+=" $base/sdk/helper/cryptoutil"
|
||||
test_packages[6]+=" $base/sdk/helper/identitytpl"
|
||||
test_packages[6]+=" $base/sdk/helper/kdf"
|
||||
test_packages[6]+=" $base/sdk/helper/locksutil"
|
||||
test_packages[6]+=" $base/sdk/helper/pathmanager"
|
||||
test_packages[6]+=" $base/sdk/helper/roottoken"
|
||||
test_packages[6]+=" $base/sdk/helper/testhelpers/schema"
|
||||
test_packages[6]+=" $base/sdk/helper/xor"
|
||||
test_packages[6]+=" $base/sdk/physical/file"
|
||||
test_packages[6]+=" $base/sdk/plugin/pb"
|
||||
test_packages[6]+=" $base/serviceregistration/kubernetes/client"
|
||||
test_packages[6]+=" $base/shamir"
|
||||
test_packages[6]+=" $base/vault/cluster"
|
||||
test_packages[6]+=" $base/vault/eventbus"
|
||||
test_packages[6]+=" $base/vault/external_tests/api"
|
||||
if [ "${ENTERPRISE:+x}" == "x" ] ; then
|
||||
test_packages[6]+=" $base/vault/external_tests/consistencyheaders"
|
||||
fi
|
||||
test_packages[6]+=" $base/vault/external_tests/expiration"
|
||||
test_packages[6]+=" $base/vault/external_tests/hcp_link"
|
||||
test_packages[6]+=" $base/vault/external_tests/kv"
|
||||
if [ "${ENTERPRISE:+x}" == "x" ] ; then
|
||||
test_packages[6]+=" $base/vault/external_tests/plugins"
|
||||
fi
|
||||
test_packages[6]+=" $base/vault/external_tests/quotas"
|
||||
test_packages[6]+=" $base/vault/seal"
|
||||
|
||||
# Total time: 389
|
||||
test_packages[7]+=" $base/builtin/credential/userpass"
|
||||
test_packages[7]+=" $base/builtin/logical/pki"
|
||||
test_packages[7]+=" $base/builtin/logical/transit"
|
||||
test_packages[7]+=" $base/command/agent"
|
||||
test_packages[7]+=" $base/helper/monitor"
|
||||
test_packages[7]+=" $base/sdk/database/helper/connutil"
|
||||
test_packages[7]+=" $base/sdk/database/helper/dbutil"
|
||||
test_packages[7]+=" $base/sdk/helper/cidrutil"
|
||||
test_packages[7]+=" $base/sdk/helper/custommetadata"
|
||||
test_packages[7]+=" $base/sdk/helper/jsonutil"
|
||||
test_packages[7]+=" $base/sdk/helper/ldaputil"
|
||||
test_packages[7]+=" $base/sdk/helper/logging"
|
||||
test_packages[7]+=" $base/sdk/helper/policyutil"
|
||||
test_packages[7]+=" $base/sdk/helper/salt"
|
||||
test_packages[7]+=" $base/sdk/helper/template"
|
||||
test_packages[7]+=" $base/sdk/helper/useragent"
|
||||
test_packages[7]+=" $base/sdk/logical"
|
||||
test_packages[7]+=" $base/sdk/plugin/mock"
|
||||
test_packages[7]+=" $base/sdk/queue"
|
||||
if [ "${ENTERPRISE:+x}" == "x" ] ; then
|
||||
test_packages[7]+=" $base/vault/autosnapshots"
|
||||
test_packages[7]+=" $base/vault/external_tests/activity"
|
||||
fi
|
||||
test_packages[7]+=" $base/vault/external_tests/approle"
|
||||
if [ "${ENTERPRISE:+x}" == "x" ] ; then
|
||||
test_packages[7]+=" $base/vault/external_tests/kmip"
|
||||
fi
|
||||
test_packages[7]+=" $base/vault/external_tests/mfa"
|
||||
test_packages[7]+=" $base/vault/external_tests/misc"
|
||||
test_packages[7]+=" $base/vault/quotas"
|
||||
|
||||
# Total time: 779
|
||||
test_packages[8]+=" $base/builtin/credential/aws/pkcs7"
|
||||
test_packages[8]+=" $base/builtin/logical/totp"
|
||||
test_packages[8]+=" $base/command/agent/auth"
|
||||
test_packages[8]+=" $base/physical/raft"
|
||||
test_packages[8]+=" $base/sdk/framework"
|
||||
test_packages[8]+=" $base/sdk/plugin"
|
||||
test_packages[8]+=" $base/vault"
|
||||
if [ "${ENTERPRISE:+x}" == "x" ] ; then
|
||||
test_packages[8]+=" $base/vault/external_tests/barrier"
|
||||
test_packages[8]+=" $base/vault/external_tests/cubbyholes"
|
||||
fi
|
||||
test_packages[8]+=" $base/vault/external_tests/metrics"
|
||||
if [ "${ENTERPRISE:+x}" == "x" ] ; then
|
||||
test_packages[8]+=" $base/vault/external_tests/replication"
|
||||
fi
|
||||
test_packages[8]+=" $base/vault/external_tests/router"
|
||||
if [ "${ENTERPRISE:+x}" == "x" ] ; then
|
||||
test_packages[8]+=" $base/vault/external_tests/system"
|
||||
test_packages[8]+=" $base/vault/managed_key"
|
||||
fi
|
||||
|
||||
# Total time: 310
|
||||
test_packages[9]+=" $base/vault/hcp_link/capabilities/api_capability"
|
||||
test_packages[9]+=" $base/vault/external_tests/plugin"
|
||||
|
||||
# Total time: 925
|
||||
test_packages[10]+=" $base/builtin/credential/ldap"
|
||||
test_packages[10]+=" $base/builtin/logical/database"
|
||||
test_packages[10]+=" $base/physical/etcd"
|
||||
test_packages[10]+=" $base/physical/postgresql"
|
||||
|
||||
# Total time: 851
|
||||
test_packages[11]+=" $base/builtin/logical/rabbitmq"
|
||||
test_packages[11]+=" $base/physical/dynamodb"
|
||||
test_packages[11]+=" $base/plugins/database/influxdb"
|
||||
test_packages[11]+=" $base/vault/external_tests/identity"
|
||||
test_packages[11]+=" $base/vault/external_tests/token"
|
||||
|
||||
# Total time: 340
|
||||
test_packages[12]+=" $base/builtin/logical/consul"
|
||||
test_packages[12]+=" $base/physical/couchdb"
|
||||
test_packages[12]+=" $base/plugins/database/mongodb"
|
||||
test_packages[12]+=" $base/plugins/database/mssql"
|
||||
test_packages[12]+=" $base/plugins/database/mysql"
|
||||
|
||||
# Total time: 704
|
||||
test_packages[13]+=" $base/builtin/logical/pkiext"
|
||||
test_packages[13]+=" $base/command/server"
|
||||
test_packages[13]+=" $base/physical/aerospike"
|
||||
test_packages[13]+=" $base/physical/cockroachdb"
|
||||
test_packages[13]+=" $base/plugins/database/postgresql"
|
||||
if [ "${ENTERPRISE:+x}" == "x" ] ; then
|
||||
test_packages[13]+=" $base/vault/external_tests/filteredpathsext"
|
||||
fi
|
||||
test_packages[13]+=" $base/vault/external_tests/policy"
|
||||
|
||||
# Total time: 374
|
||||
test_packages[14]+=" $base/builtin/credential/radius"
|
||||
test_packages[14]+=" $base/builtin/logical/ssh"
|
||||
if [ "${ENTERPRISE:+x}" == "x" ] ; then
|
||||
test_packages[14]+=" $base/enthelpers/wal"
|
||||
fi
|
||||
test_packages[14]+=" $base/physical/azure"
|
||||
test_packages[14]+=" $base/serviceregistration/consul"
|
||||
if [ "${ENTERPRISE:+x}" == "x" ] ; then
|
||||
test_packages[14]+=" $base/vault/external_tests/quotas-docker"
|
||||
fi
|
||||
test_packages[14]+=" $base/vault/external_tests/raftha"
|
||||
|
||||
# Total time: 362
|
||||
test_packages[15]+=" $base/builtin/logical/nomad"
|
||||
test_packages[15]+=" $base/physical/mysql"
|
||||
test_packages[15]+=" $base/plugins/database/cassandra"
|
||||
if [ "${ENTERPRISE:+x}" == "x" ] ; then
|
||||
test_packages[15]+=" $base/vault/external_tests/namespaces"
|
||||
fi
|
||||
test_packages[15]+=" $base/vault/external_tests/sealmigrationext"
|
||||
|
||||
# Total time: 635
|
||||
test_packages[16]+=" $base/physical/cassandra"
|
||||
test_packages[16]+=" $base/physical/consul"
|
||||
if [ "${ENTERPRISE:+x}" == "x" ] ; then
|
||||
test_packages[16]+=" $base/vault/external_tests/autosnapshots"
|
||||
test_packages[16]+=" $base/vault/external_tests/replicationext"
|
||||
test_packages[16]+=" $base/vault/external_tests/sealext"
|
||||
fi
|
|
@ -0,0 +1,72 @@
|
|||
#!/bin/bash
|
||||
set -e${DEBUG+x}o pipefail
|
||||
|
||||
#
|
||||
# This script is run to make sure that every package returned by
|
||||
# go list -test ./... (when run from the repo root, api/, and sdk/ directory)
|
||||
# appear in the test_packages array defined in the sibling file
|
||||
# generate-test-package-lists.sh
|
||||
#
|
||||
# This script is executed as part of the ci workflow triggered by pull_requests
|
||||
# events. In the event that the job that runs this script fails, examine the
|
||||
# output of the 'test' step in that job to obtain the list of test packages that
|
||||
# are missing in the test_packages array or that should be removed from it.
|
||||
#
|
||||
|
||||
dir=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
|
||||
|
||||
source generate-test-package-lists.sh
|
||||
|
||||
get_module_packages() {
|
||||
local package_list=($(go list -test -json ./... | jq -r '.ForTest | select(.!=null)' | grep -v vault/integ | grep '^github.com/hashicorp/'))
|
||||
|
||||
for package in "${package_list[@]}" ; do
|
||||
# Check if the current package already exists in all_packages
|
||||
if ! grep "\b$package\b" <<< "${all_packages[@]}" &> /dev/null; then
|
||||
all_packages+=($package)
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
find_packages() {
|
||||
for package in "${all_packages[@]}" ; do
|
||||
if ! grep "\b${package}\b" <<< "${test_packages[@]}" &> /dev/null ; then
|
||||
echo "Error: package ${package} is not present in test_packages"
|
||||
exit 1
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
count_test_packages() {
|
||||
count=0
|
||||
for test_package in "${test_packages[@]}" ; do
|
||||
count=$((${count}+$(wc -w <<< "${test_package}")))
|
||||
done
|
||||
|
||||
echo $count
|
||||
}
|
||||
|
||||
all_packages=()
|
||||
|
||||
cd "$dir/../.."
|
||||
get_module_packages
|
||||
|
||||
cd "$dir/../../sdk"
|
||||
get_module_packages
|
||||
|
||||
cd "$dir/../../api"
|
||||
get_module_packages
|
||||
|
||||
find_packages
|
||||
|
||||
test_package_count=$(count_test_packages)
|
||||
if (( ${#all_packages[@]} != $test_package_count )) ; then
|
||||
echo "Error: there are currently ${#all_packages[@]} packages in the repository but $test_package_count packages in test_packages"
|
||||
|
||||
unused_packages="${test_packages[@]} "
|
||||
for ap in ${all_packages[@]} ; do
|
||||
unused_packages="$(echo "$unused_packages" | sed -r "s~$ap ~ ~" )"
|
||||
done
|
||||
|
||||
echo "Packages in test_packages that aren't used: ${unused_packages// /}"
|
||||
fi
|
|
@ -0,0 +1,83 @@
|
|||
name: CI
|
||||
on:
|
||||
push:
|
||||
|
||||
jobs:
|
||||
setup:
|
||||
name: Setup
|
||||
runs-on: ubuntu-latest
|
||||
outputs:
|
||||
runs-on: ${{ steps.setup-outputs.outputs.runs-on }}
|
||||
enterprise: ${{ steps.setup-outputs.outputs.enterprise }}
|
||||
go-tags: ${{ steps.setup-outputs.outputs.go-tags }}
|
||||
steps:
|
||||
- id: setup-outputs
|
||||
name: Setup outputs
|
||||
run: |
|
||||
github_repository="${{ github.repository }}"
|
||||
|
||||
if [ "${github_repository##*/}" == "vault-enterprise" ] ; then
|
||||
echo 'runs-on=["self-hosted","ondemand","linux","type=c5.2xlarge"]' >> $GITHUB_OUTPUT
|
||||
echo 'enterprise=1' >> $GITHUB_OUTPUT
|
||||
echo 'go-tags=ent enterprise' >> $GITHUB_OUTPUT
|
||||
else
|
||||
echo 'runs-on=ubuntu-latest' >> $GITHUB_OUTPUT
|
||||
echo 'enterprise=' >> $GITHUB_OUTPUT
|
||||
echo 'go-tags=' >> $GITHUB_OUTPUT
|
||||
fi
|
||||
semgrep:
|
||||
name: Semgrep
|
||||
needs:
|
||||
- setup
|
||||
runs-on: ${{ fromJSON(needs.setup.outputs.runs-on) }}
|
||||
container:
|
||||
image: returntocorp/semgrep@sha256:ffc6f3567654f9431456d49fd059dfe548f007c494a7eb6cd5a1a3e50d813fb3
|
||||
steps:
|
||||
- uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c
|
||||
- name: Run Semgrep Rules
|
||||
id: semgrep
|
||||
run: semgrep ci --include '*.go' --config 'tools/semgrep/ci'
|
||||
setup-go-cache:
|
||||
name: Go Caches
|
||||
needs:
|
||||
- setup
|
||||
uses: ./.github/workflows/setup-go-cache.yml
|
||||
with:
|
||||
runs-on: ${{ needs.setup.outputs.runs-on }}
|
||||
secrets: inherit
|
||||
fmt:
|
||||
name: Check Format
|
||||
needs:
|
||||
- setup
|
||||
runs-on: ${{ fromJSON(needs.setup.outputs.runs-on) }}
|
||||
steps:
|
||||
- uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c
|
||||
- uses: actions/setup-go@d0a58c1c4d2b25278816e339b944508c875f3613
|
||||
with:
|
||||
go-version-file: ./.go-version
|
||||
cache: true
|
||||
- id: format
|
||||
run: |
|
||||
echo "Using gofumpt version $(go run mvdan.cc/gofumpt -version)"
|
||||
make fmt
|
||||
if ! git diff --exit-code; then
|
||||
echo "Code has formatting errors. Run 'make fmt' to fix"
|
||||
exit 1
|
||||
fi
|
||||
test-go:
|
||||
name: Run Go tests
|
||||
needs:
|
||||
- setup
|
||||
- setup-go-cache
|
||||
# Don't run this job for branches starting with 'ui/', 'docs/', or 'backport/docs/'
|
||||
if: ${{ ! (startsWith( github.ref_name, 'ui/' ) || startsWith( github.ref_name, 'docs/' ) || startsWith( github.ref_name, 'backport/docs/') ) }}
|
||||
uses: ./.github/workflows/test-go.yml
|
||||
with:
|
||||
# The example inputs below are just here to get the workflow to run during the migration.
|
||||
# In the future, they will be substituted - possibly with references to values coming from a testing matrix.
|
||||
go-arch: amd64
|
||||
go-tags: ${{ needs.setup.outputs.go-tags }}
|
||||
extra-tags: deadlock
|
||||
runs-on: ${{ needs.setup.outputs.runs-on }}
|
||||
enterprise: ${{ needs.setup.outputs.enterprise }}
|
||||
secrets: inherit
|
|
@ -0,0 +1,33 @@
|
|||
on:
|
||||
workflow_call:
|
||||
inputs:
|
||||
runs-on:
|
||||
required: true
|
||||
type: string
|
||||
jobs:
|
||||
setup-go-cache:
|
||||
runs-on: ${{ fromJSON(inputs.runs-on) }}
|
||||
steps:
|
||||
- uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c #v3.3.0 as of 2023-01-18
|
||||
- id: setup-go
|
||||
name: Setup go
|
||||
uses: actions/setup-go@d0a58c1c4d2b25278816e339b944508c875f3613 #v3.4.0 as of 2022-12-07
|
||||
with:
|
||||
go-version-file: ./.go-version
|
||||
cache: true
|
||||
- id: setup-git
|
||||
name: Setup Git configuration
|
||||
run: |
|
||||
git config --global url."https://${{ secrets.ELEVATED_GITHUB_TOKEN }}@github.com".insteadOf https://github.com
|
||||
- id: download-modules
|
||||
name: Download go modules
|
||||
run: |
|
||||
# go list ./... forces downloading some additional versions of modules that 'go mod
|
||||
# download' misses. We need this because we make use of go list itself during
|
||||
# code generation in later builds that rely on this module cache.
|
||||
go list ./...
|
||||
go list -test ./...
|
||||
|
||||
go mod download
|
||||
( cd sdk && go mod download )
|
||||
( cd api && go mod download )
|
|
@ -0,0 +1,164 @@
|
|||
on:
|
||||
workflow_call:
|
||||
inputs:
|
||||
go-arch:
|
||||
description: The execution architecture (arm, amd64, etc.)
|
||||
required: true
|
||||
type: string
|
||||
extra-tags:
|
||||
description: A comma-separated list of additional build tags.
|
||||
required: false
|
||||
type: string
|
||||
runs-on:
|
||||
description: An expression indicating which kind of runners to use.
|
||||
required: false
|
||||
type: string
|
||||
default: ubuntu-latest
|
||||
enterprise:
|
||||
description: A flag indicating if this workflow is executing for the enterprise repository.
|
||||
required: true
|
||||
type: string
|
||||
go-tags:
|
||||
description: The go tags to include on the go test command.
|
||||
required: false
|
||||
type: string
|
||||
|
||||
env:
|
||||
total-runners: 16
|
||||
|
||||
jobs:
|
||||
test-generate-test-package-list:
|
||||
runs-on: ${{ fromJSON(inputs.runs-on) }}
|
||||
name: Verify Test Package Distribution
|
||||
steps:
|
||||
- uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c
|
||||
- id: test
|
||||
working-directory: .github/scripts
|
||||
run: |
|
||||
ENTERPRISE=${{ inputs.enterprise }} ./test-generate-test-package-lists.sh
|
||||
runner-indexes:
|
||||
runs-on: ${{ fromJSON(inputs.runs-on) }}
|
||||
name: Generate runner indexes
|
||||
#
|
||||
# This job generates a JSON Array of integers ranging from 1 to 16.
|
||||
# That array is used in the matrix section of the test-go job below.
|
||||
#
|
||||
outputs:
|
||||
runner-indexes: ${{ steps.generate-index-list.outputs.indexes }}
|
||||
steps:
|
||||
- id: generate-index-list
|
||||
run: |
|
||||
INDEX_LIST=$(seq 1 ${{ env.total-runners }})
|
||||
INDEX_JSON=$(jq --null-input --compact-output '. |= [inputs]' <<< ${INDEX_LIST})
|
||||
echo "indexes=${INDEX_JSON}" >> ${GITHUB_OUTPUT}
|
||||
test-go:
|
||||
permissions:
|
||||
id-token: write # Note: this permission is explicitly required for Vault auth
|
||||
contents: read
|
||||
name: ${{ inputs.packages }}
|
||||
needs:
|
||||
- runner-indexes
|
||||
# Use GitHub runners on the OSS Vault repo and self-hosted runners otherwise.
|
||||
runs-on: ${{ fromJSON(inputs.runs-on) }}
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
#
|
||||
# Initialize the runner-index key with the JSON array of integers
|
||||
# generated above.
|
||||
#
|
||||
runner-index: ${{ fromJSON(needs.runner-indexes.outputs.runner-indexes) }}
|
||||
env:
|
||||
GOPRIVATE: github.com/hashicorp/*
|
||||
TIMEOUT_IN_MINUTES: 60
|
||||
steps:
|
||||
- id: setup-git
|
||||
name: Setup Git configuration
|
||||
run: |
|
||||
git config --global url."https://${{ secrets.ELEVATED_GITHUB_TOKEN }}@github.com".insteadOf https://github.com
|
||||
- uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c
|
||||
- uses: actions/setup-go@d0a58c1c4d2b25278816e339b944508c875f3613
|
||||
with:
|
||||
go-version-file: ./.go-version
|
||||
cache: true
|
||||
- name: Authenticate to Vault
|
||||
id: vault-auth
|
||||
if: github.repository == 'hashicorp/vault-enterprise'
|
||||
run: vault-auth
|
||||
- name: Fetch Secrets
|
||||
id: secrets
|
||||
if: github.repository == 'hashicorp/vault-enterprise'
|
||||
uses: hashicorp/vault-action@130d1f5f4fe645bb6c83e4225c04d64cfb62de6e
|
||||
with:
|
||||
url: ${{ steps.vault-auth.outputs.addr }}
|
||||
caCertificate: ${{ steps.vault-auth.outputs.ca_certificate }}
|
||||
token: ${{ steps.vault-auth.outputs.token }}
|
||||
secrets: |
|
||||
kv/data/github/${{ github.repository }}/license license_1 | VAULT_LICENSE_CI;
|
||||
kv/data/github/${{ github.repository }}/license license_2 | VAULT_LICENSE_2;
|
||||
kv/data/github/${{ github.repository }}/hcp-link HCP_API_ADDRESS;
|
||||
kv/data/github/${{ github.repository }}/hcp-link HCP_AUTH_URL;
|
||||
kv/data/github/${{ github.repository }}/hcp-link HCP_CLIENT_ID;
|
||||
kv/data/github/${{ github.repository }}/hcp-link HCP_CLIENT_SECRET;
|
||||
kv/data/github/${{ github.repository }}/hcp-link HCP_RESOURCE_ID;
|
||||
kv/data/github/${{ github.repository }}/hcp-link HCP_SCADA_ADDRESS;
|
||||
- id: run-go-tests
|
||||
name: Run Go tests
|
||||
timeout-minutes: ${{ fromJSON(env.TIMEOUT_IN_MINUTES) }}
|
||||
run: |
|
||||
set -exo pipefail
|
||||
|
||||
#
|
||||
# This script creates a Bash array with 16 elements each
|
||||
# containing a space delimited list of package names. The
|
||||
# array element corresponding to this instance's
|
||||
# matrix.runner-index value.
|
||||
#
|
||||
ENTERPRISE=${{ inputs.enterprise }} source .github/scripts/generate-test-package-lists.sh
|
||||
|
||||
# Build the dynamically generated source files.
|
||||
make prep
|
||||
|
||||
mkdir -p test-results/go-test
|
||||
|
||||
# We don't want VAULT_LICENSE set when running Go tests, because that's
|
||||
# not what developers have in their environments and it could break some
|
||||
# tests; it would be like setting VAULT_TOKEN. However some non-Go
|
||||
# CI commands, like the UI tests, shouldn't have to worry about licensing.
|
||||
# So we provide the tests which want an externally supplied license with licenses
|
||||
# via the VAULT_LICENSE_CI and VAULT_LICENSE_2 environment variables, and here we unset it.
|
||||
VAULT_LICENSE=
|
||||
|
||||
# Assign test licenses to relevant variables if they aren't already
|
||||
if [[ ${{ github.repository }} == 'hashicorp/vault' ]]; then
|
||||
export VAULT_LICENSE_CI=${{ secrets.ci_license }}
|
||||
export VAULT_LICENSE_2=${{ secrets.ci_license_2 }}
|
||||
export HCP_API_ADDRESS=${{ secrets.HCP_API_ADDRESS }}
|
||||
export HCP_AUTH_URL=${{ secrets.HCP_AUTH_URL }}
|
||||
export HCP_CLIENT_ID=${{ secrets.HCP_CLIENT_ID }}
|
||||
export HCP_CLIENT_SECRET=${{ secrets.HCP_CLIENT_SECRET }}
|
||||
export HCP_RESOURCE_ID=${{ secrets.HCP_RESOURCE_ID }}
|
||||
export HCP_SCADA_ADDRESS=${{ secrets.HCP_SCADA_ADDRESS }}
|
||||
fi
|
||||
|
||||
GOARCH=${{ inputs.go-arch }} \
|
||||
go run gotest.tools/gotestsum --format=short-verbose \
|
||||
--junitfile test-results/go-test/results.xml \
|
||||
--jsonfile test-results/go-test/results.json \
|
||||
-- \
|
||||
-tags "${{ inputs.go-tags }} ${{ inputs.extra-tags }}" \
|
||||
-timeout=${{ env.TIMEOUT_IN_MINUTES }}m \
|
||||
-parallel=20 \
|
||||
\
|
||||
${test_packages[${{ matrix.runner-index }}]}
|
||||
- name: Archive test results
|
||||
uses: actions/upload-artifact@0b7f8abb1508181956e8e162db84b466c27e18ce
|
||||
with:
|
||||
name: test-results-${{ matrix.runner-index }}
|
||||
path: test-results/
|
||||
- name: Create a summary of tests
|
||||
uses: test-summary/action@62bc5c68de2a6a0d02039763b8c754569df99e3f
|
||||
with:
|
||||
paths: "test-results/go-test/results.xml"
|
||||
show: "fail"
|
||||
if: always()
|
|
@ -534,6 +534,10 @@ func TestDebugCommand_NoConnection(t *testing.T) {
|
|||
t.Fatal(err)
|
||||
}
|
||||
|
||||
if err := client.SetAddress(""); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
_, cmd := testDebugCommand(t)
|
||||
cmd.client = client
|
||||
cmd.skipTimingChecks = true
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package server
|
||||
|
||||
import (
|
||||
"os"
|
||||
"testing"
|
||||
|
||||
"github.com/go-test/deep"
|
||||
|
@ -9,6 +10,10 @@ import (
|
|||
)
|
||||
|
||||
func TestHCPLinkConfig(t *testing.T) {
|
||||
os.Unsetenv("HCP_CLIENT_ID")
|
||||
os.Unsetenv("HCP_CLIENT_SECRET")
|
||||
os.Unsetenv("HCP_RESOURCE_ID")
|
||||
|
||||
config, err := LoadConfigFile("./test-fixtures/hcp_link_config.hcl")
|
||||
if err != nil {
|
||||
t.Fatalf("err: %s", err)
|
||||
|
|
3
go.mod
3
go.mod
|
@ -208,6 +208,7 @@ require (
|
|||
google.golang.org/protobuf v1.28.1
|
||||
gopkg.in/ory-am/dockertest.v3 v3.3.4
|
||||
gopkg.in/square/go-jose.v2 v2.6.0
|
||||
gotest.tools/gotestsum v1.9.0
|
||||
k8s.io/utils v0.0.0-20220728103510-ee6ede2d64ed
|
||||
layeh.com/radius v0.0.0-20190322222518-890bc1058917
|
||||
mvdan.cc/gofumpt v0.3.1
|
||||
|
@ -293,6 +294,7 @@ require (
|
|||
github.com/dgryski/go-metro v0.0.0-20180109044635-280f6062b5bc // indirect
|
||||
github.com/digitalocean/godo v1.7.5 // indirect
|
||||
github.com/dimchansky/utfbom v1.1.1 // indirect
|
||||
github.com/dnephin/pflag v1.0.7 // indirect
|
||||
github.com/docker/cli v20.10.18+incompatible // indirect
|
||||
github.com/docker/distribution v2.8.1+incompatible // indirect
|
||||
github.com/docker/go-units v0.5.0 // indirect
|
||||
|
@ -302,6 +304,7 @@ require (
|
|||
github.com/envoyproxy/protoc-gen-validate v0.1.0 // indirect
|
||||
github.com/evanphx/json-patch/v5 v5.6.0 // indirect
|
||||
github.com/form3tech-oss/jwt-go v3.2.5+incompatible // indirect
|
||||
github.com/fsnotify/fsnotify v1.5.4 // indirect
|
||||
github.com/gabriel-vasile/mimetype v1.3.1 // indirect
|
||||
github.com/gammazero/deque v0.0.0-20190130191400-2afb3858e9c7 // indirect
|
||||
github.com/gammazero/workerpool v0.0.0-20190406235159-88d534f22b56 // indirect
|
||||
|
|
18
go.sum
18
go.sum
|
@ -512,6 +512,8 @@ github.com/dimchansky/utfbom v1.1.1/go.mod h1:SxdoEBH5qIqFocHMyGOXVAybYJdr71b1Q/
|
|||
github.com/dnaeon/go-vcr v1.0.1/go.mod h1:aBB1+wY4s93YsC3HHjMBMrwTj2R9FHDzUr9KyGc8n1E=
|
||||
github.com/dnaeon/go-vcr v1.2.0 h1:zHCHvJYTMh1N7xnV7zf1m1GPBF9Ad0Jk/whtQ1663qI=
|
||||
github.com/dnaeon/go-vcr v1.2.0/go.mod h1:R4UdLID7HZT3taECzJs4YgbbH6PIGXB6W/sc5OLb6RQ=
|
||||
github.com/dnephin/pflag v1.0.7 h1:oxONGlWxhmUct0YzKTgrpQv9AUA1wtPBn7zuSjJqptk=
|
||||
github.com/dnephin/pflag v1.0.7/go.mod h1:uxE91IoWURlOiTUIA8Mq5ZZkAv3dPUfZNaT80Zm7OQE=
|
||||
github.com/docker/cli v0.0.0-20191017083524-a8ff7f821017/go.mod h1:JLrzqnKDaYBop7H2jaqPtU4hHvMKP+vjCwu2uszcLI8=
|
||||
github.com/docker/cli v20.10.8+incompatible/go.mod h1:JLrzqnKDaYBop7H2jaqPtU4hHvMKP+vjCwu2uszcLI8=
|
||||
github.com/docker/cli v20.10.9+incompatible/go.mod h1:JLrzqnKDaYBop7H2jaqPtU4hHvMKP+vjCwu2uszcLI8=
|
||||
|
@ -589,8 +591,9 @@ github.com/frankban/quicktest v1.13.0/go.mod h1:qLE0fzW0VuyUAJgPU19zByoIr0HtCHN/
|
|||
github.com/frankban/quicktest v1.14.3 h1:FJKSZTDHjyhriyC81FLQ0LY93eSai0ZyR/ZIkd3ZUKE=
|
||||
github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo=
|
||||
github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ=
|
||||
github.com/fsnotify/fsnotify v1.5.1 h1:mZcQUHVQUQWoPXXtuf9yuEXKudkV2sx1E06UadKWpgI=
|
||||
github.com/fsnotify/fsnotify v1.5.1/go.mod h1:T3375wBYaZdLLcVNkcVbzGHY7f1l/uK5T5Ai1i3InKU=
|
||||
github.com/fsnotify/fsnotify v1.5.4 h1:jRbGcIw6P2Meqdwuo0H1p6JVLbL5DHKAKlYndzMwVZI=
|
||||
github.com/fsnotify/fsnotify v1.5.4/go.mod h1:OVB6XrOHzAwXMpEM7uPOzcehqUV2UqJxmVXmkdnm1bU=
|
||||
github.com/fullsailor/pkcs7 v0.0.0-20190404230743-d7302db945fa/go.mod h1:KnogPXtdwXqoenmZCw6S+25EAm2MkxbG0deNDu4cbSA=
|
||||
github.com/gabriel-vasile/mimetype v1.3.1 h1:qevA6c2MtE1RorlScnixeG0VA1H4xrXyhyX3oWBynNQ=
|
||||
github.com/gabriel-vasile/mimetype v1.3.1/go.mod h1:fA8fi6KUiG7MgQQ+mEWotXoEOvmxRtOJlERCzSmRvr8=
|
||||
|
@ -1857,6 +1860,7 @@ github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9de
|
|||
github.com/yuin/goldmark v1.1.32/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
|
||||
github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
|
||||
github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k=
|
||||
github.com/yuin/goldmark v1.4.1/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k=
|
||||
github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
|
||||
github.com/yuin/gopher-lua v0.0.0-20200816102855-ee81675732da/go.mod h1:E1AXubJBdNmFERAOucpDIxNzeGfLzg0mYh+UfMWdChA=
|
||||
github.com/yuin/gopher-lua v0.0.0-20210529063254-f4c35e4016d9 h1:k/gmLsJDWwWqbLCur2yWnJzwQEKRcAHXo6seXGuSwWw=
|
||||
|
@ -2074,6 +2078,7 @@ golang.org/x/net v0.0.0-20210805182204-aaa1db679c0d/go.mod h1:9nx3DQGgdP8bBQD5qx
|
|||
golang.org/x/net v0.0.0-20210813160813-60bc85c4be6d/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
|
||||
golang.org/x/net v0.0.0-20210825183410-e898025ed96a/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
|
||||
golang.org/x/net v0.0.0-20211008194852-3b03d305991f/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
|
||||
golang.org/x/net v0.0.0-20211015210444-4f30a5c0130f/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
|
||||
golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
|
||||
golang.org/x/net v0.0.0-20211216030914-fe4d6282115f/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
|
||||
golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c=
|
||||
|
@ -2105,6 +2110,7 @@ golang.org/x/sync v0.0.0-20200625203802-6e8e738ad208/go.mod h1:RxMgew5VJxzue5/jJ
|
|||
golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20201207232520-09787c993a3a/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20220601150217-0de741cfad7f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.1.0 h1:wsuoTGHzEhffawBOhz5CYhcrV4IdKZbEyZjBMuTp12o=
|
||||
golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
|
@ -2218,6 +2224,7 @@ golang.org/x/sys v0.0.0-20210818153620-00dd8d7831e7/go.mod h1:oPkhp1MJrh7nUepCBc
|
|||
golang.org/x/sys v0.0.0-20210906170528-6f6e22806c34/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20210927094055-39ccf1dd6fa6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20211007075335-d3039528d8ac/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20211019181941-9d821ace8654/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20211025201205-69cdffdb9359/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20211031064116-611d5d643895/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20211116061358-0a5406a5449c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
|
@ -2238,6 +2245,7 @@ golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXR
|
|||
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
|
||||
golang.org/x/term v0.0.0-20210615171337-6886f2dfbf5b/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
|
||||
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
|
||||
golang.org/x/term v0.0.0-20220526004731-065cf7ba2467/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
|
||||
golang.org/x/term v0.1.0/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
|
||||
golang.org/x/term v0.4.0/go.mod h1:9P2UbLfCdcvo3p/nzKvsmas4TnlujnuoV9hGgYzW1lQ=
|
||||
golang.org/x/term v0.5.0 h1:n2a8QNdAb0sZNpU9R1ALUXBbY+w51fCQDN+7EdxNBsY=
|
||||
|
@ -2334,10 +2342,12 @@ golang.org/x/tools v0.0.0-20200916195026-c9a70fc28ce3/go.mod h1:z6u4i615ZeAfBE4X
|
|||
golang.org/x/tools v0.0.0-20201224043029-2b0845dc783e/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA=
|
||||
golang.org/x/tools v0.0.0-20210101214203-2dba1e4ea05c/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA=
|
||||
golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA=
|
||||
golang.org/x/tools v0.1.0/go.mod h1:xkSsbof2nBLbhDlRMhhhyNLN/zl3eTqcnHD5viDpcZ0=
|
||||
golang.org/x/tools v0.1.1/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk=
|
||||
golang.org/x/tools v0.1.2/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk=
|
||||
golang.org/x/tools v0.1.4/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk=
|
||||
golang.org/x/tools v0.1.5/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk=
|
||||
golang.org/x/tools v0.1.11/go.mod h1:SgwaegtQh8clINPpECJMqnxLv9I09HLqnW3RMqW0CA4=
|
||||
golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc=
|
||||
golang.org/x/tools v0.2.0 h1:G6AHpWxTMGY1KyEYoAQ5WTtIekUUvDNjan3ugu60JvE=
|
||||
golang.org/x/tools v0.2.0/go.mod h1:y4OqIKeOV/fWJetJ8bXPU1sEVniLMIyDAZWeHdV+NTA=
|
||||
|
@ -2519,9 +2529,13 @@ gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
|
|||
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||
gotest.tools v2.2.0+incompatible h1:VsBPFP1AI068pPrMxtb/S8Zkgf9xEmTLJjfM+P5UIEo=
|
||||
gotest.tools v2.2.0+incompatible/go.mod h1:DsYFclhRJ6vuDpmuTbkuFWG+y2sxOXAzmJt81HFBacw=
|
||||
gotest.tools/gotestsum v1.9.0 h1:Jbo/0k/sIOXIJu51IZxEAt27n77xspFEfL6SqKUR72A=
|
||||
gotest.tools/gotestsum v1.9.0/go.mod h1:6JHCiN6TEjA7Kaz23q1bH0e2Dc3YJjDUZ0DmctFZf+w=
|
||||
gotest.tools/v3 v3.0.2/go.mod h1:3SzNCllyD9/Y+b5r9JIKQ474KzkZyqLqEfYqMsX94Bk=
|
||||
gotest.tools/v3 v3.0.3/go.mod h1:Z7Lb0S5l+klDB31fvDQX8ss/FlKDxtlFlw3Oa8Ymbl8=
|
||||
gotest.tools/v3 v3.2.0 h1:I0DwBVMGAx26dttAj1BtJLAkVGncrkkUXfJLC4Flt/I=
|
||||
gotest.tools/v3 v3.3.0 h1:MfDY1b1/0xN1CyMlQDac0ziEy9zJQd9CXBRRDHw2jJo=
|
||||
gotest.tools/v3 v3.3.0/go.mod h1:Mcr9QNxkg0uMvy/YElmo4SpXgJKWgQvYrT7Kw5RzJ1A=
|
||||
honnef.co/go/tools v0.0.0-20180728063816-88497007e858/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
|
||||
honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
|
||||
honnef.co/go/tools v0.0.0-20190106161140-3f1c8253044a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
|
||||
honnef.co/go/tools v0.0.0-20190418001031-e561f6794a2a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package testing
|
||||
|
||||
import (
|
||||
_ "embed"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
|
@ -18,15 +19,27 @@ import (
|
|||
const (
|
||||
ExpectedNamespace = "default"
|
||||
ExpectedPodName = "shell-demo"
|
||||
|
||||
// File names of samples pulled from real life.
|
||||
caCrtFile = "ca.crt"
|
||||
respGetPod = "resp-get-pod.json"
|
||||
respNotFound = "resp-not-found.json"
|
||||
respUpdatePod = "resp-update-pod.json"
|
||||
tokenFile = "token"
|
||||
)
|
||||
|
||||
// Pull real-life-based testing data in from files at compile time.
|
||||
// We decided to embed them in the test binary because of past issues
|
||||
// with reading files that we encountered on CI workers.
|
||||
|
||||
//go:embed ca.crt
|
||||
var caCrt string
|
||||
|
||||
//go:embed resp-get-pod.json
|
||||
var getPodResponse string
|
||||
|
||||
//go:embed resp-not-found.json
|
||||
var notFoundResponse string
|
||||
|
||||
//go:embed resp-update-pod.json
|
||||
var updatePodTagsResponse string
|
||||
|
||||
//go:embed token
|
||||
var token string
|
||||
|
||||
var (
|
||||
// ReturnGatewayTimeouts toggles whether the test server should return,
|
||||
// well, gateway timeouts...
|
||||
|
@ -78,28 +91,6 @@ func Server(t *testing.T) (testState *State, testConf *Conf, closeFunc func()) {
|
|||
}
|
||||
}
|
||||
|
||||
// Read in our sample files.
|
||||
token, err := readFile(tokenFile)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
caCrt, err := readFile(caCrtFile)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
notFoundResponse, err := readFile(respNotFound)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
getPodResponse, err := readFile(respGetPod)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
updatePodTagsResponse, err := readFile(respUpdatePod)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
// Plant our token in a place where it can be read for the config.
|
||||
tmpToken, err := ioutil.TempFile("", "token")
|
||||
if err != nil {
|
||||
|
|
|
@ -17,6 +17,7 @@ package tools
|
|||
//go:generate go install google.golang.org/grpc/cmd/protoc-gen-go-grpc
|
||||
//go:generate go install github.com/favadi/protoc-go-inject-tag
|
||||
//go:generate go install github.com/golangci/revgrep/cmd/revgrep
|
||||
//go:generate go install gotest.tools/gotestsum
|
||||
import (
|
||||
_ "golang.org/x/tools/cmd/goimports"
|
||||
|
||||
|
@ -31,4 +32,6 @@ import (
|
|||
_ "github.com/favadi/protoc-go-inject-tag"
|
||||
|
||||
_ "github.com/golangci/revgrep/cmd/revgrep"
|
||||
|
||||
_ "gotest.tools/gotestsum"
|
||||
)
|
||||
|
|
Loading…
Reference in New Issue