Skip to content

Commit 79f0ab0

Browse files
author
utam0k
committed
werft: Fix weird repeat running behavior
#12795
1 parent 2914ee8 commit 79f0ab0

File tree

2 files changed

+16
-9
lines changed

2 files changed

+16
-9
lines changed

.werft/ide-integration-tests-startup.yaml

+1
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ pod:
6767
sudo chown -R gitpod:gitpod /workspace
6868
6969
# Fix weird repeat running behavior
70+
# https://github.com/gitpod-io/gitpod/issues/12795
7071
LAST_COMMIT_MSG=$(git log --pretty=format:"%s" -1)
7172
if [[ $LAST_COMMIT_MSG =~ "integration test" ]]; then exit 0; fi
7273

.werft/workspace-run-integration-tests.sh

+15-9
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@
22

33
set -euo pipefail
44

5+
TEMP_COMMIT_MSG="integration test"
6+
# TODO(toru): Fix weird repeat running behavior
7+
# https://github.com/gitpod-io/gitpod/issues/12795
8+
LAST_COMMIT_MSG=$(git log --pretty=format:"%s" -1)
9+
if [[ $LAST_COMMIT_MSG == "$TEMP_COMMIT_MSG" ]]; then exit 0; fi
10+
511
BRANCH="wk-inte-test/"$(date +%Y%m%d%H%M%S)
612
FAILURE_COUNT=0
713
RUN_COUNT=0 # Prevent multiple cleanup runs
@@ -19,19 +25,19 @@ function cleanup ()
1925
fi
2026
DO_CLEANUP=1
2127
werft log phase "slack notification and cleanup $SIGNAL" "Slack notification and cleanup: $SIGNAL"
22-
28+
2329
werftJobUrl="https://werft.gitpod-dev.com/job/${context_name}"
24-
30+
2531
if [ "${RUN_COUNT}" -eq "0" ]; then
2632
title=":x: *Workspace integration test fail*"
2733
title=$title"\n_Repo:_ ${context_repo}\n_Build:_ ${context_name}"
28-
34+
2935
errs="Failed at preparing the preview environment"
3036
BODY="{\"blocks\":[{\"type\":\"section\",\"text\":{\"type\":\"mrkdwn\",\"text\":\"${title}\"},\"accessory\":{\"type\":\"button\",\"text\":{\"type\":\"plain_text\",\"text\":\":werft: Go to Werft\",\"emoji\":true},\"value\":\"click_me_123\",\"url\":\"${werftJobUrl}\",\"action_id\":\"button-action\"}},{\"type\":\"section\",\"text\":{\"type\":\"mrkdwn\",\"text\":\"\`\`\`\\n${errs}\\n\`\`\`\"}}]}"
3137
elif [ "${FAILURE_COUNT}" -ne "0" ]; then
3238
title=":x: *Workspace integration test fail*"
3339
title=$title"\n_Repo:_ ${context_repo}\n_Build:_ ${context_name}"
34-
40+
3541
errs=""
3642
for TEST_NAME in ${!FAILURE_TESTS[*]}; do
3743
title=$title"\n_Tests_: ${TEST_NAME}"
@@ -41,21 +47,21 @@ function cleanup ()
4147
BODY="{\"blocks\":[{\"type\":\"section\",\"text\":{\"type\":\"mrkdwn\",\"text\":\"${title}\"},\"accessory\":{\"type\":\"button\",\"text\":{\"type\":\"plain_text\",\"text\":\":werft: Go to Werft\",\"emoji\":true},\"value\":\"click_me_123\",\"url\":\"${werftJobUrl}\",\"action_id\":\"button-action\"}},{\"type\":\"section\",\"text\":{\"type\":\"mrkdwn\",\"text\":\"\`\`\`\\n${errs}\\n\`\`\`\"}}]}"
4248
else
4349
title=":white_check_mark: *Workspace integration test pass*"
44-
50+
4551
title=$title"\n_Repo:_ ${context_repo}\n_Build:_ ${context_name}"
4652
BODY="{\"blocks\":[{\"type\":\"section\",\"text\":{\"type\":\"mrkdwn\",\"text\":\"${title}\"},\"accessory\":{\"type\":\"button\",\"text\":{\"type\":\"plain_text\",\"text\":\":werft: Go to Werft\",\"emoji\":true},\"value\":\"click_me_123\",\"url\":\"${werftJobUrl}\",\"action_id\":\"button-action\"}}]}"
4753
fi
48-
54+
4955
echo "Sending Slack notificaition" | werft log slice "slack notification"
5056
curl -X POST \
5157
-H 'Content-type: application/json' \
5258
-d "${BODY}" \
5359
"https://hooks.slack.com/${SLACK_NOTIFICATION_PATH}"
5460
werft log result "slack notification" "${PIPESTATUS[0]}"
5561
werft log slice "slack notification" --done
56-
62+
5763
git push origin :"${BRANCH}" | werft log slice "clean up"
58-
64+
5965
echo "Finished cleaning up based on signal $SIGNAL" | werft log slice "clean up"
6066
werft log slice "clean up" --done
6167
}
@@ -73,7 +79,7 @@ werft log phase "build preview environment" "build preview environment"
7379
# Create a new branch and asks Werft to create a preview environment for it
7480
( \
7581
git checkout -B "${BRANCH}" && \
76-
git commit -m "integration test" --allow-empty && \
82+
git commit -m "${TEMP_COMMIT_MSG}" --allow-empty && \
7783
git push --set-upstream origin "${BRANCH}" && \
7884
werft run github -a with-preview=true
7985
) | werft log slice "build preview environment"

0 commit comments

Comments
 (0)