-
Notifications
You must be signed in to change notification settings - Fork 2
93 lines (78 loc) · 2.26 KB
/
run.unit-tests.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
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/[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
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