Skip to content

Commit

Permalink
Merge pull request #336 from warrensbox/master
Browse files Browse the repository at this point in the history
Testing new pipeline
  • Loading branch information
warrensbox committed Apr 1, 2024
2 parents d602fb2 + b74a6fd commit 387ad96
Show file tree
Hide file tree
Showing 19 changed files with 451 additions and 1,006 deletions.
61 changes: 61 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
name: Run test

on:
push:
branches:
- '*' # matches every branch that doesn't contain a '/'
- '*/*' # matches every branch containing a single '/'
- '**' # matches every branch
- '!master' # excludes master
jobs:

integration_tests_linux:
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 code
run: go build -v ./...

- name: Running 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
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
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: |
go test -v ./...
86 changes: 86 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
# 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

# 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 }}


27 changes: 15 additions & 12 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ builds:
- 7
ignore:
- goos: windows
goarch: arm
goarch: arm64
checksum:
name_template: '{{ .ProjectName }}_{{.Env.RELEASE_VERSION}}_checksums.txt'
changelog:
Expand All @@ -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
Expand All @@ -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:
Expand Down
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,11 @@ Installation for other linux operation systems.
```sh
curl -L https://github.com/raw/warrensbox/terraform-switcher/release/install.sh | bash
```

By default installer script will try to download `tfswitch` binary into `/usr/local/bin`
To install at custom path use below:
```sh
curl -L https://github.com/raw/warrensbox/terraform-switcher/release/install.sh | bash -s -- -b $HOME/.local/bin latest
```
### Arch User Repository (AUR) packages for Arch Linux

```sh
Expand Down
35 changes: 19 additions & 16 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,35 +5,38 @@ go 1.22
require (
github.com/hashicorp/go-version v1.6.0
github.com/hashicorp/hcl2 v0.0.0-20191002203319-fb75b3253c80
github.com/hashicorp/terraform-config-inspect v0.0.0-20211115214459-90acf1ca460f
github.com/hashicorp/terraform-config-inspect v0.0.0-20231204233900-a34142ec2a72
github.com/manifoldco/promptui v0.9.0
github.com/mitchellh/go-homedir v1.1.0
github.com/pborman/getopt v1.1.0
github.com/spf13/viper v1.12.0
golang.org/x/sys v0.0.0-20220627191245-f75cf1eec38b
github.com/spf13/viper v1.18.2
golang.org/x/sys v0.18.0
)

require (
github.com/agext/levenshtein v1.2.2 // indirect
github.com/apparentlymart/go-textseg v1.0.0 // indirect
github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e // indirect
github.com/fsnotify/fsnotify v1.5.4 // indirect
github.com/google/go-cmp v0.5.8 // indirect
github.com/fsnotify/fsnotify v1.7.0 // indirect
github.com/google/go-cmp v0.5.9 // indirect
github.com/hashicorp/hcl v1.0.0 // indirect
github.com/hashicorp/hcl/v2 v2.0.0 // indirect
github.com/magiconair/properties v1.8.6 // indirect
github.com/magiconair/properties v1.8.7 // indirect
github.com/mitchellh/go-wordwrap v1.0.0 // indirect
github.com/mitchellh/mapstructure v1.5.0 // indirect
github.com/pelletier/go-toml v1.9.5 // indirect
github.com/pelletier/go-toml/v2 v2.0.1 // indirect
github.com/spf13/afero v1.8.2 // indirect
github.com/spf13/cast v1.5.0 // indirect
github.com/spf13/jwalterweatherman v1.1.0 // indirect
github.com/pelletier/go-toml/v2 v2.1.0 // indirect
github.com/sagikazarmark/locafero v0.4.0 // indirect
github.com/sagikazarmark/slog-shim v0.1.0 // indirect
github.com/sourcegraph/conc v0.3.0 // indirect
github.com/spf13/afero v1.11.0 // indirect
github.com/spf13/cast v1.6.0 // indirect
github.com/spf13/pflag v1.0.5 // indirect
github.com/subosito/gotenv v1.3.0 // indirect
github.com/subosito/gotenv v1.6.0 // indirect
github.com/zclconf/go-cty v1.1.0 // indirect
golang.org/x/text v0.3.7 // indirect
gopkg.in/ini.v1 v1.66.4 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.0 // indirect
go.uber.org/atomic v1.9.0 // indirect
go.uber.org/multierr v1.9.0 // indirect
golang.org/x/exp v0.0.0-20230905200255-921286631fa9 // indirect
golang.org/x/text v0.14.0 // indirect
gopkg.in/ini.v1 v1.67.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)
Loading

0 comments on commit 387ad96

Please sign in to comment.