From 47888bd703582efb6f465a9e0019ca76c908d02e Mon Sep 17 00:00:00 2001 From: Mathias Fredriksson Date: Fri, 10 Feb 2023 20:08:19 +0200 Subject: [PATCH] ci: Add fmt and gen linting (#98) --- .github/workflows/test.yml | 111 ++++++++++++------ .../resources/coder_parameter/resource.tf | 30 ++--- 2 files changed, 87 insertions(+), 54 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index c8dd09ec..97715835 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -5,10 +5,10 @@ name: Tests on: pull_request: paths-ignore: - - 'README.md' + - "README.md" push: paths-ignore: - - 'README.md' + - "README.md" jobs: build: @@ -16,23 +16,22 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 5 steps: + - name: Set up Go + uses: actions/setup-go@v3 + with: + go-version: "1.20" + id: go - - name: Set up Go - uses: actions/setup-go@v3 - with: - go-version: '1.17' - id: go + - name: Check out code into the Go module directory + uses: actions/checkout@v3 - - name: Check out code into the Go module directory - uses: actions/checkout@v3 + - name: Get dependencies + run: | + go mod download - - name: Get dependencies - run: | - go mod download - - - name: Build - run: | - go build -v . + - name: Build + run: | + go build -v . # run acceptance tests in a matrix with Terraform core versions test: @@ -44,31 +43,65 @@ jobs: fail-fast: false matrix: terraform: - - '1.0.*' - - '1.1.*' + - "1.0.*" + - "1.1.*" + - "1.2.*" + - "1.3.*" + steps: + - name: Set up Go + uses: actions/setup-go@v3 + with: + go-version: "1.20" + id: go + + - uses: hashicorp/setup-terraform@v2 + with: + terraform_version: ${{ matrix.terraform }} + terraform_wrapper: false + + - name: Check out code into the Go module directory + uses: actions/checkout@v3 + + - name: Get dependencies + run: | + go mod download + + - name: TF acceptance tests + timeout-minutes: 10 + env: + TF_ACC: "1" + run: | + go test -v -cover ./provider/ + + lint: + name: Lint + runs-on: ubuntu-latest + timeout-minutes: 5 steps: + - name: Set up Go + uses: actions/setup-go@v3 + with: + go-version: "1.20" + id: go + + - uses: hashicorp/setup-terraform@v2 + with: + terraform_version: "1.3.*" + terraform_wrapper: false - - name: Set up Go - uses: actions/setup-go@v3 - with: - go-version: '1.17' - id: go + - name: Check out code into the Go module directory + uses: actions/checkout@v3 - - uses: hashicorp/setup-terraform@v2 - with: - terraform_version: ${{ matrix.terraform }} - terraform_wrapper: false + - name: Get dependencies + run: | + go mod download - - name: Check out code into the Go module directory - uses: actions/checkout@v3 + - name: Lint fmt + run: | + make fmt + git diff --exit-code - - name: Get dependencies - run: | - go mod download - - - name: TF acceptance tests - timeout-minutes: 10 - env: - TF_ACC: "1" - run: | - go test -v -cover ./provider/ + - name: Lint gen + run: | + make gen + git diff --exit-code diff --git a/examples/resources/coder_parameter/resource.tf b/examples/resources/coder_parameter/resource.tf index c4d7e859..42ca4495 100644 --- a/examples/resources/coder_parameter/resource.tf +++ b/examples/resources/coder_parameter/resource.tf @@ -20,7 +20,7 @@ data "coder_parameter" "example" { } data "coder_parameter" "ami" { - name = "Machine Image" + name = "Machine Image" description = <<-EOT # Provide the machine image See the [registry](https://container.registry.blah/namespace) for options. @@ -33,39 +33,39 @@ data "coder_parameter" "ami" { } data "coder_parameter" "is_public_instance" { - name = "Is public instance?" - type = "bool" - icon = "/icon/docker.svg" + name = "Is public instance?" + type = "bool" + icon = "/icon/docker.svg" default = false } data "coder_parameter" "cores" { - name = "CPU Cores" - type = "number" - icon = "/icon/cpu.svg" + name = "CPU Cores" + type = "number" + icon = "/icon/cpu.svg" default = 3 } data "coder_parameter" "disk_size" { - name = "Disk Size" - type = "number" + name = "Disk Size" + type = "number" default = "5" validation { # This can apply to number. - min = 0 - max = 10 + min = 0 + max = 10 monotonic = "increasing" } } data "coder_parameter" "cat_lives" { - name = "Cat Lives" - type = "number" + name = "Cat Lives" + type = "number" default = "9" validation { # This can apply to number. - min = 0 - max = 10 + min = 0 + max = 10 monotonic = "decreasing" } }