Nvm test #413
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 | |
- v2.x | |
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@v5 | |
with: | |
go-version: 1.22.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@v5 | |
with: | |
go-version: 1.22.x | |
- name: Generate | |
run: | | |
go install github.com/golang/mock/[email protected] | |
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 | |
cat report.txt | go-junit-report -set-exit-code > report.xml | |
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: Test Summary | |
uses: test-summary/action@v2 | |
if: always() | |
with: | |
paths: ./report.xml | |
- name: Upload coverage reports to Codecov | |
uses: codecov/[email protected] | |
with: | |
files: coverage.out | |
token: ${{ secrets.CODECOV_TOKEN }} | |
verbose: true | |
name: coverage-${{ github.sha }} |