From fae75b9382cd6181c82bdf3d1a9523e7ddab6590 Mon Sep 17 00:00:00 2001
From: Alexander Samusev <41779041+alvicsam@users.noreply.github.com>
Date: Mon, 15 Aug 2022 13:59:54 +0200
Subject: [PATCH] [ci] Improve cancel-pipeline job (#5874)

* [ci] test-linux-stable and cancel-pipelines improvements

* fail check-try-runtime

* import changes from master

* fix needs

* fix check-try-runtime

* remove cancel pipeline from check-try-runtime

* return before_script to check-try-runtime
---
 polkadot/.gitlab-ci.yml | 35 ++++++++++++++++++++++++++---------
 1 file changed, 26 insertions(+), 9 deletions(-)

diff --git a/polkadot/.gitlab-ci.yml b/polkadot/.gitlab-ci.yml
index 2ea530e03bd..d73a90cb3a6 100644
--- a/polkadot/.gitlab-ci.yml
+++ b/polkadot/.gitlab-ci.yml
@@ -54,6 +54,19 @@ default:
     paths:
       - ./artifacts/
 
+# collecting vars for pipeline stopper
+# they will be used if the job fails
+.pipeline-stopper-vars:            &pipeline-stopper-vars
+    - echo "FAILED_JOB_URL=${CI_JOB_URL}" > pipeline-stopper.env
+    - echo "FAILED_JOB_NAME=${CI_JOB_NAME}" >> pipeline-stopper.env
+    - echo "FAILED_JOB_NAME=${CI_JOB_NAME}" >> pipeline-stopper.env
+    - echo "PR_NUM=${CI_COMMIT_REF_NAME}" >> pipeline-stopper.env
+
+.pipeline-stopper-artifacts:       &pipeline-stopper-artifacts
+  artifacts:
+     reports:
+       dotenv: pipeline-stopper.env
+
 .kubernetes-env:                   &kubernetes-env
   retry:
     max: 2
@@ -223,8 +236,12 @@ build-linux-stable:
 test-linux-stable:
   stage:                           stage1
   <<:                              *docker-env
-  <<:                              *compiler-info
   <<:                              *common-refs
+  <<:                              *pipeline-stopper-artifacts
+  before_script:
+    - rustup show
+    - cargo --version
+    - *pipeline-stopper-vars
   variables:
     RUST_TOOLCHAIN: stable
     # Enable debug assertions since we are running optimized builds for testing
@@ -606,7 +623,6 @@ check-try-runtime:
   script:
     # Check that everything compiles with `try-runtime` feature flag.
     - cargo check --features try-runtime --all
-    - sccache -s
 
 check-no-default-features:
   stage:                           stage3
@@ -1005,17 +1021,18 @@ short-benchmark-westend:
       when: on_failure
   variables:
     PROJECT_ID:                    "${CI_PROJECT_ID}"
+    PROJECT_NAME:                  "${CI_PROJECT_NAME}"
     PIPELINE_ID:                   "${CI_PIPELINE_ID}"
-  trigger:                         "parity/infrastructure/ci_cd/pipeline-stopper"
+    FAILED_JOB_URL:                "${FAILED_JOB_URL}"
+    FAILED_JOB_NAME:               "${FAILED_JOB_NAME}"
+    PR_NUM:                        "${PR_NUM}"
+  trigger:
+    project:                       "parity/infrastructure/ci_cd/pipeline-stopper"
+    # remove branch, when pipeline-stopper for polakdot is updated to the same branch
+    branch:                        "as-improve"
 
 cancel-pipeline-test-linux-stable:
   extends:                         .cancel-pipeline-template
   needs:
     - job:                         test-linux-stable
-      artifacts:                   false
 
-cancel-pipeline-check-try-runtime:
-  extends:                         .cancel-pipeline-template
-  needs:
-    - job:                         check-try-runtime
-      artifacts:                   false
-- 
GitLab