Skip to content

Commit

Permalink
ci(GITHUB): enforce python version
Browse files Browse the repository at this point in the history
  • Loading branch information
niall-byrne committed Mar 10, 2023
1 parent e493a3e commit 580cb8f
Show file tree
Hide file tree
Showing 5 changed files with 69 additions and 40 deletions.
2 changes: 1 addition & 1 deletion .github/scripts/requirements.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ set -eo pipefail

main () {

pip install cookiecutter poetry
python -m pip install cookiecutter poetry --verbose

}

Expand Down
68 changes: 37 additions & 31 deletions .github/workflows/self-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -93,15 +93,15 @@ jobs:
env:
WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK }}

- name: Ansible Lint -- Install Template Requirements
run: |
source ./template/.github/scripts/requirements.sh
- name: Ansible Lint -- Set up Python ${{ env.PYTHON_VERSION }}
uses: actions/setup-python@v4
with:
python-version: ${{ env.PYTHON_VERSION }}

- name: Ansible Lint -- Install Template Requirements
run: |
source ./template/.github/scripts/requirements.sh
- name: Ansible Lint -- Initialize Cache Locations
run: |
mkdir -p ~/.cache/pypoetry/virtualenvs
Expand All @@ -119,7 +119,7 @@ jobs:
uses: actions/cache@v3
with:
key: poetry-${{ hashFiles('./template/{{cookiecutter.profile_slug}}/pyproject.toml') }}-${{ runner.os }}-${{ env.CACHE_TTL }}
path: ~/.cache/pypoetry/virtualenvs/
path: ~/.cache/pypoetry/virtualenvs

- name: Ansible Lint -- Render Template
run: |
Expand Down Expand Up @@ -278,15 +278,15 @@ jobs:
env:
WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK }}

- name: Documentation Test -- Install Template Requirements
run: |
source ./template/.github/scripts/requirements.sh
- name: Documentation Test -- Set up Python ${{ env.PYTHON_VERSION }}
uses: actions/setup-python@v4
with:
python-version: ${{ env.PYTHON_VERSION }}

- name: Documentation Test -- Install Template Requirements
run: |
source ./template/.github/scripts/requirements.sh
- name: Documentation Test -- Render Template
run: |
source ./template/.github/scripts/template.sh
Expand Down Expand Up @@ -342,6 +342,11 @@ jobs:
env:
WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK }}

- name: Pre-Commit Test -- Set up Python ${{ env.PYTHON_VERSION }}
uses: actions/setup-python@v4
with:
python-version: ${{ env.PYTHON_VERSION }}

- name: Pre-Commit Test -- Install Template Requirements
run: |
source ./template/.github/scripts/requirements.sh
Expand All @@ -350,11 +355,6 @@ jobs:
run: |
sudo apt-get install -y golang-github-pelletier-go-toml
- name: Pre-Commit Test -- Set up Python ${{ env.PYTHON_VERSION }}
uses: actions/setup-python@v4
with:
python-version: ${{ env.PYTHON_VERSION }}

- name: Pre-Commit -- Initialize Cache Locations
run: |
mkdir -p ~/.cache/pypoetry/virtualenvs
Expand All @@ -372,7 +372,7 @@ jobs:
uses: actions/cache@v3
with:
key: poetry-${{ hashFiles('./template/{{cookiecutter.profile_slug}}/pyproject.toml') }}-${{ runner.os }}-${{ env.CACHE_TTL }}
path: ~/.cache/pypoetry/virtualenvs/
path: ~/.cache/pypoetry/virtualenvs

- name: Pre-Commit Test -- Render Template
run: |
Expand Down Expand Up @@ -434,15 +434,21 @@ jobs:
env:
WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK }}

- name: Push Test -- Install Template Requirements
run: |
source ./template/.github/scripts/requirements.sh
- name: Push Test -- Set up Python ${{ env.PYTHON_VERSION }}
uses: actions/setup-python@v4
with:
python-version: ${{ env.PYTHON_VERSION }}

- name: Push Test -- Install Template Requirements
run: |
source ./template/.github/scripts/requirements.sh
- name: Push Test -- Clean Up Test Releases
run: |
source ./template/.github/scripts/prune_test_releases.sh
env:
GITHUB_TOKEN: ${{ secrets.REMOTE_TOKEN }}

- name: Push Test -- Render Template
run: |
source ./template/.github/scripts/template.sh "${SELECTION_TOML}" "GitHub Action" "[email protected]"
Expand Down Expand Up @@ -545,15 +551,15 @@ jobs:
env:
WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK }}

- name: Shellcheck -- Install Template Requirements
run: |
source ./template/.github/scripts/requirements.sh
- name: Shellcheck -- Set up Python ${{ env.PYTHON_VERSION }}
uses: actions/setup-python@v4
with:
python-version: ${{ env.PYTHON_VERSION }}

- name: Shellcheck -- Install Template Requirements
run: |
source ./template/.github/scripts/requirements.sh
- name: Shellcheck -- Render Template
run: |
source ./template/.github/scripts/template.sh
Expand Down Expand Up @@ -600,15 +606,15 @@ jobs:
env:
WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK }}

- name: Toml Lint -- Install Template Requirements
run: |
source ./template/.github/scripts/requirements.sh
- name: Toml Lint -- Set up Python ${{ env.PYTHON_VERSION }}
uses: actions/setup-python@v4
with:
python-version: ${{ env.PYTHON_VERSION }}

- name: Toml Lint -- Install Template Requirements
run: |
source ./template/.github/scripts/requirements.sh
- name: Toml Lint -- Render Template
run: |
source ./template/.github/scripts/template.sh
Expand Down Expand Up @@ -651,15 +657,15 @@ jobs:
env:
WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK }}

- name: Yaml Lint Test-- Install Template Requirements
run: |
source ./template/.github/scripts/requirements.sh
- name: Yaml Lint Test -- Set up Python ${{ env.PYTHON_VERSION }}
uses: actions/setup-python@v4
with:
python-version: ${{ env.PYTHON_VERSION }}

- name: Yaml Lint Test-- Install Template Requirements
run: |
source ./template/.github/scripts/requirements.sh
- name: Yaml Lint Test -- Render Template
run: |
source ./template/.github/scripts/template.sh "${SELECTION_TOML}"
Expand Down
2 changes: 1 addition & 1 deletion hooks/post_gen_project.sh
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ initialize_git() {
initialize_poetry() {

if [[ "${PROFILE_GENERATOR_SKIP_POETRY}" != "1" ]]; then
poetry install
poetry install --verbose
fi

}
Expand Down
25 changes: 24 additions & 1 deletion {{cookiecutter.profile_slug}}/.github/scripts/poetry.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,32 @@

set -eo pipefail

install_poetry() {

python -m pip install poetry --verbose

}

install_project() {

poetry install --verbose

}

main () {

pip install poetry
case $1 in
install-poetry)
install_poetry
;;
install-project)
install_project
;;
*)
echo "Invalid option."
exit 127
;;
esac

}

Expand Down
12 changes: 6 additions & 6 deletions {{cookiecutter.profile_slug}}/.github/workflows/push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -81,15 +81,15 @@ jobs:
env:
WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK }}

- name: Ansible Lint -- Install Poetry
run: |
source .github/scripts/poetry.sh
- name: Ansible Lint -- Set up Python ${{ env.PYTHON_VERSION }}
uses: {% endraw %}{{ cookiecutter._GITHUB_ACTION_PYTHON }}{% raw %}
with:
python-version: ${{ env.PYTHON_VERSION }}

- name: Ansible Lint -- Install Poetry
run: |
source .github/scripts/poetry.sh "install-poetry"
- name: Ansible Lint -- Initialize Cache Locations
run: |
mkdir -p ~/.cache/pypoetry/virtualenvs
Expand All @@ -111,7 +111,7 @@ jobs:

- name: Ansible Lint -- Install Requirements
run: |
poetry install
source .github/scripts/poetry.sh "install-project"
- name: Ansible Lint -- Install Ansible Galaxy Dependencies
run: |
Expand Down Expand Up @@ -163,7 +163,7 @@ jobs:
- name: Create Release -- Install poetry
if: steps.filter.outputs.release_candidate == 'TRUE'
run: |
source ./.github/scripts/poetry.sh
source ./.github/scripts/poetry.sh "install-poetry"
- name: Create Release -- Check 'pyproject.toml' Matches Tag
if: steps.filter.outputs.release_candidate == 'TRUE'
Expand Down

0 comments on commit 580cb8f

Please sign in to comment.