diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index a2e36ebca2076b0344dba318df384b41d3f7c7b3..b24f4c76efe7550fe20cd858f566ec03524be8cd 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -38,6 +38,14 @@ build codecov: DEPLOY_DOCKERFILE: ci/codecov/deploy.Dockerfile DEPLOY_IMAGE: $CI_REGISTRY_IMAGE/codecov/deploy:$CI_COMMIT_SHA +notify_github_start: + stage: build + allow_failure: true + only: ['master', 'staging', 'trying'] + tags: ['kubernetes'] + image: stabbles/git-curl + script: ./ci/set_github_status.sh pending + # Some variables used for running on daint variables: @@ -158,4 +166,20 @@ deallocate codecov: stage: cleanup extends: .daint_dealloc variables: - ALLOCATION_NAME: arbor-ci-codecov-$CI_PIPELINE_ID \ No newline at end of file + ALLOCATION_NAME: arbor-ci-codecov-$CI_PIPELINE_ID + +notify_github_success: + stage: cleanup + when: on_success + only: ['master', 'staging', 'trying'] + tags: ['kubernetes'] + image: stabbles/git-curl + script: ./ci/set_github_status.sh success + +notify_github_failure: + stage: cleanup + when: on_failure + only: ['master', 'staging', 'trying'] + tags: ['kubernetes'] + image: stabbles/git-curl + script: ./ci/set_github_status.sh failure diff --git a/ci/set_github_status.sh b/ci/set_github_status.sh new file mode 100755 index 0000000000000000000000000000000000000000..05418fa053b220e86801f4e0cec6b14d7f72785c --- /dev/null +++ b/ci/set_github_status.sh @@ -0,0 +1,27 @@ +#!/bin/bash + +function submit() { + local commit_status=${1} + local commit_sha=${2} + + curl --verbose \ + --url "https://api.github.com/repos/arbor-sim/arbor/statuses/${commit_sha}" \ + --header 'Content-Type: application/json' \ + --header "authorization: Bearer ${GITHUB_TOKEN}" \ + --data "{ \"state\": \"${commit_status}\", \"target_url\": \"${CI_PIPELINE_URL}\", \"description\": \"All Gitlab pipelines\", \"context\": \"ci/gitlab/full-pipeline\" }" +} + +commit_status=${1} + +# always submit for the current commit +submit "${commit_status}" "$CI_COMMIT_SHA" + +# For Bors: get the latest commit before the merge to set the status. +if [[ $CI_COMMIT_REF_NAME =~ ^(trying|staging)$ ]]; then + parent_sha=`git rev-parse --verify -q "$CI_COMMIT_SHA"^2` + if [[ $? -eq 0 ]]; then + submit "${commit_status}" "${parent_sha}" + fi +fi + +exit 0