-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
build: run integration tests and dry-run build
- Loading branch information
1 parent
77ca7f7
commit fb9e488
Showing
6 changed files
with
110 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
name: CI | ||
|
||
on: [push, pull_request] | ||
|
||
jobs: | ||
check: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v2 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- name: Set up Go | ||
uses: actions/setup-go@v2 | ||
with: | ||
go-version: 1.15 | ||
|
||
- name: Test | ||
run: | | ||
./test.sh | ||
- name: Run GoReleaser | ||
uses: goreleaser/goreleaser-action@v2 | ||
with: | ||
args: build --snapshot | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,5 @@ | ||
# ignore built binaries | ||
/terraform-demux | ||
|
||
# ignore test output | ||
test-log |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -e | ||
|
||
GIT_ROOT="$(git rev-parse --show-toplevel)" | ||
TMP_DIR="$(mktemp -d)" | ||
|
||
if ! [[ $TMP_DIR ]]; then | ||
panic "could not create temporary directory" | ||
else | ||
# shellcheck disable=SC2064 | ||
trap "rm -r $TMP_DIR" EXIT | ||
|
||
export XDG_CACHE_HOME="$TMP_DIR" | ||
fi | ||
|
||
function terraform_demux_version() { | ||
go run "$GIT_ROOT/cmd/..." -- -version >test-log 2>&1 | ||
} | ||
|
||
function expect_log() { | ||
(grep -q "$1" test-log && pass "Found '$1' in test-log") || fail "Expected to find '$1' in test-log" | ||
} | ||
|
||
function pass() { | ||
echo "PASS:" "$@" >&2 | ||
} | ||
|
||
function fail() { | ||
echo "FAIL:" "$@" >&2 | ||
exit 1 | ||
} | ||
|
||
function panic() { | ||
echo "PANIC:" "$@" >&2 | ||
exit 1 | ||
} | ||
|
||
function terraform_demux_version_test() { | ||
local dir="$1" | ||
local expected_version="$2" | ||
|
||
pushd "$dir" >/dev/null | ||
|
||
terraform_demux_version | ||
|
||
(grep -q "$expected_version" test-log && pass "Found '$expected_version' in $dir/test-log") \ | ||
|| fail "Expected to find '$expected_version' in $dir/test-log" | ||
|
||
popd >/dev/null | ||
} | ||
|
||
function test_pre_0.12_exact() { | ||
terraform_demux_version_test "testdata/terraform-pre-0.12-exact" "Terraform v0.11.15" | ||
} | ||
|
||
function test_post_0.12_exact() { | ||
terraform_demux_version_test "testdata/terraform-post-0.12-exact" "Terraform v1.0.3" | ||
} | ||
|
||
function test_pessimistic_constraint() { | ||
terraform_demux_version_test "testdata/terraform-pessimistic" "Terraform v0.14." | ||
} | ||
|
||
test_pre_0.12_exact | ||
|
||
test_post_0.12_exact | ||
|
||
test_pessimistic_constraint |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
terraform { | ||
required_version = "~> 0.14.0" | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
terraform { | ||
required_version = "1.0.3" | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
terraform { | ||
required_version = "0.11.15" | ||
} |