From fc6e0176e56dc72b3426aa2bbf7defc455946015 Mon Sep 17 00:00:00 2001 From: Casper Welzel Andersen Date: Fri, 29 Sep 2023 12:18:03 +0200 Subject: [PATCH 1/6] Make using dependencies branch toggleable Update name for this input in workflow for updating pyproject.toml to be `target_branch`, deprecating `permanent_dependencies_branch`. --- .../ci_cd_updated_default_branch.yml | 7 ++++++- .../ci_check_pyproject_dependencies.yml | 21 ++++++++++++++----- .github/workflows/ci_tests.yml | 2 +- .../workflows/ci_cd_updated_default_branch.md | 1 + .../ci_check_pyproject_dependencies.md | 5 +++-- 5 files changed, 27 insertions(+), 9 deletions(-) diff --git a/.github/workflows/ci_cd_updated_default_branch.yml b/.github/workflows/ci_cd_updated_default_branch.yml index d4aa793d..5d874752 100644 --- a/.github/workflows/ci_cd_updated_default_branch.yml +++ b/.github/workflows/ci_cd_updated_default_branch.yml @@ -26,6 +26,11 @@ on: default: false # Update permanent dependencies branch + update_dependencies_branch: + description: "Whether or not to update the permanent dependencies branch." + required: false + type: boolean + default: true permanent_dependencies_branch: description: "The branch name for the permanent dependency updates branch." required: false @@ -414,7 +419,7 @@ jobs: name: Update permanent dependencies branch runs-on: ubuntu-latest needs: deploy_docs - if: always() + if: always() && inputs.update_dependencies_branch steps: - name: Checkout ${{ github.repository }} diff --git a/.github/workflows/ci_check_pyproject_dependencies.yml b/.github/workflows/ci_check_pyproject_dependencies.yml index 2e6f1113..a8a2beeb 100644 --- a/.github/workflows/ci_check_pyproject_dependencies.yml +++ b/.github/workflows/ci_check_pyproject_dependencies.yml @@ -11,8 +11,13 @@ on: description: "A git user's email address (used to set the 'user.email' config option)." required: true type: string - permanent_dependencies_branch: - description: "The branch name for the permanent dependency updates branch." + target_branch: + description: "The branch name for the target of the opened PR." + required: false + type: string + # default: "ci/dependency-updates" + permanent_dependencies_branch: # DEPRECATED - v2.6.0 REMOVAL + description: "DEPRECATED - use `target_branch` instead. Will be removed in v2.6.0. The branch name for the permanent dependency updates branch." required: false type: string default: "ci/dependency-updates" @@ -48,7 +53,7 @@ on: default: "" secrets: PAT: - description: "A personal access token (PAT) with rights to update the `permanent_dependencies_branch`. This will fallback on `GITHUB_TOKEN`." + description: "A personal access token (PAT) with rights to create PRs. This will fallback on `GITHUB_TOKEN`." required: false jobs: @@ -57,10 +62,16 @@ jobs: runs-on: ubuntu-latest steps: - - name: Checkout permanent dependencies branch in ${{ github.repository }} + - name: Check inputs + run: | + if [ -n "${{ inputs.permanent_dependencies_branch }}" ]; then + echo "::warning file=${{ github.workflow_ref }},title=Deprecation Warning::'permanent_dependencies_branch' is deprecated and will be removed in v2.6.0. Use 'target_branch' instead." + fi + + - name: Checkout ${{ inputs.target_branch || inputs.permanent_dependencies_branch }} in ${{ github.repository }} uses: actions/checkout@v4 with: - ref: ${{ inputs.permanent_dependencies_branch }} + ref: ${{ inputs.target_branch || inputs.permanent_dependencies_branch }} fetch-depth: 0 - name: Set up Python ${{ inputs.python_version }} diff --git a/.github/workflows/ci_tests.yml b/.github/workflows/ci_tests.yml index 5410feec..8bfc2c05 100644 --- a/.github/workflows/ci_tests.yml +++ b/.github/workflows/ci_tests.yml @@ -465,7 +465,7 @@ jobs: else STRICT= - echo "::warning file=ci_tests.yml,line=446,col=11,endColumn=18::Beware that the documentation may succeed building, but will not be rendered or built as intended. To ensure this is the case, set 'warnings_as_errors' to 'true' (using '--strict' (MkDocs) or '-W' (Sphinx))." + echo "::warning file=ci_tests.yml,line=467,col=11,endColumn=18::Beware that the documentation may succeed building, but will not be rendered or built as intended. To ensure this is the case, set 'warnings_as_errors' to 'true' (using '--strict' (MkDocs) or '-W' (Sphinx))." fi # Run build command diff --git a/docs/workflows/ci_cd_updated_default_branch.md b/docs/workflows/ci_cd_updated_default_branch.md index af31ddbe..38e701ad 100644 --- a/docs/workflows/ci_cd_updated_default_branch.md +++ b/docs/workflows/ci_cd_updated_default_branch.md @@ -46,6 +46,7 @@ Inputs related to updating the permanent dependencies branch. | **Name** | **Description** | **Required** | **Default** | **Type** | |:--- |:--- |:---:|:---:|:---:| +| `update_dependencies_branch` | Whether or not to update the permanent dependencies branch. | No | `true` | _boolean_ | | `permanent_dependencies_branch` | The branch name for the permanent dependency updates branch. | No | ci/dependency-updates | _string_ | | `update_dependencies_pr_body_file` | Relative path to a PR body file from the root of the repository, which is used in the 'CI - Update dependencies PR' workflow, if used.

Example: `'.github/utils/pr_body_update_deps.txt'`. | No | _Empty string_ | _string_ | diff --git a/docs/workflows/ci_check_pyproject_dependencies.md b/docs/workflows/ci_check_pyproject_dependencies.md index cf51b592..e9dce614 100644 --- a/docs/workflows/ci_check_pyproject_dependencies.md +++ b/docs/workflows/ci_check_pyproject_dependencies.md @@ -58,7 +58,8 @@ The repository contains the following: |:--- |:--- |:---:|:---:|:---:| | `git_username` | A git username (used to set the 'user.name' config option). | **_Yes_** | | _string_ | | `git_email` | A git user's email address (used to set the 'user.email' config option). | **_Yes_** | | _string_ | -| `permanent_dependencies_branch` | The branch name for the permanent dependency updates branch. | No | ci/dependency-updates | _string_ | +| `target_branch` | The branch name for the target of the opened PR. | No | _Empty string_ | _string_ | +| `permanent_dependencies_branch` | **DEPRECATED** - Will be removed in v2.6.0. Use `target_branch` instead.

The branch name for the permanent dependency updates branch. | No | ci/dependency-updates | _string_ | | `python_version` | The Python version to use for the workflow. | No | 3.9 | _string_ | | `install_extras` | Any extras to install from the local repository through 'pip'. Must be encapsulated in square parentheses (`[]`) and be separated by commas (`,`) without any spaces.

Example: `'[dev,release]'`. | No | _Empty string_ | _string_ | | `pr_body_file` | Relative path to PR body file from the root of the repository.

Example: `'.github/utils/pr_body_deps_check.txt'`. | No | _Empty string_ | _string_ | @@ -93,7 +94,7 @@ jobs: with: git_username: "Casper Welzel Andersen" git_email: "CasperWA@github.com" - permanent_dependencies_branch: "ci/dependency-updates" + target_branch: "ci/dependency-updates" python_version: "3.9" install_extras: "[dev]" pr_labels: "CI/CD" From ecff44c041a48ce2345fd3b91cade9e98b6fdc40 Mon Sep 17 00:00:00 2001 From: Casper Welzel Andersen Date: Fri, 29 Sep 2023 12:25:30 +0200 Subject: [PATCH 2/6] Test warning message --- .../_local_ci_check_pyproject_dependencies.yml | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/.github/workflows/_local_ci_check_pyproject_dependencies.yml b/.github/workflows/_local_ci_check_pyproject_dependencies.yml index f4d5815a..5bc9e29c 100644 --- a/.github/workflows/_local_ci_check_pyproject_dependencies.yml +++ b/.github/workflows/_local_ci_check_pyproject_dependencies.yml @@ -1,10 +1,11 @@ name: CI - Check dependencies PR on: - schedule: - # At 7:30 every Monday (5:30 UTC) - - cron: "30 5 * * 1" - workflow_dispatch: + # schedule: + # # At 7:30 every Monday (5:30 UTC) + # - cron: "30 5 * * 1" + # workflow_dispatch: + pull_request: # for testing jobs: update-pyproject-dependencies: @@ -14,7 +15,7 @@ jobs: with: git_username: "TEAM 4.0[bot]" git_email: "TEAM4.0@SINTEF.no" - permanent_dependencies_branch: "ci/dependency-updates" + permanent_dependencies_branch: "cwa/close-183-toggle-dependencies-branch" install_extras: "[dev,docs]" pr_labels: "CI/CD" secrets: From 2d46b17fad36c8eed5fd09428d55e4aa8e65ac89 Mon Sep 17 00:00:00 2001 From: Casper Welzel Andersen Date: Fri, 29 Sep 2023 12:30:13 +0200 Subject: [PATCH 3/6] Revert "Test warning message" This reverts commit ecff44c041a48ce2345fd3b91cade9e98b6fdc40. --- .../_local_ci_check_pyproject_dependencies.yml | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/.github/workflows/_local_ci_check_pyproject_dependencies.yml b/.github/workflows/_local_ci_check_pyproject_dependencies.yml index 5bc9e29c..f4d5815a 100644 --- a/.github/workflows/_local_ci_check_pyproject_dependencies.yml +++ b/.github/workflows/_local_ci_check_pyproject_dependencies.yml @@ -1,11 +1,10 @@ name: CI - Check dependencies PR on: - # schedule: - # # At 7:30 every Monday (5:30 UTC) - # - cron: "30 5 * * 1" - # workflow_dispatch: - pull_request: # for testing + schedule: + # At 7:30 every Monday (5:30 UTC) + - cron: "30 5 * * 1" + workflow_dispatch: jobs: update-pyproject-dependencies: @@ -15,7 +14,7 @@ jobs: with: git_username: "TEAM 4.0[bot]" git_email: "TEAM4.0@SINTEF.no" - permanent_dependencies_branch: "cwa/close-183-toggle-dependencies-branch" + permanent_dependencies_branch: "ci/dependency-updates" install_extras: "[dev,docs]" pr_labels: "CI/CD" secrets: From ac6f42992aee7988396580ce03afbb6c26d7ce8c Mon Sep 17 00:00:00 2001 From: Casper Welzel Andersen Date: Fri, 29 Sep 2023 12:30:48 +0200 Subject: [PATCH 4/6] Use updated input name --- .github/workflows/_local_ci_check_pyproject_dependencies.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/_local_ci_check_pyproject_dependencies.yml b/.github/workflows/_local_ci_check_pyproject_dependencies.yml index f4d5815a..59444421 100644 --- a/.github/workflows/_local_ci_check_pyproject_dependencies.yml +++ b/.github/workflows/_local_ci_check_pyproject_dependencies.yml @@ -14,7 +14,7 @@ jobs: with: git_username: "TEAM 4.0[bot]" git_email: "TEAM4.0@SINTEF.no" - permanent_dependencies_branch: "ci/dependency-updates" + target_branch: "ci/dependency-updates" install_extras: "[dev,docs]" pr_labels: "CI/CD" secrets: From 95531291e61937064eeba16ca038c57a86d307b5 Mon Sep 17 00:00:00 2001 From: Casper Welzel Andersen Date: Mon, 6 Nov 2023 14:40:23 +0100 Subject: [PATCH 5/6] Better handling for deprecated input Handle all the different cases between the now deprecated 'permanent_dependencies_branch' input value and the replacement 'target_branch' value with more appropriate warning messages and results. --- .../ci_check_pyproject_dependencies.yml | 34 ++++++++++++++++--- 1 file changed, 29 insertions(+), 5 deletions(-) diff --git a/.github/workflows/ci_check_pyproject_dependencies.yml b/.github/workflows/ci_check_pyproject_dependencies.yml index 763a4499..66b0b4db 100644 --- a/.github/workflows/ci_check_pyproject_dependencies.yml +++ b/.github/workflows/ci_check_pyproject_dependencies.yml @@ -15,12 +15,12 @@ on: description: "The branch name for the target of the opened PR." required: false type: string - # default: "ci/dependency-updates" + default: "" permanent_dependencies_branch: # DEPRECATED - v2.6.0 REMOVAL description: "DEPRECATED - use `target_branch` instead. Will be removed in v2.6.0. The branch name for the permanent dependency updates branch." required: false type: string - default: "ci/dependency-updates" + default: "" python_version: description: "The Python version to use for the workflow." required: false @@ -74,14 +74,38 @@ jobs: steps: - name: Check inputs run: | - if [ -n "${{ inputs.permanent_dependencies_branch }}" ]; then + # Check the depreacted 'permanent_dependencies_branch' input. + if [ -z "${{ inputs.target_branch }}" && -z "${{ inputs.permanent_dependencies_branch }}" ]; then + # Scenario expected to be: One has not explicitly set 'permanent_dependencies_branch' previously, using the (old) default value. + # While not knowing that it is now deprecated, and one should instead use 'target_branch' with an explicitly set value. + # Cause of action: Set 'target_branch' to the (old) default value, and emit a deprecation warning. + + echo "::warning file=${{ github.workflow_ref }},title=Deprecation Warning::'permanent_dependencies_branch' is deprecated and will be removed in v2.6.0. Use 'target_branch' instead with explicit value. The old default value for 'permanent_dependencies_branch' was: 'ci/dependency-updates'." + echo "target_branch=ci/dependency-updates" >> $GITHUB_ENV + elif [ -z "${{ inputs.target_branch }}" && -n "${{ inputs.permanent_dependencies_branch }}" ]; then + # Scenario expected to be: One has set an explicit value for 'permanent_dependencies_branch' previously. + # While not knowing that it is now deprecated, and one should instead use 'target_branch' with an explicitly set value. + # Cause of action: Set 'target_branch' to the value of 'permanent_dependencies_branch', and emit a deprecation warning. + echo "::warning file=${{ github.workflow_ref }},title=Deprecation Warning::'permanent_dependencies_branch' is deprecated and will be removed in v2.6.0. Use 'target_branch' instead." + echo "target_branch=${{ inputs.permanent_dependencies_branch }}" >> $GITHUB_ENV + elif [ -n "${{ inputs.target_branch }}" && -n "${{ inputs.permanent_dependencies_branch }}" ]; then + # Scenario expected to be: One has set an explicit value for both 'target_branch' and forgotten to remove the explicit value set for 'permanent_dependencies_branch'. + # Cause of action: Emit a warning and use value for 'target_branch'. + + echo "::warning file=${{ github.workflow_ref }},title=Deprecation Warning::'permanent_dependencies_branch' is deprecated and will be removed in v2.6.0. Use only 'target_branch' instead." + echo "target_branch=${{ inputs.target_branch }}" >> $GITHUB_ENV + elif [ -n "${{ inputs.target_branch }}" && -z "${{ inputs.permanent_dependencies_branch }}" ]; then + # Scenario expected to be: One has set an explicit value for 'target_branch' and is currently not using 'permanent_dependencies_branch'. + # Cause of action: Use value for 'target_branch'. + + echo "target_branch=${{ inputs.target_branch }}" >> $GITHUB_ENV fi - - name: Checkout ${{ inputs.target_branch || inputs.permanent_dependencies_branch }} in ${{ github.repository }} + - name: Checkout ${{ env.target_branch }} in ${{ github.repository }} uses: actions/checkout@v4 with: - ref: ${{ inputs.target_branch || inputs.permanent_dependencies_branch }} + ref: ${{ env.target_branch }} fetch-depth: 0 - name: Set up Python ${{ inputs.python_version }} From 8bb9073c65cfcfd2649a121007032d51ced56505 Mon Sep 17 00:00:00 2001 From: Casper Welzel Andersen Date: Mon, 6 Nov 2023 14:45:21 +0100 Subject: [PATCH 6/6] Be more clear in docs about `target_branch` --- docs/workflows/ci_check_pyproject_dependencies.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/workflows/ci_check_pyproject_dependencies.md b/docs/workflows/ci_check_pyproject_dependencies.md index 6701c963..8464ece0 100644 --- a/docs/workflows/ci_check_pyproject_dependencies.md +++ b/docs/workflows/ci_check_pyproject_dependencies.md @@ -62,7 +62,7 @@ The repository contains the following: |:--- |:--- |:---:|:---:|:---:| | `git_username` | A git username (used to set the 'user.name' config option). | **_Yes_** | | _string_ | | `git_email` | A git user's email address (used to set the 'user.email' config option). | **_Yes_** | | _string_ | -| `target_branch` | The branch name for the target of the opened PR. | No | _Empty string_ | _string_ | +| `target_branch` | The branch name for the target of the opened PR.

**Note**: If a value is not given for this nor `permanent_dependencies_branch`, the default value for `permanent_dependencies_branch` will be used until v2.6.0, whereafter providing an explicit value for `target_branch` is **required**. | No | _Empty string_ | _string_ | | `permanent_dependencies_branch` | **DEPRECATED** - Will be removed in v2.6.0. Use `target_branch` instead.

The branch name for the permanent dependency updates branch. | No | ci/dependency-updates | _string_ | | `python_version` | The Python version to use for the workflow. | No | 3.9 | _string_ | | `install_extras` | Any extras to install from the local repository through 'pip'. Must be encapsulated in square parentheses (`[]`) and be separated by commas (`,`) without any spaces.

Example: `'[dev,release]'`. | No | _Empty string_ | _string_ |