summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBen Gamari <ben@smart-cactus.org>2019-10-02 19:16:14 -0400
committerMarge Bot <ben+marge-bot@smart-cactus.org>2021-03-23 20:43:36 -0400
commitdf895b3f972e0062a81c8c136fa9fdd79badea5c (patch)
tree4519989fa33a3221ed3d45476e5f7d2242ea4c44
parent05c5c0549bee022be84344cef46f0eded5564c3b (diff)
downloadhaskell-df895b3f972e0062a81c8c136fa9fdd79badea5c.tar.gz
gitlab-ci: Rework handling of head.hackage job trigger
GitLab 12.3 now has reasonable support [1] for cross-project job dependencies, allowing us to drop the awful hack of a shell script we used previously. [1] https://docs.gitlab.com/ee/ci/multi_project_pipelines.html#mirroring-status-from-triggered-pipeline
-rw-r--r--.gitlab-ci.yml17
-rw-r--r--.gitlab/start-head.hackage.sh80
2 files changed, 9 insertions, 88 deletions
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 72cb116556..e60f8d1c3a 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -1339,14 +1339,14 @@ source-tarball:
.hackage:
stage: testing
needs: [doc-tarball]
- image: ghcci/x86_64-linux-deb9:0.2
- tags:
- - x86_64-linux
- dependencies: []
variables:
- HEAD_HACKAGE_PROJECT_ID: "78"
- script:
- - bash .gitlab/start-head.hackage.sh
+ UPSTREAM_PROJECT_PATH: "$CI_PROJECT_PATH"
+ UPSTREAM_COMMIT_SHA: "$CI_COMMIT_SHA"
+ EXTRA_HC_OPTS: "-dcore-lint"
+ trigger:
+ project: "ghc/head.hackage"
+ branch: "master"
+ strategy: "depend"
hackage:
extends: .hackage
@@ -1358,7 +1358,8 @@ hackage-label:
- if: '$CI_MERGE_REQUEST_LABELS =~ /.*user-facing.*/'
nightly-hackage:
- <<: *nightly
+ rules:
+ - if: $NIGHTLY
extends: .hackage
############################################################
diff --git a/.gitlab/start-head.hackage.sh b/.gitlab/start-head.hackage.sh
deleted file mode 100644
index 12771fd029..0000000000
--- a/.gitlab/start-head.hackage.sh
+++ /dev/null
@@ -1,80 +0,0 @@
-#!/usr/bin/env bash
-set -e
-
-# Start a head.hackage job and wait for completion. Expected to be called from
-# GitLab CI.
-
-if [ -z "$HEAD_HACKAGE_TRIGGER_TOKEN" ]; then
- echo "Error: Expected head.hackage trigger token in HEAD_HACKAGE_TRIGGER_TOKEN"
- exit 1
-fi
-
-if [ -z "$CI_PIPELINE_ID" ]; then
- echo "Error: Expected pipeline id in CI_PIPELINE_ID"
- exit 1
-fi
-
-if [ -z "$HEAD_HACKAGE_PROJECT_ID" ]; then
- HEAD_HACKAGE_PROJECT_ID="78"
-fi
-
-# Start pipeline
-curl --silent --show-error \
- --request POST \
- -F "token=$HEAD_HACKAGE_TRIGGER_TOKEN" \
- -F "ref=master" \
- -F "variables[GHC_PIPELINE_ID]=$CI_PIPELINE_ID" \
- -F "variables[EXTRA_HC_OPTS]=-dcore-lint" \
- https://gitlab.haskell.org/api/v4/projects/$HEAD_HACKAGE_PROJECT_ID/trigger/pipeline \
- | tee resp.json
-
-echo
-pipeline_id=$(jq .id < resp.json)
-url=$(jq .web_url < resp.json)
-echo
-echo "Started head.hackage pipeline $pipeline_id: $url"
-
-# Wait for completion
-running=
-echo "Waiting for build to complete..."
-while true; do
- sleep 10
- curl --silent --show-error \
- --request GET \
- -F "job_token=$CI_JOB_TOKEN" \
- https://gitlab.haskell.org/api/v4/projects/$HEAD_HACKAGE_PROJECT_ID/pipelines/$pipeline_id \
- > resp.json
- status=$(jq .status < resp.json)
-
- case $status in
- "\"pending\"")
- ;;
- "\"running\"")
- if [ -z "$running" ]; then
- echo "Pipeline $pipeline_id is now running."
- running=1
- fi
- ;;
- "\"success\"")
- echo "Pipeline $pipeline_id finished successfully."
- exit 0
- ;;
- "\"failed\"")
- echo "Pipeline $pipeline_id failed."
- exit 1
- ;;
- "\"canceled\"")
- echo "Pipeline $pipeline_id was canceled."
- exit 1
- ;;
- "\"skipped\"")
- echo "Pipeline $pipeline_id was skipped."
- exit 1
- ;;
- *)
- cat resp.json
- echo "Error: Unknown pipeline status $status"
- exit 2
- ;;
- esac
-done