From 8ae93c17bd011e4ef539eebeee3f5c1553afa3f3 Mon Sep 17 00:00:00 2001 From: Thomas A Caswell Date: Wed, 12 Jan 2022 15:54:54 -0500 Subject: [PATCH] Backport PR #21833: Enforce backport conditions on v*-doc branches Merge pull request #21833 from QuLogic/clean-doc-backports CI: Enforce backport conditions on v*-doc branches --- .circleci/config.yml | 10 +++++++++- .github/workflows/clean_pr.yml | 23 ++++++++++++++++++++++- 2 files changed, 31 insertions(+), 2 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index bcaafc27aa38..8d5d4d8a72f0 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -103,7 +103,15 @@ commands: steps: - run: name: Install Matplotlib - command: python -m pip install --user -ve . + command: | + if [[ "$CIRCLE_BRANCH" == v*-doc ]]; then + # The v*-doc branches must build against the specified release. + version=${CIRCLE_BRANCH%-doc} + version=${version#v} + python -m pip install matplotlib==${version} + else + python -m pip install --user -ve . + fi - save_cache: key: build-deps-1 paths: diff --git a/.github/workflows/clean_pr.yml b/.github/workflows/clean_pr.yml index fc2acc0b2e4c..51350aab6773 100644 --- a/.github/workflows/clean_pr.yml +++ b/.github/workflows/clean_pr.yml @@ -19,4 +19,25 @@ jobs: printf 'The following files were both added and deleted in this PR:\n%s\n' "$ad" exit 1 fi - + - name: Check for added-and-modified images + run: | + git fetch --quiet origin "$GITHUB_BASE_REF" + base="$(git merge-base "origin/$GITHUB_BASE_REF" 'HEAD^2')" + am="$(git log "$base..HEAD^2" --pretty=tformat: --name-status --diff-filter=AM | + cut --fields 2 | sort | uniq --repeated | + grep -E '\.(png|pdf|ps|eps|svg)' || true)" + if [[ -n "$am" ]]; then + printf 'The following images were both added and modified in this PR:\n%s\n' "$am" + exit 1 + fi + - name: Check for invalid backports to -doc branches + if: endsWith(github.base_ref, '-doc') + run: | + git fetch --quiet origin "$GITHUB_BASE_REF" + base="$(git merge-base "origin/$GITHUB_BASE_REF" 'HEAD^2')" + lib="$(git log "$base..HEAD^2" --pretty=tformat: --name-status -- lib src | + cut --fields 2 | sort || true)" + if [[ -n "$lib" ]]; then + printf 'Changes to the following files have no effect and should not be backported:\n%s\n' "$lib" + exit 1 + fi