From 6028b243b5133164cd05f5f500b84a0d82c777f2 Mon Sep 17 00:00:00 2001 From: Davide Bontempelli Date: Wed, 7 Aug 2024 18:50:41 +0200 Subject: [PATCH 1/2] feat: add workflows for plain python --- .github/workflows/python-step-lint-check.yml | 76 ++++++++++++++++++++ .github/workflows/python-workflow-common.yml | 53 ++++++++++++++ 2 files changed, 129 insertions(+) create mode 100644 .github/workflows/python-step-lint-check.yml create mode 100644 .github/workflows/python-workflow-common.yml diff --git a/.github/workflows/python-step-lint-check.yml b/.github/workflows/python-step-lint-check.yml new file mode 100644 index 00000000..368397cc --- /dev/null +++ b/.github/workflows/python-step-lint-check.yml @@ -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 . + diff --git a/.github/workflows/python-workflow-common.yml b/.github/workflows/python-workflow-common.yml new file mode 100644 index 00000000..e0b13d8e --- /dev/null +++ b/.github/workflows/python-workflow-common.yml @@ -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 From cfe5051e284a05e83d38f01588e58319c9c85ad6 Mon Sep 17 00:00:00 2001 From: Davide Bontempelli Date: Wed, 7 Aug 2024 18:55:28 +0200 Subject: [PATCH 2/2] feat: typo --- .github/workflows/python-step-lint-check.yml | 2 +- .github/workflows/python-workflow-common.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/python-step-lint-check.yml b/.github/workflows/python-step-lint-check.yml index 368397cc..684aebc9 100644 --- a/.github/workflows/python-step-lint-check.yml +++ b/.github/workflows/python-step-lint-check.yml @@ -1,4 +1,4 @@ -name: Lint and check a Django app +name: Lint and check a Python app on: workflow_call: diff --git a/.github/workflows/python-workflow-common.yml b/.github/workflows/python-workflow-common.yml index e0b13d8e..5deaf5a6 100644 --- a/.github/workflows/python-workflow-common.yml +++ b/.github/workflows/python-workflow-common.yml @@ -1,4 +1,4 @@ -name: Django common +name: Python common on: workflow_call: