Skip to content

Test

Test #473

Workflow file for this run

name: Test
on:
push:
branches:
- master
pull_request:
workflow_dispatch:
schedule:
- cron: '0 3 * * *'
jobs:
test:
strategy:
matrix:
go-version: [1.16.x]
os: [ubuntu-latest, macos-latest, windows-latest]
fail-fast: false
runs-on: ${{ matrix.os }}
steps:
- name: Install Go
uses: actions/setup-go@v2
with:
go-version: ${{ matrix.go-version }}
- name: Checkout code
uses: actions/checkout@v2
- name: Test
run: go test ./...
e2e_test:
strategy:
matrix:
terraform-version: ["0.14", "1.0", "1.8", "latest"]
config: [examples/basic, examples/advanced, examples/on_call_calendars]
fail-fast: false
runs-on: ubuntu-latest
steps:
- name: Install Go
uses: actions/setup-go@v2
with:
go-version: 1.16.x
- name: Install Terraform
uses: hashicorp/setup-terraform@v3
with:
terraform_version: ${{ matrix.terraform-version }}
- name: Checkout code
uses: actions/checkout@v2
- name: Add resources via Terraform
run: make terraform CONFIGURATION="${{ matrix.config }}" ARGS="apply --auto-approve --input=false"
env:
BETTERUPTIME_API_TOKEN: ${{ secrets.UPTIME_E2E_TEAM_TOKEN }}
- name: Plan resources via Terraform - must be empty
run: |
make terraform CONFIGURATION="${{ matrix.config }}" ARGS="plan --input=false --out=tfplan"
make terraform CONFIGURATION="${{ matrix.config }}" ARGS="show --json tfplan > tfplan.json"
CHANGES="$(jq "[.resource_changes[]? | select(.change.actions != [\"no-op\"])] | length" "${{ matrix.config }}/tfplan.json")"
if [ "$CHANGES" == "0" ]; then
echo "No planned changes detected after first apply. Success!"
else
echo "$CHANGES planned changes detected after first apply. Failure!"
exit 1
fi
env:
BETTERUPTIME_API_TOKEN: ${{ secrets.UPTIME_E2E_TEAM_TOKEN }}
- name: Destroy resources via Terraform
if: always()
run: make terraform CONFIGURATION="${{ matrix.config }}" ARGS="destroy --auto-approve --input=false"
env:
BETTERUPTIME_API_TOKEN: ${{ secrets.UPTIME_E2E_TEAM_TOKEN }}