|
| 1 | +# This GitHub action runs your tests for each commit push and/or PR. Optionally |
| 2 | +# you can turn it on using a cron schedule for regular testing. |
| 3 | +# |
| 4 | +name: Tests |
| 5 | +on: |
| 6 | + pull_request: |
| 7 | + paths-ignore: |
| 8 | + - 'README.md' |
| 9 | + push: |
| 10 | + paths-ignore: |
| 11 | + - 'README.md' |
| 12 | + # For systems with an upstream API that could drift unexpectedly (like most SaaS systems, etc.), |
| 13 | + # we recommend testing at a regular interval not necessarily tied to code changes. This will |
| 14 | + # ensure you are alerted to something breaking due to an API change, even if the code did not |
| 15 | + # change. |
| 16 | + # schedule: |
| 17 | + # - cron: '0 13 * * *' |
| 18 | +jobs: |
| 19 | + # ensure the code builds... |
| 20 | + build: |
| 21 | + name: Build |
| 22 | + runs-on: ubuntu-latest |
| 23 | + timeout-minutes: 5 |
| 24 | + steps: |
| 25 | + |
| 26 | + - name: Check out code into the Go module directory |
| 27 | + uses: actions/checkout@v3 |
| 28 | + |
| 29 | + - name: Set up Go |
| 30 | + uses: actions/setup-go@v3 |
| 31 | + with: |
| 32 | + go-version-file: 'go.mod' |
| 33 | + cache: true |
| 34 | + id: go |
| 35 | + |
| 36 | + - name: Get dependencies |
| 37 | + run: | |
| 38 | + go mod download |
| 39 | +
|
| 40 | + - name: Build |
| 41 | + run: | |
| 42 | + go build -v . |
| 43 | +
|
| 44 | + generate: |
| 45 | + runs-on: ubuntu-latest |
| 46 | + steps: |
| 47 | + - uses: actions/checkout@v3 |
| 48 | + - uses: actions/setup-go@v3 |
| 49 | + with: |
| 50 | + go-version-file: 'go.mod' |
| 51 | + cache: true |
| 52 | + - run: go generate ./... |
| 53 | + - name: git diff |
| 54 | + run: | |
| 55 | + git diff --compact-summary --exit-code || \ |
| 56 | + (echo; echo "Unexpected difference in directories after code generation. Run 'go generate ./...' command and commit."; exit 1) |
| 57 | +
|
| 58 | + # run acceptance tests in a matrix with Terraform core versions |
| 59 | + test: |
| 60 | + name: Matrix Test |
| 61 | + needs: build |
| 62 | + runs-on: ubuntu-latest |
| 63 | + timeout-minutes: 15 |
| 64 | + strategy: |
| 65 | + fail-fast: false |
| 66 | + matrix: |
| 67 | + # list whatever Terraform versions here you would like to support |
| 68 | + terraform: |
| 69 | + - '1.1.*' |
| 70 | + - '1.2.*' |
| 71 | + - '1.3.*' |
| 72 | + steps: |
| 73 | + |
| 74 | + - name: Check out code into the Go module directory |
| 75 | + uses: actions/checkout@v3 |
| 76 | + |
| 77 | + - name: Set up Go |
| 78 | + uses: actions/setup-go@v3 |
| 79 | + with: |
| 80 | + go-version-file: 'go.mod' |
| 81 | + cache: true |
| 82 | + id: go |
| 83 | + |
| 84 | + - uses: hashicorp/setup-terraform@v2 |
| 85 | + with: |
| 86 | + terraform_version: ${{ matrix.terraform }} |
| 87 | + terraform_wrapper: false |
| 88 | + |
| 89 | + - name: Get dependencies |
| 90 | + run: | |
| 91 | + go mod download |
| 92 | +
|
| 93 | + - name: TF acceptance tests |
| 94 | + timeout-minutes: 10 |
| 95 | + env: |
| 96 | + TF_ACC: "1" |
| 97 | + |
| 98 | + # Set whatever additional acceptance test env vars here. You can |
| 99 | + # optionally use data from your repository secrets using the |
| 100 | + # following syntax: |
| 101 | + # SOME_VAR: ${{ secrets.SOME_VAR }} |
| 102 | + |
| 103 | + run: | |
| 104 | + go test -v -cover ./mixtool |
0 commit comments