Skip to content
This repository has been archived by the owner on Nov 7, 2023. It is now read-only.

Commit

Permalink
build(PYTHON): upgrade python version, refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
niall-byrne committed Feb 25, 2023
1 parent c6196cd commit c678219
Show file tree
Hide file tree
Showing 6 changed files with 50 additions and 18 deletions.
32 changes: 25 additions & 7 deletions .github/workflows/self-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,34 @@ on:
workflow_dispatch:

env:
CONFIGURE_PYTHON_VERSIONS: "[3.9]"
PROJECT_NAME: "ansible-workbench"
USERNAME: "niall-byrne"
TEMPLATED_NAME: "flower-generator"
VERBOSE_NOTIFICATIONS: 0

jobs:

_create_python_versions:

runs-on: ubuntu-latest
outputs:
python-versions: ${{ steps.create_matrix.outputs.python-versions }}

steps:
- name: Create Python Versions -- Set Configured Python Versions as Output
id: create_matrix
run: |
echo "python-versions=${CONFIGURE_PYTHON_VERSIONS}" >> $GITHUB_OUTPUT
documentation_test:
needs: [_create_python_versions]

runs-on: ubuntu-latest
strategy:
max-parallel: 4
matrix:
python-version: [3.8]
python-version: ${{ fromJson(needs._create_python_versions.outputs.python-versions) }}

steps:
- name: Documentation Test -- Checkout Repository
Expand Down Expand Up @@ -74,12 +88,13 @@ jobs:
./template/{{cookiecutter.project_slug}}/.github/scripts/notifications.sh "${NOTIFICATION}" ":x: documentation checks failed!"
molecule_lint_test:
needs: [_create_python_versions]

runs-on: ubuntu-latest
strategy:
max-parallel: 4
matrix:
python-version: [3.8]
python-version: ${{ fromJson(needs._create_python_versions.outputs.python-versions) }}

steps:
- name: Molecule Lint -- Checkout Repository
Expand Down Expand Up @@ -115,13 +130,13 @@ jobs:
./template/{{cookiecutter.project_slug}}/.github/scripts/notifications.sh "${NOTIFICATION}" ":x: molecule linting checks failed!"
push_repository_test:
needs: [documentation_test, molecule_lint_test, security_test, shellcheck_test, workflow_lint_test]
needs: [_create_python_versions, documentation_test, molecule_lint_test, security_test, shellcheck_test, workflow_lint_test]

runs-on: ubuntu-latest
strategy:
max-parallel: 4
matrix:
python-version: [3.8]
python-version: ${{ fromJson(needs._create_python_versions.outputs.python-versions) }}

steps:
- name: Push Test -- Checkout Repository
Expand Down Expand Up @@ -241,12 +256,13 @@ jobs:
./{{cookiecutter.project_slug}}/.github/scripts/notifications.sh "${NOTIFICATION}" ":x: automated release creation has failed!"
security_test:
needs: [_create_python_versions]

runs-on: ubuntu-latest
strategy:
max-parallel: 4
matrix:
python-version: [3.8]
python-version: ${{ fromJson(needs._create_python_versions.outputs.python-versions) }}

steps:
- name: Security Test -- Checkout Repository
Expand Down Expand Up @@ -288,12 +304,13 @@ jobs:
./template/{{cookiecutter.project_slug}}/.github/scripts/notifications.sh "${NOTIFICATION}" ":x: security checks failed!"
shellcheck_test:
needs: [_create_python_versions]

runs-on: ubuntu-latest
strategy:
max-parallel: 4
matrix:
python-version: [3.8]
python-version: ${{ fromJson(needs._create_python_versions.outputs.python-versions) }}

steps:
- name: Shellcheck -- Checkout Repository
Expand Down Expand Up @@ -385,12 +402,13 @@ jobs:
./template/{{cookiecutter.project_slug}}/.github/scripts/notifications.sh "${NOTIFICATION}" ":x: error reporting job status!"
workflow_lint_test:
needs: [_create_python_versions]

runs-on: ubuntu-latest
strategy:
max-parallel: 4
matrix:
python-version: [3.8]
python-version: ${{ fromJson(needs._create_python_versions.outputs.python-versions) }}

steps:
- name: Workflow Lint -- Checkout Repository
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ Ansible Role Development Environment.
This template generates a development environment for Ansible Roles with a functional CI/CD template for both Travis CI and Github.

## Requirements
You'll need [Python](https://www.python.org/) 3.8 or later to use this template.
You'll need [Python](https://www.python.org/) 3.9 or later to use this template.

## Quick Start Guide

Expand Down
1 change: 1 addition & 0 deletions cookiecutter.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"author": "Niall Byrne",
"company": "Shared Vision Solutions",
"email": "[email protected]",
"_GITHUB_CI_PYTHON_VERSIONS": ["3.9"],
"_GITHUB_ACTION_MARKDOWN_LINK_CHECK": "gaurav-nelson/[email protected]",
"_GITHUB_GITLEAKS_ACTION": "zricethezav/[email protected]",
"_GITHUB_PUSH_ACTION": "ad-m/[email protected]"
Expand Down
21 changes: 18 additions & 3 deletions {{cookiecutter.project_slug}}/.github/workflows/push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,18 @@ env:
{% raw %}
jobs:

_create_python_versions:

runs-on: ubuntu-latest
outputs:
python-versions: ${{ steps.create_matrix.outputs.python-versions }}

steps:
- name: Create Python Versions -- Set Configured Python Versions as Output
id: create_matrix
run: |
echo 'python-versions={% endraw %}{{ cookiecutter._GITHUB_CI_PYTHON_VERSIONS | tojson }}{% raw %}' >> $GITHUB_OUTPUT
create_release:
needs: [molecule_test, molecule_lint, documentation_test, security_test, start_notification]

Expand Down Expand Up @@ -96,12 +108,13 @@ jobs:
./.github/scripts/notifications.sh "${NOTIFICATION}" ":x: documentation test has failed!"
molecule_lint:
needs: [_create_python_versions]

runs-on: ubuntu-latest
strategy:
max-parallel: 4
matrix:
python-version: [3.8]
python-version: ${{ fromJson(needs._create_python_versions.outputs.python-versions) }}

steps:

Expand Down Expand Up @@ -139,12 +152,13 @@ jobs:
./.github/scripts/notifications.sh "${NOTIFICATION}" ":x: molecule linting has failed!"
molecule_test:
needs: [_create_python_versions]

runs-on: ubuntu-latest
strategy:
max-parallel: 4
matrix:
python-version: [3.8]
python-version: ${{ fromJson(needs._create_python_versions.outputs.python-versions) }}

steps:
- name: Molecule Test -- Checkout Repository
Expand Down Expand Up @@ -181,12 +195,13 @@ jobs:
./.github/scripts/notifications.sh "${NOTIFICATION}" ":x: molecule test has failed!"
security_test:
needs: [_create_python_versions]

runs-on: ubuntu-latest
strategy:
max-parallel: 4
matrix:
python-version: [3.8]
python-version: ${{ fromJson(needs._create_python_versions.outputs.python-versions) }}

steps:
- name: Security Test -- Checkout Repository
Expand Down
10 changes: 4 additions & 6 deletions {{cookiecutter.project_slug}}/.github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,15 @@ on:

env:
PROJECT_NAME: "{{ cookiecutter.project_slug }}"
PYTHON_VERSIONS: '{{ cookiecutter._GITHUB_CI_PYTHON_VERSIONS | tojson }}'
USERNAME: "{{ cookiecutter.github_handle }}"

{% raw %}
jobs:

publish_to_galaxy:

runs-on: ubuntu-latest
strategy:
max-parallel: 4
matrix:
python-version: [3.8]

steps:

Expand All @@ -44,10 +42,10 @@ jobs:
with:
fetch-depth: 0

- name: Publish to Galaxy -- Set up Python ${{ matrix.python-version }}
- name: Publish to Galaxy -- Set up Python ${{ toJSON(env.PYTHON_VERSIONS)[0] }}
uses: actions/setup-python@v1
with:
python-version: ${{ matrix.python-version }}
python-version: ${{ toJSON(env.PYTHON_VERSIONS)[0] }}

- name: Publish to Galaxy -- Setup Environment
run: |
Expand Down
2 changes: 1 addition & 1 deletion {{cookiecutter.project_slug}}/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ description = "{{cookiecutter.description}}"
authors = ["{{cookiecutter.author}} <{{cookiecutter.email}}>"]

[tool.poetry.dependencies]
python = ">=3.8.0,<4.0"
python = ">={{ cookiecutter._GITHUB_CI_PYTHON_VERSIONS | first }}.0,<4.0"

[tool.poetry.dev-dependencies]
ansible = "^5.2.0"
Expand Down

0 comments on commit c678219

Please sign in to comment.