IZE-776 Goreleaser & Go installer updated #426
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
name: "Tests: Unit" | |
defaults: | |
run: | |
shell: bash | |
env: | |
AWS_PROFILE: default | |
AWS_REGION: us-east-1 | |
on: | |
workflow_dispatch: | |
pull_request: | |
push: | |
branches: | |
- main | |
jobs: | |
build: | |
name: Build | |
strategy: | |
matrix: | |
os: | |
- ubuntu-latest | |
# TODO: re-enable other platforms after Ubuntu is working fine | |
# - macos-latest | |
# - windows-latest | |
runs-on: ${{ matrix.os }} | |
steps: | |
- name: Install Go | |
uses: actions/setup-go@v2 | |
with: | |
go-version: 1.18.x | |
- name: Checkout Code | |
uses: actions/checkout@v2 | |
- name: Build | |
run: | | |
go mod download | |
make bin | |
- name: Upload Artifact | |
uses: actions/upload-artifact@v3 | |
with: | |
name: ize-${{ matrix.os }}-${{ github.sha }} | |
path: ${{ github.workspace }}/ize | |
# TODO: this should be executed before the release and fail in proper cases | |
unit-tests: | |
name: Unit Tests | |
needs: build | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Set up Go | |
uses: actions/setup-go@v3 | |
with: | |
go-version: 1.18 | |
- name: Generate | |
run: | | |
go install github.com/golang/mock/mockgen@v1.6.0 | |
go generate ./... | |
- name: Build | |
run: go build -v ./... | |
- name: Generate Test SSH Key | |
run: ssh-keygen -q -f ~/.ssh/id_rsa | |
- name: Install Junit Reporter | |
run: | | |
go install github.com/jstemmer/go-junit-report/v2@latest | |
- name: Coverage Test | |
run: | | |
# If we rerun with DEBUG then we'll see the actual log. Otherwise just JUnit report | |
if [ ! -z $RUNNER_DEBUG ]; then | |
go test -v ./... -coverprofile=coverage.out -covermode=atomic 2>&1 ./... | tee report.txt | |
cat report.txt | go-junit-report -set-exit-code > report.xml | |
else | |
go test -v ./... -coverprofile=coverage.out -covermode=atomic 2>&1 ./... > report.txt | |
fi | |
- name: Publish Test Report | |
uses: mikepenz/action-junit-report@v3 | |
if: always() # always run even if the previous step fails | |
with: | |
report_paths: './report.xml' | |
- name: Upload coverage to Codecov | |
uses: codecov/codecov-action@v2 |