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

✨ feat: Python package integration and deployment workflows #20

Merged
merged 2 commits into from
Feb 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
66 changes: 66 additions & 0 deletions .github/workflows/deployment-python-pypi.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
name: Deploy a python package to PyPi and GitHub
on:
workflow_call:
inputs:
environment:
required: true
type: string
description: 'The environment to deploy to'
default: 'pypi'
environment_url:
required: true
type: string
description: 'The environment URL to deploy to'
project_install_command:
required: false
type: string
description: 'The command to install the project'
default: 'just install'
project_build_command:
required: false
type: string
description: 'The command to build the project'
default: 'just build'
use_just:
default: true
description: 'Use just to run commands'
required: false
type: boolean


jobs:
release:
runs-on: ubuntu-latest
permissions: write-all
environment:
name: ${{ inputs.environment }}
url: ${{ inputs.environment_url }}
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Semantic release
id: semantic-release
uses: python-semantic-release@v8.7.2

- name: Install just
if: ${{ inputs.use_just }}
run: sudo snap install --edge --classic just

- name: Install dependencies
if: steps.semantic-release.outputs.released == 'true'
run: ${{ inputs.project_install_command }}

- name: Build project
if: steps.semantic-release.outputs.released == 'true'
run: ${{ inputs.project_build_command }}

- name: Publish to PyPi
if: steps.semantic-release.outputs.released == 'true'
uses: pypa/gh-action-pypi-publish@v1.8.11

- name: Publish to GitHub
if: steps.semantic-release.outputs.released == 'true'
uses: python-semantic-release/upload-to-gh-release@main
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
72 changes: 72 additions & 0 deletions .github/workflows/integration-python.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
name: Unit tests and code format checks for a python project
on:
workflow_call:
inputs:
python_version:
default: '3.12'
description: 'Python version'
required: true
type: string
check_format_command:
default: 'just check-format'
description: 'Check format command'
required: false
type: string
install_command:
default: 'just install'
description: 'Install command'
required: false
type: string
test_command:
default: 'just test'
description: 'Test command'
required: false
type: string
use_just:
default: true
description: 'Use just to run commands'
required: false
type: boolean

jobs:
code-format:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Install just
if: ${{ inputs.use_just == true }}
run: sudo snap install --edge --classic just

- name: Install python
uses: actions/setup-python@v5
with:
python-version: ${{ inputs.python_version }}

- name: Install Dependencies
run: ${{ inputs.install_command }}

- name: Check code format
run: ${{ inputs.check_format_command }}

unit-tests:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Install just
if: ${{ inputs.use_just == true }}
run: sudo snap install --edge --classic just

- name: Install python
uses: actions/setup-python@v5
with:
python-version: ${{ inputs.python_version }}

- name: Install Dependencies
run: ${{ inputs.install_command }}

- name: Run unit tests
run: ${{ inputs.test_command }}
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,12 @@ jobs:
| automation | [comment-pr](./.github/workflows/automation-comment-pr.yml) | Add or update a comment on the pull request |
| automation | [greeter](./.github/workflows/automation-greeter.yml) | Greetings |
| automation | [labeler](./.github/workflows/automation-labeler.yml) | Labeler |
| deployment | [python-pypi](./.github/workflows/deployment-python-pypi.yml) | Deploy a python package to PyPi and GitHub |
| deployment | [s3](./.github/workflows/deployment-s3.yml) | Upload files to AWS S3 |
| integration | [commit-validator](./.github/workflows/integration-commit-validator.yml) | Validate commit or PR title format is correct |
| integration | [linter-pre-commit](./.github/workflows/integration-linter-pre-commit.yml) | Pre-commit |
| integration | [modification-script](./.github/workflows/integration-modification-script.yml) | Execute script and commit changes to git |
| integration | [python](./.github/workflows/integration-python.yml) | Unit tests and code format checks for a python project |
| integration | [integration](./.github/workflows/integration.yml) | Code integration |
| security | [codeql](./.github/workflows/security-codeql.yml) | Code Quality and Security Analysis |
| security | [dependencies](./.github/workflows/security-dependencies.yml) | Dependency Scanning |
Expand Down