forked from juju/juju
-
Notifications
You must be signed in to change notification settings - Fork 0
57 lines (49 loc) · 1.3 KB
/
gen.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
name: "Generate"
on:
push:
pull_request:
types: [opened, synchronize, reopened, ready_for_review]
paths:
- '**.go'
- 'go.mod'
- '.github/workflows/gen.yml'
workflow_dispatch:
permissions:
contents: read
jobs:
Generate:
name: Generate
runs-on: ubuntu-latest
if: github.event.pull_request.draft == false
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Set up Go
uses: actions/setup-go@v3
with:
go-version-file: 'go.mod'
cache: true
- name: go get dependencies
run: go get ./...
- name: Delete all mocks
shell: bash
run: |
for FILE in $(grep '// Code generated by MockGen. DO NOT EDIT.' -r . -l --include \*.go); do
rm $FILE
done
- name: Regenerate code
shell: bash
run: go generate -x ./...
- name: Check diff
if: success() || failure()
shell: bash
run: |
git add -A
if [[ -n $(git diff HEAD) ]]; then
echo "*****"
echo "The following generated files have been modified:"
git diff --name-status HEAD
echo "Please regenerate these files and check in the changes."
echo "*****"
exit 1
fi