From 8370fa7ac04a8a00329241dab060f64fde721539 Mon Sep 17 00:00:00 2001
From: Wouter Deconinck <wdconinc@gmail.com>
Date: Tue, 16 Aug 2022 07:15:47 +0000
Subject: [PATCH] feat: add github status report jobs

---
 .gitlab-ci.yml | 48 ++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 48 insertions(+)

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index a4ad2672..e6147128 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -22,6 +22,7 @@ default:
       dotenv: juggler.env
 
 stages:
+  - status-pending
   - config
   - initialize
   - compile
@@ -31,6 +32,32 @@ stages:
   - process
   - collect
   - finish
+  - status-report
+
+.status:
+  before_script: []
+  script:
+    - |
+      if [ -n "${GITHUB_SHA}" ] ; then
+        curl \
+          -X POST \
+          -H "Accept: application/vnd.github+json" \
+          -H "Authorization: token ${GITHUB_REPO_STATUS_TOKEN}" \
+          "https://api.github.com/repos/${GITHUB_REPOSITORY}/statuses/${GITHUB_SHA}" \
+          -d '{"state":"'"${STATE}"'",
+               "target_url":"'"${CI_PIPELINE_URL}"'",
+               "description":"'"${DESCRIPTION}"'",
+               "context":"eicweb/reconstruction_benchmarks"
+              }' ;
+      fi
+
+benchmarks:reconstruction:pending:
+  stage: status-pending
+  extends: .status
+  variables:
+    STATE: "pending"
+    DESCRIPTION: "The reconstruction benchmarks are running..."
+  when: always
 
 common:setup:
   stage: config
@@ -95,3 +122,24 @@ final_report:
     - echo "It was a success!"
   allow_failure: true
 
+benchmarks:reconstruction:success:
+  stage: status-report
+  needs:
+    - ["final_report"]
+  extends: .status
+  variables:
+    STATE: "success"
+    DESCRIPTION: "The reconstruction benchmarks succeeded!"
+  when: on_success
+
+benchmarks:reconstruction:failure:
+  stage: status-report
+  needs:
+    - ["final_report"]
+  extends: .status
+  variables:
+    STATE: "failure"
+    DESCRIPTION: "The reconstruction benchmarks failed!"
+  when: on_failure
+
+
-- 
GitLab