CI - HIL #2927
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Hardware-in-the-loop tests. They run on a self-hosted runner with the labels | |
| # below, wired to a real UniFi controller — infrastructure that only exists in | |
| # the upstream repo. The `if:` guard on the job keeps this inert in forks: | |
| # without it, a fork's PR/schedule queues a job that can never be scheduled | |
| # (no matching runner), leaving the required check stuck "Expected" forever. | |
| # | |
| # To opt a fork into HIL: | |
| # 1. replace the repository name in the `if:` guard below with your own `owner/repo` | |
| # 2. register a self-hosted runner with the `self-hosted` + `terrifi-hardware-test` labels, pointed at your controller | |
| # 3. add the `TERRIFI_HIL_TEST_UNIFI_API_KEY` secret in https://github.com/<owner/repo>/settings/secrets/actions. | |
| name: CI - HIL | |
| concurrency: | |
| group: ${{ github.workflow }} | |
| cancel-in-progress: false | |
| on: | |
| workflow_dispatch: | |
| pull_request: | |
| branches: [main] | |
| schedule: | |
| - cron: '22 * * * *' | |
| jobs: | |
| main: | |
| name: Main | |
| # Skip everywhere except the upstream repo — see header. | |
| if: github.repository == 'alexklibisz/terraform-provider-terrifi' | |
| runs-on: | |
| - self-hosted | |
| - terrifi-hardware-test | |
| env: | |
| # Using IP instead of hostname for reliability in the self-hosted runner. | |
| UNIFI_API: https://192.168.1.3:11443 | |
| UNIFI_API_KEY: ${{ secrets.TERRIFI_HIL_TEST_UNIFI_API_KEY }} | |
| UNIFI_INSECURE: true | |
| steps: | |
| - name: Checkout | |
| timeout-minutes: 1 | |
| uses: actions/checkout@v4 | |
| - name: Set up Go | |
| timeout-minutes: 1 | |
| uses: actions/setup-go@v5 | |
| with: | |
| go-version-file: go.mod | |
| cache: false | |
| - name: Set up OpenTofu | |
| timeout-minutes: 1 | |
| uses: opentofu/setup-opentofu@v1 | |
| with: | |
| tofu_wrapper: false | |
| - name: Configure OpenTofu for acceptance tests | |
| run: | | |
| echo "TF_ACC_TERRAFORM_PATH=$(which tofu)" >> "$GITHUB_ENV" | |
| echo "TF_ACC_PROVIDER_HOST=registry.opentofu.org" >> "$GITHUB_ENV" | |
| - name: Install Task | |
| timeout-minutes: 1 | |
| uses: arduino/setup-task@v2 | |
| with: | |
| version: 3.x | |
| repo-token: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Check UniFi API key | |
| timeout-minutes: 1 | |
| run: task checkAPIConnection | |
| - name: Download Go dependencies | |
| timeout-minutes: 10 | |
| run: task deps | |
| - name: Build | |
| timeout-minutes: 10 | |
| run: task build | |
| - name: Cleanup leftover test resources | |
| timeout-minutes: 5 | |
| run: go run ./cmd/terrifi-tests cleanup | |
| - name: Acceptance tests (HIL) | |
| timeout-minutes: 10 | |
| run: task test:acc:hardware |