1
0
Fork 0
mirror of https://github.com/borgbase/vorta synced 2024-12-22 15:57:34 +00:00
vorta/.github/actions/setup/action.yml
yfprojects 5a3a7cf58e
Run pre-commit in lint ci and polish ci setup. (#1712)
Fix phonies in Makefile and run pre-commit for lint target.
Instead of running black, flake8 and ruff the lint phony now runs pre-commit which has these tools configured as hooks.

* Makefile

Define common composite action for setting up pre-commit and python.

* .github/actions/setup/action.yml

* .github/workflows/test.yml

Update codecov/codecov-action used in test ci to v3.

* .github/workflows/test.yml
2023-05-28 15:41:58 +00:00

55 lines
1.6 KiB
YAML

name: Setup
description: Sets up python and pre-commit
# note:
# this is a local composite action
# documentation: https://docs.github.com/en/actions/creating-actions/creating-a-composite-action
# code example: https://github.com/GuillaumeFalourd/poc-github-actions/blob/main/.github/actions/local-action/action.yaml
inputs:
pre-commit:
description: Whether pre-commit shall be setup, too
required: false
default: "" # == false
python-version:
description: The python version to install
required: true
default: "3.10"
runs:
using: "composite"
steps:
- name: Set up Python ${{ inputs.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ inputs.python-version }}
- name: Get pip cache dir
shell: bash
id: pip-cache
run: |
echo "dir=$(pip cache dir)" >> $GITHUB_OUTPUT
- name: pip cache
uses: actions/cache@v3
with:
path: ${{ steps.pip-cache.outputs.dir }}
key: ${{ runner.os }}-pip-${{ hashFiles('setup.cfg', 'requirements.d/**') }}
restore-keys: |
${{ runner.os }}-pip-
- name: Install Vorta
shell: bash
run: |
pip install -e .
pip install -r requirements.d/dev.txt
- name: Hash python version
if: ${{ inputs.setup-pre-commit }}
shell: bash
run: echo "PY=$(python -VV | sha256sum | cut -d' ' -f1)" >> $GITHUB_ENV
- name: Caching for Pre-Commit
if: ${{ inputs.setup-pre-commit }}
uses: actions/cache@v3
with:
path: ~/.cache/pre-commit
key: pre-commit|${{ env.PY }}|${{ hashFiles('.pre-commit-config.yaml') }}