Skip to content

Commit 719681f

Browse files
authored
Adopt new paths filter and refactor CI (#181)
1 parent 23debb3 commit 719681f

10 files changed

Lines changed: 282 additions & 335 deletions

File tree

.asf.yaml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,3 +28,12 @@ github:
2828
squash: true
2929
merge: false
3030
rebase: false
31+
protected_branches:
32+
master:
33+
required_status_checks:
34+
strict: true
35+
contexts:
36+
- Required
37+
required_pull_request_reviews:
38+
dismiss_stale_reviews: true
39+
required_approving_review_count: 1

.github/file-filters.txt

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Licensed to the Apache Software Foundation (ASF) under one
2+
# or more contributor license agreements. See the NOTICE file
3+
# distributed with this work for additional information
4+
# regarding copyright ownership. The ASF licenses this file
5+
# to you under the Apache License, Version 2.0 (the
6+
# "License"); you may not use this file except in compliance
7+
# with the License. You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
17+
**/*.go
18+
go.mod
19+
.golangci.yml
20+
.github/**/*

.github/file-filters.yml

Lines changed: 0 additions & 25 deletions
This file was deleted.

.github/workflows/CI.yaml

Lines changed: 199 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,199 @@
1+
#
2+
# Licensed to the Apache Software Foundation (ASF) under one
3+
# or more contributor license agreements. See the NOTICE file
4+
# distributed with this work for additional information
5+
# regarding copyright ownership. The ASF licenses this file
6+
# to you under the Apache License, Version 2.0 (the
7+
# "License"); you may not use this file except in compliance
8+
# with the License. You may obtain a copy of the License at
9+
#
10+
# http://www.apache.org/licenses/LICENSE-2.0
11+
#
12+
# Unless required by applicable law or agreed to in writing,
13+
# software distributed under the License is distributed on an
14+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
# KIND, either express or implied. See the License for the
16+
# specific language governing permissions and limitations
17+
# under the License.
18+
#
19+
name: CI
20+
21+
on:
22+
pull_request:
23+
push:
24+
branches:
25+
- master
26+
schedule:
27+
- cron: "0 18 * * *" # TimeZone: UTC 0
28+
29+
concurrency:
30+
group: skywalking-cli-${{ github.event.pull_request.number || github.ref }}
31+
cancel-in-progress: true
32+
33+
jobs:
34+
check-license:
35+
name: License header
36+
if: (github.event_name == 'schedule' && github.repository == 'apache/skywalking-cli') || (github.event_name != 'schedule')
37+
runs-on: ubuntu-latest
38+
steps:
39+
- uses: actions/checkout@v3
40+
41+
- name: Check License Header
42+
uses: apache/skywalking-eyes@5dfa68f93380a5e57259faaf95088b7f133b5778
43+
env:
44+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
45+
46+
- name: Setup Go
47+
uses: actions/setup-go@v4
48+
with:
49+
go-version: "1.18"
50+
51+
- name: Check Dependencies License
52+
run: make dependency-license
53+
54+
55+
changes:
56+
runs-on: ubuntu-latest
57+
if: github.event_name != 'schedule'
58+
timeout-minutes: 10
59+
outputs:
60+
cli: ${{ steps.filter-cli.outputs.any_modified }}
61+
steps:
62+
- uses: actions/checkout@v3 # required for push event
63+
with:
64+
fetch-depth: 0
65+
- name: Check for CLI source changes
66+
id: filter-cli
67+
# The GHA version is pinned by infra
68+
uses: tj-actions/changed-files@v35.9.2
69+
with:
70+
files_from_source_file: .github/file-filters.txt
71+
- name: List all modified files
72+
if: steps.filter-cli.outputs.any_modified == 'true'
73+
run: |
74+
echo "Files that have changed or modified:"
75+
echo "Filter-cli: ${{ steps.filter-cli.outputs.all_changed_and_modified_files }}"
76+
77+
78+
golang-lint:
79+
name: Golang Lint
80+
runs-on: ubuntu-latest
81+
needs: [changes]
82+
if: |
83+
( always() && ! cancelled() ) &&
84+
((github.event_name == 'schedule' && github.repository == 'apache/skywalking-cli') || needs.changes.outputs.cli == 'true')
85+
steps:
86+
- uses: actions/checkout@v3
87+
- name: Set up Go
88+
uses: actions/setup-go@v4
89+
with:
90+
go-version: 1.18
91+
92+
- name: golangci-lint
93+
uses: golangci/golangci-lint-action@v3
94+
with:
95+
version: v1.50.0
96+
args: --timeout 5m
97+
98+
99+
build:
100+
name: Build
101+
needs: [changes]
102+
runs-on: ubuntu-latest
103+
if: |
104+
( always() && ! cancelled() ) &&
105+
((github.event_name == 'schedule' && github.repository == 'apache/skywalking-cli') || needs.changes.outputs.cli == 'true')
106+
steps:
107+
- uses: actions/checkout@v3
108+
- name: Set up Go
109+
uses: actions/setup-go@v4
110+
with:
111+
go-version: 1.18
112+
113+
- name: Check code generation
114+
run: make check-codegen
115+
116+
- uses: actions/upload-artifact@v3
117+
if: failure()
118+
with:
119+
name: check-diff
120+
path: /tmp/swctl/check.diff
121+
122+
- name: Build
123+
run: make build -j3
124+
125+
- name: Build Docker images
126+
run: make docker
127+
128+
129+
command-tests:
130+
name: Command Tests
131+
runs-on: ubuntu-latest
132+
needs: [changes]
133+
if: |
134+
( always() && ! cancelled() ) &&
135+
((github.event_name == 'schedule' && github.repository == 'apache/skywalking-cli') || needs.changes.outputs.cli == 'true')
136+
strategy:
137+
matrix:
138+
oap:
139+
- 6fa89c79917cb10dbf48591c46abee3b513a2bab # March 28th
140+
steps:
141+
- uses: actions/checkout@v3
142+
- name: Set up Go
143+
uses: actions/setup-go@v4
144+
with:
145+
go-version: 1.18
146+
147+
- name: Test commands
148+
uses: apache/skywalking-infra-e2e@2b3aa53dbba73909730b211d5b8065abc74b56ad
149+
env:
150+
OAP_TAG: ${{ matrix.oap }}
151+
with:
152+
e2e-file: test/cases/basic/test.yaml
153+
154+
155+
unit-tests:
156+
name: Unit Tests
157+
runs-on: ubuntu-latest
158+
needs: [changes]
159+
if: |
160+
( always() && ! cancelled() ) &&
161+
((github.event_name == 'schedule' && github.repository == 'apache/skywalking-cli') || needs.changes.outputs.cli == 'true')
162+
steps:
163+
- uses: actions/checkout@v3
164+
- name: setup go
165+
uses: actions/setup-go@v4
166+
with:
167+
go-version: '1.18'
168+
169+
- name: run unit tests and report coverage
170+
working-directory: ./
171+
run: |
172+
make coverage
173+
174+
required:
175+
if: always()
176+
name: Required
177+
needs:
178+
- check-license
179+
- golang-lint
180+
- build
181+
- command-tests
182+
- unit-tests
183+
runs-on: ubuntu-latest
184+
timeout-minutes: 10
185+
steps:
186+
- name: Merge Requirement
187+
run: |
188+
execute=${{ needs.changes.outputs.cli }}
189+
checkLicense=${{ needs.check-license.result }}
190+
[[ ${checkLicense} == 'success' ]] || exit -1;
191+
golangLint=${{ needs.golang-lint.result }};
192+
build=${{ needs.build.result }};
193+
commandTests=${{ needs.command-tests.result }};
194+
unitTests=${{ needs.unit-tests.result }};
195+
[[ ${golangLint} == 'success' ]] || [[ ${execute} != 'true' && ${golangLint} == 'skipped' ]] || exit -2;
196+
[[ ${build} == 'success' ]] || [[ ${execute} != 'true' && ${build} == 'skipped' ]] || exit -3;
197+
[[ ${commandTests} == 'success' ]] || [[ ${execute} != 'true' && ${commandTests} == 'skipped' ]] || exit -4;
198+
[[ ${unitTests} == 'success' ]] || [[ ${execute} != 'true' && ${unitTests} == 'skipped' ]] || exit -5;
199+
exit 0;

.github/workflows/command-tests.yml

Lines changed: 0 additions & 55 deletions
This file was deleted.

.github/workflows/go.yml

Lines changed: 0 additions & 58 deletions
This file was deleted.

0 commit comments

Comments
 (0)