-
Notifications
You must be signed in to change notification settings - Fork 13
184 lines (153 loc) · 5.21 KB
/
tests.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
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
name: Tests
on:
push:
branches: [main]
paths:
- "client/scripts/ci"
- "client/scripts/minio"
- ".github/workflows/tests.yml"
- "**/*.go"
- go.mod
schedule:
- cron: "0 8 * * *"
pull_request:
repository_dispatch:
types: [tests]
workflow_dispatch:
jobs:
tests:
name: Tests
strategy:
fail-fast: false
matrix:
directory: [server]
os: [ubuntu-latest]
runs-on: ${{ matrix.os }}
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version-file: ${{ matrix.directory }}/go.mod
- name: Prepare environment
run: |
# coverage directory
export TRDL_TEST_COVERAGE_DIR=$GITHUB_WORKSPACE/tests_coverage/tests/${{ matrix.os }}/${{ matrix.directory }}
mkdir -p $TRDL_TEST_COVERAGE_DIR
echo TRDL_TEST_COVERAGE_DIR=$TRDL_TEST_COVERAGE_DIR >> $GITHUB_ENV
# git user
./e2e/scripts/ci/git.sh
# install gpg
sudo apt-get update
sudo apt-get install gpg
# install git-signatures
git clone https://github.com/werf/3p-git-signatures.git
cd 3p-git-signatures
make install
echo "~/.local/bin" >> $GITHUB_PATH
# install ginkgo
go install github.com/onsi/ginkgo/v2/[email protected]
shell: bash
- name: Test
working-directory: ${{ matrix.directory }}
run: ginkgo --vet=off --race --keep-going --cover --coverpkg=./... --output-dir=$TRDL_TEST_COVERAGE_DIR ./...
- name: Upload coverage artifact
uses: actions/upload-artifact@v4
with:
name: tests_coverage
path: tests_coverage
e2e_tests:
name: End-to-end tests
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest]
runs-on: ${{ matrix.os }}
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version-file: e2e/go.mod
- name: Prepare environment
working-directory: e2e
run: |
# coverage directory
export TRDL_TEST_COVERAGE_DIR=$GITHUB_WORKSPACE/tests_coverage/e2e/${{ matrix.os }}
mkdir -p $TRDL_TEST_COVERAGE_DIR
echo TRDL_TEST_COVERAGE_DIR=$TRDL_TEST_COVERAGE_DIR >> $GITHUB_ENV
# coverage trdl binary
./scripts/ci/trdl_with_coverage.sh
export TRDL_TEST_BINARY_PATH=$GITHUB_WORKSPACE/e2e/bin/tests/trdl_with_coverage
chmod +x $TRDL_TEST_BINARY_PATH
echo TRDL_TEST_BINARY_PATH=$TRDL_TEST_BINARY_PATH >> $GITHUB_ENV
# git user
./scripts/ci/git.sh
# install gpg
sudo apt-get update
sudo apt-get install gpg
# install git-signatures
git clone https://github.com/werf/3p-git-signatures.git
cd 3p-git-signatures
make install
echo "~/.local/bin" >> $GITHUB_PATH
go install github.com/onsi/ginkgo/v2/[email protected]
- name: Test
working-directory: e2e
run: ginkgo -p --keep-going --cover --coverpkg=../client/...,../server/... --output-dir=$TRDL_TEST_COVERAGE_DIR ./...
- name: Upload coverage artifact
uses: actions/upload-artifact@v4
with:
name: e2e_coverage
path: tests_coverage
upload_coverage:
name: Upload coverage
needs:
- tests
- e2e_tests
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version-file: e2e/go.mod
- name: Download coverage artifact
uses: actions/download-artifact@v4
with:
path: tests_coverage
- name: Prepare environment
run: |
curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
chmod +x ./cc-test-reporter
go install github.com/wadey/gocovmerge@latest
echo TRDL_TEST_COVERAGE_DIR=tests_coverage >> $GITHUB_ENV
- name: Prepare coverage file
run: |
find $TRDL_TEST_COVERAGE_DIR -type f -exec \
sed -i -e "s|/home/ubuntu/actions-runner/_work/werf/trdl|github.com/werf/trdl|g" {} +
coverage_files=$(find $TRDL_TEST_COVERAGE_DIR -type f)
gocovmerge ${coverage_files[@]} > coverage.out
- name: Format and upload
run: |
export GIT_BRANCH=${GITHUB_REF:11}
export GIT_COMMIT_SHA=$GITHUB_SHA
./cc-test-reporter format-coverage \
-t=gocov \
-p=github.com/werf/trdl/ \
coverage.out
./cc-test-reporter upload-coverage
env:
CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }}
notification:
name: Notification
if: always()
needs: upload_coverage
uses: werf/common-ci/.github/workflows/notification.yml@main
secrets:
loopNotificationGroup: ${{ secrets.LOOP_NOTIFICATION_GROUP }}
webhook: ${{ secrets.LOOP_NOTIFICATION_WEBHOOK }}
notificationChannel: ${{ secrets.LOOP_NOTIFICATION_CHANNEL }}