Skip to content

Commit

Permalink
feat: add acceptance tests workflow (#17)
Browse files Browse the repository at this point in the history
  • Loading branch information
gmichels authored Mar 24, 2023
1 parent 55d5a6e commit 95f2a97
Show file tree
Hide file tree
Showing 5 changed files with 84 additions and 52 deletions.
45 changes: 45 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# Terraform Provider release workflow
name: Release

on:
push:
tags:
- "v*"

# releases need permissions to read and write the repository contents
permissions:
contents: write

jobs:
# run acceptance tests
tests:
uses: ./.github/workflows/testacc.yaml
goreleaser:
# require tests to pass
needs: [tests]
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
with:
# allow goreleaser to access older tag information
fetch-depth: 0
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version-file: "go.mod"
cache: true
- name: Import GPG key
uses: crazy-max/ghaction-import-gpg@v5.2.0
id: import_gpg
with:
gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }}
passphrase: ${{ secrets.PASSPHRASE }}
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v4.2.0
with:
args: release --clean
env:
# GitHub sets the GITHUB_TOKEN secret automatically
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GPG_FINGERPRINT: ${{ steps.import_gpg.outputs.fingerprint }}
41 changes: 0 additions & 41 deletions .github/workflows/release.yml

This file was deleted.

33 changes: 33 additions & 0 deletions .github/workflows/testacc.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: Acceptance Tests

on:
pull_request:
types: ["opened", "synchronize"]
paths:
- "**.go"
- go.mod
- ".github/workflows/testacc.yaml"
# allow this workflow to be called from other workflows
workflow_call:

env:
GOPROXY: https://proxy.golang.org,direct
DEBIAN_FRONTEND: noninteractive
GO_VERSION: "1.20"
TERRAFORM_VERSION: "1.4.2"

jobs:
testacc:
runs-on: ubuntu-20.04
timeout-minutes: 10
steps:
- uses: actions/checkout@v3
- uses: actions/setup-go@v3
with:
go-version: ${{ env.GO_VERSION }}
- uses: hashicorp/setup-terraform@v2
with:
terraform_version: ${{ env.TERRAFORM_VERSION }}
terraform_wrapper: false
- name: Run acceptance tests
run: make testacc
11 changes: 3 additions & 8 deletions .goreleaser.yml → .goreleaser.yaml
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
# Visit https://goreleaser.com for documentation on how to customize this
# behavior.
before:
hooks:
# this is just an example and not a requirement for provider building/publishing
- go mod tidy
builds:
- env:
# goreleaser does not work with CGO, it could also complicate
# usage by users in CI/CD systems like Terraform Cloud where
# they are unable to install libraries.
# they are unable to install libraries
- CGO_ENABLED=0
mod_timestamp: "{{ .CommitTimestamp }}"
flags:
Expand Down Expand Up @@ -42,7 +39,7 @@ signs:
- artifacts: checksum
args:
# if you are using this in a GitHub action or some other automated pipeline, you
# need to pass the batch flag to indicate its not interactive.
# need to pass the batch flag to indicate its not interactive
- "--batch"
- "--local-user"
- "{{ .Env.GPG_FINGERPRINT }}" # set this environment variable for your signing key
Expand All @@ -54,7 +51,5 @@ release:
extra_files:
- glob: "terraform-registry-manifest.json"
name_template: "{{ .ProjectName }}_{{ .Version }}_manifest.json"
# If you want to manually examine the release before its live, uncomment this line:
# if you want to manually examine the release before its live, uncomment this line:
# draft: true
changelog:
skip: true
6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
TEST?=$$(go list ./... | grep -v 'vendor')
TEST?=$$(go list ./adguard | grep -v 'vendor')
HOSTNAME=registry.terraform.io
NAMESPACE=gmichels
NAME=adguard
BINARY=terraform-provider-${NAME}
VERSION=0.1.0
VERSION=0.0.1
OS_ARCH=darwin_amd64

default: install
Expand Down Expand Up @@ -35,6 +35,6 @@ test:

testacc:
docker compose -f ./docker/docker-compose.yaml up -d
TF_ACC=1 go test $(TEST) -v $(TESTARGS) -timeout 120m
TF_ACC=1 go test $(TEST) -v $(TESTARGS) -timeout 10m
docker compose -f ./docker/docker-compose.yaml down
git checkout HEAD -- ./docker/conf/AdGuardHome.yaml

0 comments on commit 95f2a97

Please sign in to comment.