Skip to content

oxide_ip_pool_silo_link: use composite attributes for id #1852

oxide_ip_pool_silo_link: use composite attributes for id

oxide_ip_pool_silo_link: use composite attributes for id #1852

Workflow file for this run

name: build & test
on:
push:
branches:
- main
- '[0-9].[0-9]+'
- 'rel/v*'
pull_request:
schedule:
# Cron jobs test against omicron main to catch breaking changes early.
- cron: "25 7 * * *"
workflow_dispatch:
inputs:
omicron_version:
description: 'Git object to use for Omicron (commit SHA, tag, branch etc.). If not specified, the VERSION_OMICRON from oxide.go is used.'
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}/acctest-omicron-dev
jobs:
build-test:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
tf-binary:
- terraform
- tofu
steps:
- uses: actions/checkout@v7
- uses: actions/setup-go@v6
with:
go-version-file: 'go.mod'
- uses: hashicorp/setup-terraform@v4
if: matrix.tf-binary == 'terraform'
with:
terraform_wrapper: false
- uses: opentofu/setup-opentofu@v2
if: matrix.tf-binary == 'tofu'
with:
tofu_wrapper: false
- uses: astral-sh/setup-uv@v7
with:
# We don't have any Python dependencies to cache.
enable-cache: false
- name: set env
run: |
echo "CHECKPOINT_DISABLE=1" >> "$GITHUB_ENV"
echo "TF_ACC_TERRAFORM_PATH=$(which ${{ matrix.tf-binary }})" >> "$GITHUB_ENV"
- name: build
run: make build
- name: test
run: |
mkdir ./unittest
make test
env:
CHECKPOINT_DISABLE: "1"
TEST_GOTESTSUM_ARGS: "--rerun-fails-report=./unittest/unit-test-rerun.txt --junitfile=./unittest/unit-tests.xml"
# Explicitly skip TestAcc* test to avoid polluting TestRail results
# with unnecessary Skipped results.
TEST_NAME: "^Test($|[^A]|A$|A[^c]|Ac$|Ac[^c])"
TF_ACC_PROVIDER_NAMESPACE: oxidecomputer
- name: lint
if: matrix.tf-binary == 'terraform' # Linting tools require Terraform to be installed.
run: make lint
- name: upload test results to TestRail
if: always()
continue-on-error: true
env:
TR_CLI_HOST: ${{ secrets.TESTRAIL_HOST }}
TR_CLI_USERNAME: ${{ secrets.TESTRAIL_USERNAME }}
TR_CLI_KEY: ${{ secrets.TESTRAIL_API_KEY }}
TR_CLI_PROJECT: ${{ secrets.TESTRAIL_PROJECT }}
run: |
uvx trcli \
--yes `# Auto-create new test cases.` \
parse_junit \
--file './unittest/unit-tests.xml' \
--title 'Unit Tests (${{ matrix.tf-binary }}) - ${{ github.run_id }} - ${{ job.check_run_id }}' \
--run-description 'GitHub workflow: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}/job/${{ job.check_run_id }}' \
--update-existing-cases 'yes' \
--case-matcher 'auto' \
--close-run
# Choose the appropriate omicron version for acceptance tests. For cron jobs, use `main`, since
# our goal is to detect breaking changes in omicron. Otherwise, look up the omicron version from
# the VERSION_OMICRON file in oxide.go, checking the expected version of oxide.go from go.mod.
#
# Note: we use the omicron commit hash throughout for tagging and fetching the docker image, so
# it has to be a complete SHA, not a branch name or partial SHA.
omicron-version:
runs-on: ubuntu-latest
outputs:
sha: ${{ steps.version.outputs.sha }}
steps:
- uses: actions/checkout@v7
- id: version
env:
GH_TOKEN: ${{ github.token }}
IS_SCHEDULE: ${{ github.event_name == 'schedule' }}
OMICRON_VERSION: ${{ inputs.omicron_version }}
run: |
if [[ "${IS_SCHEDULE}" == "true" ]]; then
OMICRON_VERSION='main'
fi
OMICRON_SHA=$(./acctest/omicron-version.sh "${OMICRON_VERSION}")
echo "**Omicron version:** \`${OMICRON_VERSION:--}\`" >> $GITHUB_STEP_SUMMARY
echo "**Omicron SHA:** [\`${OMICRON_SHA}\`](https://github.com/oxidecomputer/omicron/commit/${OMICRON_SHA})" >> $GITHUB_STEP_SUMMARY
echo "sha=${OMICRON_SHA}" >> $GITHUB_OUTPUT
# Build and push the acctest docker image before running acceptance tests.
# This ensures the image is available in the registry for acceptance tests to pull.
#
# Note: images are cached by omicron SHA only. If you change acctest/Dockerfile, manually delete
# the cached image from ghcr.io/oxidecomputer/terraform-provider-oxide/acctest-omicron-dev.
publish-image:
needs: omicron-version
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- uses: actions/checkout@v7
- name: Check if image exists
id: check
run: |
if docker manifest inspect ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ needs.omicron-version.outputs.sha }} > /dev/null 2>&1; then
echo "exists=true" >> $GITHUB_OUTPUT
else
echo "exists=false" >> $GITHUB_OUTPUT
fi
- name: Clean up disk space
if: steps.check.outputs.exists == 'false'
run: |
sudo rm -rf /usr/share/dotnet /usr/local/lib/android /opt/ghc /opt/hostedtoolcache/CodeQL
sudo docker image prune --all --force
sudo docker builder prune -a
- name: Log in to GHCR
if: steps.check.outputs.exists == 'false'
uses: docker/login-action@v4
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Set up Docker Buildx
if: steps.check.outputs.exists == 'false'
uses: docker/setup-buildx-action@v4
- name: Build and push
if: steps.check.outputs.exists == 'false'
uses: docker/build-push-action@v7
with:
context: acctest
platforms: linux/amd64
push: true
build-args: |
OMICRON_SHA=${{ needs.omicron-version.outputs.sha }}
tags: |
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ needs.omicron-version.outputs.sha }}
acceptance:
needs: [omicron-version, publish-image]
uses: "./.github/workflows/acceptance-sim.yml"
with:
omicron-sha: ${{ needs.omicron-version.outputs.sha }}
secrets:
testrail-host: ${{ secrets.TESTRAIL_HOST }}
testrail-username: ${{ secrets.TESTRAIL_USERNAME }}
testrail-api-key: ${{ secrets.TESTRAIL_API_KEY }}
testrail-project: ${{ secrets.TESTRAIL_PROJECT }}