Skip to content

Commit 6590975

Browse files
committed
Autogen cache without checkin to vcs
Signed-off-by: Lorenzo <[email protected]>
1 parent 7bee131 commit 6590975

File tree

3 files changed

+60
-50
lines changed

3 files changed

+60
-50
lines changed

.github/workflows/autogen.yaml

Lines changed: 0 additions & 47 deletions
This file was deleted.

.github/workflows/test.yaml

Lines changed: 53 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
name: Test
22
on:
3+
workflow_run:
4+
workflows: ["Autogenerate"]
5+
types:
6+
- completed
37
push:
48
paths-ignore:
59
- "**.md"
@@ -13,12 +17,59 @@ on:
1317
workflow_dispatch:
1418

1519
jobs:
20+
autogen:
21+
name: Generate mocks
22+
runs-on: ubuntu-latest
23+
24+
# Permissions are needed to push the changes back to the repository
25+
permissions:
26+
contents: write
27+
28+
steps:
29+
- name: Checkout code
30+
uses: actions/checkout@v4
31+
with:
32+
ref: ${{ github.head_ref }}
33+
- name: Setup Go
34+
uses: actions/setup-go@v5
35+
with:
36+
go-version: 1.17
37+
- name: Install Mockery
38+
uses: jaxxstorm/[email protected]
39+
with: # Grab a specific tag
40+
repo: vektra/mockery
41+
tag: v2.53.3
42+
- name: Generate mocks
43+
run: mockery
44+
- name: Cache generated mocks
45+
uses: actions/cache@v4
46+
with:
47+
path: |
48+
ocpp1.6_test/mocks/
49+
ocpp2.0.1_test/mocks/
50+
ocppj/mocks/
51+
ws/mocks/
52+
key: ${{ runner.os }}-mocks-${{ github.sha }}
1653
unit:
1754
runs-on: ubuntu-latest
1855
name: Unit tests
56+
needs: autogen
1957
steps:
2058
- name: Checkout code
2159
uses: actions/[email protected]
60+
- name: Restore generated mocks
61+
id: cache-mocks
62+
uses: actions/cache/restore@v4
63+
with:
64+
path: |
65+
ocpp1.6_test/mocks/
66+
ocpp2.0.1_test/mocks/
67+
ocppj/mocks/
68+
ws/mocks/
69+
key: ${{ runner.os }}-mocks-${{ github.sha }}
70+
- name: Check cache hit
71+
if: steps.cache-mocks.outputs.cache-hit != 'true'
72+
run: exit 1
2273
- name: Run tests
2374
run: |
2475
docker compose -f docker-compose.test.yaml up unit_test --abort-on-container-exit
@@ -54,7 +105,7 @@ jobs:
54105
publish_coverage:
55106
runs-on: ubuntu-latest
56107
# Unit and integration tests must be run before publishing coverage
57-
needs: [ unit, integration ]
108+
needs: [unit, integration]
58109
name: Publish coverage
59110
steps:
60111
- name: Checkout code
@@ -68,4 +119,4 @@ jobs:
68119
with:
69120
path-to-profile: coverage.out
70121
env:
71-
COVERALLS_TOKEN: ${{ secrets.GITHUB_TOKEN }}
122+
COVERALLS_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.gitignore

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,10 @@
1818
certs/
1919

2020
central_system_sim
21-
charge_point_sim
21+
charge_point_sim
22+
23+
# Generatd files
24+
ocpp1.6_test/mocks/
25+
ocpp2.0.1_test/mocks/
26+
ocppj/mocks/
27+
ws/mocks/

0 commit comments

Comments
 (0)