Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make using dependencies branch toggleable #184

Merged
merged 17 commits into from
Dec 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
7 changes: 6 additions & 1 deletion .github/workflows/ci_cd_updated_default_branch.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -438,7 +443,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 }}
Expand Down
45 changes: 39 additions & 6 deletions .github/workflows/ci_check_pyproject_dependencies.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,16 @@ 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"
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."
daniel-sintef marked this conversation as resolved.
Show resolved Hide resolved
required: false
type: string
default: ""
python_version:
description: "The Python version to use for the workflow."
required: false
Expand Down Expand Up @@ -63,7 +68,7 @@ on:
default: false
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:
Expand All @@ -80,10 +85,38 @@ jobs:
exit 1
fi

- name: Checkout permanent dependencies branch in ${{ github.repository }}
# Check the deprecated '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 ${{ env.target_branch }} in ${{ github.repository }}
uses: actions/checkout@v4
with:
ref: ${{ inputs.permanent_dependencies_branch }}
ref: ${{ env.target_branch }}
fetch-depth: 0

- name: Set up Python ${{ inputs.python_version }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ci_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -477,7 +477,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
Expand Down
1 change: 1 addition & 0 deletions docs/workflows/ci_cd_updated_default_branch.md
Original file line number Diff line number Diff line change
Expand Up @@ -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_ |
daniel-sintef marked this conversation as resolved.
Show resolved Hide resolved
| `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.</br></br>Example: `'.github/utils/pr_body_update_deps.txt'`. | No | _Empty string_ | _string_ |

Expand Down
5 changes: 3 additions & 2 deletions docs/workflows/ci_check_pyproject_dependencies.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,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.</br></br>**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.</br></br>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.</br></br>Example: `'[dev,release]'`. | No | _Empty string_ | _string_ |
| `pr_body_file` | Relative path to PR body file from the root of the repository.</br></br>Example: `'.github/utils/pr_body_deps_check.txt'`. | No | _Empty string_ | _string_ |
Expand Down Expand Up @@ -100,7 +101,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"
Expand Down