|
| 1 | +version: 2.1 |
| 2 | + |
| 3 | +orbs: |
| 4 | + |
| 5 | + |
| 6 | + |
| 7 | +env: &env |
| 8 | + environment: |
| 9 | + GO111MODULE: auto |
| 10 | + GRUNTWORK_INSTALLER_VERSION: v0.0.39 |
| 11 | + MODULE_CI_VERSION: v0.57.0 |
| 12 | + TERRATEST_LOG_PARSER_VERSION: v0.37.0 |
| 13 | + GOLANG_VERSION: 1.21.1 |
| 14 | + |
| 15 | +defaults: &defaults |
| 16 | + docker: |
| 17 | + - image: 087285199408.dkr.ecr.us-east-1.amazonaws.com/circle-ci-test-image-base:go1.21.9-tf1.5-tg58.8-pck1.8-ci56.0 |
| 18 | + <<: *env |
| 19 | + |
| 20 | +run_precommit: &run_precommit |
| 21 | + # Fail the build if the pre-commit hooks don't pass. Note: if you run $ pre-commit install locally within this repo, these hooks will |
| 22 | + # execute automatically every time before you commit, ensuring the build never fails at this step! |
| 23 | + name: run pre-commit hooks |
| 24 | + command: | |
| 25 | + pre-commit install |
| 26 | + pre-commit run --all-files |
| 27 | +
|
| 28 | +install_gruntwork_utils: &install_gruntwork_utils |
| 29 | + name: install gruntwork utils |
| 30 | + command: | |
| 31 | + curl -Ls https://raw.githubusercontent.com/gruntwork-io/gruntwork-installer/master/bootstrap-gruntwork-installer.sh | bash /dev/stdin --version "${GRUNTWORK_INSTALLER_VERSION}" |
| 32 | + gruntwork-install --module-name "gruntwork-module-circleci-helpers" --repo "https://github.com/gruntwork-io/terraform-aws-ci" --tag "${MODULE_CI_VERSION}" |
| 33 | + gruntwork-install --module-name "git-helpers" --repo "https://github.com/gruntwork-io/terraform-aws-ci" --tag "${MODULE_CI_VERSION}" |
| 34 | + gruntwork-install --binary-name "terratest_log_parser" --repo "https://github.com/gruntwork-io/terratest" --tag "${TERRATEST_LOG_PARSER_VERSION}" |
| 35 | + configure-environment-for-gruntwork-module \ |
| 36 | + --mise-version "NONE" \ |
| 37 | + --terraform-version "NONE" \ |
| 38 | + --terragrunt-version "NONE" \ |
| 39 | + --packer-version "NONE" \ |
| 40 | + --go-version ${GOLANG_VERSION} |
| 41 | +#---------------------------------------------------------------------------------------------------------------------- |
| 42 | +# BUILD JOBS |
| 43 | +#---------------------------------------------------------------------------------------------------------------------- |
| 44 | +jobs: |
| 45 | + precommit: |
| 46 | + <<: *env |
| 47 | + docker: |
| 48 | + - image: 087285199408.dkr.ecr.us-east-1.amazonaws.com/circle-ci-test-image-base:go1.21.9-tf1.5-tg39.1-pck1.8-ci54.0 |
| 49 | + steps: |
| 50 | + - checkout |
| 51 | + # Fail the build if the pre-commit hooks don't pass. Note: if you run pre-commit install locally, these hooks will |
| 52 | + # execute automatically every time before you commit, ensuring the build never fails at this step! |
| 53 | + - run: |
| 54 | + <<: *run_precommit |
| 55 | + tests: |
| 56 | + <<: *defaults |
| 57 | + steps: |
| 58 | + - checkout |
| 59 | + - attach_workspace: |
| 60 | + at: /home/circleci |
| 61 | + - run: |
| 62 | + <<: *install_gruntwork_utils |
| 63 | + - run: |
| 64 | + name: Install tools |
| 65 | + command: | |
| 66 | + make tools |
| 67 | + - run: |
| 68 | + name: Tidy check |
| 69 | + command: | |
| 70 | + go mod tidy |
| 71 | + - run: |
| 72 | + name: Run lint |
| 73 | + command: | |
| 74 | + make lint |
| 75 | + - run: |
| 76 | + command: | |
| 77 | + mkdir -p logs |
| 78 | + run-go-tests --parallelism 1 --packages "$(go list ./... | grep -v /test | tr '\n' ' ')" | tee logs/unit.log |
| 79 | + - run: |
| 80 | + name: Terratest log parser |
| 81 | + command: | |
| 82 | + terratest_log_parser --testlog logs/unit.log --outputdir logs |
| 83 | + when: always |
| 84 | + - store_artifacts: |
| 85 | + path: logs |
| 86 | + - store_test_results: |
| 87 | + path: logs |
| 88 | + integration_tests: |
| 89 | + <<: *defaults |
| 90 | + steps: |
| 91 | + - checkout |
| 92 | + - attach_workspace: |
| 93 | + at: /home/circleci |
| 94 | + - run: |
| 95 | + <<: *install_gruntwork_utils |
| 96 | + - run: |
| 97 | + name: Install tools |
| 98 | + command: | |
| 99 | + make tools |
| 100 | + - run: |
| 101 | + name: Tidy check |
| 102 | + command: | |
| 103 | + go mod tidy |
| 104 | + - run: |
| 105 | + command: | |
| 106 | + mkdir -p logs |
| 107 | + run-go-tests --packages "$(go list ./... | grep /test | tr '\n' ' ')" | tee logs/integration.log |
| 108 | + - run: |
| 109 | + name: Terratest log parser |
| 110 | + command: | |
| 111 | + terratest_log_parser --testlog logs/integration.log --outputdir logs |
| 112 | + when: always |
| 113 | + - store_artifacts: |
| 114 | + path: logs |
| 115 | + - store_test_results: |
| 116 | + path: logs |
| 117 | + test_windows: |
| 118 | + executor: |
| 119 | + name: win/default |
| 120 | + size: "large" |
| 121 | + steps: |
| 122 | + - checkout |
| 123 | + - run: |
| 124 | + name: Install golang |
| 125 | + shell: powershell.exe |
| 126 | + command: ./.circleci/install-golang.ps1 |
| 127 | + - run: |
| 128 | + name: Install Terraform |
| 129 | + shell: powershell.exe |
| 130 | + command: ./.circleci/install-terraform.ps1 |
| 131 | + - run: |
| 132 | + name: Run go terraform tests |
| 133 | + shell: powershell.exe |
| 134 | + command: | |
| 135 | + # to save time, we're running the tests in one go |
| 136 | + go mod tidy |
| 137 | + go test -v ./... |
| 138 | +
|
| 139 | + build: |
| 140 | + resource_class: xlarge |
| 141 | + <<: *defaults |
| 142 | + steps: |
| 143 | + - checkout |
| 144 | + - run: |
| 145 | + <<: *install_gruntwork_utils |
| 146 | + - run: | |
| 147 | + go mod tidy |
| 148 | + build-go-binaries --app-name terragrunt-iac-engine-terraform --dest-path bin --ld-flags "-X github.com/gruntwork-io/go-commons/version.Version=$CIRCLE_TAG -extldflags '-static'" |
| 149 | + - persist_to_workspace: |
| 150 | + root: . |
| 151 | + paths: [bin] |
| 152 | + - store_artifacts: |
| 153 | + path: bin |
| 154 | + release: |
| 155 | + <<: *env |
| 156 | + macos: |
| 157 | + xcode: 15.3.0 |
| 158 | + resource_class: macos.m1.medium.gen1 |
| 159 | + steps: |
| 160 | + - checkout |
| 161 | + - attach_workspace: |
| 162 | + at: . |
| 163 | + - go/install: |
| 164 | + version: "1.21.1" |
| 165 | + - run: |
| 166 | + name: Install sign-binary-helpers |
| 167 | + command: | |
| 168 | + curl -Ls https://raw.githubusercontent.com/gruntwork-io/gruntwork-installer/master/bootstrap-gruntwork-installer.sh | bash /dev/stdin --version "${GRUNTWORK_INSTALLER_VERSION}" |
| 169 | + gruntwork-install --module-name "gruntwork-module-circleci-helpers" --repo "https://github.com/gruntwork-io/terraform-aws-ci" --tag "${MODULE_CI_VERSION}" |
| 170 | + gruntwork-install --module-name "sign-binary-helpers" --repo "https://github.com/gruntwork-io/terraform-aws-ci" --tag "${MODULE_CI_VERSION}" |
| 171 | + gruntwork-install --module-name "github-release-helpers" --repo "https://github.com/gruntwork-io/terraform-aws-ci" --branch "github-release-helpers" |
| 172 | + - run: |
| 173 | + name: Compile and sign the binaries |
| 174 | + command: | |
| 175 | + export AC_PASSWORD=${MACOS_AC_PASSWORD} |
| 176 | + export AC_PROVIDER=${MACOS_AC_PROVIDER} |
| 177 | +
|
| 178 | + sign-binary --os mac --install-macos-sign-dependencies .gon_amd64.hcl |
| 179 | + sign-binary --os mac .gon_arm64.hcl |
| 180 | + echo "Done signing the binary" |
| 181 | + mkdir -p bin |
| 182 | + |
| 183 | + # Replace the files in bin. These are the same file names generated from .gon_amd64.hcl and .gon_arm64.hcl |
| 184 | + unzip terragrunt-iac-engine-terraform_amd64.zip |
| 185 | + mv terragrunt-iac-engine-terraform_darwin_amd64 bin/ |
| 186 | +
|
| 187 | + unzip terragrunt-iac-engine-terraform_arm64.zip |
| 188 | + mv terragrunt-iac-engine-terraform_darwin_arm64 bin/ |
| 189 | + - run: |
| 190 | + name: Install required packages |
| 191 | + command: | |
| 192 | + brew install coreutils gpg gh |
| 193 | + # setting sign key |
| 194 | + echo "${GW_ENGINE_GPG_KEY}" | base64 --decode > privatekey.asc |
| 195 | + echo "${GW_ENGINE_GPG_KEY_PW}" | gpg --batch --yes --import privatekey.asc |
| 196 | + KEY_ID=$(gpg --list-keys --with-colons | awk -F: '/^pub/{print $5}') |
| 197 | + echo -e "trust\n5\ny\n" | gpg --command-fd 0 --edit-key $KEY_ID trust |
| 198 | + mkdir -p ~/.gnupg |
| 199 | + echo "default-key $KEY_ID" >> ~/.gnupg/gpg.conf |
| 200 | + - run: |
| 201 | + name: Package release files |
| 202 | + command: | |
| 203 | + export RC_VERSION="${CIRCLE_TAG}" |
| 204 | + export VERSION=${RC_VERSION%-rc*} |
| 205 | + mkdir -p release |
| 206 | + sign-files --source-dir $(pwd)/bin --out-dir $(pwd)/release --name terragrunt-iac-engine-terraform --version ${VERSION} |
| 207 | + create-release --repo-owner gruntwork-io --repo-name terragrunt-engine-terraform --version ${VERSION} --rc-version ${RC_VERSION} --release-dir $(pwd)/release |
| 208 | + - persist_to_workspace: |
| 209 | + root: . |
| 210 | + paths: [release] |
| 211 | + - store_artifacts: |
| 212 | + path: release |
| 213 | +#---------------------------------------------------------------------------------------------------------------------- |
| 214 | +# WORKFLOWS |
| 215 | +#---------------------------------------------------------------------------------------------------------------------- |
| 216 | +workflows: |
| 217 | + version: 2 |
| 218 | + build-and-test: |
| 219 | + jobs: |
| 220 | + - precommit: |
| 221 | + context: |
| 222 | + - AWS__PHXDEVOPS__circle-ci-test |
| 223 | + - GITHUB__PAT__gruntwork-ci |
| 224 | + filters: |
| 225 | + tags: |
| 226 | + only: /^v.*/ |
| 227 | + - tests: |
| 228 | + context: |
| 229 | + - AWS__PHXDEVOPS__circle-ci-test |
| 230 | + - GITHUB__PAT__gruntwork-ci |
| 231 | + - SLACK__TOKEN__refarch-deployer-test |
| 232 | + - SLACK__WEBHOOK__refarch-deployer-test |
| 233 | + - SLACK__CHANNEL__test-workflow-approvals |
| 234 | + requires: |
| 235 | + - precommit |
| 236 | + filters: |
| 237 | + tags: |
| 238 | + only: /^v.*/ |
| 239 | + - integration_tests: |
| 240 | + filters: |
| 241 | + tags: |
| 242 | + only: /^v.*/ |
| 243 | + context: |
| 244 | + - AWS__PHXDEVOPS__circle-ci-test |
| 245 | + - GCP__automated-tests |
| 246 | + - GITHUB__PAT__gruntwork-ci |
| 247 | + requires: |
| 248 | + - precommit |
| 249 | + - test_windows: |
| 250 | + filters: |
| 251 | + tags: |
| 252 | + only: /^v.*/ |
| 253 | + context: |
| 254 | + - AWS__PHXDEVOPS__circle-ci-test |
| 255 | + - GCP__automated-tests |
| 256 | + - GITHUB__PAT__gruntwork-ci |
| 257 | + requires: |
| 258 | + - precommit |
| 259 | + - build: |
| 260 | + filters: |
| 261 | + tags: |
| 262 | + only: /^v.*/ |
| 263 | + context: |
| 264 | + - AWS__PHXDEVOPS__circle-ci-test |
| 265 | + - GCP__automated-tests |
| 266 | + - GITHUB__PAT__gruntwork-ci |
| 267 | + requires: |
| 268 | + - precommit |
| 269 | + - release: |
| 270 | + requires: |
| 271 | + - build |
| 272 | + filters: |
| 273 | + tags: |
| 274 | + only: /^.*-rc.*$/ |
| 275 | + branches: |
| 276 | + ignore: /.*/ |
| 277 | + context: |
| 278 | + - AWS__PHXDEVOPS__circle-ci-test |
| 279 | + - GCP__automated-tests |
| 280 | + - GITHUB__PAT__gruntwork-ci |
| 281 | + - APPLE__OSX__code-signing |
| 282 | + - TERRAGRUNT_ENGINE__circle-ci |
0 commit comments