-
Notifications
You must be signed in to change notification settings - Fork 37
116 lines (102 loc) · 4.1 KB
/
test.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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
name: Protolock source & CLI test
on: [push, pull_request]
jobs:
test:
runs-on: ubuntu-latest
env:
GOPATH: ${{ github.workspace }}
GOBIN: ${{ github.workspace }}/bin
GO111MODULE: "on"
defaults:
run:
working-directory: ${{ env.GOPATH }}/src/github.com/nilslice/protolock
name: build
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 1
path: ${{ env.GOPATH }}/src/github.com/nilslice/protolock
- name: Set Up Go
uses: actions/setup-go@v4
with:
go-version: '1.20'
- name: fetch depenencies, test code
run: |
go get -v -d ./...
go test -v -race ./...
- name: install binary, test commands
run: |
go install ./...
protolock
stat proto.lock
cat proto.lock | grep "testdata:/:test.proto"
protolock status
protolock commit
protolock status --plugins=_not-a-plugin_ | grep "executable file not found"
- name: check output using plugin-sample-error
run: |
set +o pipefail
protolock status --plugins=plugin-sample-error | grep "some error"
- name: check output using plugin-sample
run: |
set +o pipefail
WARNINGS=$(protolock status --plugins=plugin-sample | wc -l)
if [ "$WARNINGS" != 2 ]; then
exit 1
fi
- name: check output using plugin-sample-wasm
run: |
set +o pipefail
protolock status --plugins=plugin-samples/plugin-sample-wasm/status.wasm | grep "Extism plugin ran"
- name: check output using multiple plugins, with one error expected
run: |
set +o pipefail
WASM=plugin-samples/plugin-sample-wasm/status.wasm
protolock status --plugins=plugin-sample,plugin-sample-error,$WASM | grep "some error"
protolock status --plugins=plugin-sample-error,plugin-sample | grep "some error"
protolock status --plugins=plugin-sample,plugin-sample-error,$WASM | grep "Extism plugin ran"
- name: check output using multiple plugins with errors
run: |
set +o pipefail
ERRS=$(protolock status --plugins=plugin-sample-error,plugin-sample-error | grep "some error" | wc -l)
if [ "$ERRS" != 4 ]; then # (4 = 2 * 2, since errors are now reported using 2 lines)
exit 1
fi
MOREERRS=$(protolock status --plugins=plugin-sample-error,plugin-sample-error,plugin-sample-error | grep "some error" | wc -l)
if [ "$MOREERRS" != 6 ]; then # (6 = 3 * 2, since errors are now reported using 2 lines)
exit 1
fi
- name: remove a test proto file, expect violations.txt to contain data from plugin-sample
run: |
set +o pipefail
rm testdata/test.proto
protolock status --plugins=plugin-sample || true # let this fail, don't stop CI
stat violations.txt
cat violations.txt | grep "Encountered changes in violation of: NoRemovingFieldsWithoutReserve"
- name: check if proto.lock is up-to-date with the .proto files in the tree
run: |
set +o pipefail
cat >testdata/newProto.proto <<EOL
syntax = "proto3";
package testdata;
message newProto {}
EOL
# checkout to HEAD to revert the changes made by previous tests
git reset --hard HEAD
# basic status check should not fail even though the lock file is
# now technically out of date, compared to the protos
protolock status
NOCHECK=$(protolock status --uptodate=false | wc -l) # false=default
if [ "$NOCHECK" != 0 ]; then
exit 1
fi
CHECK=$(protolock status --uptodate=true | wc -l)
if [ "$CHECK" = 0 ]; then
exit 1
fi
- name: check that proto.lock records aggregate options with array values
run: |
set +o pipefail
rm proto.lock && protolock init
cat proto.lock | grep "4.56"
cat proto.lock | grep "7.89"