Skip to content

Commit

Permalink
added more test
Browse files Browse the repository at this point in the history
  • Loading branch information
warrensbox committed Mar 31, 2024
1 parent 75a2d4e commit 27d68ec
Show file tree
Hide file tree
Showing 2 changed files with 112 additions and 4 deletions.
15 changes: 11 additions & 4 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -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:
Expand Down Expand Up @@ -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
101 changes: 101 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -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 }}


0 comments on commit 27d68ec

Please sign in to comment.