[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.
This commit is contained in:
Michał Wawrzyniec Urbańczyk 2024-03-05 16:40:46 +01:00 committed by GitHub
parent b0842feea2
commit 1a76f6383d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
9 changed files with 115 additions and 85 deletions

View File

@ -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:

View File

@ -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:

View File

@ -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:

View File

@ -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:

View File

@ -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:

View File

@ -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:

View File

@ -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:

View File

@ -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.

View File

@ -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<Workflow> {
}
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()
}