Skip to content

Fix device management #645

Fix device management

Fix device management #645

# Terraform Provider testing workflow.
name: resource development branch tests
# This GitHub action runs your tests for each pull request and push.
# Optionally, you can turn it on using a schedule for regular testing.
on:
push:
branches-ignore:
- main
- development
# Testing only needs permissions to read the repository contents.
permissions:
contents: read
jobs:
# Ensure project builds before running testing matrix
build:

Check failure on line 18 in .github/workflows/integration-test-branch.yml

View workflow run for this annotation

GitHub Actions / resource development branch tests

Invalid workflow file

The workflow is not valid. .github/workflows/integration-test-branch.yml (Line: 18, Col: 3): The workflow must contain at least one job with no dependencies.
name: Build
runs-on: ubuntu-latest
timeout-minutes: 30
needs: lint # Add dependency on the "lint" job in the lint.yml workflow
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version-file: './internal/go.mod'
cache: true
- run: go mod download
working-directory: ./internal
- run: go build -v .
generate:
needs: build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version-file: './internal/go.mod'
cache: true
- run: go generate ./...
working-directory: ./internal
- name: git diff
run: |
git diff --compact-summary --exit-code || \
(echo; echo "Unexpected difference in directories after code generation. Run 'go generate ./...' command and commit."; exit 1)
# Run acceptance tests for the resource on the development branch
test:
name: Terraform Provider Acceptance Tests
needs: generate
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version-file: 'go.mod'
cache: true
- uses: hashicorp/setup-terraform@v2
with:
terraform_version: '1.2.*'
terraform_wrapper: false
- run: go mod download
working-directory: ./internal
- env:
TF_ACC: "1"
MERAKI_DASHBOARD_API_KEY: ${{ secrets.MERAKI_DASHBOARD_API_KEY }}
run: |
go test -sweep -v -cover ./internal/provider/
timeout-minutes: 10
# Check test results and fail the workflow if the tests fail
check_results:
needs: test
runs-on: ubuntu-latest
steps:
- name: Check test results
run: |
changed_files=$(git diff --name-only HEAD $(git merge-base HEAD main))
test_function=$(grep -E '^func TestAcc.*\(t \*testing.T\)' $changed_files | awk -F 'func ' '{print $2}' | awk -F '(' '{print $1}')
if [[ -n "$test_function" ]]; then
# Run the test and store the output in a variable
test_output=$(go test -v -cover -run "$test_function" ./internal/provider/ 2>&1)
# Check if the test passed by searching for a specific pattern in the output
if echo "$test_output" | grep -q "PASS"; then
echo "TestAcc Passed"
else
echo "TestAcc Failed"
exit 1
fi
else
echo "TestAcc function not found"
fi