forked from hashicorp/consul-k8s
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request hashicorp#1086 from hashicorp/crt-build-and-tests
Migrate most of build-and-test CircleCI jobs to Github Actions
- Loading branch information
Showing
10 changed files
with
541 additions
and
120 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,300 @@ | ||
name: test-and-build | ||
on: | ||
push: | ||
|
||
env: | ||
TEST_RESULTS: /tmp/test-results # path to where test results are saved | ||
CONSUL_VERSION: 1.11.2 # Consul's OSS version to use in tests | ||
CONSUL_ENT_VERSION: 1.11.2+ent # Consul's enterprise version to use in tests | ||
GOTESTSUM_VERSION: 1.6.4 # You cannot use environment variables with workflows. The gotestsum version is hardcoded in the reusable workflows too. | ||
|
||
jobs: | ||
validate-helm-gen: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v2 | ||
|
||
- name: Setup go | ||
uses: actions/setup-go@v2 | ||
with: | ||
go-version: 1.17.2 | ||
|
||
- name: Setup go mod cache | ||
uses: actions/cache@v2 | ||
with: | ||
path: | | ||
~/.cache/go-build | ||
~/go/pkg/mod | ||
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} | ||
restore-keys: | | ||
${{ runner.os }}-go- | ||
- name: Validate helm gen | ||
working-directory: hack/helm-reference-gen | ||
run: | | ||
go run ./... -validate | ||
golangci-lint-helm-gen: | ||
uses: hashicorp/consul-k8s/.github/workflows/reusable-golangci-lint.yml@main | ||
with: | ||
directory: hack/helm-reference-gen | ||
go-version: 1.17.2 | ||
#TODO: This is a workaround in order to get pipelines working. godot and staticcheck fail for helm-reference-gen | ||
args: "--no-config --disable-all --enable gofmt,govet" | ||
|
||
unit-helm-gen: | ||
needs: [golangci-lint-helm-gen, validate-helm-gen] | ||
uses: hashicorp/consul-k8s/.github/workflows/reusable-unit.yml@main | ||
with: | ||
directory: hack/helm-reference-gen | ||
go-version: 1.17.2 | ||
|
||
unit-test-helm-templates: | ||
needs: [unit-helm-gen] | ||
runs-on: ubuntu-latest | ||
container: | ||
image: docker.mirror.hashicorp.services/hashicorpdev/consul-helm-test:0.10.0 | ||
options: --user 1001 | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v2 | ||
|
||
- name: Run Unit Tests | ||
working-directory: charts/consul | ||
run: bats --jobs 4 ./test/unit | ||
|
||
lint-control-plane: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v2 | ||
|
||
- name: Setup go | ||
uses: actions/setup-go@v2 | ||
with: | ||
go-version: 1.17.2 | ||
|
||
- run: go get -u github.com/hashicorp/lint-consul-retry && lint-consul-retry | ||
|
||
- name: Run lint | ||
working-directory: control-plane | ||
run: go run hack/lint-api-new-client/main.go | ||
|
||
golangci-lint-control-plane: | ||
uses: hashicorp/consul-k8s/.github/workflows/reusable-golangci-lint.yml@main | ||
with: | ||
directory: control-plane | ||
go-version: 1.17.2 | ||
|
||
test-control-plane: | ||
needs: [lint-control-plane, golangci-lint-control-plane] | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v2 | ||
|
||
- name: Setup go | ||
uses: actions/setup-go@v2 | ||
with: | ||
go-version: 1.17.2 | ||
|
||
- name: Setup go mod cache | ||
uses: actions/cache@v2 | ||
with: | ||
path: | | ||
~/.cache/go-build | ||
~/go/pkg/mod | ||
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} | ||
restore-keys: | | ||
${{ runner.os }}-go- | ||
- name: Install gotestsum | ||
run: | | ||
wget https://github.com/gotestyourself/gotestsum/releases/download/v${{env.GOTESTSUM_VERSION}}/gotestsum_${{env.GOTESTSUM_VERSION}}_linux_amd64.tar.gz | ||
sudo tar -C /usr/local/bin -xzf gotestsum_${{env.GOTESTSUM_VERSION}}_linux_amd64.tar.gz | ||
rm gotestsum_${{env.GOTESTSUM_VERSION}}_linux_amd64.tar.gz | ||
- run: mkdir -p ${{env.TEST_RESULTS}} | ||
- run: echo "$HOME/bin" >> $GITHUB_PATH | ||
|
||
- name: Download consul | ||
working-directory: control-plane | ||
run: | | ||
mkdir -p $HOME/bin | ||
wget https://releases.hashicorp.com/consul/${{env.CONSUL_VERSION}}/consul_${{env.CONSUL_VERSION}}_linux_amd64.zip && \ | ||
unzip consul_${{env.CONSUL_VERSION}}_linux_amd64.zip -d $HOME/bin && \ | ||
rm consul_${{env.CONSUL_VERSION}}_linux_amd64.zip | ||
chmod +x $HOME/bin/consul | ||
- name: Run go tests | ||
working-directory: control-plane | ||
run: | | ||
PACKAGE_NAMES=$(go list ./...) | ||
gotestsum --junitfile ${{env.TEST_RESULTS}}/gotestsum-report.xml -- -p 4 $PACKAGE_NAMES | ||
test-enterprise-control-plane: | ||
if: github.repository_owner == 'hashicorp' # Do not run on forks as this requires secrets | ||
needs: [lint-control-plane, golangci-lint-control-plane] | ||
runs-on: ubuntu-latest | ||
env: | ||
CONSUL_LICENSE: ${{secrets.CONSUL_LICENSE}} | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v2 | ||
|
||
- name: Setup go | ||
uses: actions/setup-go@v2 | ||
with: | ||
go-version: 1.17.2 | ||
|
||
- name: Setup go mod cache | ||
uses: actions/cache@v2 | ||
with: | ||
path: | | ||
~/.cache/go-build | ||
~/go/pkg/mod | ||
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} | ||
restore-keys: | | ||
${{ runner.os }}-go- | ||
- name: Install gotestsum | ||
run: | | ||
wget https://github.com/gotestyourself/gotestsum/releases/download/v${{env.GOTESTSUM_VERSION}}/gotestsum_${{env.GOTESTSUM_VERSION}}_linux_amd64.tar.gz | ||
sudo tar -C /usr/local/bin -xzf gotestsum_${{env.GOTESTSUM_VERSION}}_linux_amd64.tar.gz | ||
rm gotestsum_${{env.GOTESTSUM_VERSION}}_linux_amd64.tar.gz | ||
- run: mkdir -p ${{env.TEST_RESULTS}} | ||
- run: echo "$HOME/bin" >> $GITHUB_PATH | ||
|
||
- name: Download consul | ||
working-directory: control-plane | ||
run: | | ||
mkdir -p $HOME/bin | ||
wget https://releases.hashicorp.com/consul/${{env.CONSUL_ENT_VERSION}}/consul_${{env.CONSUL_ENT_VERSION}}_linux_amd64.zip && \ | ||
unzip consul_${{env.CONSUL_ENT_VERSION}}_linux_amd64.zip -d $HOME/bin && \ | ||
rm consul_${{env.CONSUL_ENT_VERSION}}_linux_amd64.zip | ||
chmod +x $HOME/bin/consul | ||
- name: Run go tests | ||
working-directory: control-plane | ||
run: | | ||
PACKAGE_NAMES=$(go list ./...) | ||
gotestsum --junitfile ${{env.TEST_RESULTS}}/gotestsum-report.xml -- -tags=enterprise -p 4 $PACKAGE_NAMES | ||
build-distros: | ||
needs: [test-control-plane, test-enterprise-control-plane] | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
include: | ||
- {go: "1.17.2", goos: "linux", goarch: "386"} | ||
- {go: "1.17.2", goos: "linux", goarch: "amd64"} | ||
- {go: "1.17.2", goos: "linux", goarch: "arm"} | ||
- {go: "1.17.2", goos: "linux", goarch: "arm64"} | ||
fail-fast: true | ||
|
||
name: Go ${{ matrix.go }} ${{ matrix.goos }} ${{ matrix.goarch }} build | ||
steps: | ||
- uses: actions/checkout@v2 | ||
|
||
- name: Setup go | ||
uses: actions/setup-go@v2 | ||
with: | ||
go-version: ${{ matrix.go }} | ||
|
||
- name: Build | ||
working-directory: control-plane | ||
env: | ||
GOOS: ${{ matrix.goos }} | ||
GOARCH: ${{ matrix.goarch }} | ||
CGO_ENABLED: 0 | ||
run: | | ||
XC_OS=${{ matrix.goos }} XC_ARCH=${{ matrix.goarch }} ./build-support/scripts/build-local.sh | ||
zip -r -j consul-k8s_${{ matrix.goos }}_${{ matrix.goarch }}.zip bin | ||
- uses: actions/upload-artifact@v2 | ||
with: | ||
name: consul-k8s_${{ matrix.goos }}_${{ matrix.goarch }}.zip | ||
path: control-plane/consul-k8s_${{ matrix.goos }}_${{ matrix.goarch }}.zip | ||
|
||
golangci-lint-acceptance: | ||
uses: hashicorp/consul-k8s/.github/workflows/reusable-golangci-lint.yml@main | ||
with: | ||
directory: acceptance | ||
go-version: 1.17.2 | ||
|
||
unit-acceptance-framework: | ||
needs: golangci-lint-acceptance | ||
uses: hashicorp/consul-k8s/.github/workflows/reusable-unit.yml@main | ||
with: | ||
directory: acceptance/framework | ||
go-version: 1.17.2 | ||
|
||
golangci-lint-cli: | ||
uses: hashicorp/consul-k8s/.github/workflows/reusable-golangci-lint.yml@main | ||
with: | ||
directory: cli | ||
go-version: 1.17.2 | ||
|
||
unit-cli: | ||
needs: golangci-lint-cli | ||
uses: hashicorp/consul-k8s/.github/workflows/reusable-unit.yml@main | ||
with: | ||
directory: cli | ||
go-version: 1.17.2 | ||
|
||
# Disabling for now until we get faster VMs to run acceptance tests. Faster VMs for Github Actions are supposed | ||
# to be available in the summer of 2022. For now, run the dev-upload docker and acceptance tests in CircleCI | ||
# dev-upload-docker: | ||
# if: github.repository_owner == 'hashicorp' # Do not run on forks as this requires secrets | ||
# needs: build-distros | ||
# runs-on: ubuntu-latest | ||
# | ||
# env: | ||
# GITHUB_PULL_REQUEST: ${{github.event.pull_request.number}} | ||
# DOCKER_USER: ${{secrets.DOCKER_USER}} | ||
# DOCKER_PASS: ${{secrets.DOCKER_PASS}} | ||
# steps: | ||
# - uses: actions/checkout@v2 | ||
# | ||
# - run: mkdir -p control-plane/pkg/bin/linux_amd64 | ||
# | ||
# - uses: actions/download-artifact@v3 | ||
# with: | ||
# name: consul-k8s_linux_amd64.zip | ||
# path: control-plane | ||
# | ||
# - name: Docker build | ||
# working-directory: control-plane | ||
# run: | | ||
# unzip consul-k8s_linux_amd64.zip -d ./pkg/bin/linux_amd64 | ||
# make ci.dev-docker-github | ||
# | ||
# acceptance-tproxy: | ||
# needs: [unit-cli, dev-upload-docker, unit-acceptance-framework, unit-test-helm-templates] | ||
# needs: dev-upload-docker | ||
# uses: hashicorp/consul-k8s/.github/workflows/reusable-acceptance.yml@main | ||
# with: | ||
# name: acceptance-tproxy | ||
# directory: acceptance/tests | ||
# go-version: 1.17.2 | ||
# additional-flags: "-use-kind -kubecontext=kind-dc1 -secondary-kubecontext=kind-dc2 -enable-transparent-proxy" | ||
# gotestsum-version: 1.6.4 | ||
# secrets: | ||
# CONSUL_ENT_LICENSE: ${{ secrets.CONSUL_ENT_LICENSE }} | ||
# | ||
# acceptance: | ||
# #needs: [unit-cli, dev-upload-docker, unit-acceptance-framework, unit-test-helm-templates] | ||
# needs: dev-upload-docker | ||
# uses: hashicorp/consul-k8s/.github/workflows/reusable-acceptance.yml@main | ||
# with: | ||
# name: acceptance | ||
# directory: acceptance/tests | ||
# go-version: 1.17.2 | ||
# additional-flags: "-use-kind -kubecontext=kind-dc1 -secondary-kubecontext=kind-dc2" | ||
# gotestsum-version: 1.6.4 | ||
# secrets: | ||
# CONSUL_ENT_LICENSE: ${{ secrets.CONSUL_ENT_LICENSE }} | ||
|
||
|
Oops, something went wrong.