Skip to content

Commit 787bac7

Browse files
committed
chore: cherry pick pre check workflow (#10286)
(cherry picked from commit 637c004)
1 parent dadf489 commit 787bac7

3 files changed

Lines changed: 96 additions & 5 deletions

File tree

.github/workflows/cherry-pick.yml

Lines changed: 90 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,101 @@ on:
66

77
env:
88
GH_TOKEN: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
9+
GO_VERSION: "1.25"
910

1011
jobs:
11-
cherry-pick:
12+
trigger-mode:
1213
if: github.event.issue.pull_request != '' && contains(github.event.comment.body, '/cherry-pick')
1314
runs-on: ubuntu-latest
15+
outputs:
16+
trigger-mode: ${{ steps.get_trigger_mode.outputs.trigger_mode }}
17+
steps:
18+
- uses: actions/checkout@v4
19+
with:
20+
token: ${{ env.GH_TOKEN }}
21+
fetch-depth: 0
22+
23+
- name: Simulation Cherry Pick
24+
uses: apecloud-inc/gha-cherry-pick@v2
25+
env:
26+
GITHUB_TOKEN: ${{ env.GH_TOKEN }}
27+
28+
- name: Get trigger mode
29+
id: get_trigger_mode
30+
run: |
31+
TARGET_BRANCH=$(jq -r ".comment.body" "$GITHUB_EVENT_PATH" | awk '{ print $2 }' | tr -d '[:space:]')
32+
echo "TARGET_BRANCH:$TARGET_BRANCH"
33+
34+
TRIGGER_MODE=`bash .github/utils/utils.sh --type 6 \
35+
--branch-name "${TARGET_BRANCH}" \
36+
--base-branch "origin/${TARGET_BRANCH}"`
37+
38+
echo "TRIGGER_MODE:$TRIGGER_MODE"
39+
echo trigger_mode=$TRIGGER_MODE >> $GITHUB_OUTPUT
40+
41+
cherry-pick-pre-check:
42+
needs: [ trigger-mode ]
43+
if: contains(needs.trigger-mode.outputs.trigger-mode, '[test]')
44+
runs-on: ubuntu-latest
45+
timeout-minutes: ${{ (matrix.ops == 'lint' && 6) || (matrix.ops == 'manifests' && 5) || 2 }}
46+
strategy:
47+
fail-fast: true
48+
matrix:
49+
ops: [ 'manifests', 'mod-vendor', 'generate', 'lint' ]
50+
steps:
51+
- uses: actions/checkout@v4
52+
with:
53+
token: ${{ env.GH_TOKEN }}
54+
fetch-depth: 0
55+
56+
- name: Simulation Cherry Pick
57+
uses: apecloud-inc/gha-cherry-pick@v2
58+
env:
59+
GITHUB_TOKEN: ${{ env.GH_TOKEN }}
60+
61+
- name: install lib
62+
run: |
63+
sudo rm -f /etc/apt/sources.list.d/microsoft-prod.list
64+
sudo apt-get update
65+
sudo apt-get install -y --no-install-recommends \
66+
libbtrfs-dev \
67+
libdevmapper-dev
68+
69+
- name: Set up Go
70+
uses: actions/setup-go@v4
71+
with:
72+
go-version: "${{ env.GO_VERSION }}"
73+
74+
- name: Install golangci-lint
75+
if: matrix.ops == 'lint'
76+
run: |
77+
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v2.8.0
78+
79+
- name: make ${{ matrix.ops }}
80+
run: |
81+
BEFORE_PICK=$(git rev-parse HEAD)
82+
make ${{ matrix.ops }}
83+
FILE_CHANGES=`git diff --name-only ${BEFORE_PICK}`
84+
if [[ ("${{ matrix.ops }}" == 'generate' || "${{ matrix.ops }}" == 'manifests') && -n "$FILE_CHANGES" ]]; then
85+
echo $FILE_CHANGES
86+
echo "make "${{ matrix.ops }}" causes inconsistent files"
87+
exit 1
88+
fi
89+
90+
cherry-pick:
91+
needs: [ trigger-mode, cherry-pick-pre-check ]
92+
if: always() && github.event.issue.pull_request != ''
93+
&& contains(github.event.comment.body, '/cherry-pick')
94+
&& needs.trigger-mode.result == 'success'
95+
runs-on: ubuntu-latest
1496
steps:
97+
- name: cherry-pick pre check
98+
run: |
99+
if [[ "${{ needs.cherry-pick-pre-check.result }}" == "failure" || "${{ needs.cherry-pick-pre-check.result }}" == "cancelled" ]]; then
100+
echo "cherry pick pre check fail"
101+
exit 1
102+
fi
103+
15104
- uses: actions/checkout@v4
16105
with:
17106
token: ${{ env.GH_TOKEN }}

.github/workflows/cicd-pull-request.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ jobs:
7777
needs: trigger-mode
7878
if: ${{ contains(needs.trigger-mode.outputs.trigger-mode, '[test]') }}
7979
runs-on: ubuntu-latest
80+
timeout-minutes: ${{ (matrix.ops == 'test' && 15) || (matrix.ops == 'lint' && 6) || (matrix.ops == 'manifests' && 5) || 2 }}
8081
strategy:
8182
fail-fast: true
8283
matrix:
@@ -85,7 +86,7 @@ jobs:
8586
- uses: actions/checkout@v4
8687
- name: install lib
8788
run: |
88-
sudo rm /etc/apt/sources.list.d/microsoft-prod.list
89+
sudo rm -f /etc/apt/sources.list.d/microsoft-prod.list
8990
sudo apt-get update
9091
sudo apt-get install -y --no-install-recommends \
9192
libbtrfs-dev \

.github/workflows/cicd-push.yml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ jobs:
7272
fetch-depth: 0
7373
- name: install pcregrep
7474
run: |
75-
sudo rm /etc/apt/sources.list.d/microsoft-prod.list
75+
sudo rm -f /etc/apt/sources.list.d/microsoft-prod.list
7676
sudo apt-get update
7777
sudo apt-get install pcregrep
7878
@@ -102,6 +102,7 @@ jobs:
102102
needs: trigger-mode
103103
if: contains(needs.trigger-mode.outputs.trigger-mode, '[test]')
104104
runs-on: ubuntu-latest
105+
timeout-minutes: ${{ (matrix.ops == 'test' && 15) || (matrix.ops == 'lint' && 6) || (matrix.ops == 'manifests' && 5) || 2 }}
105106
strategy:
106107
fail-fast: true
107108
matrix:
@@ -110,7 +111,7 @@ jobs:
110111
- uses: actions/checkout@v4
111112
- name: install lib
112113
run: |
113-
sudo rm /etc/apt/sources.list.d/microsoft-prod.list
114+
sudo rm -f /etc/apt/sources.list.d/microsoft-prod.list
114115
sudo apt-get update
115116
sudo apt-get install -y --no-install-recommends \
116117
libbtrfs-dev \
@@ -236,7 +237,7 @@ jobs:
236237
- uses: actions/checkout@v4
237238
- name: install lib
238239
run: |
239-
sudo rm /etc/apt/sources.list.d/microsoft-prod.list
240+
sudo rm -f /etc/apt/sources.list.d/microsoft-prod.list
240241
sudo apt-get update
241242
sudo apt-get install -y --no-install-recommends \
242243
libbtrfs-dev \

0 commit comments

Comments
 (0)