Skip to content
Snippets Groups Projects
Commit a0aa0711 authored by Timothée AUFORT's avatar Timothée AUFORT
Browse files

feat(ci): update .gitlab-ci.yml file

parent 79405641
No related branches found
No related tags found
No related merge requests found
image:
name: hashicorp/terraform:0.14.8
name: hashicorp/terraform:0.14.9
entrypoint:
- '/usr/bin/env'
- 'PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin'
......@@ -9,26 +9,17 @@ stages:
- Staging Plan
- Staging Apply
- Integration Test
- Production Plan
- Production Apply
- Destroy
Test and Lint:
stage: Test and Lint
script:
- echo "test to do"
rules:
- if: '$CI_MERGE_REQUEST_TARGET_BRANCH_NAME =~ /^(master|production)$/ || $CI_COMMIT_BRANCH =~ /^(master|production)$/'
Validate Terraform:
stage: Test and Lint
script:
- cd deploy/
- terraform fmt -check -recursive
- terraform init -backend=false
- terraform validate
- terraform fmt -check
rules:
- if: '$CI_MERGE_REQUEST_TARGET_BRANCH_NAME =~ /^(master|production)$/ || $CI_COMMIT_BRANCH =~ /^(master|production)$/'
- if: '$CI_MERGE_REQUEST_TARGET_BRANCH_NAME =~ /^(master)$/ || $CI_COMMIT_BRANCH =~ /^(master)$/'
Staging Plan:
stage: Staging Plan
......@@ -38,7 +29,7 @@ Staging Plan:
- terraform workspace select staging || terraform workspace new staging
- terraform plan
rules:
- if: '$CI_COMMIT_BRANCH =~ /^(master|production)$/'
- if: '$CI_MERGE_REQUEST_TARGET_BRANCH_NAME =~ /^(master)$/ || $CI_COMMIT_BRANCH =~ /^(master)$/'
Staging Apply:
stage: Staging Apply
......@@ -56,22 +47,22 @@ Staging Apply:
reports:
dotenv: deploy.env
rules:
- if: '$CI_COMMIT_BRANCH =~ /^(master|production)$/'
- if: '$CI_COMMIT_BRANCH =~ /^(master)$/'
Integration Tests:
stage: Integration Test
image:
name: postman/newman
name: postman/newman:5
entrypoint: [""]
script:
- newman run Lambda_CRUD.postman_collection.json --env-var "endpoint=$API_ENDPOINT"
rules:
- if: '$CI_COMMIT_BRANCH =~ /^(master|production)$/'
- if: '$CI_COMMIT_BRANCH =~ /^(master)$/'
Load Tests:
stage: Integration Test
image:
name: peterevans/vegeta
name: peterevans/vegeta:6.9
entrypoint: [""]
script:
- echo "GET $API_ENDPOINT/crud" | vegeta attack -duration=3s -rate=100/s | vegeta report
......@@ -79,29 +70,9 @@ Load Tests:
- echo "PATCH $API_ENDPOINT/crud" | vegeta attack -duration=3s -rate=100/s | vegeta report
- echo "DELETE $API_ENDPOINT/crud" | vegeta attack -duration=3s -rate=100/s | vegeta report
rules:
- if: '$CI_COMMIT_BRANCH =~ /^(master|production)$/'
- if: '$CI_COMMIT_BRANCH =~ /^(master)$/'
when: manual
Production Plan:
stage: Production Plan
script:
- cd deploy/
- terraform init
- terraform workspace select production || terraform workspace new production
- terraform plan
rules:
- if: '$CI_COMMIT_BRANCH == "production"'
Production Apply:
stage: Production Apply
script:
- cd deploy/
- terraform init
- terraform workspace select production
- terraform apply -auto-approve
rules:
- if: '$CI_COMMIT_BRANCH == "production"'
Staging Destroy:
stage: Destroy
script:
......@@ -110,16 +81,5 @@ Staging Destroy:
- terraform workspace select staging
- terraform destroy -auto-approve
rules:
- if: '$CI_COMMIT_BRANCH =~ /^(master|production)$/'
when: manual
Production Destroy:
stage: Destroy
script:
- cd deploy/
- terraform init
- terraform workspace select production
- terraform destroy -auto-approve
rules:
- if: '$CI_COMMIT_BRANCH == "production"'
- if: '$CI_COMMIT_BRANCH =~ /^(master)$/'
when: manual
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment