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: add workflows for plain python #112

Merged
merged 2 commits into from
Aug 7, 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
76 changes: 76 additions & 0 deletions .github/workflows/python-step-lint-check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
name: Lint and check a Python app

on:
workflow_call:
inputs:
RUN_ON:
required: false
type: string
default: 'zupit-agents'
RUNNERS_CONTAINER_GROUP:
required: false
type: string
default: 'Container'
WORKING_DIRECTORY:
required: true
type: string
PYTHON_IMAGE:
required: true
type: string
RUN:
required: false
type: boolean
default: true
SETUP_COMMANDS:
required: false
type: string
default: ""
ENABLE_LFS:
required: false
type: boolean
default: false
# Workaround for https://github.com/actions/checkout/issues/1169
LFS_REPO_PATH:
required: false
type: string
default: ""

env: "${{secrets}}"

jobs:
python-linter:
if: ${{ inputs.RUN }}
runs-on:
labels: ${{ inputs.RUN_ON }}
group: ${{ inputs.RUNNERS_CONTAINER_GROUP }}
container: ${{ inputs.PYTHON_IMAGE }}

defaults:
run:
working-directory: ${{ inputs.WORKING_DIRECTORY }}

steps:
- name: Install prerequisites
if: ${{ inputs.ENABLE_LFS == true }}
run: apt-get update && apt-get install -y git-lfs
- name: Checkout code
uses: actions/checkout@v4
if: ${{ inputs.ENABLE_LFS == true }}
with:
lfs: 'true'
- uses: actions/checkout@v4
if: ${{ inputs.ENABLE_LFS == false }}
- name: Checkout LFS objects
if: ${{ inputs.ENABLE_LFS == true }}
run: git lfs pull
- name: Setup
run: ${{ inputs.SETUP_COMMANDS }}
- name: Install dependencies
run: pip install -r requirements.txt
- name: Copy env file
run: cp .env.github .env
- name: Lint with flake8
run: python -m flake8 .
- name: Lint with black
run: python -m black --check .

53 changes: 53 additions & 0 deletions .github/workflows/python-workflow-common.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
name: Python common

on:
workflow_call:
inputs:
# Projects inputs
WORKING_DIRECTORY:
required: true
type: string
PYTHON_IMAGE:
required: true
type: string
SETUP_COMMANDS:
required: false
type: string
default: ""
# Workflow inputs
RUN_ON:
required: false
type: string
default: 'zupit-agents'
RUNNERS_CONTAINER_GROUP:
required: false
type: string
default: 'Container'
RUN:
required: false
type: boolean
default: true
ENABLE_LFS:
required: false
type: boolean
default: false
# Workaround for https://github.com/actions/checkout/issues/1169
LFS_REPO_PATH:
required: false
type: string
default: ""

jobs:
django-lint-check:
uses:
./.github/workflows/python-step-lint-check.yml
with:
RUN_ON: ${{inputs.RUN_ON}}
RUNNERS_CONTAINER_GROUP: ${{inputs.RUNNERS_CONTAINER_GROUP}}
WORKING_DIRECTORY: ${{inputs.WORKING_DIRECTORY}}
PYTHON_IMAGE: ${{inputs.PYTHON_IMAGE}}
RUN: ${{inputs.RUN}}
SETUP_COMMANDS: ${{inputs.SETUP_COMMANDS}}
ENABLE_LFS: ${{inputs.ENABLE_LFS}}
LFS_REPO_PATH: ${{inputs.LFS_REPO_PATH}}
secrets: inherit