Skip to content

Commit 8eda856

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

File tree

1 file changed

+65
-18
lines changed

1 file changed

+65
-18
lines changed

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

Lines changed: 65 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
@@ -161,32 +167,73 @@ jobs:
161167
env:
162168
ARCH: ${{ matrix.arch }}
163169
steps:
164-
- name: Install osc
165-
run: |
166-
sudo apt-get update && sudo apt install -y osc
170+
- name: Set commit status as pending
171+
uses: myrotvorets/set-commit-status-action@master
172+
with:
173+
token: ${{ github.token }}
174+
status: pending
175+
context: "${{ needs.build.outputs.pkgname }}_${{ matrix.arch }}_testing_repository_building"
176+
targetUrl: "${{ needs.build.outputs.targeturl }}${{ matrix.arch }}"
177+
sha: ${{ github.event.pull_request.head.sha }}
178+
179+
- name: Wait for build to succeed
180+
uses: cloudposse/github-action-wait-commit-status@main
181+
id: wait-for-build
182+
with:
183+
repository: ${{ github.repository }}
184+
sha: ${{ github.event.pull_request.head.sha }}
185+
status: "${{ needs.build.outputs.pkgname }}_${{ matrix.arch }}_testing_repository_building"
186+
expected_state: "success"
187+
token: ${{ github.token }}
188+
check-retry-interval: 60
189+
check-retry-count: 60
167190

168-
- name: build log tracker
191+
- name: Do something with a build time out
192+
if: steps.wait-for-build.outputs.conclusion == 'timed_out'
193+
id: wait_time_out
169194
run: |
170195
set -x
196+
sudo apt-get update && sudo apt install -y osc
171197
mkdir -p ~/.config/osc
172198
echo "${{ secrets.OSCRC }}" > ~/.config/osc/oscrc
173199
pkgname="${{ needs.build.outputs.pkgname }}"
174200
if [ "$COMPONENT" = "main" ]; then
175201
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
183202
else
184203
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
192204
fi
205+
206+
timeouturl="${{ needs.build.outputs.targeturl }}${{ matrix.arch }}"
207+
description="wait build complete timeout"
208+
status="pending"
209+
buildresult=$(osc results -a ${ARCH} -r testing |awk '{print $3}')
210+
if [ "$buildresult" = "succeeded" ];then
211+
status="success"
212+
description=""
213+
elif [ "$buildresult" = "excluded" ]; then
214+
status="success"
215+
description="build excluded"
216+
timeouturl=""
217+
elif [ "$buildresult" = "failed" ]; then
218+
status="failure"
219+
description=""
220+
fi
221+
echo "timeouturl=$timeouturl" >> $GITHUB_OUTPUT
222+
echo "description=$description" >> $GITHUB_OUTPUT
223+
echo "status=$status" >> $GITHUB_OUTPUT
224+
225+
- name: Update status build status as timeout
226+
if: steps.wait-for-build.outputs.conclusion == 'timed_out'
227+
uses: myrotvorets/set-commit-status-action@master
228+
with:
229+
token: ${{ github.token }}
230+
status: ${{ steps.wait_time_out.outputs.status }}
231+
context: "${{ needs.build.outputs.pkgname }}_${{ matrix.arch }}_testing_repository_building"
232+
targetUrl: ${{ steps.wait_time_out.outputs.timeouturl }}
233+
sha: ${{ github.event.pull_request.head.sha }}
234+
description: ${{ steps.wait_time_out.outputs.description }}
235+
236+
#- name: report build error at action
237+
# if: steps.wait_time_out.outputs.status != 'success' || steps.wait-for-build.outputs.conclusion == 'failure'
238+
# run: |
239+
# exit -1

0 commit comments

Comments
 (0)