From 210b09e10150655ecbd07d1f0f678a9de9d6d68b Mon Sep 17 00:00:00 2001
From: Eric Timmons <etimmons@mit.edu>
Date: Wed, 2 Jun 2021 17:18:32 +0000
Subject: [PATCH] Clean up gitlab-ci.yml and add trigger for new lisp
 implementation versions

---
 Makefile                                      |   5 +-
 gitlab-ci.yml                                 | 425 ++----------------
 .../new-implementation-version.yml            |  58 +++
 gitlab-pipelines/standard-pipeline.yml        | 146 ++++++
 4 files changed, 238 insertions(+), 396 deletions(-)
 create mode 100644 gitlab-pipelines/new-implementation-version.yml
 create mode 100644 gitlab-pipelines/standard-pipeline.yml

diff --git a/Makefile b/Makefile
index 9e5d4bc0f..ae769ea09 100644
--- a/Makefile
+++ b/Makefile
@@ -80,6 +80,7 @@ XCL ?= xcl
 
 # If you need to sudo in order to use docker, modify this.
 DOCKER ?= docker
+docker_tag ?= latest
 
 header_lisp := header.lisp
 driver_lisp := uiop/package.lisp uiop/common-lisp.lisp uiop/utility.lisp uiop/version.lisp uiop/os.lisp uiop/pathname.lisp uiop/filesystem.lisp uiop/stream.lisp uiop/image.lisp uiop/lisp-build.lisp uiop/launch-program.lisp uiop/run-program.lisp uiop/configuration.lisp uiop/backward-driver.lisp uiop/driver.lisp
@@ -209,10 +210,10 @@ t: test-lisp
 
 # Useful for reproducing test failures with Docker.
 test-docker-repl:
-	@${DOCKER} run --rm -i -t --pull always -u $(shell id -u):$(shell id -g) -v $(sourceDirectory):$(sourceDirectory) -w $(sourceDirectory)/test clfoundation/${l}:latest
+	@${DOCKER} run --rm -i -t --pull always -u $(shell id -u):$(shell id -g) -v $(sourceDirectory):$(sourceDirectory) -w $(sourceDirectory)/test clfoundation/${l}:${docker_tag}
 
 test-docker-lisp: build/asdf.lisp show-version
-	@${DOCKER} run --rm -i -t --pull always -u $(shell id -u):$(shell id -g) -v $(sourceDirectory):$(sourceDirectory) -w $(sourceDirectory) clfoundation/${l}:latest make test-lisp l=${l} t=${t}
+	@${DOCKER} run --rm -i -t --pull always -u $(shell id -u):$(shell id -g) -v $(sourceDirectory):$(sourceDirectory) -w $(sourceDirectory) clfoundation/${l}:${docker_tag} make test-lisp l=${l} t=${t}
 
 td: test-docker-lisp
 
diff --git a/gitlab-ci.yml b/gitlab-ci.yml
index 7502f1705..1e7185b9b 100644
--- a/gitlab-ci.yml
+++ b/gitlab-ci.yml
@@ -1,403 +1,40 @@
-###############################################################################
-# Global configuration
-###############################################################################
-
-variables:
-  # Just let the runner fetch and update the submodules for us.
-  GIT_SUBMODULE_STRATEGY: normal
-  ABCL_IMAGE: clfoundation/abcl
-  ABCL_TAG: latest
-  CCL_IMAGE: clfoundation/ccl
-  CCL_TAG: latest
-  CLASP_IMAGE: clfoundation/clasp
-  CLASP_TAG: latest
-  CLISP_IMAGE: clfoundation/clisp
-  CLISP_TAG: latest
-  CMUCL_IMAGE: clfoundation/cmucl
-  CMUCL_TAG: latest
-  ECL_IMAGE: clfoundation/ecl
-  ECL_TAG: latest
-  SBCL_IMAGE: clfoundation/sbcl
-  SBCL_TAG: latest
-
-
-# This causes pipelines to be created only on the default branch, tags, merge
-# requests, and when triggered via the web interface.
-workflow:
+# Run the standard pipeline (regression and upgrade tests on all supported
+# implementations) on the default branch, tags, merge requests, and when
+# triggered via the web interface.
+
+Standard pipeline:
+  trigger:
+    include:
+      - local: gitlab-pipelines/standard-pipeline.yml
+    strategy: depend
   rules:
     - if: $CI_MERGE_REQUEST_IID
     - if: $CI_COMMIT_TAG
     - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
     - if: $CI_PIPELINE_SOURCE == "web"
 
-# Split regression testing into a separate stage than upgrade tests. The
-# upgrade tests tend to run slower and are generally less important than
-# regression tests for most changes.
-stages:
-  - build
-  - regression
-  - upgrade
-
-###############################################################################
-# Build jobs
-###############################################################################
-
-Build ASDF:
-  stage: build
-  image: buildpack-deps:latest
-  script:
-    - make
-  artifacts:
-    paths:
-      - build/asdf.lisp
-
-Build docs:
-  stage: build
-  image: buildpack-deps:buster
-  script:
-    - apt-get update
-    - apt-get install -y --no-install-recommends texinfo texlive
-    - make -C doc
-  artifacts:
-    paths:
-      - doc/asdf.html
-      - doc/asdf.info
-      - doc/asdf.pdf
-
-Build asdf-tools:
-  stage: build
-  image: $SBCL_IMAGE:$SBCL_TAG
-  script:
-    - make -f Makefile-lisp-scripting build-asdf-tools
-  artifacts:
-    paths:
-      - build/asdf-tools
+# This pipeline is triggered by the cl-docker-images project using a CI
+# Trigger. It is run whenever a new image is released for an implementation
+# release candidate or full release.
+New image pipeline:
+  trigger:
+    include:
+      - local: gitlab-pipelines/new-implementation-version.yml
+    strategy: depend
+  variables:
+    l: $CLDI_IMAGE_NAME
+    IMAGE_TAG: $CLDI_IMAGE_TAG
+    LISP_VERSION: $CLDI_LISP_VERSION
   rules:
-    - if: $ENABLE_ASDF_TOOLS
-
-###############################################################################
-# Testing Templates
-###############################################################################
-
-.Regression tests:
-  stage: regression
-  script:
-    - make
-    - make test
-  artifacts:
-    paths:
-      - build/results/$l-test.text
-  needs: []
-
-.Upgrade tests:
-  stage: upgrade
+    - if: '$CI_PIPELINE_TRIGGERED && ($CLDI_EVENT == "new-rc" || $CLDI_EVENT == "new-version")'
+
+# This job is also included when triggered by the cl-docker-images project. It
+# exists only to have the trigger variables visible for debugging and
+# traceability. This is needed because bridge jobs (such as above) do not have
+# an individual job page that shows all the information.
+Show cldi trigger info:
+  image: alpine
   script:
-    - make
-    - make test-upgrade
-  artifacts:
-    paths:
-      - build/results/$l-upgrade.text
-  needs: []
-  allow_failure: true
+    - "true"
   rules:
-    - if: $RUN_UPGRADE_TESTS
-
-.REQUIRE upgrade tests:
-  extends: .Upgrade tests
-  variables:
-    ASDF_UPGRADE_TEST_TAGS: REQUIRE
-  rules:
-    - if: $RUN_UPGRADE_TESTS
-      when: never
-    - when: on_success
-
-.Scripting regression tests:
-  extends: .Regression tests
-  before_script:
-    - ln -s Makefile-lisp-scripting GNUmakefile
-  needs:
-    - Build asdf-tools
-  rules:
-    - if: $ENABLE_ASDF_TOOLS
-
-.Scripting upgrade tests:
-  extends: .Upgrade tests
-  before_script:
-    - ln -s Makefile-lisp-scripting GNUmakefile
-  needs:
-    - Build asdf-tools
-  rules:
-    - if: $ENABLE_ASDF_TOOLS && $RUN_UPGRADE_TESTS
-
-.REQUIRE scripting upgrade tests:
-  extends: .Scripting upgrade tests
-  variables:
-    ASDF_UPGRADE_TEST_TAGS: REQUIRE
-  rules:
-    - if: $ENABLE_ASDF_TOOLS && $RUN_UPGRADE_TESTS
-      when: never
-    - if: $ENABLE_ASDF_TOOLS
-
-###############################################################################
-# Actual test jobs - Makefile based harness
-###############################################################################
-
-ABCL regression tests:
-  extends: .Regression tests
-  image: $ABCL_IMAGE:$ABCL_TAG
-  variables:
-    l: abcl
-  allow_failure: true
-
-# ABCL 1.8.0 has some issues that cause ASDF tests to fail. Remove this job
-# when the above job starts to pass again.
-ABCL 1.7.1 regression tests:
-  extends: .Regression tests
-  image: $ABCL_IMAGE:1.7.1-jdk8
-  variables:
-    l: abcl
-
-ABCL upgrade tests:
-  extends: .Upgrade tests
-  image: $ABCL_IMAGE:$ABCL_TAG
-  variables:
-    l: abcl
-
-ABCL REQUIRE upgrade tests:
-  extends: .REQUIRE upgrade tests
-  image: $ABCL_IMAGE:$ABCL_TAG
-  variables:
-    l: abcl
-
-CCL regression tests:
-  extends: .Regression tests
-  image: $CCL_IMAGE:$CCL_TAG
-  variables:
-    l: ccl
-
-CCL upgrade tests:
-  extends: .Upgrade tests
-  image: $CCL_IMAGE:$CCL_TAG
-  variables:
-    l: ccl
-
-CCL REQUIRE upgrade tests:
-  extends: .REQUIRE upgrade tests
-  image: $CCL_IMAGE:$CCL_TAG
-  variables:
-    l: ccl
-
-Clasp regression tests:
-  extends: .Regression tests
-  image: $CLASP_IMAGE:$CLASP_TAG
-  variables:
-    l: clasp
-
-Clasp upgrade tests:
-  extends: .Upgrade tests
-  image: $CLASP_IMAGE:$CLASP_TAG
-  variables:
-    l: clasp
-
-Clasp REQUIRE upgrade tests:
-  extends: .REQUIRE upgrade tests
-  image: $CLASP_IMAGE:$CLASP_TAG
-  variables:
-    l: clasp
-
-CLISP regression tests:
-  extends: .Regression tests
-  image: $CLISP_IMAGE:$CLISP_TAG
-  variables:
-    l: clisp
-
-CLISP upgrade tests:
-  extends: .Upgrade tests
-  image: $CLISP_IMAGE:$CLISP_TAG
-  variables:
-    l: clisp
-
-CLISP REQUIRE upgrade tests:
-  extends: .REQUIRE upgrade tests
-  image: $CLISP_IMAGE:$CLISP_TAG
-  variables:
-    l: clisp
-
-CMUCL regression tests:
-  extends: .Regression tests
-  image: $CMUCL_IMAGE:$CMUCL_TAG
-  variables:
-    l: cmucl
-
-CMUCL upgrade tests:
-  extends: .Upgrade tests
-  image: $CMUCL_IMAGE:$CMUCL_TAG
-  variables:
-    l: cmucl
-
-CMUCL REQUIRE upgrade tests:
-  extends: .REQUIRE upgrade tests
-  image: $CMUCL_IMAGE:$CMUCL_TAG
-  variables:
-    l: cmucl
-
-ECL regression tests:
-  extends: .Regression tests
-  image: $ECL_IMAGE:$ECL_TAG
-  variables:
-    l: ecl
-
-ECL upgrade tests:
-  extends: .Upgrade tests
-  image: $ECL_IMAGE:$ECL_TAG
-  variables:
-    l: ecl
-
-ECL REQUIRE upgrade tests:
-  extends: .REQUIRE upgrade tests
-  image: $ECL_IMAGE:$ECL_TAG
-  variables:
-    l: ecl
-
-SBCL regression tests:
-  extends: .Regression tests
-  image: $SBCL_IMAGE:$SBCL_TAG
-  variables:
-    l: sbcl
-
-SBCL upgrade tests:
-  extends: .Upgrade tests
-  image: $SBCL_IMAGE:$SBCL_TAG
-  variables:
-    l: sbcl
-
-SBCL REQUIRE upgrade tests:
-  extends: .REQUIRE upgrade tests
-  image: $SBCL_IMAGE:$SBCL_TAG
-  variables:
-    l: sbcl
-
-
-###############################################################################
-# Actual test jobs - lisp scripting based harness
-###############################################################################
-
-ABCL scripting regression tests:
-  extends: .Scripting regression tests
-  image: $ABCL_IMAGE:$ABCL_TAG
-  variables:
-    l: abcl
-
-ABCL scripting upgrade tests:
-  extends: .Scripting upgrade tests
-  image: $ABCL_IMAGE:$ABCL_TAG
-  variables:
-    l: abcl
-
-ABCL REQUIRE scripting upgrade tests:
-  extends: .REQUIRE scripting upgrade tests
-  image: $ABCL_IMAGE:$ABCL_TAG
-  variables:
-    l: abcl
-
-CCL scripting regression tests:
-  extends: .Scripting regression tests
-  image: $CCL_IMAGE:$CCL_TAG
-  variables:
-    l: ccl
-
-CCL scripting upgrade tests:
-  extends: .Scripting upgrade tests
-  image: $CCL_IMAGE:$CCL_TAG
-  variables:
-    l: ccl
-
-CCL REQUIRE scripting upgrade tests:
-  extends: .REQUIRE scripting upgrade tests
-  image: $CCL_IMAGE:$CCL_TAG
-  variables:
-    l: ccl
-
-Clasp scripting regression tests:
-  extends: .Scripting regression tests
-  image: $CLASP_IMAGE:$CLASP_TAG
-  variables:
-    l: clasp
-
-Clasp scripting upgrade tests:
-  extends: .Scripting upgrade tests
-  image: $CLASP_IMAGE:$CLASP_TAG
-  variables:
-    l: clasp
-
-CLISP scripting regression tests:
-  extends: .Scripting regression tests
-  image: $CLISP_IMAGE:$CLISP_TAG
-  variables:
-    l: clisp
-
-CLISP scripting upgrade tests:
-  extends: .Scripting upgrade tests
-  image: $CLISP_IMAGE:$CLISP_TAG
-  variables:
-    l: clisp
-
-CLISP REQUIRE scripting upgrade tests:
-  extends: .REQUIRE scripting upgrade tests
-  image: $CLISP_IMAGE:$CLISP_TAG
-  variables:
-    l: clisp
-
-CMUCL scripting regression tests:
-  extends: .Scripting regression tests
-  image: $CMUCL_IMAGE:$CMUCL_TAG
-  variables:
-    l: cmucl
-
-CMUCL scripting upgrade tests:
-  extends: .Scripting upgrade tests
-  image: $CMUCL_IMAGE:$CMUCL_TAG
-  variables:
-    l: cmucl
-
-CMUCL REQUIRE scripting upgrade tests:
-  extends: .REQUIRE scripting upgrade tests
-  image: $CMUCL_IMAGE:$CMUCL_TAG
-  variables:
-    l: cmucl
-
-ECL scripting regression tests:
-  extends: .Scripting regression tests
-  image: $ECL_IMAGE:$ECL_TAG
-  variables:
-    l: ecl
-
-ECL scripting upgrade tests:
-  extends: .Scripting upgrade tests
-  image: $ECL_IMAGE:$ECL_TAG
-  variables:
-    l: ecl
-
-ECL REQUIRE scripting upgrade tests:
-  extends: .REQUIRE scripting upgrade tests
-  image: $ECL_IMAGE:$ECL_TAG
-  variables:
-    l: ecl
-
-SBCL scripting regression tests:
-  extends: .Scripting regression tests
-  image: $SBCL_IMAGE:$SBCL_TAG
-  variables:
-    l: sbcl
-
-SBCL scripting upgrade tests:
-  extends: .Scripting upgrade tests
-  image: $SBCL_IMAGE:$SBCL_TAG
-  variables:
-    l: sbcl
-
-SBCL REQUIRE scripting upgrade tests:
-  extends: .REQUIRE scripting upgrade tests
-  image: $SBCL_IMAGE:$SBCL_TAG
-  variables:
-    l: sbcl
+    - if: '$CI_PIPELINE_TRIGGERED && ($CLDI_EVENT == "new-rc" || $CLDI_EVENT == "new-version")'
diff --git a/gitlab-pipelines/new-implementation-version.yml b/gitlab-pipelines/new-implementation-version.yml
new file mode 100644
index 000000000..433308096
--- /dev/null
+++ b/gitlab-pipelines/new-implementation-version.yml
@@ -0,0 +1,58 @@
+# This pipeline is run when a new implementation version is released (or about
+# to be released).
+
+variables:
+  # Just let the runner fetch and update the submodules for us.
+  GIT_SUBMODULE_STRATEGY: normal
+
+stages:
+  - regression
+  - upgrade
+  - notify
+
+Regression test:
+  stage: regression
+  image: ${CI_DEPENDENCY_PROXY_GROUP_IMAGE_PREFIX}/clfoundation/$l:$IMAGE_TAG
+  script:
+    - make
+    - make test
+  artifacts:
+    paths:
+      - build/results/$l-test.text
+  needs: []
+  retry:
+    max: 2
+    when:
+      - job_execution_timeout
+
+REQUIRE Upgrade test:
+  stage: upgrade
+  image: ${CI_DEPENDENCY_PROXY_GROUP_IMAGE_PREFIX}/clfoundation/$l:$IMAGE_TAG
+  variables:
+    ASDF_UPGRADE_TEST_TAGS: REQUIRE
+  script:
+    - make
+    - make test-upgrade
+  artifacts:
+    paths:
+      - build/results/$l-upgrade.text
+  needs: []
+
+# Open an issue so that job failures are not lost in the noise.
+
+Open issue:
+  stage: notify
+  image: ${CI_DEPENDENCY_PROXY_GROUP_IMAGE_PREFIX}/alpine
+  script:
+    - apk add curl jq
+    # If we've already opened an issue, bail out.
+    - '[ $(curl -fsSL -G -d "labels=bot" -d "search=test+failure+for+$l+$LISP_VERSION" "$CI_API_V4_URL/projects/$CI_PROJECT_ID/issues" | jq length) = "0" ] || exit 0'
+    # Otherwise, open a new issue!
+    - |
+      curl -fsSL -X \
+           -H "PRIVATE-TOKEN: $ASDF_ISSUE_BOT_PAT"
+           -d "labels=bot" \
+           -d "title=Test failure for $l $LISP_VERSION" \
+           -d "description=An automated pipeline using image clfoundation/$l:$IMAGE_TAG has failed. See: <$CI_PIPELINE_URL>" \
+           "$CI_API_V4_URL/projects/$CI_PROJECT_ID/issues"
+  when: on_failure
diff --git a/gitlab-pipelines/standard-pipeline.yml b/gitlab-pipelines/standard-pipeline.yml
new file mode 100644
index 000000000..649a20a0c
--- /dev/null
+++ b/gitlab-pipelines/standard-pipeline.yml
@@ -0,0 +1,146 @@
+###############################################################################
+# Global configuration
+###############################################################################
+
+variables:
+  # Just let the runner fetch and update the submodules for us.
+  GIT_SUBMODULE_STRATEGY: normal
+
+# Split regression testing into a separate stage than upgrade tests. The
+# upgrade tests tend to run slower and are generally less important than
+# regression tests for most changes.
+stages:
+  - build
+  - regression
+  - upgrade
+
+# This is needed otherwise the jobs won't always be added to MR pipelines. We
+# can just say when: always because this is run as a child pipeline and only
+# triggered under the desired conditions.
+workflow:
+  rules:
+    - when: always
+
+###############################################################################
+# Build jobs
+###############################################################################
+
+Build ASDF:
+  stage: build
+  image: ${CI_DEPENDENCY_PROXY_GROUP_IMAGE_PREFIX}/buildpack-deps:latest
+  script:
+    - make
+  artifacts:
+    paths:
+      - build/asdf.lisp
+
+Build docs:
+  stage: build
+  image: ${CI_DEPENDENCY_PROXY_GROUP_IMAGE_PREFIX}/buildpack-deps:buster
+  script:
+    - apt-get update
+    - apt-get install -y --no-install-recommends texinfo texlive
+    - make -C doc
+  artifacts:
+    paths:
+      - doc/asdf.html
+      - doc/asdf.info
+      - doc/asdf.pdf
+
+###############################################################################
+# Regression tests
+###############################################################################
+
+.Regression test template:
+  stage: regression
+  image: ${CI_DEPENDENCY_PROXY_GROUP_IMAGE_PREFIX}/clfoundation/$l:$IMAGE_TAG
+  variables:
+    IMAGE_TAG: latest
+  script:
+    - make
+    - make test
+  artifacts:
+    paths:
+      - build/results/$l-test.text
+  needs: []
+  retry:
+    max: 2
+    when:
+      - job_execution_timeout
+
+Regression test:
+  extends: .Regression test template
+  parallel:
+    matrix:
+      - l: [ccl, clasp, clisp, cmucl, ecl, sbcl]
+        IMAGE_TAG: latest
+      - l: abcl
+        IMAGE_TAG: 1.7.1-jdk8
+
+Regression test expected failure:
+  extends: .Regression test template
+  parallel:
+    matrix:
+      - l: [abcl]
+        IMAGE_TAG: latest
+  allow_failure: true
+
+###############################################################################
+# Upgrade tests
+###############################################################################
+
+.Upgrade test template:
+  stage: upgrade
+  image: ${CI_DEPENDENCY_PROXY_GROUP_IMAGE_PREFIX}/clfoundation/$l:$IMAGE_TAG
+  variables:
+    IMAGE_TAG: latest
+  script:
+    - make
+    - make test-upgrade
+  artifacts:
+    paths:
+      - build/results/$l-upgrade.text
+  needs: []
+  rules:
+    - if: $RUN_UPGRADE_TESTS
+
+Upgrade test:
+  extends: .Upgrade test template
+  parallel:
+    matrix:
+      - l: [abcl, ccl, clasp, clisp, cmucl, ecl, sbcl]
+        IMAGE_TAG: latest
+
+Upgrade test known failure:
+  extends: .Upgrade test template
+  parallel:
+    matrix:
+      - l: [abcl]
+        IMAGE_TAG: latest
+  allow_failure: true
+
+.REQUIRE upgrade test template:
+  extends: .Upgrade test template
+  rules:
+    - if: $RUN_UPGRADE_TESTS
+      when: never
+    - when: on_success
+
+REQUIRE upgrade test:
+  extends: .REQUIRE upgrade test template
+  variables:
+    ASDF_UPGRADE_TEST_TAGS: REQUIRE
+  parallel:
+    matrix:
+      - l: [ccl, clasp, clisp, cmucl, ecl, sbcl]
+        IMAGE_TAG: latest
+
+REQUIRE upgrade test known failure:
+  extends: .REQUIRE upgrade test template
+  variables:
+    ASDF_UPGRADE_TEST_TAGS: REQUIRE
+  parallel:
+    matrix:
+      - l: abcl
+        IMAGE_TAG: latest
+  allow_failure: true
-- 
GitLab