-
Notifications
You must be signed in to change notification settings - Fork 170
122 lines (115 loc) · 3.29 KB
/
test.yaml
File metadata and controls
122 lines (115 loc) · 3.29 KB
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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
name: Test
on:
workflow_run:
workflows: ["Autogenerate"]
types:
- completed
push:
paths-ignore:
- "**.md"
- LICENSE
pull_request:
paths-ignore:
- "**.md"
- LICENSE
workflow_dispatch:
jobs:
autogen:
name: Generate mocks
runs-on: ubuntu-latest
# Permissions are needed to push the changes back to the repository
permissions:
contents: write
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
ref: ${{ github.head_ref }}
- name: Setup Go
uses: actions/setup-go@v5
with:
go-version: 1.17
- name: Install Mockery
uses: jaxxstorm/action-install-gh-release@v1.10.0
with: # Grab a specific tag
repo: vektra/mockery
tag: v3.5.3
- name: Generate mocks
run: mockery --config .mockery.yaml
- name: Cache generated mocks
uses: actions/cache@v4
with:
path: |
ocpp1.6_test/mocks/
ocpp2.0.1_test/mocks/
ocppj/mocks/
ws/mocks/
key: ${{ runner.os }}-mocks-${{ github.sha }}
unit:
runs-on: ubuntu-latest
name: Unit tests
needs: autogen
steps:
- name: Checkout code
uses: actions/checkout@v4.2.2
- name: Restore generated mocks
id: cache-mocks
uses: actions/cache/restore@v4
with:
path: |
ocpp1.6_test/mocks/
ocpp2.0.1_test/mocks/
ocppj/mocks/
ws/mocks/
key: ${{ runner.os }}-mocks-${{ github.sha }}
- name: Check cache hit
if: steps.cache-mocks.outputs.cache-hit != 'true'
run: exit 1
- name: Run tests
run: |
docker compose -f docker-compose.test.yaml up unit_test --abort-on-container-exit
- name: Archive code coverage results
uses: actions/upload-artifact@v4
with:
name: unit_coverage_${{ github.sha }}
path: ./coverage.out
integration:
name: Integration tests
runs-on: ubuntu-latest
needs: unit
steps:
- name: Checkout code
uses: actions/checkout@v4.2.2
- name: Download coverage from unit tests
uses: actions/download-artifact@v4
with:
name: unit_coverage_${{ github.sha }}
- name: Run integration tests
run: |
docker compose -f docker-compose.test.yaml up integration_test --abort-on-container-exit
- name: Merge coverage
run: |
sed '1d;$d' integration_coverage.out >> coverage.out
- name: Archive code coverage results
uses: actions/upload-artifact@v4
with:
name: coverage_${{ github.sha }}
path: ./coverage.out
publish_coverage:
runs-on: ubuntu-latest
# Unit and integration tests must be run before publishing coverage
needs: [unit, integration]
name: Publish coverage
steps:
- name: Checkout code
uses: actions/checkout@v4.2.2
- name: Download coverage from tests
uses: actions/download-artifact@v4
with:
name: coverage_${{ github.sha }}
- name: Publish
uses: shogo82148/actions-goveralls@v1
with:
path-to-profile: coverage.out
env:
COVERALLS_TOKEN: ${{ secrets.GITHUB_TOKEN }}