Skip to content

Commit

Permalink
feat: add workflows for plain python
Browse files Browse the repository at this point in the history
  • Loading branch information
davide-bontempelli-zupit committed Aug 7, 2024
1 parent b4ee5f0 commit 6028b24
Show file tree
Hide file tree
Showing 2 changed files with 129 additions and 0 deletions.
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 Django 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: Django 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

0 comments on commit 6028b24

Please sign in to comment.