From 1a76f6383d0283bf1cf7cdcaf8ff824770105f7d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Wawrzyniec=20Urba=C5=84czyk?= Date: Tue, 5 Mar 2024 16:40:46 +0100 Subject: [PATCH] [CI] Checkbox for requesting a clean build when manually dispatching a workflow (#9270) This PR allows requesting a clean build when triggering the workflow through the manual dispatch. Previously it was possible only by creating PR and adding the label to it. --- .github/workflows/changelog.yml | 4 +- .github/workflows/engine-benchmark.yml | 4 +- .github/workflows/gui.yml | 60 ++++++++++++---------- .github/workflows/promote.yml | 4 +- .github/workflows/release.yml | 64 ++++++++++++------------ .github/workflows/scala-new.yml | 20 +++++--- .github/workflows/std-libs-benchmark.yml | 4 +- build/build/src/ci.rs | 6 +++ build/build/src/ci_gen.rs | 34 +++++++++---- 9 files changed, 115 insertions(+), 85 deletions(-) diff --git a/.github/workflows/changelog.yml b/.github/workflows/changelog.yml index eed1b906f43..ec82ffbf5a1 100644 --- a/.github/workflows/changelog.yml +++ b/.github/workflows/changelog.yml @@ -40,7 +40,7 @@ jobs: run: ./run --help env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - if: "contains(github.event.pull_request.labels.*.name, 'CI: Clean build required')" + - if: "(contains(github.event.pull_request.labels.*.name, 'CI: Clean build required') || inputs.clean_build_required)" name: Clean before run: ./run git-clean env: @@ -54,7 +54,7 @@ jobs: - if: failure() && runner.os != 'Windows' name: List files if failed (non-Windows) run: ls -lAR - - if: "always() && contains(github.event.pull_request.labels.*.name, 'CI: Clean build required')" + - if: "(always()) && (contains(github.event.pull_request.labels.*.name, 'CI: Clean build required') || inputs.clean_build_required)" name: Clean after run: ./run git-clean env: diff --git a/.github/workflows/engine-benchmark.yml b/.github/workflows/engine-benchmark.yml index f6a116e6e79..1b83729444b 100644 --- a/.github/workflows/engine-benchmark.yml +++ b/.github/workflows/engine-benchmark.yml @@ -42,7 +42,7 @@ jobs: run: ./run --help env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - if: always() + - if: (always()) name: Clean before run: ./run git-clean env: @@ -56,7 +56,7 @@ jobs: - if: failure() && runner.os != 'Windows' name: List files if failed (non-Windows) run: ls -lAR - - if: always() + - if: (always()) name: Clean after run: ./run git-clean env: diff --git a/.github/workflows/gui.yml b/.github/workflows/gui.yml index 77a1093ae5a..c57cc91ac4e 100644 --- a/.github/workflows/gui.yml +++ b/.github/workflows/gui.yml @@ -7,7 +7,13 @@ on: branches: - develop pull_request: {} - workflow_dispatch: {} + workflow_dispatch: + inputs: + clean_build_required: + description: Clean before and after the run. + required: false + type: boolean + default: false jobs: enso-build-ci-gen-job-build-backend-linux-x86_64: name: Build Backend (linux, x86_64) @@ -39,7 +45,7 @@ jobs: run: ./run --help env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - if: "contains(github.event.pull_request.labels.*.name, 'CI: Clean build required')" + - if: "(contains(github.event.pull_request.labels.*.name, 'CI: Clean build required') || inputs.clean_build_required)" name: Clean before run: ./run git-clean env: @@ -53,7 +59,7 @@ jobs: - if: failure() && runner.os != 'Windows' name: List files if failed (non-Windows) run: ls -lAR - - if: "always() && contains(github.event.pull_request.labels.*.name, 'CI: Clean build required')" + - if: "(always()) && (contains(github.event.pull_request.labels.*.name, 'CI: Clean build required') || inputs.clean_build_required)" name: Clean after run: ./run git-clean env: @@ -87,7 +93,7 @@ jobs: run: ./run --help env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - if: "contains(github.event.pull_request.labels.*.name, 'CI: Clean build required')" + - if: "(contains(github.event.pull_request.labels.*.name, 'CI: Clean build required') || inputs.clean_build_required)" name: Clean before run: ./run git-clean env: @@ -101,7 +107,7 @@ jobs: - if: failure() && runner.os != 'Windows' name: List files if failed (non-Windows) run: ls -lAR - - if: "always() && contains(github.event.pull_request.labels.*.name, 'CI: Clean build required')" + - if: "(always()) && (contains(github.event.pull_request.labels.*.name, 'CI: Clean build required') || inputs.clean_build_required)" name: Clean after run: ./run git-clean env: @@ -136,7 +142,7 @@ jobs: run: ./run --help env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - if: "contains(github.event.pull_request.labels.*.name, 'CI: Clean build required')" + - if: "(contains(github.event.pull_request.labels.*.name, 'CI: Clean build required') || inputs.clean_build_required)" name: Clean before run: ./run git-clean env: @@ -150,7 +156,7 @@ jobs: - if: failure() && runner.os != 'Windows' name: List files if failed (non-Windows) run: ls -lAR - - if: "always() && contains(github.event.pull_request.labels.*.name, 'CI: Clean build required')" + - if: "(always()) && (contains(github.event.pull_request.labels.*.name, 'CI: Clean build required') || inputs.clean_build_required)" name: Clean after run: ./run git-clean env: @@ -197,7 +203,7 @@ jobs: run: ./run --help env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - if: "contains(github.event.pull_request.labels.*.name, 'CI: Clean build required')" + - if: "(contains(github.event.pull_request.labels.*.name, 'CI: Clean build required') || inputs.clean_build_required)" name: Clean before run: ./run git-clean env: @@ -211,7 +217,7 @@ jobs: - if: failure() && runner.os != 'Windows' name: List files if failed (non-Windows) run: ls -lAR - - if: "always() && contains(github.event.pull_request.labels.*.name, 'CI: Clean build required')" + - if: "(always()) && (contains(github.event.pull_request.labels.*.name, 'CI: Clean build required') || inputs.clean_build_required)" name: Clean after run: ./run git-clean env: @@ -246,7 +252,7 @@ jobs: run: ./run --help env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - if: "contains(github.event.pull_request.labels.*.name, 'CI: Clean build required')" + - if: "(contains(github.event.pull_request.labels.*.name, 'CI: Clean build required') || inputs.clean_build_required)" name: Clean before run: ./run git-clean env: @@ -260,7 +266,7 @@ jobs: - if: failure() && runner.os != 'Windows' name: List files if failed (non-Windows) run: ls -lAR - - if: "always() && contains(github.event.pull_request.labels.*.name, 'CI: Clean build required')" + - if: "(always()) && (contains(github.event.pull_request.labels.*.name, 'CI: Clean build required') || inputs.clean_build_required)" name: Clean after run: ./run git-clean env: @@ -295,7 +301,7 @@ jobs: run: ./run --help env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - if: "contains(github.event.pull_request.labels.*.name, 'CI: Clean build required')" + - if: "(contains(github.event.pull_request.labels.*.name, 'CI: Clean build required') || inputs.clean_build_required)" name: Clean before run: ./run git-clean env: @@ -309,7 +315,7 @@ jobs: - if: failure() && runner.os != 'Windows' name: List files if failed (non-Windows) run: ls -lAR - - if: "always() && contains(github.event.pull_request.labels.*.name, 'CI: Clean build required')" + - if: "(always()) && (contains(github.event.pull_request.labels.*.name, 'CI: Clean build required') || inputs.clean_build_required)" name: Clean after run: ./run git-clean env: @@ -343,7 +349,7 @@ jobs: run: ./run --help env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - if: "contains(github.event.pull_request.labels.*.name, 'CI: Clean build required')" + - if: "(contains(github.event.pull_request.labels.*.name, 'CI: Clean build required') || inputs.clean_build_required)" name: Clean before run: ./run git-clean env: @@ -357,7 +363,7 @@ jobs: - if: failure() && runner.os != 'Windows' name: List files if failed (non-Windows) run: ls -lAR - - if: "always() && contains(github.event.pull_request.labels.*.name, 'CI: Clean build required')" + - if: "(always()) && (contains(github.event.pull_request.labels.*.name, 'CI: Clean build required') || inputs.clean_build_required)" name: Clean after run: ./run git-clean env: @@ -392,7 +398,7 @@ jobs: run: ./run --help env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - if: "contains(github.event.pull_request.labels.*.name, 'CI: Clean build required')" + - if: "(contains(github.event.pull_request.labels.*.name, 'CI: Clean build required') || inputs.clean_build_required)" name: Clean before run: ./run git-clean env: @@ -406,7 +412,7 @@ jobs: - if: failure() && runner.os != 'Windows' name: List files if failed (non-Windows) run: ls -lAR - - if: "always() && contains(github.event.pull_request.labels.*.name, 'CI: Clean build required')" + - if: "(always()) && (contains(github.event.pull_request.labels.*.name, 'CI: Clean build required') || inputs.clean_build_required)" name: Clean after run: ./run git-clean env: @@ -441,7 +447,7 @@ jobs: run: ./run --help env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - if: "contains(github.event.pull_request.labels.*.name, 'CI: Clean build required')" + - if: "(contains(github.event.pull_request.labels.*.name, 'CI: Clean build required') || inputs.clean_build_required)" name: Clean before run: ./run git-clean env: @@ -455,7 +461,7 @@ jobs: - if: failure() && runner.os != 'Windows' name: List files if failed (non-Windows) run: ls -lAR - - if: "always() && contains(github.event.pull_request.labels.*.name, 'CI: Clean build required')" + - if: "(always()) && (contains(github.event.pull_request.labels.*.name, 'CI: Clean build required') || inputs.clean_build_required)" name: Clean after run: ./run git-clean env: @@ -492,7 +498,7 @@ jobs: run: ./run --help env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - if: "contains(github.event.pull_request.labels.*.name, 'CI: Clean build required')" + - if: "(contains(github.event.pull_request.labels.*.name, 'CI: Clean build required') || inputs.clean_build_required)" name: Clean before run: ./run git-clean env: @@ -506,7 +512,7 @@ jobs: - if: failure() && runner.os != 'Windows' name: List files if failed (non-Windows) run: ls -lAR - - if: "always() && contains(github.event.pull_request.labels.*.name, 'CI: Clean build required')" + - if: "(always()) && (contains(github.event.pull_request.labels.*.name, 'CI: Clean build required') || inputs.clean_build_required)" name: Clean after run: ./run git-clean env: @@ -542,7 +548,7 @@ jobs: run: ./run --help env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - if: "contains(github.event.pull_request.labels.*.name, 'CI: Clean build required')" + - if: "(contains(github.event.pull_request.labels.*.name, 'CI: Clean build required') || inputs.clean_build_required)" name: Clean before run: ./run git-clean env: @@ -569,7 +575,7 @@ jobs: - if: failure() && runner.os != 'Windows' name: List files if failed (non-Windows) run: ls -lAR - - if: "always() && contains(github.event.pull_request.labels.*.name, 'CI: Clean build required')" + - if: "(always()) && (contains(github.event.pull_request.labels.*.name, 'CI: Clean build required') || inputs.clean_build_required)" name: Clean after run: ./run git-clean env: @@ -606,7 +612,7 @@ jobs: run: ./run --help env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - if: "contains(github.event.pull_request.labels.*.name, 'CI: Clean build required')" + - if: "(contains(github.event.pull_request.labels.*.name, 'CI: Clean build required') || inputs.clean_build_required)" name: Clean before run: ./run git-clean env: @@ -622,7 +628,7 @@ jobs: - if: failure() && runner.os != 'Windows' name: List files if failed (non-Windows) run: ls -lAR - - if: "always() && contains(github.event.pull_request.labels.*.name, 'CI: Clean build required')" + - if: "(always()) && (contains(github.event.pull_request.labels.*.name, 'CI: Clean build required') || inputs.clean_build_required)" name: Clean after run: ./run git-clean env: @@ -657,7 +663,7 @@ jobs: run: ./run --help env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - if: "contains(github.event.pull_request.labels.*.name, 'CI: Clean build required')" + - if: "(contains(github.event.pull_request.labels.*.name, 'CI: Clean build required') || inputs.clean_build_required)" name: Clean before run: ./run git-clean env: @@ -671,7 +677,7 @@ jobs: - if: failure() && runner.os != 'Windows' name: List files if failed (non-Windows) run: ls -lAR - - if: "always() && contains(github.event.pull_request.labels.*.name, 'CI: Clean build required')" + - if: "(always()) && (contains(github.event.pull_request.labels.*.name, 'CI: Clean build required') || inputs.clean_build_required)" name: Clean after run: ./run git-clean env: diff --git a/.github/workflows/promote.yml b/.github/workflows/promote.yml index d9cc876e4bf..04472479794 100644 --- a/.github/workflows/promote.yml +++ b/.github/workflows/promote.yml @@ -51,7 +51,7 @@ jobs: run: ./run --help env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - if: "contains(github.event.pull_request.labels.*.name, 'CI: Clean build required')" + - if: "(contains(github.event.pull_request.labels.*.name, 'CI: Clean build required') || inputs.clean_build_required)" name: Clean before run: ./run git-clean env: @@ -66,7 +66,7 @@ jobs: - if: failure() && runner.os != 'Windows' name: List files if failed (non-Windows) run: ls -lAR - - if: "always() && contains(github.event.pull_request.labels.*.name, 'CI: Clean build required')" + - if: "(always()) && (contains(github.event.pull_request.labels.*.name, 'CI: Clean build required') || inputs.clean_build_required)" name: Clean after run: ./run git-clean env: diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 8f8b1e7c5ea..14230422ffd 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -83,7 +83,7 @@ jobs: run: ./run --help env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - if: "contains(github.event.pull_request.labels.*.name, 'CI: Clean build required')" + - if: "(contains(github.event.pull_request.labels.*.name, 'CI: Clean build required') || inputs.clean_build_required)" name: Clean before run: ./run git-clean env: @@ -98,7 +98,7 @@ jobs: - if: failure() && runner.os != 'Windows' name: List files if failed (non-Windows) run: ls -lAR - - if: "always() && contains(github.event.pull_request.labels.*.name, 'CI: Clean build required')" + - if: "(always()) && (contains(github.event.pull_request.labels.*.name, 'CI: Clean build required') || inputs.clean_build_required)" name: Clean after run: ./run git-clean env: @@ -135,7 +135,7 @@ jobs: run: ./run --help env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - if: "contains(github.event.pull_request.labels.*.name, 'CI: Clean build required')" + - if: "(contains(github.event.pull_request.labels.*.name, 'CI: Clean build required') || inputs.clean_build_required)" name: Clean before run: ./run git-clean env: @@ -152,7 +152,7 @@ jobs: - if: failure() && runner.os != 'Windows' name: List files if failed (non-Windows) run: ls -lAR - - if: "always() && contains(github.event.pull_request.labels.*.name, 'CI: Clean build required')" + - if: "(always()) && (contains(github.event.pull_request.labels.*.name, 'CI: Clean build required') || inputs.clean_build_required)" name: Clean after run: ./run git-clean env: @@ -190,7 +190,7 @@ jobs: run: ./run --help env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - if: "contains(github.event.pull_request.labels.*.name, 'CI: Clean build required')" + - if: "(contains(github.event.pull_request.labels.*.name, 'CI: Clean build required') || inputs.clean_build_required)" name: Clean before run: ./run git-clean env: @@ -208,7 +208,7 @@ jobs: - if: failure() && runner.os != 'Windows' name: List files if failed (non-Windows) run: ls -lAR - - if: "always() && contains(github.event.pull_request.labels.*.name, 'CI: Clean build required')" + - if: "(always()) && (contains(github.event.pull_request.labels.*.name, 'CI: Clean build required') || inputs.clean_build_required)" name: Clean after run: ./run git-clean env: @@ -248,7 +248,7 @@ jobs: run: ./run --help env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - if: always() + - if: (always()) name: Clean before run: ./run git-clean env: @@ -262,7 +262,7 @@ jobs: - if: failure() && runner.os != 'Windows' name: List files if failed (non-Windows) run: ls -lAR - - if: always() + - if: (always()) name: Clean after run: ./run git-clean env: @@ -303,7 +303,7 @@ jobs: run: ./run --help env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - if: always() + - if: (always()) name: Clean before run: ./run git-clean env: @@ -317,7 +317,7 @@ jobs: - if: failure() && runner.os != 'Windows' name: List files if failed (non-Windows) run: ls -lAR - - if: always() + - if: (always()) name: Clean after run: ./run git-clean env: @@ -356,7 +356,7 @@ jobs: run: ./run --help env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - if: always() + - if: (always()) name: Clean before run: ./run git-clean env: @@ -370,7 +370,7 @@ jobs: - if: failure() && runner.os != 'Windows' name: List files if failed (non-Windows) run: ls -lAR - - if: always() + - if: (always()) name: Clean after run: ./run git-clean env: @@ -410,7 +410,7 @@ jobs: run: ./run --help env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - if: always() + - if: (always()) name: Clean before run: ./run git-clean env: @@ -424,7 +424,7 @@ jobs: - if: failure() && runner.os != 'Windows' name: List files if failed (non-Windows) run: ls -lAR - - if: always() + - if: (always()) name: Clean after run: ./run git-clean env: @@ -474,7 +474,7 @@ jobs: run: ./run --help env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - if: "contains(github.event.pull_request.labels.*.name, 'CI: Clean build required')" + - if: "(contains(github.event.pull_request.labels.*.name, 'CI: Clean build required') || inputs.clean_build_required)" name: Clean before run: ./run git-clean env: @@ -488,7 +488,7 @@ jobs: - if: failure() && runner.os != 'Windows' name: List files if failed (non-Windows) run: ls -lAR - - if: "always() && contains(github.event.pull_request.labels.*.name, 'CI: Clean build required')" + - if: "(always()) && (contains(github.event.pull_request.labels.*.name, 'CI: Clean build required') || inputs.clean_build_required)" name: Clean after run: ./run git-clean env: @@ -533,7 +533,7 @@ jobs: run: ./run --help env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - if: always() + - if: (always()) name: Clean before run: ./run git-clean env: @@ -547,7 +547,7 @@ jobs: - if: failure() && runner.os != 'Windows' name: List files if failed (non-Windows) run: ls -lAR - - if: always() + - if: (always()) name: Clean after run: ./run git-clean env: @@ -590,7 +590,7 @@ jobs: run: ./run --help env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - if: always() + - if: (always()) name: Clean before run: ./run git-clean env: @@ -617,7 +617,7 @@ jobs: - if: failure() && runner.os != 'Windows' name: List files if failed (non-Windows) run: ls -lAR - - if: always() + - if: (always()) name: Clean after run: ./run git-clean env: @@ -658,7 +658,7 @@ jobs: run: ./run --help env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - if: always() + - if: (always()) name: Clean before run: ./run git-clean env: @@ -685,7 +685,7 @@ jobs: - if: failure() && runner.os != 'Windows' name: List files if failed (non-Windows) run: ls -lAR - - if: always() + - if: (always()) name: Clean after run: ./run git-clean env: @@ -727,7 +727,7 @@ jobs: run: ./run --help env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - if: always() + - if: (always()) name: Clean before run: ./run git-clean env: @@ -743,7 +743,7 @@ jobs: - if: failure() && runner.os != 'Windows' name: List files if failed (non-Windows) run: ls -lAR - - if: always() + - if: (always()) name: Clean after run: ./run git-clean env: @@ -784,7 +784,7 @@ jobs: run: ./run --help env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - if: always() + - if: (always()) name: Clean before run: ./run git-clean env: @@ -798,7 +798,7 @@ jobs: - if: failure() && runner.os != 'Windows' name: List files if failed (non-Windows) run: ls -lAR - - if: always() + - if: (always()) name: Clean after run: ./run git-clean env: @@ -840,7 +840,7 @@ jobs: run: ./run --help env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - if: always() + - if: (always()) name: Clean before run: ./run git-clean env: @@ -867,7 +867,7 @@ jobs: - if: failure() && runner.os != 'Windows' name: List files if failed (non-Windows) run: ls -lAR - - if: always() + - if: (always()) name: Clean after run: ./run git-clean env: @@ -907,7 +907,7 @@ jobs: run: ./run --help env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - if: always() + - if: (always()) name: Clean before run: ./run git-clean env: @@ -934,7 +934,7 @@ jobs: - if: failure() && runner.os != 'Windows' name: List files if failed (non-Windows) run: ls -lAR - - if: always() + - if: (always()) name: Clean after run: ./run git-clean env: @@ -975,7 +975,7 @@ jobs: run: ./run --help env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - if: always() + - if: (always()) name: Clean before run: ./run git-clean env: @@ -991,7 +991,7 @@ jobs: - if: failure() && runner.os != 'Windows' name: List files if failed (non-Windows) run: ls -lAR - - if: always() + - if: (always()) name: Clean after run: ./run git-clean env: diff --git a/.github/workflows/scala-new.yml b/.github/workflows/scala-new.yml index 33a6880960a..8da9b37561f 100644 --- a/.github/workflows/scala-new.yml +++ b/.github/workflows/scala-new.yml @@ -7,7 +7,13 @@ on: branches: - develop pull_request: {} - workflow_dispatch: {} + workflow_dispatch: + inputs: + clean_build_required: + description: Clean before and after the run. + required: false + type: boolean + default: false jobs: enso-build-ci-gen-job-cancel-workflow-linux-x86_64: name: Cancel Previous Runs @@ -51,7 +57,7 @@ jobs: run: ./run --help env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - if: "contains(github.event.pull_request.labels.*.name, 'CI: Clean build required')" + - if: "(contains(github.event.pull_request.labels.*.name, 'CI: Clean build required') || inputs.clean_build_required)" name: Clean before run: ./run git-clean env: @@ -86,7 +92,7 @@ jobs: - if: failure() && runner.os != 'Windows' name: List files if failed (non-Windows) run: ls -lAR - - if: "always() && contains(github.event.pull_request.labels.*.name, 'CI: Clean build required')" + - if: "(always()) && (contains(github.event.pull_request.labels.*.name, 'CI: Clean build required') || inputs.clean_build_required)" name: Clean after run: ./run git-clean env: @@ -122,7 +128,7 @@ jobs: run: ./run --help env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - if: "contains(github.event.pull_request.labels.*.name, 'CI: Clean build required')" + - if: "(contains(github.event.pull_request.labels.*.name, 'CI: Clean build required') || inputs.clean_build_required)" name: Clean before run: ./run git-clean env: @@ -157,7 +163,7 @@ jobs: - if: failure() && runner.os != 'Windows' name: List files if failed (non-Windows) run: ls -lAR - - if: "always() && contains(github.event.pull_request.labels.*.name, 'CI: Clean build required')" + - if: "(always()) && (contains(github.event.pull_request.labels.*.name, 'CI: Clean build required') || inputs.clean_build_required)" name: Clean after run: ./run git-clean env: @@ -194,7 +200,7 @@ jobs: run: ./run --help env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - if: "contains(github.event.pull_request.labels.*.name, 'CI: Clean build required')" + - if: "(contains(github.event.pull_request.labels.*.name, 'CI: Clean build required') || inputs.clean_build_required)" name: Clean before run: ./run git-clean env: @@ -229,7 +235,7 @@ jobs: - if: failure() && runner.os != 'Windows' name: List files if failed (non-Windows) run: ls -lAR - - if: "always() && contains(github.event.pull_request.labels.*.name, 'CI: Clean build required')" + - if: "(always()) && (contains(github.event.pull_request.labels.*.name, 'CI: Clean build required') || inputs.clean_build_required)" name: Clean after run: ./run git-clean env: diff --git a/.github/workflows/std-libs-benchmark.yml b/.github/workflows/std-libs-benchmark.yml index 9446c948806..4076e8ea5ce 100644 --- a/.github/workflows/std-libs-benchmark.yml +++ b/.github/workflows/std-libs-benchmark.yml @@ -42,7 +42,7 @@ jobs: run: ./run --help env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - if: always() + - if: (always()) name: Clean before run: ./run git-clean env: @@ -56,7 +56,7 @@ jobs: - if: failure() && runner.os != 'Windows' name: List files if failed (non-Windows) run: ls -lAR - - if: always() + - if: (always()) name: Clean after run: ./run git-clean env: diff --git a/build/build/src/ci.rs b/build/build/src/ci.rs index f7f8ab5e142..a5bc977ce73 100644 --- a/build/build/src/ci.rs +++ b/build/build/src/ci.rs @@ -14,6 +14,12 @@ pub mod labels { pub const CLEAN_BUILD_REQUIRED: &str = "CI: Clean build required"; } +/// Names used to represent common workflow dispatch events inputs. +pub mod inputs { + /// Input allowing to request a clean build for the workflow. + pub const CLEAN_BUILD_REQUIRED: &str = "clean_build_required"; +} + /// Check if this is a "big memory" machine. /// /// Our self-hosted runners are big memory machines, but the GitHub-hosted ones are not. diff --git a/build/build/src/ci_gen.rs b/build/build/src/ci_gen.rs index cc0fc1421ed..7a6952d6b88 100644 --- a/build/build/src/ci_gen.rs +++ b/build/build/src/ci_gen.rs @@ -1,6 +1,5 @@ use crate::prelude::*; -use crate::ci::labels::CLEAN_BUILD_REQUIRED; use crate::ci_gen::job::plain_job; use crate::ci_gen::job::with_packaging_steps; use crate::ci_gen::job::RunsOn; @@ -153,25 +152,34 @@ impl RunsOn for BenchmarkRunner { pub enum CleaningCondition { /// Always clean, even if the job was canceled or failed. Always, - /// Clean only if the "Clean required" label is present on the pull request. + /// Clean only if the clean build was requested by the actor. #[default] - OnLabel, + OnRequest, } -impl CleaningCondition { - /// Pretty print (for GH Actions) the `if` condition for the cleaning step. - pub fn format(self) -> String { +impl Display for CleaningCondition { + fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result { // Note that we need to use `always() &&` to make this condition evaluate on failed and // canceled runs. See: https://docs.github.com/en/actions/learn-github-actions/expressions#always // // Using `always() &&` is not a no-op like `true &&` would be. match self { - Self::Always => "always()".into(), - Self::OnLabel => format!( - "contains(github.event.pull_request.labels.*.name, '{CLEAN_BUILD_REQUIRED}')" + Self::Always => write!(f, "always()"), + Self::OnRequest => write!( + f, + "contains(github.event.pull_request.labels.*.name, '{}') || inputs.{}", + crate::ci::labels::CLEAN_BUILD_REQUIRED, + crate::ci::inputs::CLEAN_BUILD_REQUIRED ), } } +} + +impl CleaningCondition { + /// Pretty print (for GH Actions) the `if` condition for the cleaning step. + pub fn format(self) -> String { + self.to_string() + } /// Format condition as `if` expression. /// @@ -181,7 +189,7 @@ impl CleaningCondition { if conditions.is_empty() { None } else { - Some(conditions.into_iter().map(Self::format).join(" && ")) + conditions.into_iter().map(|c| format!("({})", c.format())).join(" && ").into() } } } @@ -581,9 +589,13 @@ pub fn promote() -> Result { } pub fn typical_check_triggers() -> Event { + let clean_build_input = + WorkflowDispatchInput::new_boolean("Clean before and after the run.", false, false); + let workflow_dispatch = WorkflowDispatch::default() + .with_input(crate::ci::inputs::CLEAN_BUILD_REQUIRED, clean_build_input); Event { pull_request: Some(default()), - workflow_dispatch: Some(default()), + workflow_dispatch: Some(workflow_dispatch), push: Some(on_default_branch_push()), ..default() }