-
Notifications
You must be signed in to change notification settings - Fork 378
167 lines (158 loc) · 4.99 KB
/
ci-it-noneed.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
# Copyright (c) 2021 Terminus, Inc.
#
# This program is free software: you can use, redistribute, and/or modify
# it under the terms of the GNU Affero General Public License, version 3
# or later ("AGPL"), as published by the Free Software Foundation.
#
# This program is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
name: CI AND IT
on:
push:
tags:
- v*
branches:
- develop
- master
- release/*
paths:
- '**'
- '!**.go'
- '!**/go.mod'
- '!**/go.sum'
- '!**/*.proto'
pull_request:
paths:
- '**'
- '!**.go'
- '!**/go.mod'
- '!**/go.sum'
- '!**/*.proto'
jobs:
CHECK-CHANGED-FILES:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0 # OR "2" -> To retrieve the preceding commit.
- name: Get changed files
id: changed-files
uses: tj-actions/changed-files@v21
- name: List all changed files
id: check
run: |
for file in ${{ steps.changed-files.outputs.all_changed_files }}; do
ext="${file##*.}"
echo "file: $file, ext: $ext"
echo "::set-output name=have-${ext}::true"
base_filename=$(basename "${file}")
if [[ "${base_filename}" == "go.mod" || "${base_filename}" == "go.sum" ]]; then
echo "::set-output name=have-go::true"
fi
if [[ "$ext" == "proto" ]]; then
echo "::set-output name=have-go::true"
fi
if [[ "$file" == .erda/migrations/* ]]; then
echo "::set-output name=have-dbmigration::true"
fi
done
outputs:
have-go: ${{ steps.check.outputs.have-go }}
have-dbmigration: ${{ steps.check.outputs.have-dbmigration }}
# PATCH-PR-CHECK-STATUS:
# runs-on: ubuntu-latest
# needs: CHECK-CHANGED-FILES
# if: needs.CHECK-CHANGED-FILES.outputs.have-go != 'true'
# env:
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# steps:
# - run: echo "No CODE-TEST required"
# - name: Fetch check run ids
# id: fetch
# uses: octokit/[email protected]
# with:
# repo: ${{ github.repository }}
# run_id: ${{ github.run_id }}
# route: GET /repos/{repo}/actions/runs/{run_id}/jobs
# - name: Echo check run ids
# run: |
# echo '${{ toJSON(fromJSON(steps.fetch.outputs.data)) }}'
# for run_id in $(jq '.[]' <<< '${{ toJSON(fromJSON(steps.fetch.outputs.data).jobs.*.id) }}'); do
# echo ${run_id}
# done
PREPARE:
runs-on: ubuntu-latest
needs: CHECK-CHANGED-FILES
if: ${{ needs.CHECK-CHANGED-FILES.outputs.have-go != 'true' }}
steps:
- run: echo "No PREPARE required"
CI:
runs-on: ubuntu-latest
needs: CHECK-CHANGED-FILES
if: ${{ needs.CHECK-CHANGED-FILES.outputs.have-go != 'true' }}
steps:
- run: echo "No CI required"
DB-MIGRATION-CHECK:
runs-on: ubuntu-latest
needs: CHECK-CHANGED-FILES
if: ${{ needs.CHECK-CHANGED-FILES.outputs.have-dbmigration == 'true' }}
container:
image: registry.erda.cloud/erda/gohub:1.0.9.alpha.1
steps:
- name: Clone repo
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Debug
run: |
ls -l /__w/erda/erda
git config --global --add safe.directory /__w/erda/erda
- name: Prepare
run: HOME=/root make proto-go-in-local && make prepare
- name: Run SQL Lint
run: make miglint
CODE-CHECK:
runs-on: ubuntu-latest
needs: CHECK-CHANGED-FILES
if: ${{ needs.CHECK-CHANGED-FILES.outputs.have-go != 'true' }}
steps:
- run: echo "No CODE-CHECK required"
CODE-TEST:
runs-on: ubuntu-latest
needs: CHECK-CHANGED-FILES
if: ${{ needs.CHECK-CHANGED-FILES.outputs.have-go != 'true' }}
steps:
- run: echo "No CODE-TEST required"
CODE-COV:
runs-on: ubuntu-latest
needs: CHECK-CHANGED-FILES
if: needs.CHECK-CHANGED-FILES.outputs.have-go != 'true'
steps:
- run: echo "No CODE-COV required"
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Download codecov reports from another workflow
uses: dawidd6/action-download-artifact@v2
with:
workflow: ci-it.yml
workflow_conclusion: success
name: pure-coverage
path: ./coverage/
search_artifacts: true
- name: very quick codecov
shell: bash
run: |
rm codecov.yml
cat <<-EOF >codecov.yml
coverage:
status:
project: off
patch: off
EOF
cat codecov.yml
curl -s https://codecov.io/bash | bash -s - -s ./coverage/