tests #207
This file contains 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
name: tests | |
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.13", "1.0", "1.8", "latest"] | |
config: [examples/basic, examples/advanced, examples/scrape] | |
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: | |
LOGTAIL_API_TOKEN: ${{ secrets.LOGS_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: | |
LOGTAIL_API_TOKEN: ${{ secrets.LOGS_E2E_TEAM_TOKEN }} | |
- name: Destroy resources via Terraform | |
if: always() | |
run: make terraform CONFIGURATION="${{ matrix.config }}" ARGS="destroy --auto-approve --input=false" | |
env: | |
LOGTAIL_API_TOKEN: ${{ secrets.LOGS_E2E_TEAM_TOKEN }} |