Skip to content

Commit

Permalink
Validate input Python version
Browse files Browse the repository at this point in the history
This is validated only when the `ci-cd` package is installed and used,
and is validated against the Python versions it supports.
  • Loading branch information
CasperWA committed Nov 3, 2023
1 parent 18a917c commit 1b561ef
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 9 deletions.
8 changes: 8 additions & 0 deletions .github/workflows/cd_release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,14 @@ jobs:
runs-on: ubuntu-latest

steps:
- name: Validate inputs
run: |
if [[ ! "${{ inputs.python_version_build}}" =~ ^3\.(7|8|9|10).*$ ]]; then
echo "Python version '${{ inputs.python_version_build}}' is not supported."
echo "Supported versions are: 3.7, 3.8, 3.9, 3.10"
exit 1
fi
- name: Checkout ${{ github.repository }}
uses: actions/checkout@v4
with:
Expand Down
25 changes: 16 additions & 9 deletions .github/workflows/ci_cd_updated_default_branch.yml
Original file line number Diff line number Diff line change
Expand Up @@ -164,15 +164,6 @@ jobs:
UPDATE_DEFAULT_BRANCH: false

steps:
- name: Check input
run: |
valid_frameworks=("mkdocs sphinx")
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
- name: Release check
run: |
COMMIT_MSG="$(gh api /repos/${{ github.repository}}/commits/${{ inputs.default_repo_branch }} --jq '.commit.message')"
Expand All @@ -186,6 +177,22 @@ jobs:
env:
GITHUB_TOKEN: ${{ secrets.PAT || secrets.GITHUB_TOKEN }}

- name: Validate inputs
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."
echo "Valid inputs are: ${valid_frameworks[*]}"
exit 1
fi
if [[ ! "${{ inputs.python_version}}" =~ ^3\.(7|8|9|10).*$ ]]; then
echo "Python version '${{ inputs.python_version}}' is not supported."
echo "Supported versions are: 3.7, 3.8, 3.9, 3.10"
exit 1
fi
- name: Checkout ${{ github.repository }}
if: env.RELEASE_RUN == 'false'
uses: actions/checkout@v4
Expand Down
8 changes: 8 additions & 0 deletions .github/workflows/ci_check_pyproject_dependencies.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,14 @@ jobs:
runs-on: ubuntu-latest

steps:
- name: Validate inputs
run: |
if [[ ! "${{ inputs.python_version}}" =~ ^3\.(7|8|9|10).*$ ]]; then
echo "Python version '${{ inputs.python_version}}' is not supported."
echo "Supported versions are: 3.7, 3.8, 3.9, 3.10"
exit 1
fi
- name: Checkout permanent dependencies branch in ${{ github.repository }}
uses: actions/checkout@v4
with:
Expand Down
8 changes: 8 additions & 0 deletions .github/workflows/ci_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -345,6 +345,14 @@ jobs:
exit 1
fi
- name: Validate inputs
run: |
if [[ "${{ env.framework }}" == "mkdocs" && ! "${{ inputs.python_version_docs}}" =~ ^3\.(7|8|9|10).*$ ]]; then
echo "Python version '${{ inputs.python_version_docs}}' is not supported."
echo "Supported versions are: 3.7, 3.8, 3.9, 3.10"
exit 1
fi
- name: Checkout ${{ github.repository }}
uses: actions/checkout@v4
with:
Expand Down

0 comments on commit 1b561ef

Please sign in to comment.