forked from viamrobotics/goutils
-
Notifications
You must be signed in to change notification settings - Fork 0
133 lines (115 loc) · 3.96 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
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
name: Build and Test
on:
workflow_dispatch:
push:
branches: [ main ]
pull_request_target:
branches: [ main ]
types: [ labeled ]
jobs:
test_passing:
name: All Tests Passing
needs: [build_and_test]
runs-on: ubuntu-latest
if: always()
steps:
- name: Check Results
run: |
echo Main Tests: ${{ needs.build_and_test.result }}
[ "${{ needs.build_and_test.result }}" == "success" ]
build_and_test:
name: Build and Test
runs-on: ubuntu-latest
timeout-minutes: 20
if: |
github.event_name == 'workflow_dispatch' || github.event_name == 'push' ||
(github.event_name == 'pull_request_target' && github.event.label.name == 'safe to test' && contains(github.event.pull_request.labels.*.name, 'safe to test'))
steps:
- name: Setup go
uses: actions/setup-go@v5
with:
go-version: '1.21'
- name: Setup node
uses: actions/setup-node@v3
with:
node-version: 18
- name: Install Protoc
uses: arduino/setup-protoc@v3
with:
version: "21.x"
- name: Install protoc-gen-js and plugins
run: npm install -g protoc-gen-js protoc-gen-grpc-web
- name: Check out main branch code
if: github.event_name == 'workflow_dispatch' || github.event_name == 'push'
uses: actions/checkout@v3
with:
fetch-depth: 2
- name: Check out PR branch code
if: github.event_name == 'pull_request_target'
uses: actions/checkout@v3
with:
ref: ${{ github.event.pull_request.head.sha }}
fetch-depth: 2
- name: Set main env vars
if: github.event_name != 'pull_request_target'
run: |
echo "GITHUB_X_HEAD_SHA=${GITHUB_SHA}" >> $GITHUB_ENV
echo "GITHUB_X_HEAD_REF=${GITHUB_REF_NAME}" >> $GITHUB_ENV
- name: Set PR env vars
if: github.event_name == 'pull_request_target'
env:
GITHUB_HEAD_REF_SAN: ${{ github.event.pull_request.head.label }}
run: |
echo "GITHUB_X_HEAD_SHA=${{ github.event.pull_request.head.sha }}" >> $GITHUB_ENV
echo "GITHUB_X_HEAD_REF=${GITHUB_HEAD_REF_SAN}" >> $GITHUB_ENV
echo "GITHUB_X_PR_BASE_SHA=${{ github.event.pull_request.base.sha }}" >> $GITHUB_ENV
echo "GITHUB_X_PR_BASE_REF=${{ github.event.pull_request.base.ref }}" >> $GITHUB_ENV
- name: Verify no uncommitted changes from "make build lint"
run: |
git init
git add .
make build lint
GEN_DIFF=$(git status -s)
if [ -n "$GEN_DIFF" ]; then
echo '"make build lint" resulted in changes not in git' 1>&2
git status
exit 1
fi
- name: Test js library
run: CI=true make test-web
- if: failure()
name: Upload js test report
uses: actions/upload-artifact@v3
with:
name: playwright-report
path: rpc/examples/echo/playwright-report
retention-days: 30
- name: Test go library
env:
TEST_MONGODB_URI: ${{ secrets.TEST_MONGODB_URI }}
MONGODB_TEST_OUTPUT_URI: ${{ secrets.MONGODB_TEST_OUTPUT_URI }}
run: |
echo "${{ secrets.ARTIFACT_GOOGLE_APPLICATION_CREDENTIALS }}" | base64 -d > artifact_google_creds.json
export ARTIFACT_GOOGLE_APPLICATION_CREDENTIALS=`pwd`/artifact_google_creds.json
make cover
- name: Upload test.json
if: always()
uses: actions/upload-artifact@v3
with:
name: test.json
path: json.log
retention-days: 30
# this one runs as root for CAP_SETUID
- name: test run-as-user
env:
TEST_SUBPROC_USER: subproc_user
run: |
sudo useradd $TEST_SUBPROC_USER
sudo go test -v ./pexec -run TestManagedProcessStart
- name: Add Coverage PR Comment
uses: marocchino/[email protected]
if: github.event_name == 'pull_request'
with:
recreate: true
path: code-coverage-results.md
GITHUB_TOKEN: ${{ secrets.GIT_ACCESS_TOKEN }}