From 7805e203f03ca129035d068ad31c12a979bd96a0 Mon Sep 17 00:00:00 2001 From: Guillaume Ballet <3272758+gballet@users.noreply.github.com> Date: Wed, 26 Nov 2025 23:36:35 +0100 Subject: [PATCH] .github/workflows: validate that the directories exist (#33289) A new pointless fad appeared recently where people just create a fairly low information tag at the beginning of their github PR titles. Something like `feat` or other keywords. This seems to originate from the angular community and to be used for automation scripts over there. We do not use any of those scripts and if we did we would be using the github labels, which offer strictly equivalent functionalities without wasting useful PR title space. In order for these keywords to fail the validation, I am adding a check that these directories listed indeed exist in the repository. --- .github/workflows/validate_pr.yml | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/.github/workflows/validate_pr.yml b/.github/workflows/validate_pr.yml index 0719ca2e3d..57e8c12b5e 100644 --- a/.github/workflows/validate_pr.yml +++ b/.github/workflows/validate_pr.yml @@ -8,10 +8,15 @@ jobs: validate-pr: runs-on: ubuntu-latest steps: + - name: Checkout repository + uses: actions/checkout@v4 + - name: Check PR Title Format uses: actions/github-script@v7 with: script: | + const fs = require('fs'); + const path = require('path'); const prTitle = context.payload.pull_request.title; const titleRegex = /^([\w\s,{}/.]+): .+/; @@ -19,5 +24,21 @@ jobs: core.setFailed(`PR title "${prTitle}" does not match required format: directory, ...: description`); return; } + + const match = prTitle.match(titleRegex); + const dirPart = match[1]; + const directories = dirPart.split(',').map(d => d.trim()); + const missingDirs = []; + for (const dir of directories) { + const fullPath = path.join(process.env.GITHUB_WORKSPACE, dir); + if (!fs.existsSync(fullPath)) { + missingDirs.push(dir); + } + } + + if (missingDirs.length > 0) { + core.setFailed(`The following directories in the PR title do not exist: ${missingDirs.join(', ')}`); + return; + } console.log('✅ PR title format is valid');