]> git.madduck.net Git - etc/vim.git/blob - .github/workflows/diff_shades.yml

madduck's git repository

Every one of the projects in this repository is available at the canonical URL git://git.madduck.net/madduck/pub/<projectpath> — see each project's metadata for the exact URL.

All patches and comments are welcome. Please squash your changes to logical commits before using git-format-patch and git-send-email to patches@git.madduck.net. If you'd read over the Git project's submission guidelines and adhered to them, I'd be especially grateful.

SSH access, as well as push access can be individually arranged.

If you use my repositories frequently, consider adding the following snippet to ~/.gitconfig and using the third clone URL listed for each project:

[url "git://git.madduck.net/madduck/"]
  insteadOf = madduck:

Enforce no formatting changes for PRs via CI (GH-2951)
[etc/vim.git] / .github / workflows / diff_shades.yml
1 name: diff-shades
2
3 on:
4   push:
5     branches: [main]
6     paths: ["src/**", "setup.*", "pyproject.toml", ".github/workflows/*"]
7
8   pull_request:
9     paths: ["src/**", "setup.*", "pyproject.toml", ".github/workflows/*"]
10
11 concurrency:
12   group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.run_id }}
13   cancel-in-progress: true
14
15 jobs:
16   configure:
17     runs-on: ubuntu-latest
18     outputs:
19       matrix: ${{ steps.set-config.outputs.matrix }}
20
21     steps:
22       - uses: actions/checkout@v3
23       - uses: actions/setup-python@v3
24
25       - name: Install diff-shades and support dependencies
26         run: |
27           python -m pip install click packaging urllib3
28           python -m pip install https://github.com/ichard26/diff-shades/archive/stable.zip
29
30       - name: Calculate run configuration & metadata
31         id: set-config
32         env:
33           GITHUB_TOKEN: ${{ github.token }}
34         run: >
35           python scripts/diff_shades_gha_helper.py config ${{ github.event_name }} ${{ matrix.mode }}
36
37   analysis:
38     name: analysis / ${{ matrix.mode }}
39     needs: configure
40     runs-on: ubuntu-latest
41     env:
42       # Clang is less picky with the C code it's given than gcc (and may
43       # generate faster binaries too).
44       CC: clang-12
45     strategy:
46       fail-fast: false
47       matrix:
48         include: ${{ fromJson(needs.configure.outputs.matrix )}}
49
50     steps:
51       - name: Checkout this repository (full clone)
52         uses: actions/checkout@v3
53         with:
54           # The baseline revision could be rather old so a full clone is ideal.
55           fetch-depth: 0
56
57       - uses: actions/setup-python@v3
58
59       - name: Install diff-shades and support dependencies
60         run: |
61           python -m pip install https://github.com/ichard26/diff-shades/archive/stable.zip
62           python -m pip install click packaging urllib3
63           python -m pip install -r .github/mypyc-requirements.txt
64           # After checking out old revisions, this might not exist so we'll use a copy.
65           cat scripts/diff_shades_gha_helper.py > helper.py
66           git config user.name "diff-shades-gha"
67           git config user.email "diff-shades-gha@example.com"
68
69       - name: Attempt to use cached baseline analysis
70         id: baseline-cache
71         uses: actions/cache@v2.1.7
72         with:
73           path: ${{ matrix.baseline-analysis }}
74           key: ${{ matrix.baseline-cache-key }}
75
76       - name: Build and install baseline revision
77         if: steps.baseline-cache.outputs.cache-hit != 'true'
78         env:
79           GITHUB_TOKEN: ${{ github.token }}
80         run: >
81           ${{ matrix.baseline-setup-cmd }}
82           && python setup.py --use-mypyc bdist_wheel
83           && python -m pip install dist/*.whl && rm build dist -r
84
85       - name: Analyze baseline revision
86         if: steps.baseline-cache.outputs.cache-hit != 'true'
87         run: >
88           diff-shades analyze -v --work-dir projects-cache/
89           ${{ matrix.baseline-analysis }} ${{ matrix.force-flag }}
90
91       - name: Build and install target revision
92         env:
93           GITHUB_TOKEN: ${{ github.token }}
94         run: >
95           ${{ matrix.target-setup-cmd }}
96           && python setup.py --use-mypyc bdist_wheel
97           && python -m pip install dist/*.whl
98
99       - name: Analyze target revision
100         run: >
101           diff-shades analyze -v --work-dir projects-cache/
102           ${{ matrix.target-analysis }} --repeat-projects-from
103           ${{ matrix.baseline-analysis }} ${{ matrix.force-flag }}
104
105       - name: Generate HTML diff report
106         run: >
107           diff-shades --dump-html diff.html compare --diff
108           ${{ matrix.baseline-analysis }} ${{ matrix.target-analysis }}
109
110       - name: Upload diff report
111         uses: actions/upload-artifact@v2
112         with:
113           name: ${{ matrix.mode }}-diff.html
114           path: diff.html
115
116       - name: Upload baseline analysis
117         uses: actions/upload-artifact@v2
118         with:
119           name: ${{ matrix.baseline-analysis }}
120           path: ${{ matrix.baseline-analysis }}
121
122       - name: Upload target analysis
123         uses: actions/upload-artifact@v2
124         with:
125           name: ${{ matrix.target-analysis }}
126           path: ${{ matrix.target-analysis }}
127
128       - name: Generate summary file (PR only)
129         if: github.event_name == 'pull_request' && matrix.mode == 'preview-changes'
130         run: >
131           python helper.py comment-body
132           ${{ matrix.baseline-analysis }} ${{ matrix.target-analysis }}
133           ${{ matrix.baseline-sha }} ${{ matrix.target-sha }}
134           ${{ github.event.pull_request.number }}
135
136       - name: Upload summary file (PR only)
137         if: github.event_name == 'pull_request' && matrix.mode == 'preview-changes'
138         uses: actions/upload-artifact@v2
139         with:
140           name: .pr-comment.json
141           path: .pr-comment.json
142
143       - name: Verify zero changes (PR only)
144         if: matrix.mode == 'assert-no-changes'
145         run: >
146           diff-shades compare --check ${{ matrix.baseline-analysis }} ${{ matrix.target-analysis }}
147           || (echo "Please verify you didn't change the stable code style unintentionally!" && exit 1)
148
149       - name: Check for failed files for target revision
150         # Even if the previous step failed, we should still check for failed files.
151         if: always()
152         run: >
153           diff-shades show-failed --check --show-log ${{ matrix.target-analysis }}
154           --check-allow 'sqlalchemy:test/orm/test_relationship_criteria.py'