From 6f38ac81d66f2732183004dd4844cf40baf8240d Mon Sep 17 00:00:00 2001 From: AlessandroMiola Date: Fri, 9 Feb 2024 22:18:31 +0100 Subject: [PATCH] feat(ci): add github actions config --- .github/workflows/actions.yaml | 61 ++++++++++++++++++++++++++++++++++ justfile | 2 +- 2 files changed, 62 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/actions.yaml diff --git a/.github/workflows/actions.yaml b/.github/workflows/actions.yaml new file mode 100644 index 0000000..7709a07 --- /dev/null +++ b/.github/workflows/actions.yaml @@ -0,0 +1,61 @@ +name: Lint, Test + +on: + push: + pull_request: + branches: [main] + +concurrency: + # New commit on branch cancels running workflows of the same branch + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +env: + PYTHON_VERSION: "3.10" + POETRY_VERSION: "1.6.1" + +jobs: + lint-and-test: + runs-on: ubuntu-latest + defaults: + run: + shell: bash + + steps: + - name: Check out repository + uses: actions/checkout@v4 + + - name: Setup python + uses: actions/setup-python@v4 + with: + python-version: ${{ env.PYTHON_VERSION }} + + - name: Install Poetry + uses: snok/install-poetry@v1 + with: + virtualenvs-create: true + virtualenvs-in-project: true + installer-parallel: true + + - name: Load cached venv if cache exists + id: cached-poetry-dependencies + uses: actions/cache@v3 + with: + path: .venv + key: venv-${{ runner.os }}-${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('**/poetry.lock') }} + + - name: Install dependencies if cache does not exist + if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true' + run: poetry install --no-interaction --no-root + + - name: Install project + run: poetry install --no-interaction + + - name: Setup just + uses: taiki-e/install-action@just + + - name: Enforce code style (Ruff) + run: just ruff-show-violations + + - name: Verify code formatting (Black) + run: just black-diff diff --git a/justfile b/justfile index 50e282e..1b3728c 100644 --- a/justfile +++ b/justfile @@ -1,5 +1,5 @@ # Use PowerShell instead of sh -set shell := ["powershell.exe", "-c"] +# set shell := ["powershell.exe", "-c"] help: @just --list