Use newer github actions to install and cache poetry (#1395)

* Use newer github actions to install and cache poetry

* Update setup-python action to v4

* Parallel execution

* Build depends on lint

* Added missing req deps

* Install in all

* Remove unused

* No need to lint on all python versions

* Remove matrix deps

Co-authored-by: Adrià Casajús <adria.casajus@proton.ch>
This commit is contained in:
Adrià Casajús 2022-11-02 17:59:36 +01:00 committed by GitHub
parent 90d60217a4
commit efc7760ecb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 36 additions and 30 deletions

View File

@ -1,9 +1,32 @@
name: Run tests & Publish to Docker Registry name: Test and lint
on: on:
push: push:
jobs: jobs:
lint:
runs-on: ubuntu-latest
steps:
- name: Check out repo
uses: actions/checkout@v3
- name: Install poetry
run: pipx install poetry
- uses: actions/setup-python@v4
with:
python-version: '3.9'
cache: 'poetry'
- name: Install dependencies
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
run: poetry install --no-interaction
- name: Check formatting & linting
run: |
poetry run pre-commit run --all-files
test: test:
runs-on: ubuntu-latest runs-on: ubuntu-latest
strategy: strategy:
@ -38,32 +61,16 @@ jobs:
--health-retries 5 --health-retries 5
steps: steps:
- name: Start Redis v6 - name: Check out repo
uses: superchargejs/redis-github-action@1.1.0 uses: actions/checkout@v3
with:
redis-version: 6
- name: Check out repository
uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Install poetry - name: Install poetry
uses: snok/install-poetry@v1 run: pipx install poetry
with:
virtualenvs-create: true
virtualenvs-in-project: true
installer-parallel: true
- name: Run caching - uses: actions/setup-python@v4
id: cached-poetry-dependencies
uses: actions/cache@v2
with: with:
path: .venv python-version: ${{ matrix.python-version }}
key: venv-${{ runner.os }}-${{ matrix.python-version }}-${{ hashFiles('**/poetry.lock') }} cache: 'poetry'
- name: Install OS dependencies - name: Install OS dependencies
if: ${{ matrix.python-version }} == '3.10' if: ${{ matrix.python-version }} == '3.10'
@ -73,14 +80,13 @@ jobs:
- name: Install dependencies - name: Install dependencies
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true' if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
run: poetry install --no-interaction --no-root
- name: Install library
run: poetry install --no-interaction run: poetry install --no-interaction
- name: Check formatting & linting
run: | - name: Start Redis v6
poetry run pre-commit run --all-files uses: superchargejs/redis-github-action@1.1.0
with:
redis-version: 6
- name: Run db migration - name: Run db migration
run: | run: |
@ -105,7 +111,7 @@ jobs:
build: build:
runs-on: ubuntu-latest runs-on: ubuntu-latest
needs: ['test'] needs: ['test', 'lint']
if: github.event_name == 'push' && (github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags/v')) if: github.event_name == 'push' && (github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags/v'))
steps: steps: