|
1 | 1 | name: Pre-commit check
|
2 | 2 |
|
3 | 3 | on:
|
| 4 | + workflow_dispatch: |
4 | 5 | pull_request:
|
5 | 6 | types: [opened, reopened, synchronize, labeled]
|
| 7 | + workflow_run: |
| 8 | + workflows: ["ESP32 Arduino CI"] |
| 9 | + types: [completed] |
| 10 | + |
| 11 | +concurrency: |
| 12 | + group: pre-commit-${{github.event.pull_request.number || github.ref}} |
| 13 | + cancel-in-progress: true |
6 | 14 |
|
7 | 15 | jobs:
|
| 16 | + save-workflow-id: |
| 17 | + if: ${{ github.event_name == 'workflow_run' && github.event.workflow_run.conclusion == 'success' }} |
| 18 | + name: Save compilation workflow ID |
| 19 | + runs-on: ubuntu-latest |
| 20 | + outputs: |
| 21 | + workflow_id: ${{ steps.save-workflow-id.outputs.workflow_id }} |
| 22 | + steps: |
| 23 | + - name: Save workflow ID |
| 24 | + id: save-workflow-id |
| 25 | + run: echo "workflow_id=${{ github.event.workflow_run.id }}" >> $GITHUB_OUTPUT |
| 26 | + |
8 | 27 | lint:
|
9 |
| - if: | |
10 |
| - contains(github.event.pull_request.labels.*.name, 'Status: Pending Merge') |
11 |
| - name: Checking if any fixes are needed |
| 28 | + if: always() |
| 29 | + #if: ${{ always() && contains(github.event.pull_request.labels.*.name, 'Status: Pending Merge') }} |
| 30 | + needs: save-workflow-id |
| 31 | + name: Run pre-commit hooks |
12 | 32 | runs-on: ubuntu-latest
|
13 | 33 | steps:
|
14 | 34 | - name: Checkout latest commit
|
|
35 | 55 | ~/.cache/pip
|
36 | 56 | key: pre-commit|${{ env.PY_HASH }}|${{ hashFiles('.pre-commit-config.yaml', '.github/workflows/pre-commit.yml') }}
|
37 | 57 |
|
| 58 | + - name: Download compilation artifacts |
| 59 | + uses: actions/download-artifact@v4 |
| 60 | + if: ${{ needs.save-workflow-id.outputs.workflow_id != '' }} |
| 61 | + with: |
| 62 | + pattern: build-job-* |
| 63 | + merge-multiple: true |
| 64 | + path: ~/.arduino/tests/ |
| 65 | + run-id: ${{ needs.save-workflow-id.outputs.workflow_id }} |
| 66 | + github-token: ${{ secrets.GITHUB_TOKEN }} |
| 67 | + |
| 68 | + - name: Merge compile commands |
| 69 | + if: ${{ needs.save-workflow-id.outputs.workflow_id != '' }} |
| 70 | + run: | |
| 71 | + find ~/.arduino/tests/ -iname "compile_commands.json" | xargs jq -s 'map(.[])' > ~/compile_commands.json |
| 72 | +
|
| 73 | + - name: Upload compile commands |
| 74 | + if: ${{ needs.save-workflow-id.outputs.workflow_id != '' }} |
| 75 | + uses: actions/upload-artifact@v4 |
| 76 | + with: |
| 77 | + name: compile_commands |
| 78 | + path: ~/compile_commands.json |
| 79 | + |
38 | 80 | - name: Install python dependencies
|
39 | 81 | run: python -m pip install pre-commit docutils
|
40 | 82 |
|
|
0 commit comments