2020-12-09 15:31:34 +00:00
|
|
|
version: 2.1
|
|
|
|
orbs:
|
|
|
|
aws-cli: circleci/aws-cli@1.3.0
|
2021-01-27 11:54:57 +00:00
|
|
|
go: circleci/go@1.5.0
|
2020-12-09 15:31:34 +00:00
|
|
|
jobs:
|
|
|
|
build:
|
|
|
|
docker:
|
2021-02-17 08:59:51 +00:00
|
|
|
- image: golang:1.16
|
2020-12-09 15:31:34 +00:00
|
|
|
steps:
|
|
|
|
- checkout
|
|
|
|
- run: make release
|
|
|
|
- persist_to_workspace:
|
|
|
|
root: ~/project
|
|
|
|
paths:
|
|
|
|
- bin/
|
2021-01-27 11:54:57 +00:00
|
|
|
test_acc:
|
2021-02-15 14:21:54 +00:00
|
|
|
parameters:
|
|
|
|
pattern:
|
|
|
|
type: string
|
2021-01-27 11:54:57 +00:00
|
|
|
machine:
|
|
|
|
image: ubuntu-2004:202010-01
|
|
|
|
environment:
|
2021-02-15 14:21:54 +00:00
|
|
|
ACC_PATTERN: << parameters.pattern >>
|
2021-01-27 11:54:57 +00:00
|
|
|
AWS_DEFAULT_REGION: us-east-1
|
2021-02-15 14:21:54 +00:00
|
|
|
CHECKPOINT_DISABLE: true # Disable terraform version check
|
2021-01-27 11:54:57 +00:00
|
|
|
steps:
|
|
|
|
- checkout
|
|
|
|
- go/install:
|
2021-02-17 08:59:51 +00:00
|
|
|
version: "1.16"
|
2021-02-22 10:39:39 +00:00
|
|
|
cache-key: "1.16"
|
2021-01-27 11:54:57 +00:00
|
|
|
- run:
|
|
|
|
name: install dependencies
|
|
|
|
command: |
|
|
|
|
sudo apt-get -qq update && sudo apt-get -qq -y install unzip
|
|
|
|
curl "https://releases.hashicorp.com/terraform/0.14.5/terraform_0.14.5_linux_amd64.zip" --output terraform.zip
|
|
|
|
unzip terraform.zip
|
|
|
|
sudo mv terraform /usr/local/bin && sudo chmod +x /usr/local/bin
|
|
|
|
terraform version
|
|
|
|
- run: make install-tools
|
|
|
|
- run:
|
|
|
|
name: Run acceptance tests
|
|
|
|
command: make acc
|
|
|
|
- run:
|
|
|
|
name: Discord notification
|
|
|
|
when: on_fail
|
|
|
|
command: |
|
|
|
|
curl -X POST \
|
|
|
|
-H "Content-Type: application/json" \
|
2021-02-16 09:35:11 +00:00
|
|
|
-d "{\"content\": \"❌ Acceptance tests failed\nSuite: ${ACC_PATTERN}\n<${CIRCLE_BUILD_URL}>\" }"\
|
2021-01-27 11:54:57 +00:00
|
|
|
${DISCORD_WEBHOOK}
|
|
|
|
- store_test_results:
|
|
|
|
path: ./
|
2021-02-08 14:47:26 +00:00
|
|
|
lint:
|
2020-12-09 15:31:34 +00:00
|
|
|
docker:
|
2021-02-17 08:59:51 +00:00
|
|
|
- image: golang:1.16
|
2020-12-09 15:31:34 +00:00
|
|
|
steps:
|
|
|
|
- checkout
|
2020-12-23 09:54:06 +00:00
|
|
|
- run:
|
|
|
|
name: Enforce Go Formatted Code
|
|
|
|
command: |
|
|
|
|
go fmt ./...
|
|
|
|
if [[ -z $(git status --porcelain) ]]; then
|
|
|
|
echo "Git directory is clean."
|
|
|
|
else
|
|
|
|
echo "Git directory is dirty. Run make fmt locally and commit any formatting fixes or generated code."
|
|
|
|
git status --porcelain
|
|
|
|
exit 1
|
|
|
|
fi
|
2020-12-09 15:31:34 +00:00
|
|
|
- run: make install-tools
|
2021-02-08 14:47:26 +00:00
|
|
|
- run: make lint
|
|
|
|
test:
|
|
|
|
docker:
|
2021-02-17 08:59:51 +00:00
|
|
|
- image: golang:1.16
|
2021-02-08 14:47:26 +00:00
|
|
|
steps:
|
|
|
|
- checkout
|
|
|
|
- run: make install-tools
|
2020-12-09 15:31:34 +00:00
|
|
|
- run: make test
|
|
|
|
- run:
|
|
|
|
name: Codecov upload
|
|
|
|
command: |
|
|
|
|
bash <(curl -s https://codecov.io/bash)
|
|
|
|
- store_test_results:
|
|
|
|
path: ./
|
2021-02-04 12:26:11 +00:00
|
|
|
sign_release:
|
|
|
|
docker:
|
|
|
|
- image: cimg/base:2020.01
|
|
|
|
steps:
|
|
|
|
- attach_workspace:
|
|
|
|
at: ~/project
|
|
|
|
- run:
|
|
|
|
name: "Ensure GnuPG is available"
|
|
|
|
command: gpg --version
|
|
|
|
- run:
|
|
|
|
name: "Import cloudskiff signing key"
|
|
|
|
command: |
|
|
|
|
echo ${SIGNINGKEY} | base64 -d > signingkey
|
|
|
|
gpg --import signingkey
|
|
|
|
- run:
|
|
|
|
name: "Sign release"
|
|
|
|
command: |
|
|
|
|
gpg --sign -u security@cloudskiff.com bin/driftctl_SHA256SUMS
|
|
|
|
- run:
|
|
|
|
name: "Verify signature"
|
|
|
|
command: |
|
|
|
|
gpg --verify bin/driftctl_SHA256SUMS.gpg
|
|
|
|
- persist_to_workspace:
|
|
|
|
root: ~/project
|
|
|
|
paths:
|
|
|
|
- bin/
|
2020-12-09 15:31:34 +00:00
|
|
|
release:
|
|
|
|
environment:
|
|
|
|
CIRCLE_PROJECT_USERNAME: cloudskiff
|
|
|
|
CIRCLE_PROJECT_REPONAME: driftctl
|
|
|
|
docker:
|
|
|
|
- image: cibuilds/github:0.13
|
|
|
|
steps:
|
|
|
|
- attach_workspace:
|
|
|
|
at: ~/project
|
|
|
|
- run:
|
|
|
|
name: "Publish Release on GitHub"
|
|
|
|
command: |
|
|
|
|
VERSION=$(./bin/driftctl_linux_amd64 version)
|
|
|
|
ghr -t ${GITHUB_TOKEN} -u ${CIRCLE_PROJECT_USERNAME} -r ${CIRCLE_PROJECT_REPONAME} -c ${CIRCLE_SHA1} -n ${VERSION} ${VERSION} ./bin/
|
|
|
|
update-lambda:
|
|
|
|
executor: aws-cli/default
|
|
|
|
environment:
|
|
|
|
FUNCTION_NAME: driftctl-version
|
|
|
|
steps:
|
|
|
|
- aws-cli/install
|
|
|
|
- run:
|
|
|
|
name: "Update Lambda version"
|
|
|
|
command: |
|
|
|
|
aws lambda update-function-configuration --function-name $FUNCTION_NAME --environment "{\"Variables\":{\"LATEST_VERSION\":\"$CIRCLE_TAG\"}}"
|
|
|
|
workflows:
|
2021-01-27 11:54:57 +00:00
|
|
|
nightly:
|
|
|
|
jobs:
|
|
|
|
- test_acc:
|
2021-02-15 14:21:54 +00:00
|
|
|
name: "Acceptance tests: << matrix.pattern >>"
|
|
|
|
matrix:
|
|
|
|
parameters:
|
|
|
|
pattern:
|
|
|
|
- TestAcc_Aws
|
|
|
|
- TestAcc_Github_
|
2021-01-27 11:54:57 +00:00
|
|
|
context: driftctl-acc
|
|
|
|
triggers:
|
|
|
|
- schedule:
|
|
|
|
cron: "0 3 * * *"
|
|
|
|
filters:
|
|
|
|
branches:
|
|
|
|
only:
|
|
|
|
- main
|
2020-12-09 15:31:34 +00:00
|
|
|
pullrequest:
|
|
|
|
jobs:
|
2021-02-08 14:47:26 +00:00
|
|
|
- lint:
|
|
|
|
filters:
|
|
|
|
branches:
|
|
|
|
ignore:
|
|
|
|
- main
|
2020-12-09 15:31:34 +00:00
|
|
|
- test:
|
|
|
|
filters:
|
|
|
|
branches:
|
|
|
|
ignore:
|
2021-01-29 09:42:43 +00:00
|
|
|
- main
|
2020-12-09 15:31:34 +00:00
|
|
|
push:
|
|
|
|
jobs:
|
|
|
|
- test:
|
|
|
|
filters:
|
|
|
|
branches:
|
|
|
|
only:
|
2021-01-29 09:42:43 +00:00
|
|
|
- main
|
2020-12-09 15:31:34 +00:00
|
|
|
release:
|
|
|
|
jobs:
|
|
|
|
- build:
|
|
|
|
filters:
|
|
|
|
tags:
|
|
|
|
only: /^v.*/
|
|
|
|
branches:
|
|
|
|
ignore: /.*/
|
2021-02-08 14:47:26 +00:00
|
|
|
- lint:
|
|
|
|
filters:
|
|
|
|
tags:
|
|
|
|
only: /^v.*/
|
|
|
|
branches:
|
|
|
|
ignore: /.*/
|
2020-12-09 15:31:34 +00:00
|
|
|
- test:
|
|
|
|
filters:
|
|
|
|
tags:
|
|
|
|
only: /^v.*/
|
|
|
|
branches:
|
|
|
|
ignore: /.*/
|
2021-02-04 12:26:11 +00:00
|
|
|
- sign_release:
|
|
|
|
context: cloudskiff-signing
|
|
|
|
requires:
|
|
|
|
- build
|
|
|
|
filters:
|
|
|
|
tags:
|
|
|
|
only: /^v.*/
|
|
|
|
branches:
|
|
|
|
ignore: /.*/
|
2020-12-09 15:31:34 +00:00
|
|
|
- release:
|
|
|
|
context: driftctl
|
|
|
|
requires:
|
2021-02-08 14:47:26 +00:00
|
|
|
- lint
|
2020-12-09 15:31:34 +00:00
|
|
|
- test
|
2021-02-04 12:26:11 +00:00
|
|
|
- sign_release
|
2020-12-09 15:31:34 +00:00
|
|
|
filters:
|
|
|
|
tags:
|
|
|
|
only: /^v.*/
|
|
|
|
branches:
|
|
|
|
ignore: /.*/
|
|
|
|
- update-lambda:
|
|
|
|
context: driftctl-version-lambda
|
|
|
|
requires:
|
|
|
|
- release
|
|
|
|
filters:
|
|
|
|
tags:
|
|
|
|
only: /^v.*/
|
|
|
|
branches:
|
|
|
|
ignore: /.*/
|