-
Notifications
You must be signed in to change notification settings - Fork 183
174 lines (155 loc) · 5.46 KB
/
github-actions.yml
File metadata and controls
174 lines (155 loc) · 5.46 KB
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
#
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
#
name: CI
on:
push:
pull_request:
# cancel in-progress runs for the same branch or PR
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
jobs:
license-check-and-import-format:
name: License Check and Import Format
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
- name: Cache imports-formatter
id: cache-go-bin
uses: actions/cache@v4
with:
path: ~/go/bin
key: ${{ runner.os }}-go-imports-formatter-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-imports-formatter-
- name: Download imports-formatter if not cached
if: steps.cache-go-bin.outputs.cache-hit != 'true'
run: |
go install github.com/dubbogo/tools/cmd/imports-formatter@latest
- name: Check License Header
uses: apache/skywalking-eyes/header@main # NOSONAR
- name: Check Golang fmt
run: |
gofmt -s -w .
git diff --exit-code
- name: Check Import Formatting
run: |
imports-formatter
git diff --exit-code
golangci:
needs: license-check-and-import-format
name: Golang Lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
- uses: actions/setup-go@v6
with:
go-version-file: 'go.mod'
cache: true
- name: golangci-lint
uses: golangci/golangci-lint-action@v8 # NOSONAR
with:
version: v2.4.0
unit-test:
needs: golangci
name: Unit Test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
- uses: actions/setup-go@v6
with:
go-version-file: 'go.mod'
cache: true
- name: Cache Zookeeper JAR
id: cache-zk-jar
uses: actions/cache@v4
with:
path: pkg/registry/zookeeper-4unittest/contrib/fatjar
key: ${{ runner.os }}-zookeeper-jar-3.4.9
- name: Download Zookeeper JAR if not cached
if: steps.cache-zk-jar.outputs.cache-hit != 'true'
run: |
echo "Cache miss. Downloading Zookeeper JAR..."
zkJarName="zookeeper-3.4.9-fatjar.jar"
remoteJarUrl="https://github.com/dubbogo/resources/raw/master/zookeeper-4unitest/contrib/fatjar/${zkJarName}"
zkJarPath="pkg/registry/zookeeper-4unittest/contrib/fatjar"
mkdir -p ${zkJarPath}
wget -P "${zkJarPath}" ${remoteJarUrl}
- name: Run Tests and Generate Coverage
run: |
go mod download
go test ./... -gcflags=-l -race -coverprofile=coverage.txt -covermode=atomic
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v4 # NOSONAR
with:
token: ${{ secrets.CODECOV_TOKEN }}
file: ./coverage.txt
flags: unittests
integration-test:
needs: unit-test
name: Integration Test
runs-on: ubuntu-latest
outputs:
output1: ${{ steps.samples_head.outputs.sha }}
env:
SAMPLES_BRANCH: main
SAMPLES_REPO_URL: https://github.com/apache/dubbo-go-pixiu-samples.git
SAMPLES_CLONE_DIR: integrate_samples
steps:
- uses: actions/checkout@v5
- uses: actions/setup-go@v6
with:
go-version-file: 'go.mod'
cache: true
- name: Resolve samples HEAD
id: samples_head
shell: bash
run: |
set -euo pipefail
head_sha="$(git ls-remote --heads "$SAMPLES_REPO_URL" "$SAMPLES_BRANCH" | awk '{print $1}')"
if [ -z "$head_sha" ]; then
echo "Failed to resolve HEAD of $SAMPLES_REPO_URL $SAMPLES_BRANCH" >&2
exit 1
fi
echo "sha=$head_sha" >> "$GITHUB_OUTPUT"
- name: Cache dubbo-go-pixiu-samples
id: cache_samples
uses: actions/cache@v4
with:
path: ${{ env.SAMPLES_CLONE_DIR }}
key: ${{ runner.os }}-samples-${{ steps.samples_head.outputs.sha }}
restore-keys: |
${{ runner.os }}-samples-
- name: Clone dubbo-go-pixiu-samples if not cached
if: steps.cache_samples.outputs.cache-hit != 'true'
shell: bash
run: |
if [ -d "$SAMPLES_CLONE_DIR" ]; then
rm -rf "$SAMPLES_CLONE_DIR"
fi
git clone --depth 1 -b "$SAMPLES_BRANCH" "$SAMPLES_REPO_URL" "$SAMPLES_CLONE_DIR"
- name: Wire samples to local pixiu
working-directory: ${{ env.SAMPLES_CLONE_DIR }}
run: |
go mod edit -replace=github.com/apache/dubbo-go-pixiu=${{ github.workspace }}
go mod tidy
- name: Run Integration Tests
run: |
chmod +x start_integrate_test.sh
./start_integrate_test.sh