179 lines
4.8 KiB
YAML
179 lines
4.8 KiB
YAML
version: 2.1
|
|
orbs:
|
|
aws-cli: circleci/aws-cli@1.3.0
|
|
go: circleci/go@1.5.0
|
|
jobs:
|
|
build:
|
|
docker:
|
|
- image: golang:1.15
|
|
steps:
|
|
- checkout
|
|
- run: make release
|
|
- persist_to_workspace:
|
|
root: ~/project
|
|
paths:
|
|
- bin/
|
|
test_acc:
|
|
machine:
|
|
image: ubuntu-2004:202010-01
|
|
environment:
|
|
AWS_DEFAULT_REGION: us-east-1
|
|
steps:
|
|
- checkout
|
|
- go/install:
|
|
version: 1.15.7
|
|
- 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
|
|
command: |
|
|
curl -X POST \
|
|
-H "Content-Type: application/json" \
|
|
-d "{\"content\": \"✅ Acceptance tests succeeded 🎉\n<${CIRCLE_BUILD_URL}>\" }"\
|
|
${DISCORD_WEBHOOK}
|
|
- run:
|
|
name: Discord notification
|
|
when: on_fail
|
|
command: |
|
|
curl -X POST \
|
|
-H "Content-Type: application/json" \
|
|
-d "{\"content\": \"❌ Acceptance tests failed\n<${CIRCLE_BUILD_URL}>\" }"\
|
|
${DISCORD_WEBHOOK}
|
|
- store_test_results:
|
|
path: ./
|
|
test:
|
|
docker:
|
|
- image: golang:1.15
|
|
steps:
|
|
- checkout
|
|
- 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
|
|
- run: make install-tools
|
|
- run: make test
|
|
- run:
|
|
name: Codecov upload
|
|
command: |
|
|
bash <(curl -s https://codecov.io/bash)
|
|
- store_test_results:
|
|
path: ./
|
|
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\"}}"
|
|
bump-homebrew-core:
|
|
macos:
|
|
xcode: 12.3.0
|
|
steps:
|
|
- run:
|
|
name: "Bump driftctl formula"
|
|
command: |
|
|
brew install-bundler-gems -d -v
|
|
brew bump-formula-pr driftctl --url https://github.com/cloudskiff/driftctl/archive/$CIRCLE_TAG.tar.gz -d -v
|
|
workflows:
|
|
nightly:
|
|
jobs:
|
|
- test_acc:
|
|
context: driftctl-acc
|
|
triggers:
|
|
- schedule:
|
|
cron: "0 3 * * *"
|
|
filters:
|
|
branches:
|
|
only:
|
|
- main
|
|
pullrequest:
|
|
jobs:
|
|
- test:
|
|
filters:
|
|
branches:
|
|
ignore:
|
|
- main
|
|
push:
|
|
jobs:
|
|
- test:
|
|
filters:
|
|
branches:
|
|
only:
|
|
- main
|
|
release:
|
|
jobs:
|
|
- build:
|
|
filters:
|
|
tags:
|
|
only: /^v.*/
|
|
branches:
|
|
ignore: /.*/
|
|
- test:
|
|
filters:
|
|
tags:
|
|
only: /^v.*/
|
|
branches:
|
|
ignore: /.*/
|
|
- release:
|
|
context: driftctl
|
|
requires:
|
|
- test
|
|
- build
|
|
filters:
|
|
tags:
|
|
only: /^v.*/
|
|
branches:
|
|
ignore: /.*/
|
|
- update-lambda:
|
|
context: driftctl-version-lambda
|
|
requires:
|
|
- release
|
|
filters:
|
|
tags:
|
|
only: /^v.*/
|
|
branches:
|
|
ignore: /.*/
|
|
- bump-homebrew-core:
|
|
context: driftctl-homebrew
|
|
requires:
|
|
- release
|
|
filters:
|
|
tags:
|
|
only: /^v.*/
|
|
branches:
|
|
ignore: /.*/
|