terraform-provider-matrix

git clone git://archive.git.mtrnord.blog/MTRNord/terraform-provider-matrix.git
Log | Files | Refs | README | LICENSE

test.yml (2552B)


      1 # Terraform Provider testing workflow.
      2 name: Tests
      3 
      4 # This GitHub action runs your tests for each pull request and push.
      5 # Optionally, you can turn it on using a schedule for regular testing.
      6 on:
      7   pull_request:
      8     paths-ignore:
      9       - 'README.md'
     10   push:
     11     paths-ignore:
     12       - 'README.md'
     13 
     14 # Testing only needs permissions to read the repository contents.
     15 permissions:
     16   contents: read
     17 
     18 jobs:
     19   # Ensure project builds before running testing matrix
     20   build:
     21     name: Build
     22     runs-on: ubuntu-latest
     23     timeout-minutes: 5
     24     steps:
     25       - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
     26       - uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491 # v5.0.0
     27         with:
     28           go-version-file: 'go.mod'
     29           cache: true
     30       - run: go mod download
     31       - run: go build -v .
     32       - name: Run linters
     33         uses: golangci/golangci-lint-action@3a919529898de77ec3da873e3063ca4b10e7f5cc # v3.7.0
     34         with:
     35           version: latest
     36 
     37   generate:
     38     runs-on: ubuntu-latest
     39     steps:
     40       - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
     41       - uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491 # v5.0.0
     42         with:
     43           go-version-file: 'go.mod'
     44           cache: true
     45       - run: go generate ./...
     46       - name: git diff
     47         run: |
     48           git diff --compact-summary --exit-code || \
     49             (echo; echo "Unexpected difference in directories after code generation. Run 'go generate ./...' command and commit."; exit 1)
     50 
     51   # Run acceptance tests in a matrix with Terraform CLI versions
     52   test:
     53     name: Terraform Provider Acceptance Tests
     54     needs: build
     55     runs-on: ubuntu-latest
     56     timeout-minutes: 15
     57     strategy:
     58       fail-fast: false
     59       matrix:
     60         # list whatever Terraform versions here you would like to support
     61         terraform:
     62           - '1.0.*'
     63           - '1.1.*'
     64           - '1.2.*'
     65           - '1.3.*'
     66           - '1.4.*'
     67     steps:
     68       - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
     69       - uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491 # v5.0.0
     70         with:
     71           go-version-file: 'go.mod'
     72           cache: true
     73       - uses: hashicorp/setup-terraform@633666f66e0061ca3b725c73b2ec20cd13a8fdd1 # v2.0.3
     74         with:
     75           terraform_version: ${{ matrix.terraform }}
     76           terraform_wrapper: false
     77       - run: go mod download
     78       - env:
     79           TF_ACC: "1"
     80         run: go test -v -cover ./internal/provider/
     81         timeout-minutes: 10