Skip to content

Commit

Permalink
Go through another env var to set --since-tag (#233)
Browse files Browse the repository at this point in the history
Add a space in GitHub actions variables where there was none to make
them look more proper.

Define env var in GITHUB_ENV after proper definition.
An issue has been raised to do this in every place for all workflows,
see #234.

This is done as part of the code review by @DanielMarchand.
  • Loading branch information
CasperWA authored Jan 13, 2024
1 parent 892a23b commit 862c085
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 24 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/_local_ci_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,10 @@ jobs:
- name: Checkout repository
uses: actions/checkout@v4

- name: Set up Python ${{ matrix.python-version}}
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version}}
python-version: ${{ matrix.python-version }}
allow-prereleases: true

- name: Install Python dependencies
Expand Down Expand Up @@ -81,10 +81,10 @@ jobs:
- name: Checkout repository
uses: actions/checkout@v4

- name: Set up Python ${{ matrix.python-version}}
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version}}
python-version: ${{ matrix.python-version }}

- name: Install Python dependencies
run: |
Expand Down
25 changes: 17 additions & 8 deletions .github/workflows/cd_release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -160,8 +160,8 @@ jobs:
steps:
- name: Validate inputs
run: |
if [[ ! "${{ inputs.python_version_build}}" =~ ^3\.([7-9]|1[0-3])(\..*)?$ ]]; then
echo "Python version '${{ inputs.python_version_build}}' is not supported."
if [[ ! "${{ inputs.python_version_build }}" =~ ^3\.([7-9]|1[0-3])(\..*)?$ ]]; then
echo "Python version '${{ inputs.python_version_build }}' is not supported."
echo "Supported versions are: 3.7, 3.8, 3.9, 3.10, 3.11, 3.12, 3.13."
exit 1
fi
Expand Down Expand Up @@ -197,11 +197,13 @@ jobs:
else
echo 'CHANGELOG_EXCLUDE_TAGS_REGEX=' >> $GITHUB_ENV
fi
if [ -n "${{ inputs.changelog_exclude_labels}}" ]; then
if [ -n "${{ inputs.changelog_exclude_labels }}" ]; then
echo 'CHANGELOG_EXCLUDE_LABELS=--exclude-labels "${{ inputs.changelog_exclude_labels }}"' >> $GITHUB_ENV
else
echo 'CHANGELOG_EXCLUDE_LABELS=' >> $GITHUB_ENV
fi
PROJECT=$(echo $GITHUB_REPOSITORY | cut -d/ -f2- )
echo "CHANGELOG_PROJECT=--project ${PROJECT}" >> $GITHUB_ENV
Expand Down Expand Up @@ -288,15 +290,22 @@ jobs:
- name: Get tagged versions
run: |
if [ -n "${{ inputs.changelog_exclude_tags_regex }}" ]; then
echo "PREVIOUS_VERSION=$(git tag -l --sort -version:refname | grep -v -E "${{ inputs.changelog_exclude_tags_regex }}" | sed -n 2p)" >> $GITHUB_ENV
PREVIOUS_VERSION="$(git tag -l --sort -version:refname | grep -v -E "${{ inputs.changelog_exclude_tags_regex }}" | sed -n 2p)"
else
PREVIOUS_VERSION="$(git tag -l --sort -version:refname | sed -n 2p)"
fi
if [ -n "${PREVIOUS_VERSION}" ]; then
SINCE_PREVIOUS_VERSION=--since-tag "${PREVIOUS_VERSION}"
else
echo "PREVIOUS_VERSION=$(git tag -l --sort -version:refname | sed -n 2p)" >> $GITHUB_ENV
SINCE_PREVIOUS_VERSION=
fi
echo "SINCE_PREVIOUS_VERSION=${SINCE_PREVIOUS_VERSION}" >> $GITHUB_ENV
- name: Create release-specific changelog
uses: docker://githubchangeloggenerator/github-changelog-generator:1.16.2
with:
args: --user "${{ github.repository_owner }}" ${{ env.CHANGELOG_PROJECT }} --token "${{ secrets.PAT || secrets.GITHUB_TOKEN }}" --release-branch "${{ inputs.release_branch }}" --since-tag "${{ env.PREVIOUS_VERSION }}" --output release_changelog.md --usernames-as-github-logins ${{ env.CHANGELOG_EXCLUDE_TAGS_REGEX }} ${{ env.CHANGELOG_EXCLUDE_LABELS }}
args: --user "${{ github.repository_owner }}" ${{ env.CHANGELOG_PROJECT }} --token "${{ secrets.PAT || secrets.GITHUB_TOKEN }}" --release-branch "${{ inputs.release_branch }}" ${{ env.SINCE_PREVIOUS_VERSION }} --output release_changelog.md --usernames-as-github-logins ${{ env.CHANGELOG_EXCLUDE_TAGS_REGEX }} ${{ env.CHANGELOG_EXCLUDE_LABELS }}

- name: Append changelog to release body
run: |
Expand Down Expand Up @@ -334,8 +343,8 @@ jobs:
- name: Check input
run: |
valid_frameworks=("mkdocs sphinx")
if [[ ! " ${valid_frameworks[*]} " =~ " ${{ inputs.docs_framework}} " ]]; then
echo "The input '${{ inputs.docs_framework}}' is not supported."
if [[ ! " ${valid_frameworks[*]} " =~ " ${{ inputs.docs_framework }} " ]]; then
echo "The input '${{ inputs.docs_framework }}' is not supported."
echo "Valid inputs are: ${valid_frameworks[*]}"
exit 1
fi
Expand Down
14 changes: 7 additions & 7 deletions .github/workflows/ci_cd_updated_default_branch.yml
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ jobs:
steps:
- name: Release check
run: |
COMMIT_MSG="$(gh api /repos/${{ github.repository}}/commits/${{ inputs.default_repo_branch }} --jq '.commit.message')"
COMMIT_MSG="$(gh api /repos/${{ github.repository }}/commits/${{ inputs.default_repo_branch }} --jq '.commit.message')"
if [[ "${COMMIT_MSG}" =~ ^Release\ v.*$ ]] || [ "${COMMIT_MSG}" == "[bot] Update documentation" ]; then
echo "In a release or just ran this job - do not run this job !"
echo "RELEASE_RUN=true" >> $GITHUB_ENV
Expand All @@ -186,14 +186,14 @@ jobs:
if: env.RELEASE_RUN == 'false'
run: |
valid_frameworks=("mkdocs sphinx")
if [[ ! " ${valid_frameworks[*]} " =~ " ${{ inputs.docs_framework}} " ]]; then
echo "The input '${{ inputs.docs_framework}}' is not supported."
if [[ ! " ${valid_frameworks[*]} " =~ " ${{ inputs.docs_framework }} " ]]; then
echo "The input '${{ inputs.docs_framework }}' is not supported."
echo "Valid inputs are: ${valid_frameworks[*]}"
exit 1
fi
if [[ ! "${{ inputs.python_version}}" =~ ^3\.([7-9]|1[0-3])(\..*)?$ ]]; then
echo "Python version '${{ inputs.python_version}}' is not supported."
if [[ ! "${{ inputs.python_version }}" =~ ^3\.([7-9]|1[0-3])(\..*)?$ ]]; then
echo "Python version '${{ inputs.python_version }}' is not supported."
echo "Supported versions are: 3.7, 3.8, 3.9, 3.10, 3.11, 3.12, 3.13."
exit 1
fi
Expand Down Expand Up @@ -372,7 +372,7 @@ jobs:
else
echo 'CHANGELOG_EXCLUDE_TAGS_REGEX=' >> $GITHUB_ENV
fi
if [ -n "${{ inputs.changelog_exclude_labels}}" ]; then
if [ -n "${{ inputs.changelog_exclude_labels }}" ]; then
echo 'CHANGELOG_EXCLUDE_LABELS=--exclude-labels "${{ inputs.changelog_exclude_labels }}"' >> $GITHUB_ENV
else
echo 'CHANGELOG_EXCLUDE_LABELS=' >> $GITHUB_ENV
Expand Down Expand Up @@ -476,7 +476,7 @@ jobs:
run: |
git fetch origin
LATEST_PR_BODY="$(gh api /repos/${{ github.repository}}/pulls -X GET -f state=closed -f per_page=1 -f sort=updated -f direction=desc --jq '.[].body')"
LATEST_PR_BODY="$(gh api /repos/${{ github.repository }}/pulls -X GET -f state=closed -f per_page=1 -f sort=updated -f direction=desc --jq '.[].body')"
cat ${PR_BODY_FILE} | head -8 > .tmp_file.txt
if [ -z "$(printf '%s\n' "${LATEST_PR_BODY}" | head -8 | diff - .tmp_file.txt --strip-trailing-cr)" ]; then
echo "The dependencies have just been updated! Reset to ${{ inputs.default_repo_branch }}."
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/ci_check_pyproject_dependencies.yml
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,8 @@ jobs:
steps:
- name: Validate inputs
run: |
if [[ ! "${{ inputs.python_version}}" =~ ^3\.([7-9]|1[0-3])(\..*)?$ ]]; then
echo "Python version '${{ inputs.python_version}}' is not supported."
if [[ ! "${{ inputs.python_version }}" =~ ^3\.([7-9]|1[0-3])(\..*)?$ ]]; then
echo "Python version '${{ inputs.python_version }}' is not supported."
echo "Supported versions are: 3.7, 3.8, 3.9, 3.10, 3.11, 3.12, 3.13."
exit 1
fi
Expand Down Expand Up @@ -233,7 +233,7 @@ jobs:
token: ${{ secrets.PAT || secrets.GITHUB_TOKEN }}
committer: "${{ inputs.git_username }} <${{ inputs.git_email }}>"
author: "${{ inputs.git_username }} <${{ inputs.git_email }}>"
branch: ci/update-pyproject${{ inputs.branch_name_extension && format('/{0}', inputs.branch_name_extension) || ''}}
branch: ci/update-pyproject${{ inputs.branch_name_extension && format('/{0}', inputs.branch_name_extension) || '' }}
delete-branch: true
title: "[Auto-generated] Check & update dependencies (`pyproject.toml`)"
body: ${{ steps.pr_body.outputs.result }}
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/ci_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -350,8 +350,8 @@ jobs:
- name: Validate inputs
run: |
if [[ "${framework}" == "mkdocs" && ! "${{ inputs.python_version_docs}}" =~ ^3\.([7-9]|1[0-3])(\..*)?$ ]]; then
echo "Python version '${{ inputs.python_version_docs}}' is not supported."
if [[ "${framework}" == "mkdocs" && ! "${{ inputs.python_version_docs }}" =~ ^3\.([7-9]|1[0-3])(\..*)?$ ]]; then
echo "Python version '${{ inputs.python_version_docs }}' is not supported."
echo "Supported versions are: 3.7, 3.8, 3.9, 3.10, 3.11, 3.12, 3.13."
exit 1
fi
Expand Down

0 comments on commit 862c085

Please sign in to comment.