mirror of
https://github.com/opentofu/opentofu.git
synced 2024-12-28 18:01:01 -06:00
build: Remove our CircleCI configuration for PR checks
We will henceforth use the "checks.yml" GitHub Actions workflow instead of CircleCI, because we're standardizing on using GitHub Actions for all of our automation in this repository so that everything is in a consistent language and we have as few external dependencies as possible. The checks.yml workflow alone does not actually replace everything this CircleCI configuration did. Reworking things for GitHub Actions was a good opportunity to revisit the cost/benefit of the various steps here and my conclusions were: - Unit tests and consistency checks give the best signal about the correctness of new code, with broad coverage over all of our packages. These are the most important things we want to run before reviewing a pull request, although our unit test run is currently relatively slow and would probably be worth optimizing in future commits. - Our existing build.yml workflow already runs the E2E tests across various platforms and so I considered removing those but elected to keep the same single-platform (Linux) E2E test run in the pre-review checks because in practice those tests are typically faster than the full unit test run anyway and so they don't delay a green check result and can serve as a reasonable proxy for whether the cross-platform E2E tests will all succeed when we eventually check in build.yml, after merge. - We've long had a special exception to our usual rule of not running acceptance tests in CI specifically for the Consul backend. In practice the Consul backend is essentially "done" and doesn't change much, so I don't think the cost of installing and launching Consul just to test that one backend has sufficient benefit to preserve. Our unit tests do still exercise all of the generic backend machinery via the inmem and local backends, and in the event that someone does make changes to the Consul backend they can still run the acceptance tests locally as we'd expect for a change to any other backend. - We previously included jobs to run "go build" across various different platforms. Although that can occasionally help catch platform-specific issues, most code in Terraform is platform-agnostic and so it's rare to encounter single-platform build errors. These jobs were typically the long pole for completion of the CI checks before and so I've removed them here in favor of relying on similar checks already happening inside the build.yml workflow, which runs only after a PR is merged. This does increase the risk of a platform-specific error landing in a release branch before we catch it, but since platform-specific problems are rare this feels like a reasonable tradeoff. Anyone working on explicitly-platform-specific code in Terraform should typically test locally on the relevant platform anyway, and so catching these with our build step is a last gate just to make sure mistakes don't end up in production releases.
This commit is contained in:
parent
bbf540e0e3
commit
1e56e1fe0f
@ -1,200 +0,0 @@
|
||||
version: 2.1
|
||||
|
||||
orbs:
|
||||
slack: circleci/slack@3.4.2
|
||||
|
||||
references:
|
||||
images:
|
||||
middleman: &MIDDLEMAN_IMAGE docker.mirror.hashicorp.services/hashicorp/middleman-hashicorp:0.3.44
|
||||
|
||||
executors:
|
||||
go:
|
||||
docker:
|
||||
- image: docker.mirror.hashicorp.services/cimg/go:1.17.2
|
||||
environment:
|
||||
CONSUL_VERSION: 1.7.2
|
||||
GOMAXPROCS: 4
|
||||
GO111MODULE: "on"
|
||||
GOPROXY: https://proxy.golang.org/
|
||||
TEST_RESULTS_DIR: &TEST_RESULTS_DIR /tmp/test-results
|
||||
ARTIFACTS_DIR: &ARTIFACTS_DIR /tmp/artifacts
|
||||
|
||||
jobs:
|
||||
go-checks:
|
||||
executor:
|
||||
name: go
|
||||
steps:
|
||||
- checkout
|
||||
- run: go mod verify
|
||||
- run: go install honnef.co/go/tools/cmd/staticcheck
|
||||
- run: go install github.com/nishanths/exhaustive/...
|
||||
- run: make fmtcheck generate staticcheck exhaustive
|
||||
- run:
|
||||
name: verify no code was generated
|
||||
command: |
|
||||
if [[ -z $(git status --porcelain) ]]; then
|
||||
echo "Git directory is clean."
|
||||
else
|
||||
echo "Git is dirty. Run `make fmtcheck` and `make generate` locally and commit any formatting fixes or generated code."
|
||||
git status --porcelain
|
||||
exit 1
|
||||
fi
|
||||
- run:
|
||||
name: verify go.mod and go.sum are correct
|
||||
command: |
|
||||
go mod tidy
|
||||
git diff --quiet && exit 0
|
||||
echo "please run 'go mod tidy' to ensure go.mod and go.sum are up to date"
|
||||
exit 1
|
||||
- run:
|
||||
name: verify that our protobuf stubs are up-to-date
|
||||
command: |
|
||||
make protobuf
|
||||
git diff --quiet && exit 0
|
||||
echo "Run 'make protobuf' to ensure that the protobuf stubs are up-to-date."
|
||||
exit 1
|
||||
|
||||
go-test:
|
||||
executor:
|
||||
name: go
|
||||
environment:
|
||||
TF_CONSUL_TEST: 1
|
||||
parallelism: 4
|
||||
steps:
|
||||
- checkout
|
||||
- attach_workspace:
|
||||
at: .
|
||||
- run:
|
||||
name: install consul
|
||||
command: |
|
||||
curl -sLo consul.zip https://releases.hashicorp.com/consul/${CONSUL_VERSION}/consul_${CONSUL_VERSION}_linux_amd64.zip
|
||||
unzip consul.zip
|
||||
mkdir -p ~/bin
|
||||
mv consul ~/bin
|
||||
echo 'export PATH="~/bin:$PATH"'
|
||||
- run: mkdir -p $TEST_RESULTS_DIR
|
||||
- run:
|
||||
name: Run Go Tests
|
||||
command: |
|
||||
PACKAGE_NAMES=$(go list ./... | circleci tests split --split-by=timings --timings-type=classname)
|
||||
echo "Running $(echo $PACKAGE_NAMES | wc -w) packages"
|
||||
echo $PACKAGE_NAMES
|
||||
gotestsum --format=short-verbose --junitfile $TEST_RESULTS_DIR/gotestsum-report.xml -- -p 2 -cover -coverprofile=cov_$CIRCLE_NODE_INDEX.part $PACKAGE_NAMES
|
||||
|
||||
# save coverage report parts
|
||||
- persist_to_workspace:
|
||||
root: .
|
||||
paths:
|
||||
- cov_*.part
|
||||
|
||||
- store_test_results:
|
||||
path: *TEST_RESULTS_DIR
|
||||
- store_artifacts:
|
||||
path: *TEST_RESULTS_DIR
|
||||
|
||||
- slack/status:
|
||||
fail_only: true
|
||||
only_for_branches: main
|
||||
|
||||
go-test-e2e:
|
||||
executor:
|
||||
name: go
|
||||
environment:
|
||||
TF_ACC: 1
|
||||
steps:
|
||||
- checkout
|
||||
- attach_workspace:
|
||||
at: .
|
||||
- run: mkdir -p $TEST_RESULTS_DIR
|
||||
- run:
|
||||
name: Run Go E2E Tests
|
||||
command: |
|
||||
gotestsum --format=short-verbose --junitfile $TEST_RESULTS_DIR/gotestsum-report.xml -- -p 2 -cover -coverprofile=cov_e2e.part ./internal/command/e2etest
|
||||
|
||||
# save coverage report parts
|
||||
- persist_to_workspace:
|
||||
root: .
|
||||
paths:
|
||||
- cov_*.part
|
||||
|
||||
- store_test_results:
|
||||
path: *TEST_RESULTS_DIR
|
||||
- store_artifacts:
|
||||
path: *TEST_RESULTS_DIR
|
||||
|
||||
- slack/status:
|
||||
fail_only: true
|
||||
only_for_branches: main
|
||||
|
||||
# build all distros
|
||||
build-distros: &build-distros
|
||||
executor: go
|
||||
environment: &build-env
|
||||
TF_RELEASE: 1
|
||||
steps:
|
||||
- run: go get -u github.com/mitchellh/gox # go get gox before detecting go mod
|
||||
- checkout
|
||||
- run: ./scripts/build.sh
|
||||
- run: mkdir -p $ARTIFACTS_DIR
|
||||
- run: cp pkg/*.zip /tmp/artifacts
|
||||
# save dev build to CircleCI
|
||||
- store_artifacts:
|
||||
path: *ARTIFACTS_DIR
|
||||
|
||||
# build all amd64 architecture supported OS binaries
|
||||
build-amd64:
|
||||
<<: *build-distros
|
||||
environment:
|
||||
<<: *build-env
|
||||
XC_OS: "darwin linux windows"
|
||||
XC_ARCH: "amd64"
|
||||
|
||||
# build all arm architecture supported OS binaries
|
||||
build-arm:
|
||||
<<: *build-distros
|
||||
environment:
|
||||
<<: *build-env
|
||||
XC_OS: "linux"
|
||||
XC_ARCH: "arm"
|
||||
|
||||
# build all arm64 architecture supported OS binaries
|
||||
build-arm64:
|
||||
<<: *build-distros
|
||||
environment:
|
||||
<<: *build-env
|
||||
XC_OS: "darwin"
|
||||
XC_ARCH: "arm64"
|
||||
|
||||
test-docker-full:
|
||||
executor:
|
||||
name: go
|
||||
steps:
|
||||
- checkout
|
||||
- setup_remote_docker
|
||||
- run:
|
||||
name: test docker build for 'full' image
|
||||
command: docker build -t test-docker-full .
|
||||
|
||||
workflows:
|
||||
version: 2
|
||||
test:
|
||||
jobs:
|
||||
- go-checks
|
||||
- go-test:
|
||||
requires:
|
||||
- go-checks
|
||||
- go-test-e2e:
|
||||
requires:
|
||||
- go-checks
|
||||
- test-docker-full:
|
||||
filters:
|
||||
branches:
|
||||
only:
|
||||
- main
|
||||
- /^v\d+\.\d+$/ # v0.11, v0.12, etc.
|
||||
|
||||
build-distros:
|
||||
jobs:
|
||||
- build-amd64
|
||||
- build-arm
|
||||
- build-arm64
|
Loading…
Reference in New Issue
Block a user