diff options
-rw-r--r-- | .github/workflows/lint-test-build.yml | 30 |
1 files changed, 25 insertions, 5 deletions
diff --git a/.github/workflows/lint-test-build.yml b/.github/workflows/lint-test-build.yml index a6f7df45c..dc4ea5fd9 100644 --- a/.github/workflows/lint-test-build.yml +++ b/.github/workflows/lint-test-build.yml @@ -14,6 +14,7 @@ jobs: lint-test: runs-on: ubuntu-latest env: + # Dummy values for required bot environment variables BOT_API_KEY: foo BOT_SENTRY_DSN: blah BOT_TOKEN: bar @@ -21,13 +22,21 @@ jobs: REDDIT_SECRET: ham REDIS_PASSWORD: '' + # Configure pip to cache dependencies and do a user install PIP_NO_CACHE_DIR: false PIP_USER: 1 + + # Hide the graphical elements from pipenv's output PIPENV_HIDE_EMOJIS: 1 - PIPENV_IGNORE_VIRTUALENVS: 1 PIPENV_NOSPIN: 1 - PRE_COMMIT_HOME: ${{ github.workspace }}/.cache/pre-commit-cache + + # Make sure pipenv does not try reuse an environment it's running in + PIPENV_IGNORE_VIRTUALENVS: 1 + + # Specify explicit paths for python dependencies and the pre-commit + # environment so we know which directories to cache PYTHONUSERBASE: ${{ github.workspace }}/.cache/py-user-base + PRE_COMMIT_HOME: ${{ github.workspace }}/.cache/pre-commit-cache steps: - name: Add custom PYTHONUSERBASE to PATH @@ -46,6 +55,12 @@ jobs: with: python-version: '3.8' + # This step caches our Python dependencies. To make sure we + # only restore a cache when the dependencies, the python version, + # the runner operating system, and the dependency location haven't + # changed, we create a cache key that is a composite of those states. + # + # Only when the context is exactly the same, we will restore the cache. - name: Python Dependency Caching uses: actions/cache@v2 id: python_cache @@ -55,12 +70,16 @@ jobs: ${{ steps.python.outputs.python-version }}-\ ${{ hashFiles('./Pipfile', './Pipfile.lock') }}" + # Install our dependencies if we did not restore a dependency cache - name: Install dependencies using pipenv if: steps.python_cache.outputs.cache-hit != 'true' run: | pip install pipenv pipenv install --dev --deploy --system + # This step caches our pre-commit environment. To make sure we + # do create a new environment when our pre-commit setup changes, + # we create a cache key based on relevant factors. - name: Pre-commit Environment Caching uses: actions/cache@v2 with: @@ -70,12 +89,13 @@ jobs: ${{ hashFiles('./.pre-commit-config.yaml') }}" # We will not run `flake8` here, as we will use a separate flake8 - # action. As pre-commit does not support user installs, and we don't - # really need it, we set PIP_USER=0. + # action. As pre-commit does not support user installs, we set + # PIP_USER=0 to not do a user install. - name: Run pre-commit hooks run: export PIP_USER=0; SKIP=flake8 pre-commit run --all-files - # This step requires `pull_request_target` due to the use of annotations + # This step requires `pull_request_target`, as adding annotations + # requires "write" permissions to the repo. - name: Run flake8 uses: julianwachholz/flake8-action@v1 with: |