Improve CI pipeline

This commit is contained in:
Xiangxuan Liu
2019-09-11 23:17:26 +08:00
parent b6125b8501
commit 347db3e230
3 changed files with 47 additions and 35 deletions

View File

@@ -2,40 +2,52 @@ name: Lint
on: [push, pull_request] on: [push, pull_request]
jobs: jobs:
validate: tflint:
name: Validate name: TFLint
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@master - uses: actions/checkout@master
# - uses: actions/setup-ruby@v1 - name: TFLint
# with: uses: docker://wata727/tflint
# ruby-version: '2.4.6'
# - name: Install Kitchen-Terraform fmt:
# run: | name: Code Format
# gem install bundler --no-document runs-on: ubuntu-latest
# bundle install container:
- name: Install Terraform image: hashicorp/terraform:latest
run: | steps:
export TERRAFORM_VERSION=$(curl -s https://checkpoint-api.hashicorp.com/v1/check/terraform | jq -r -M '.current_version') - uses: actions/checkout@master
curl --silent --output terraform.zip "https://releases.hashicorp.com/terraform/${TERRAFORM_VERSION}/terraform_${TERRAFORM_VERSION}_linux_amd64.zip" - run: terraform fmt --recursive -check=true
unzip terraform.zip ; rm -f terraform.zip; chmod +x terraform
mkdir -p ${HOME}/bin ; export PATH=${PATH}:${HOME}/bin; mv terraform ${HOME}/bin/ docs:
terraform -v name: Docs
runs-on: macOS-latest
steps:
- uses: actions/checkout@master
- name: Install Deps
run: brew install pre-commit terraform-docs terraform
- name: Check Docs
run: pre-commit run --show-diff-on-failure --all-files terraform_docs
validate:
name: Validate
runs-on: ubuntu-latest
container:
image: hashicorp/terraform:latest
steps:
- uses: actions/checkout@master
- name: Validate Code - name: Validate Code
env: env:
AWS_REGION: 'us-east-1' AWS_REGION: 'us-east-1'
TF_VAR_region: ${AWS_REGION}
TF_WARN_OUTPUT_ERRORS: 1 TF_WARN_OUTPUT_ERRORS: 1
run: | run: |
terraform init terraform init
terraform fmt -check=true
terraform validate -var "region=${AWS_REGION}" -var "vpc_id=vpc-123456" -var "subnets=[\"subnet-12345a\"]" -var "workers_ami_id=ami-123456" -var "cluster_ingress_cidrs=[]" -var "cluster_name=test_cluster" terraform validate -var "region=${AWS_REGION}" -var "vpc_id=vpc-123456" -var "subnets=[\"subnet-12345a\"]" -var "workers_ami_id=ami-123456" -var "cluster_ingress_cidrs=[]" -var "cluster_name=test_cluster"
- name: Validate Examples - name: Validate Examples
run: | run: |
for example in $(find examples -maxdepth 1 -mindepth 1 -type d); do for example in $(find examples -maxdepth 1 -mindepth 1 -type d); do
cd $example cd $example
terraform init terraform init
terraform fmt -check=true
terraform validate terraform validate
cd - cd -
done done

View File

@@ -134,7 +134,7 @@ MIT Licensed. See [LICENSE](https://github.com/terraform-aws-modules/terraform-a
| map\_accounts | Additional AWS account numbers to add to the aws-auth configmap. See examples/basic/variables.tf for example format. | list(string) | `[]` | no | | map\_accounts | Additional AWS account numbers to add to the aws-auth configmap. See examples/basic/variables.tf for example format. | list(string) | `[]` | no |
| map\_roles | Additional IAM roles to add to the aws-auth configmap. See examples/basic/variables.tf for example format. | object | `[]` | no | | map\_roles | Additional IAM roles to add to the aws-auth configmap. See examples/basic/variables.tf for example format. | object | `[]` | no |
| map\_users | Additional IAM users to add to the aws-auth configmap. See examples/basic/variables.tf for example format. | object | `[]` | no | | map\_users | Additional IAM users to add to the aws-auth configmap. See examples/basic/variables.tf for example format. | object | `[]` | no |
| permissions\_boundary | If provided, all IAM roles will be created with this permissions boundary attached. | string | `""` | no | | permissions\_boundary | If provided, all IAM roles will be created with this permissions boundary attached. | string | `"null"` | no |
| subnets | A list of subnets to place the EKS cluster and workers within. | list(string) | n/a | yes | | subnets | A list of subnets to place the EKS cluster and workers within. | list(string) | n/a | yes |
| tags | A map of tags to add to all resources. | map(string) | `{}` | no | | tags | A map of tags to add to all resources. | map(string) | `{}` | no |
| vpc\_id | VPC where the cluster and workers will be deployed. | string | n/a | yes | | vpc\_id | VPC where the cluster and workers will be deployed. | string | n/a | yes |

View File

@@ -207,7 +207,7 @@ variable "worker_create_security_group" {
variable "permissions_boundary" { variable "permissions_boundary" {
description = "If provided, all IAM roles will be created with this permissions boundary attached." description = "If provided, all IAM roles will be created with this permissions boundary attached."
type = string type = string
default = "" default = null
} }
variable "iam_path" { variable "iam_path" {