diff options
| author | 2022-01-10 21:58:37 +0200 | |
|---|---|---|
| committer | 2022-01-10 21:58:37 +0200 | |
| commit | 75387ee1556888d2060063c1cc739324a55d4033 (patch) | |
| tree | e941fb86fa70ca27d0993ea8fbd02f825df26356 /.github/workflows | |
| parent | Merge pull request #4 from python-discord/status-embed-flow (diff) | |
| parent | Add missing if statement to status embed workflow (diff) | |
Merge pull request #5 from python-discord/vendor-ansible-lint
Ansible-lint in pre-commit and dep caching in workflows
Diffstat (limited to '.github/workflows')
| -rw-r--r-- | .github/workflows/lint.yml | 56 | ||||
| -rw-r--r-- | .github/workflows/status_embed.yaml | 3 |
2 files changed, 52 insertions, 7 deletions
diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 49b05fc..6112699 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -14,17 +14,61 @@ on: jobs: lint: runs-on: ubuntu-latest + env: + PIP_NO_CACHE_DIR: false + PIP_USER: 1 + PYTHONUSERBASE: ${{ github.workspace }}/.cache/py-user-base + PRE_COMMIT_HOME: ${{ github.workspace }}/.cache/pre-commit-cache steps: + - name: Add custom PYTHONUSERBASE to PATH + run: echo '${{ env.PYTHONUSERBASE }}/bin/' >> $GITHUB_PATH + - uses: actions/checkout@v2 - - name: Lint Ansible playbooks - uses: ansible/ansible-lint-action@master + - name: Setup python + id: python + uses: actions/setup-python@v2 + with: + python-version: '3.10' + + # 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 with: - targets: | - playbook.yml - override-deps: | - ansible-lint==5.3.2 + path: ${{ env.PYTHONUSERBASE }} + key: "python-0-${{ runner.os }}-${{ env.PYTHONUSERBASE }}-\ + ${{ steps.python.outputs.python-version }}-\ + ${{ hashFiles('./requirements.txt') }}" + + # Install our dependencies if we did not restore a dependency cache + - name: Install dependencies using poetry + if: steps.python_cache.outputs.cache-hit != 'true' + run: | + pip install -U pip wheel setuptools + pip install -r requirements.txt + + # 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: + path: ${{ env.PRE_COMMIT_HOME }} + key: "precommit-0-${{ runner.os }}-${{ env.PRE_COMMIT_HOME }}-\ + ${{ steps.python.outputs.python-version }}-\ + ${{ hashFiles('./.pre-commit-config.yaml') }}" + + # 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; pre-commit run --all-files # Prepare the Pull Request Payload artifact. If this fails, we # we fail silently using the `continue-on-error` option. It's diff --git a/.github/workflows/status_embed.yaml b/.github/workflows/status_embed.yaml index 19b492f..f327865 100644 --- a/.github/workflows/status_embed.yaml +++ b/.github/workflows/status_embed.yaml @@ -17,11 +17,12 @@ jobs: # - Always after the `Lint` workflow, as it runs at the end of our workflow sequence regardless of status. # - Always for the `pull_request` event, as it only runs one workflow. # - Always run for non-success workflows, as they terminate the workflow sequence. + if: >- (github.event.workflow_run.name == 'Lint' && github.event.workflow_run.conclusion != 'skipped') || github.event.workflow_run.event == 'pull_request' || github.event.workflow_run.conclusion == 'failure' || github.event.workflow_run.conclusion == 'cancelled' - name: Send Status Embed to Discord + name: Send Status Embed to Discord runs-on: ubuntu-latest steps: |