-
Notifications
You must be signed in to change notification settings - Fork 2
66 lines (59 loc) · 1.92 KB
/
go-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
name: "[Job] Run Go unit tests and Push coverage reports to Codecov"
on:
workflow_call:
inputs:
tag:
description: 'Tag for docker image'
required: true
type: string
branch:
description: 'The branch the workflow relates to'
required: true
type: string
commit_sha:
description: 'The commit SHA the workflow relates to'
required: true
type: string
secrets:
pact_broker_password:
description: 'Password for central OPG pact broker'
required: true
codecov_token:
description: 'Upload token for codecov'
required: true
jobs:
run:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup Go
uses: actions/[email protected]
with:
go-version: '^1.20'
cache-dependency-path: '**/go.sum'
- name: Download pact
run: |
go mod tidy
go install github.com/pact-foundation/pact-go/v2
mkdir -p ~/pact-lib
pact-go -l DEBUG -d ~/pact-lib install
- name: Run tests and generate coverage report
run: |
sudo mv ~/pact-lib/libpact_ffi.so /usr/local/lib
make go-test
- name: Publish pacts
run: |
docker run --rm -v $(pwd)/pacts:/tmp/pacts pactfoundation/pact-cli:latest \
pact-broker publish /tmp/pacts \
--consumer-app-version ${{ inputs.commit_sha }} \
--branch ${{ inputs.branch }} \
--tag ${{ inputs.tag }} \
--broker-base-url https://pact-broker.api.opg.service.justice.gov.uk \
--broker-username admin \
--broker-password ${{ secrets.pact_broker_password }}
- name: Upload coverage to Codecov
uses: codecov/[email protected]
with:
flags: unittests
files: ./coverage.out
token: ${{ secrets.codecov_token }}