From 9f80cdf639f52033a9cfcb375f236b3c116a15b6 Mon Sep 17 00:00:00 2001 From: Guillaume Martres Date: Thu, 19 Nov 2020 16:31:36 +0100 Subject: [PATCH] Add a way to run specific tests on the CI With this commit, the CI will look for some magic strings in commit messages to decide what tests to run, for example if "[test_non_bootstrapped]" anywhere in the commit message of a PR, the non-bootstrapped tests will be run on top of the normal tests we run for PRs. It's also possible for example to turn off the windows tests with "[skip test_windows]". --- .github/workflows/ci.yaml | 89 ++++++++++++++++++++++++++------------- 1 file changed, 59 insertions(+), 30 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 2471a5ce01cc..efd1b5ddc50b 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -18,11 +18,14 @@ jobs: - ${{ github.workspace }}/../../cache/sbt:/root/.sbt - ${{ github.workspace }}/../../cache/ivy:/root/.ivy2/cache - ${{ github.workspace }}/../../cache/general:/root/.cache - if: "( - github.event_name == 'push' && - !startsWith(github.event.ref, 'refs/tags/sbt-dotty-') - ) || - github.event_name == 'schedule')" + if: "github.event_name != 'pull_request' + || ( + !contains(github.event.head_commit.message, '[skip ci]') + && ( + contains(github.event.head_commit.message, '[test_non_bootstrapped]') + || (github.event_name == 'push' && !startsWith(github.event.ref, 'refs/tags/sbt-dotty-')) + ) + )" steps: - name: Set JDK 15 as default run: echo "/usr/lib/jvm/java-15-openjdk-amd64/bin" >> $GITHUB_PATH @@ -52,8 +55,11 @@ jobs: - ${{ github.workspace }}/../../cache/sbt:/root/.sbt - ${{ github.workspace }}/../../cache/ivy:/root/.ivy2/cache - ${{ github.workspace }}/../../cache/general:/root/.cache - if: "!(github.event_name == 'push' && - startsWith(github.event.ref, 'refs/tags/sbt-dotty-'))" + if: "github.event_name == 'schedule' + || ( + !contains(github.event.head_commit.message, '[skip ci]') + && !(github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags/sbt-dotty-')) + )" steps: - name: Set JDK 15 as default @@ -78,8 +84,12 @@ jobs: test_windows: runs-on: [self-hosted, Windows] - if: "!(github.event_name == 'push' && - startsWith(github.event.ref, 'refs/tags/sbt-dotty-'))" + if: "github.event_name == 'schedule' + || ( + !contains(github.event.head_commit.message, '[skip ci]') + && !contains(github.event.head_commit.message, '[skip test_windows]') + && !(github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags/sbt-dotty-')) + )" steps: - name: Git Checkout @@ -101,6 +111,11 @@ jobs: - ${{ github.workspace }}/../../cache/sbt:/root/.sbt - ${{ github.workspace }}/../../cache/ivy:/root/.ivy2/cache - ${{ github.workspace }}/../../cache/general:/root/.cache + if: "github.event_name == 'schedule' + || ( + !contains(github.event.head_commit.message, '[skip ci]') + && !contains(github.event.head_commit.message, '[skip community_build]') + )" steps: - name: Checkout cleanup script @@ -129,6 +144,11 @@ jobs: - ${{ github.workspace }}/../../cache/sbt:/root/.sbt - ${{ github.workspace }}/../../cache/ivy:/root/.ivy2/cache - ${{ github.workspace }}/../../cache/general:/root/.cache + if: "github.event_name == 'schedule' + || ( + !contains(github.event.head_commit.message, '[skip ci]') + && !contains(github.event.head_commit.message, '[skip community_build]') + )" steps: - name: Checkout cleanup script @@ -157,11 +177,14 @@ jobs: - ${{ github.workspace }}/../../cache/sbt:/root/.sbt - ${{ github.workspace }}/../../cache/ivy:/root/.ivy2/cache - ${{ github.workspace }}/../../cache/general:/root/.cache - if: ( - github.event_name == 'push' && - startsWith(github.event.ref, 'refs/tags/') - ) || - github.event_name == 'schedule' + if: "github.event_name == 'schedule' + || ( + !contains(github.event.head_commit.message, '[skip ci]') + && ( + contains(github.event.head_commit.message, '[test_sbt]') + || (github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags/')) + ) + )" steps: - name: Checkout cleanup script @@ -188,12 +211,18 @@ jobs: - ${{ github.workspace }}/../../cache/ivy:/root/.ivy2/cache - ${{ github.workspace }}/../../cache/general:/root/.cache - if: "( - github.event_name == 'push' && - startsWith(github.event.ref, 'refs/tags/') && - !startsWith(github.event.ref, 'refs/tags/sbt-dotty-') - ) || - github.event_name == 'schedule'" + if: "github.event_name == 'schedule' + || ( + !contains(github.event.head_commit.message, '[skip ci]') + && ( + contains(github.event.head_commit.message, '[test_java8]') + || ( + github.event_name == 'push' + && startsWith(github.event.ref, 'refs/tags/') + && !startsWith(github.event.ref, 'refs/tags/sbt-dotty-') + ) + ) + )" steps: - name: Set JDK 8 as default @@ -225,7 +254,7 @@ jobs: - ${{ github.workspace }}/../../cache/ivy:/root/.ivy2/cache - ${{ github.workspace }}/../../cache/general:/root/.cache needs: [test_non_bootstrapped, test, community_build_a, community_build_b, test_sbt, test_java8] - if: github.event_name == 'schedule' + if: "github.event_name == 'schedule'" env: NIGHTLYBUILD: yes PGP_PW: ${{ secrets.PGP_PW }} # PGP passphrase @@ -259,7 +288,7 @@ jobs: - ${{ github.workspace }}/../../cache/ivy:/root/.ivy2/cache - ${{ github.workspace }}/../../cache/general:/root/.cache needs: [publish_nightly] - if: github.event_name == 'schedule' + if: "github.event_name == 'schedule'" env: NIGHTLYBUILD: yes BOT_TOKEN: ${{ secrets.BOT_TOKEN }} # If you need to change this: @@ -300,9 +329,9 @@ jobs: - ${{ github.workspace }}/../../cache/ivy:/root/.ivy2/cache - ${{ github.workspace }}/../../cache/general:/root/.cache needs: [test_non_bootstrapped, test, community_build_a, community_build_b, test_sbt, test_java8] - if: github.event_name == 'push' && - startsWith(github.event.ref, 'refs/tags/') && - !startsWith(github.event.ref, 'refs/tags/sbt-dotty-') + if: "github.event_name == 'push' + && startsWith(github.event.ref, 'refs/tags/') + && !startsWith(github.event.ref, 'refs/tags/sbt-dotty-')" env: RELEASEBUILD: yes @@ -382,9 +411,9 @@ jobs: - ${{ github.workspace }}/../../cache/ivy:/root/.ivy2/cache - ${{ github.workspace }}/../../cache/general:/root/.cache needs: [publish_release] - if: github.event_name == 'push' && - startsWith(github.event.ref, 'refs/tags/') && - !startsWith(github.event.ref, 'refs/tags/sbt-dotty-') + if: "github.event_name == 'push' + && startsWith(github.event.ref, 'refs/tags/') + && !startsWith(github.event.ref, 'refs/tags/sbt-dotty-')" env: RELEASEBUILD: yes @@ -426,8 +455,8 @@ jobs: - ${{ github.workspace }}/../../cache/ivy:/root/.ivy2/cache - ${{ github.workspace }}/../../cache/general:/root/.cache needs: [community_build_a, community_build_b, test_sbt] - if: github.event_name == 'push' && - startsWith(github.event.ref, 'refs/tags/sbt-dotty-') + if: "github.event_name == 'push' + && startsWith(github.event.ref, 'refs/tags/sbt-dotty-')" env: RELEASEBUILD: yes