From 948df12e3aab4742e88fd21633f491ee6f5dea12 Mon Sep 17 00:00:00 2001 From: warrensbox Date: Sat, 30 Mar 2024 17:22:27 -0700 Subject: [PATCH 01/13] test build --- .github/workflow/build-test.yml | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 .github/workflow/build-test.yml diff --git a/.github/workflow/build-test.yml b/.github/workflow/build-test.yml new file mode 100644 index 00000000..6d72b390 --- /dev/null +++ b/.github/workflow/build-test.yml @@ -0,0 +1,32 @@ +name: Test + +on: + push: + branches: + - '*' # matches every branch that doesn't contain a '/' + - '*/*' # matches every branch containing a single '/' + - '**' # matches every branch + - '!release' # excludes master + + +jobs: + + integration_tests: + strategy: + matrix: + os: [ubuntu-latest, windows-latest] + go_version: ['1.22'] + runs-on: ${{ matrix.os }} + steps: + - uses: actions/checkout@v4 + + - name: Set up Go + uses: actions/setup-go@v5 + with: + go-version: ${{ matrix.go_version }} + + - name: Build + run: go build -v ./... + + - name: Test + run: go test -v ./... \ No newline at end of file From 18961ca6a8497985aafc988b9cbb5209b4b9da92 Mon Sep 17 00:00:00 2001 From: warrensbox Date: Sat, 30 Mar 2024 17:23:18 -0700 Subject: [PATCH 02/13] rm circle ci --- {.circleci => removecircleci}/config.yml | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {.circleci => removecircleci}/config.yml (100%) diff --git a/.circleci/config.yml b/removecircleci/config.yml similarity index 100% rename from .circleci/config.yml rename to removecircleci/config.yml From cd44d4ee857d61d570af70c56e5902f840c7315b Mon Sep 17 00:00:00 2001 From: warrensbox Date: Sat, 30 Mar 2024 17:25:14 -0700 Subject: [PATCH 03/13] typo -added s --- .github/{workflow => workflows}/build-test.yml | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename .github/{workflow => workflows}/build-test.yml (100%) diff --git a/.github/workflow/build-test.yml b/.github/workflows/build-test.yml similarity index 100% rename from .github/workflow/build-test.yml rename to .github/workflows/build-test.yml From 34397f757304c154e202a340902c5ae2184be3b6 Mon Sep 17 00:00:00 2001 From: warrensbox Date: Sat, 30 Mar 2024 17:39:34 -0700 Subject: [PATCH 04/13] test linting --- .github/workflows/build-test.yml | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build-test.yml b/.github/workflows/build-test.yml index 6d72b390..64190c07 100644 --- a/.github/workflows/build-test.yml +++ b/.github/workflows/build-test.yml @@ -10,11 +10,18 @@ on: jobs: - + lint: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-go@v3 + with: + go-version: 1.19 + - uses: golangci/golangci-lint-action@v3 integration_tests: strategy: matrix: - os: [ubuntu-latest, windows-latest] + os: [ubuntu-latest] go_version: ['1.22'] runs-on: ${{ matrix.os }} steps: From c2926b9cf004b7e0ff1092d41f0299187cd6938e Mon Sep 17 00:00:00 2001 From: warrensbox Date: Sat, 30 Mar 2024 17:42:07 -0700 Subject: [PATCH 05/13] testing --- .github/workflows/build-test.yml | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build-test.yml b/.github/workflows/build-test.yml index 64190c07..f2fa73cf 100644 --- a/.github/workflows/build-test.yml +++ b/.github/workflows/build-test.yml @@ -36,4 +36,21 @@ jobs: run: go build -v ./... - name: Test - run: go test -v ./... \ No newline at end of file + run: go test -v ./... + integration_tests: + runs-on: ubuntu-latest + needs: test + permissions: + contents: write + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-go@v3 + with: + go-version: 1.19 + - uses: go-semantic-release/action@v1 + with: + hooks: goreleaser + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + \ No newline at end of file From 75a2d4ee57c3bdf1bad0bb3d98fe7d3bf0497ca0 Mon Sep 17 00:00:00 2001 From: warrensbox Date: Sun, 31 Mar 2024 16:38:07 -0700 Subject: [PATCH 06/13] added build code --- .github/workflows/build-test.yml | 56 ------------------------- .github/workflows/{go.yml => build.yml} | 13 +++--- 2 files changed, 8 insertions(+), 61 deletions(-) delete mode 100644 .github/workflows/build-test.yml rename .github/workflows/{go.yml => build.yml} (64%) diff --git a/.github/workflows/build-test.yml b/.github/workflows/build-test.yml deleted file mode 100644 index f2fa73cf..00000000 --- a/.github/workflows/build-test.yml +++ /dev/null @@ -1,56 +0,0 @@ -name: Test - -on: - push: - branches: - - '*' # matches every branch that doesn't contain a '/' - - '*/*' # matches every branch containing a single '/' - - '**' # matches every branch - - '!release' # excludes master - - -jobs: - lint: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - uses: actions/setup-go@v3 - with: - go-version: 1.19 - - uses: golangci/golangci-lint-action@v3 - integration_tests: - strategy: - matrix: - os: [ubuntu-latest] - go_version: ['1.22'] - runs-on: ${{ matrix.os }} - steps: - - uses: actions/checkout@v4 - - - name: Set up Go - uses: actions/setup-go@v5 - with: - go-version: ${{ matrix.go_version }} - - - name: Build - run: go build -v ./... - - - name: Test - run: go test -v ./... - integration_tests: - runs-on: ubuntu-latest - needs: test - permissions: - contents: write - steps: - - uses: actions/checkout@v3 - - uses: actions/setup-go@v3 - with: - go-version: 1.19 - - uses: go-semantic-release/action@v1 - with: - hooks: goreleaser - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - \ No newline at end of file diff --git a/.github/workflows/go.yml b/.github/workflows/build.yml similarity index 64% rename from .github/workflows/go.yml rename to .github/workflows/build.yml index 706072d7..36559d0d 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/build.yml @@ -1,12 +1,15 @@ # This workflow will build a golang project # For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-go -name: Go +name: Run test on: push: - branches: [ '*' ] - + branches: + - '*' # matches every branch that doesn't contain a '/' + - '*/*' # matches every branch containing a single '/' + - '**' # matches every branch + - '!master' # excludes master jobs: integration_tests: @@ -23,8 +26,8 @@ jobs: with: go-version: ${{ matrix.go_version }} - - name: Build + - name: Build code run: go build -v ./... - - name: Test + - name: Running test run: go test -v ./... From 27d68ec85f8c6151cc70b8b84eeef4696aa0dd7c Mon Sep 17 00:00:00 2001 From: warrensbox Date: Sun, 31 Mar 2024 16:56:15 -0700 Subject: [PATCH 07/13] added more test --- .github/workflows/build.yml | 15 +++-- .github/workflows/release.yml | 101 ++++++++++++++++++++++++++++++++++ 2 files changed, 112 insertions(+), 4 deletions(-) create mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 36559d0d..dd2d212f 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,6 +1,3 @@ -# This workflow will build a golang project -# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-go - name: Run test on: @@ -30,4 +27,14 @@ jobs: run: go build -v ./... - name: Running test - run: go test -v ./... + run: + command: | + set -e + go get -v -t -d ./... + go vet -tests=false ./... + go test -v ./... + mkdir -p build + go build -v -o build/tfswitch + find ./test-data/* -type d -print0 | while read -r -d $'\0' TEST_PATH; do + ./build/tfswitch -c "${TEST_PATH}" || exit 1 + done diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 00000000..4e0354c3 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,101 @@ +# Trigger when commits are pushed to the master branch +# Trigger when MR to master is closed + +name: Build-Test-Release Code + +on: + pull_request: + types: + - closed + branches: + - release + + +jobs: + hubapp-release: + name: Release + runs-on: ubuntu-latest + steps: + + # Checkout code from repo + - uses: actions/checkout@v3 + with: + ref: ${{ github.sha }} # required for better experience using pre-releases + fetch-depth: '0' + + # Install go + - name: Checkout go + uses: actions/setup-go@v4 + with: + go-version: '1.22' # The Go version to download (if necessary) and use. + + # Double check go version + - name: Go version + id: Version + run: go version + + # Download dependencies + - name: Go download + run: go mod download + + # Run test code + - name: Go test + run: + command: | + set -e + go get -v -t -d ./... + go vet -tests=false ./... + go test -v ./... + mkdir -p build + go build -v -o build/tfswitch + find ./test-data/* -type d -print0 | while read -r -d $'\0' TEST_PATH; do + ./build/tfswitch -c "${TEST_PATH}" || exit 1 + done + continue-on-error: false + + # Test to see if tfswitch works with --help + - name: Go build + run: mkdir -p build && go build -v -o build/tfswitch && build/tfswitch --help + continue-on-error: false + + # Introduce new tag + - name: Bump version and push tag + uses: anothrNick/github-tag-action@1.67.0 + id: tagging + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + WITH_V: false + INITIAL_VERSION: 1.0.0 + RELEASE_BRANCHES: release + DEFAULT_BUMP: patch + PRERELEASE: false + DRY_RUN: false + VERBOSE: true + + # Run goreleaser to create new binaries + - name: Run GoReleaser + uses: goreleaser/goreleaser-action@v5 + with: + version: latest + args: release --clean + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + RELEASE_VERSION: ${{ steps.tagging.outputs.tag }} + PERSONAL_ACCESS_TOKEN: ${{ secrets.PERSONAL_ACCESS_TOKEN }} + + - name: Install Python + uses: actions/setup-python@v2 + with: + python-version: 3.x + + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install mkdocs-material + + - name: Build page + run: cd www && mkdocs gh-deploy --force + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + From d18976aed478ea5251fe4b26a8d631dd43dbe642 Mon Sep 17 00:00:00 2001 From: warrensbox Date: Sun, 31 Mar 2024 16:59:42 -0700 Subject: [PATCH 08/13] fix run command --- .github/workflows/build.yml | 21 ++++++++++----------- .github/workflows/release.yml | 21 ++++++++++----------- 2 files changed, 20 insertions(+), 22 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index dd2d212f..92780087 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -27,14 +27,13 @@ jobs: run: go build -v ./... - name: Running test - run: - command: | - set -e - go get -v -t -d ./... - go vet -tests=false ./... - go test -v ./... - mkdir -p build - go build -v -o build/tfswitch - find ./test-data/* -type d -print0 | while read -r -d $'\0' TEST_PATH; do - ./build/tfswitch -c "${TEST_PATH}" || exit 1 - done + run: | + set -e + go get -v -t -d ./... + go vet -tests=false ./... + go test -v ./... + mkdir -p build + go build -v -o build/tfswitch + find ./test-data/* -type d -print0 | while read -r -d $'\0' TEST_PATH; do + ./build/tfswitch -c "${TEST_PATH}" || exit 1 + done diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 4e0354c3..fd736c4a 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -40,17 +40,16 @@ jobs: # Run test code - name: Go test - run: - command: | - set -e - go get -v -t -d ./... - go vet -tests=false ./... - go test -v ./... - mkdir -p build - go build -v -o build/tfswitch - find ./test-data/* -type d -print0 | while read -r -d $'\0' TEST_PATH; do - ./build/tfswitch -c "${TEST_PATH}" || exit 1 - done + run: | + set -e + go get -v -t -d ./... + go vet -tests=false ./... + go test -v ./... + mkdir -p build + go build -v -o build/tfswitch + find ./test-data/* -type d -print0 | while read -r -d $'\0' TEST_PATH; do + ./build/tfswitch -c "${TEST_PATH}" || exit 1 + done continue-on-error: false # Test to see if tfswitch works with --help From eb0ff7f84a682600e1359829cda1d61d7b3e192e Mon Sep 17 00:00:00 2001 From: warrensbox Date: Sun, 31 Mar 2024 17:21:03 -0700 Subject: [PATCH 09/13] added cutom path --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 92780087..6cc86e46 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -35,5 +35,5 @@ jobs: mkdir -p build go build -v -o build/tfswitch find ./test-data/* -type d -print0 | while read -r -d $'\0' TEST_PATH; do - ./build/tfswitch -c "${TEST_PATH}" || exit 1 + ./build/tfswitch -c "${TEST_PATH}" -b `pwd`/bin/terraform || exit 1 done From da4d8b8346d32765e67a3ad4b6f8ba97cece32ae Mon Sep 17 00:00:00 2001 From: warrensbox Date: Sun, 31 Mar 2024 17:23:52 -0700 Subject: [PATCH 10/13] added bindir --- .github/workflows/build.yml | 1 + .github/workflows/release.yml | 14 -------------- 2 files changed, 1 insertion(+), 14 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 6cc86e46..5dd1e04d 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -34,6 +34,7 @@ jobs: go test -v ./... mkdir -p build go build -v -o build/tfswitch + mkdir `pwd`/bin/ find ./test-data/* -type d -print0 | while read -r -d $'\0' TEST_PATH; do ./build/tfswitch -c "${TEST_PATH}" -b `pwd`/bin/terraform || exit 1 done diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index fd736c4a..dbed0709 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -38,20 +38,6 @@ jobs: - name: Go download run: go mod download - # Run test code - - name: Go test - run: | - set -e - go get -v -t -d ./... - go vet -tests=false ./... - go test -v ./... - mkdir -p build - go build -v -o build/tfswitch - find ./test-data/* -type d -print0 | while read -r -d $'\0' TEST_PATH; do - ./build/tfswitch -c "${TEST_PATH}" || exit 1 - done - continue-on-error: false - # Test to see if tfswitch works with --help - name: Go build run: mkdir -p build && go build -v -o build/tfswitch && build/tfswitch --help From 5ae065a207252932b0ab2eadc2ae3c557fdf5363 Mon Sep 17 00:00:00 2001 From: warrensbox Date: Sun, 31 Mar 2024 17:28:15 -0700 Subject: [PATCH 11/13] separate windows and linux test --- .github/workflows/build.yml | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 5dd1e04d..5979defb 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -9,10 +9,10 @@ on: - '!master' # excludes master jobs: - integration_tests: + integration_tests_linux: strategy: matrix: - os: [ubuntu-latest, windows-latest] + os: [ubuntu-latest] go_version: ['1.22'] runs-on: ${{ matrix.os }} steps: @@ -38,3 +38,27 @@ jobs: find ./test-data/* -type d -print0 | while read -r -d $'\0' TEST_PATH; do ./build/tfswitch -c "${TEST_PATH}" -b `pwd`/bin/terraform || exit 1 done + + integration_tests_windows: + strategy: + matrix: + os: [windows-latest] + go_version: ['1.22'] + runs-on: ${{ matrix.os }} + steps: + - uses: actions/checkout@v4 + + - name: Set up Go + uses: actions/setup-go@v5 + with: + go-version: ${{ matrix.go_version }} + + - name: Build code + run: go build -v ./... + + - name: Running test + run: | + set -e + go get -v -t -d ./... + go vet -tests=false ./... + go test -v ./... From 0ea5a70a413b48e927791aa77e13d9ccc1c437f7 Mon Sep 17 00:00:00 2001 From: warrensbox Date: Sun, 31 Mar 2024 17:33:38 -0700 Subject: [PATCH 12/13] update goreleaser --- .goreleaser.yml | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/.goreleaser.yml b/.goreleaser.yml index b7d900a5..404117bb 100644 --- a/.goreleaser.yml +++ b/.goreleaser.yml @@ -20,7 +20,7 @@ builds: - 7 ignore: - goos: windows - goarch: arm + goarch: arm64 checksum: name_template: '{{ .ProjectName }}_{{.Env.RELEASE_VERSION}}_checksums.txt' changelog: @@ -29,17 +29,19 @@ changelog: exclude: - '^docs:' - '^test:' + archives: - - - name_template: '{{ .ProjectName }}_{{.Env.RELEASE_VERSION}}_{{ .Os }}_{{ .Arch }}{{ if .Arm }}v{{ .Arm }}{{ end }}' - replacements: - darwin: darwin - linux: linux - 386: 386 - amd64: amd64 - format_overrides: - - goos: windows - format: zip + - id: archives + name_template: >- + {{- .ProjectName }}_ + {{.Env.RELEASE_VERSION}}_ + {{- title .Os }}_ + {{- if eq .Arch "amd64" }}amd64 + {{- else if eq .Arch "386" }}386 + {{- else }}{{ .Arch }}{{ end }} + {{- if .Arm }}v{{ .Arm }}{{ end -}} + + brews: - # Name of the recipe @@ -48,9 +50,10 @@ brews: # GitHub/GitLab repository to push the formula to # Gitea is not supported yet, but the support coming - tap: + repository: owner: warrensbox name: homebrew-tap + token: "{{ .Env.PERSONAL_ACCESS_TOKEN }}" # Reporitory to push the tap to. # github: From 51dd3bfef7d886dfe6544fcc616a4c17b931b1c1 Mon Sep 17 00:00:00 2001 From: warrensbox Date: Sun, 31 Mar 2024 17:34:49 -0700 Subject: [PATCH 13/13] simplify test --- .github/workflows/build.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 5979defb..ce258a5e 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -58,7 +58,4 @@ jobs: - name: Running test run: | - set -e - go get -v -t -d ./... - go vet -tests=false ./... go test -v ./...