diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 7a9ec781..33537d3b 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -1,9 +1,32 @@ -name: Run tests & Publish to Docker Registry +name: Test and lint on: push: 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: runs-on: ubuntu-latest strategy: @@ -38,32 +61,16 @@ jobs: --health-retries 5 steps: - - name: Start Redis v6 - uses: superchargejs/redis-github-action@1.1.0 - 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: Check out repo + uses: actions/checkout@v3 - name: Install poetry - uses: snok/install-poetry@v1 - with: - virtualenvs-create: true - virtualenvs-in-project: true - installer-parallel: true + run: pipx install poetry - - name: Run caching - id: cached-poetry-dependencies - uses: actions/cache@v2 + - uses: actions/setup-python@v4 with: - path: .venv - key: venv-${{ runner.os }}-${{ matrix.python-version }}-${{ hashFiles('**/poetry.lock') }} + python-version: ${{ matrix.python-version }} + cache: 'poetry' - name: Install OS dependencies if: ${{ matrix.python-version }} == '3.10' @@ -73,14 +80,13 @@ jobs: - name: Install dependencies if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true' - run: poetry install --no-interaction --no-root - - - name: Install library run: poetry install --no-interaction - - name: Check formatting & linting - run: | - poetry run pre-commit run --all-files + + - name: Start Redis v6 + uses: superchargejs/redis-github-action@1.1.0 + with: + redis-version: 6 - name: Run db migration run: | @@ -105,7 +111,7 @@ jobs: build: 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')) steps: