diff options
author | 2021-12-27 11:03:43 -0800 | |
---|---|---|
committer | 2021-12-27 11:03:43 -0800 | |
commit | cbed6ef5bbee30e560c2aef3f9822744df7fe06d (patch) | |
tree | 81a71dec79c553fcff6278e4b53a2232bf6b1f95 | |
parent | CI: specify service name to coveralls (diff) |
CI: run linters outside the container
Remove the dependency on the container so the lint job can run in
parallel with the build job. More time has to be spent installing
Python dependencies, but this is made up for by not having to download
and load the image artefact in addition to not having to wait for the
build job.
-rw-r--r-- | .github/workflows/lint.yaml | 76 | ||||
-rw-r--r-- | .github/workflows/main.yaml | 4 |
2 files changed, 44 insertions, 36 deletions
diff --git a/.github/workflows/lint.yaml b/.github/workflows/lint.yaml index 111df54..5678f53 100644 --- a/.github/workflows/lint.yaml +++ b/.github/workflows/lint.yaml @@ -2,54 +2,66 @@ name: Lint on: workflow_call: - inputs: - artefact: - required: true - type: string - tag: - required: true - type: string jobs: lint: runs-on: ubuntu-latest + env: + PIP_DISABLE_PIP_VERSION_CHECK: 1 + PIP_NO_CACHE_DIR: false + PIP_USER: 1 # Make dependencies install into PYTHONUSERBASE. - steps: - # region container setup - - name: Download image artefact - uses: actions/download-artifact@v2 - with: - name: ${{ inputs.artefact }} + PIPENV_DONT_USE_PYENV: 1 + PIPENV_HIDE_EMOJIS: 1 + PIPENV_NOSPIN: 1 + + PYTHONUSERBASE: ${{ github.workspace }}/.cache/py-user-base + PRE_COMMIT_HOME: ${{ github.workspace }}/.cache/pre-commit-cache - - name: Load image from archive - run: docker load -i ${{ inputs.artefact }}.tar + steps: + - name: Add custom PYTHONUSERBASE to PATH + run: echo '${{ env.PYTHONUSERBASE }}/bin/' >> $GITHUB_PATH - # Needed for the Docker Compose file. - name: Checkout code uses: actions/checkout@v2 - - name: Start container - run: | - export IMAGE_SUFFIX='-venv:${{ inputs.tag }}' - docker-compose up --no-build -d - # endregion + - name: Set up Python + id: python + uses: actions/setup-python@v2 + with: + python-version: "3.10" - # Required by pre-commit. - - name: Install git + - name: Python dependency cache + uses: actions/cache@v2 + id: python_cache + with: + path: ${{ env.PYTHONUSERBASE }} + key: "python-0-${{ runner.os }}-${{ env.PYTHONUSERBASE }}-\ + ${{ steps.python.outputs.python-version }}-\ + ${{ hashFiles('./Pipfile', './Pipfile.lock') }}" + + # Install dependencies if there was a cache miss. + - name: Install Python dependencies + if: steps.python_cache.outputs.cache-hit != 'true' run: >- - docker exec snekbox_dev /bin/bash -c - 'apt-get -y update && apt-get install -y git' + pip install pipenv==2021.11.23 + && pipenv install --deploy --system --dev + + - name: Pre-commit environment cache + uses: actions/cache@v2 + with: + path: ${{ env.PRE_COMMIT_HOME }} + key: "precommit-0-${{ runner.os }}-${{ env.PRE_COMMIT_HOME }}-\ + ${{ steps.python.outputs.python-version }}-\ + ${{ hashFiles('./.pre-commit-config.yaml') }}" # pre-commit's venv doesn't work with user installs. # Skip the flake8 hook because the following step will run it. - name: Run pre-commit hooks id: run-pre-commit-hooks - run: >- - docker exec snekbox_dev /bin/bash -c - 'PIP_USER=0 SKIP=flake8 pre-commit run --all-files' + run: PIP_USER=0 SKIP=flake8 pre-commit run --all-files - - name: Show pre-commit logs + # Show the log to debug failures. + - name: Show pre-commit log if: always() && steps.run-pre-commit-hooks.outcome != 'success' - run: >- - docker exec snekbox_dev /bin/bash -c - 'cat /root/.cache/pre-commit/pre-commit.log' + run: cat "${PRE_COMMIT_HOME}/pre-commit.log" diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml index cc8a1e0..3cdf940 100644 --- a/.github/workflows/main.yaml +++ b/.github/workflows/main.yaml @@ -11,10 +11,6 @@ jobs: uses: ./.github/workflows/build.yaml lint: uses: ./.github/workflows/lint.yaml - needs: build - with: - artefact: ${{ needs.build.outputs.artefact }} - tag: ${{ needs.build.outputs.tag }} test: uses: ./.github/workflows/test.yaml needs: build |