Skip to content

Commit eb9c856

Browse files
committed
chore(CI): Use github commit status sync integrate workflow
1 parent 09b81d5 commit eb9c856

1 file changed

Lines changed: 72 additions & 18 deletions

File tree

.github/workflows/02-build-obs.yml

Lines changed: 72 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ jobs:
4747
outputs:
4848
pkgname: ${{ steps.pkgname.outputs.pkgname }}
4949
tagsha: ${{ steps.tagsha.outputs.tagsha }}
50+
targeturl: ${{ steps.build.outputs.targeturl }}
5051
steps:
5152
- name: Print Environment
5253
run: export
@@ -117,6 +118,7 @@ jobs:
117118
echo "tagsha=$TAGSHA" >> $GITHUB_OUTPUT
118119
119120
- name: Trigger build
121+
id: build
120122
run: |
121123
set -x
122124
mkdir -p ~/.config/osc
@@ -126,15 +128,19 @@ jobs:
126128
127129
curl -o meta.xml https://raw.githubusercontent.com/deepin-community/Repository-Integration/master/.github/workflows/obs-pkg-meta.tpl
128130
sed -i "s#PKGNAME#${pkgname}#g" meta.xml
131+
targeturl="https://build.deepin.com/project/show/deepin:CI:TestingIntegration:${TOPIC}"
129132
if [ "$COMPONENT" = "main" ]; then
130133
sed -i "s#Testing:COMPONENT#CI:TestingIntegration:${TOPIC}#g" meta.xml
131134
curl -X PUT -u golf66:$OSCPASS -H "Content-type: text/xml" -d @meta.xml "https://build.deepin.com/source/deepin:CI:TestingIntegration:${TOPIC}/$pkgname/_meta"
132135
osc co deepin:CI:TestingIntegration:${TOPIC}/${pkgname} && cd $_
136+
targeturl="https://build.deepin.com/package/live_build_log/deepin:CI:TestingIntegration:${TOPIC}/$pkgname/testing/"
133137
else
134138
sed -i "s#Testing:COMPONENT#CI:TestingIntegration:${TOPIC}:${COMPONENT}#g" meta.xml
135139
curl -X PUT -u golf66:$OSCPASS -H "Content-type: text/xml" -d @meta.xml "https://build.deepin.com/source/deepin:CI:TestingIntegration:${TOPIC}:${COMPONENT}/$pkgname/_meta"
136140
osc co deepin:CI:TestingIntegration:${TOPIC}:${COMPONENT}/${pkgname} && cd $_
141+
targeturl="https://build.deepin.com/package/live_build_log/deepin:CI:TestingIntegration:${TOPIC}:${COMPONENT}/$pkgname/testing/"
137142
fi
143+
echo "targeturl=$targeturl" >> $GITHUB_OUTPUT
138144
139145
needbuild=true
140146
if [ -f _branch_request ];then
@@ -149,6 +155,13 @@ jobs:
149155
sed -i "s#REPO#$REPO#g" _branch_request
150156
sed -i "s#TAGSHA#$TAGSHA#g" _branch_request
151157
osc add _branch_request && osc ci -m "update tag release: $TAGSHA"
158+
else
159+
echo "Trigger Rebuilding"
160+
if [ "$COMPONENT" = "main" ]; then
161+
osc rebuild deepin:CI:TestingIntegration:${TOPIC} ${pkgname}
162+
else
163+
osc rebuild deepin:CI:TestingIntegration:${TOPIC}:${COMPONENT} ${pkgname}
164+
fi
152165
fi
153166
154167
log:
@@ -161,32 +174,73 @@ jobs:
161174
env:
162175
ARCH: ${{ matrix.arch }}
163176
steps:
164-
- name: Install osc
165-
run: |
166-
sudo apt-get update && sudo apt install -y osc
177+
- name: Set commit status as pending
178+
uses: myrotvorets/set-commit-status-action@master
179+
with:
180+
token: ${{ github.token }}
181+
status: pending
182+
context: "${{ needs.build.outputs.pkgname }}_${{ matrix.arch }}_testing_repository_building"
183+
targetUrl: "${{ needs.build.outputs.targeturl }}${{ matrix.arch }}"
184+
sha: ${{ github.event.pull_request.head.sha }}
185+
186+
- name: Wait for build to succeed
187+
uses: cloudposse/github-action-wait-commit-status@main
188+
id: wait-for-build
189+
with:
190+
repository: ${{ github.repository }}
191+
sha: ${{ github.event.pull_request.head.sha }}
192+
status: "${{ needs.build.outputs.pkgname }}_${{ matrix.arch }}_testing_repository_building"
193+
expected_state: "success"
194+
token: ${{ github.token }}
195+
check-retry-interval: 60
196+
check-retry-count: 60
167197

168-
- name: build log tracker
198+
- name: Do something with a build time out
199+
if: steps.wait-for-build.outputs.conclusion == 'timed_out'
200+
id: wait_time_out
169201
run: |
170202
set -x
203+
sudo apt-get update && sudo apt install -y osc
171204
mkdir -p ~/.config/osc
172205
echo "${{ secrets.OSCRC }}" > ~/.config/osc/oscrc
173206
pkgname="${{ needs.build.outputs.pkgname }}"
174207
if [ "$COMPONENT" = "main" ]; then
175208
osc co deepin:CI:TestingIntegration:${TOPIC}/${pkgname} && cd $_
176-
if [ -z $(osc buildinfo testing ${ARCH} |grep "<error>excluded</error>") ]; then
177-
osc buildlog testing ${ARCH}
178-
if [ "$(osc api -X GET /build/deepin:CI:TestingIntegration:${TOPIC}/testing/${ARCH}/${pkgname}/_status |grep 'succeeded')" = "" -a "$(osc api -X GET /build/deepin:CI:TestingIntegration:${TOPIC}/testing/${ARCH}/${pkgname}/_status |grep 'finished')" = "" ];\
179-
then echo "${ARCH} build failed" && -1; else echo "${ARCH} build succeeded"; fi
180-
else
181-
echo "${ARCH} build excluded"
182-
fi
183209
else
184210
osc co deepin:CI:TestingIntegration:${TOPIC}:${COMPONENT}/${pkgname} && cd $_
185-
if [ -z $(osc buildinfo testing ${ARCH} |grep "<error>excluded</error>") ]; then
186-
osc buildlog testing ${ARCH}
187-
if [ "$(osc api -X GET /build/deepin:CI:TestingIntegration:${TOPIC}:${COMPONENT}/testing/${ARCH}/${pkgname}/_status |grep 'succeeded')" = "" -a "$(osc api -X GET /build/deepin:CI:TestingIntegration:${TOPIC}:${COMPONENT}/testing/${ARCH}/${pkgname}/_status |grep 'finished')" = "" ];\
188-
then echo "${ARCH} build failed" && -1; else echo "${ARCH} build succeeded"; fi
189-
else
190-
echo "${ARCH} build excluded"
191-
fi
192211
fi
212+
213+
timeouturl="${{ needs.build.outputs.targeturl }}${{ matrix.arch }}"
214+
description="wait build complete timeout"
215+
status="pending"
216+
buildresult=$(osc results -a ${ARCH} -r testing |awk '{print $3}')
217+
if [ "$buildresult" = "succeeded" ];then
218+
status="success"
219+
description=""
220+
elif [ "$buildresult" = "excluded" ]; then
221+
status="success"
222+
description="build excluded"
223+
timeouturl=""
224+
elif [ "$buildresult" = "failed" ]; then
225+
status="failure"
226+
description=""
227+
fi
228+
echo "timeouturl=$timeouturl" >> $GITHUB_OUTPUT
229+
echo "description=$description" >> $GITHUB_OUTPUT
230+
echo "status=$status" >> $GITHUB_OUTPUT
231+
232+
- name: Update status build status as timeout
233+
if: steps.wait-for-build.outputs.conclusion == 'timed_out'
234+
uses: myrotvorets/set-commit-status-action@master
235+
with:
236+
token: ${{ github.token }}
237+
status: ${{ steps.wait_time_out.outputs.status }}
238+
context: "${{ needs.build.outputs.pkgname }}_${{ matrix.arch }}_testing_repository_building"
239+
targetUrl: ${{ steps.wait_time_out.outputs.timeouturl }}
240+
sha: ${{ github.event.pull_request.head.sha }}
241+
description: ${{ steps.wait_time_out.outputs.description }}
242+
243+
#- name: report build error at action
244+
# if: steps.wait_time_out.outputs.status != 'success' || steps.wait-for-build.outputs.conclusion == 'failure'
245+
# run: |
246+
# exit -1

0 commit comments

Comments
 (0)