]> 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:

62cac6748fdad2153f4f1177b83f3cb1bb21bb40
[etc/vim.git] / .github / workflows / diff_shades.yml
1 name: diff-shades
2
3 on:
4   push:
5     branches: [main]
6     paths-ignore: ["docs/**", "tests/**", "**.md", "**.rst"]
7
8   pull_request:
9     paths-ignore: ["docs/**", "tests/**", "**.md", "**.rst"]
10
11   workflow_dispatch:
12     inputs:
13       baseline:
14         description: >
15           The baseline revision. Pro-tip, use `.pypi` to use the latest version
16           on PyPI or `.XXX` to use a PR.
17         required: true
18         default: main
19       baseline-args:
20         description: "Custom Black arguments (eg. -l 79)"
21         required: false
22       target:
23         description: >
24           The target revision to compare against the baseline. Same tip applies here.
25         required: true
26       target-args:
27         description: "Custom Black arguments (eg. -S)"
28         required: false
29
30 concurrency:
31   group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.run_id }}
32   cancel-in-progress: true
33
34 jobs:
35   analysis:
36     name: analysis / linux
37     runs-on: ubuntu-latest
38     env:
39       # Clang is less picky with the C code it's given than gcc (and may
40       # generate faster binaries too).
41       CC: clang-12
42
43     steps:
44       - name: Checkout this repository (full clone)
45         uses: actions/checkout@v3
46         with:
47           fetch-depth: 0
48
49       - uses: actions/setup-python@v2
50
51       - name: Install diff-shades and support dependencies
52         run: |
53           python -m pip install pip --upgrade
54           python -m pip install https://github.com/ichard26/diff-shades/archive/stable.zip
55           python -m pip install click packaging urllib3
56           python -m pip install -r .github/mypyc-requirements.txt
57           # After checking out old revisions, this might not exist so we'll use a copy.
58           cat scripts/diff_shades_gha_helper.py > helper.py
59           git config user.name "diff-shades-gha"
60           git config user.email "diff-shades-gha@example.com"
61
62       - name: Calculate run configuration & metadata
63         id: config
64         env:
65           GITHUB_TOKEN: ${{ github.token }}
66         run: >
67           python helper.py config ${{ github.event_name }}
68           ${{ github.event.inputs.baseline }} ${{ github.event.inputs.target }}
69           --baseline-args "${{ github.event.inputs.baseline-args }}"
70
71       - name: Attempt to use cached baseline analysis
72         id: baseline-cache
73         uses: actions/cache@v2.1.7
74         with:
75           path: ${{ steps.config.outputs.baseline-analysis }}
76           key: ${{ steps.config.outputs.baseline-cache-key }}
77
78       - name: Build and install baseline revision
79         if: steps.baseline-cache.outputs.cache-hit != 'true'
80         env:
81           GITHUB_TOKEN: ${{ github.token }}
82         run: >
83           ${{ steps.config.outputs.baseline-setup-cmd }}
84           && python setup.py --use-mypyc bdist_wheel
85           && python -m pip install dist/*.whl && rm build dist -r
86
87       - name: Analyze baseline revision
88         if: steps.baseline-cache.outputs.cache-hit != 'true'
89         run: >
90           diff-shades analyze -v --work-dir projects-cache/
91           ${{ steps.config.outputs.baseline-analysis }} -- ${{ github.event.inputs.baseline-args }}
92
93       - name: Build and install target revision
94         env:
95           GITHUB_TOKEN: ${{ github.token }}
96         run: >
97           ${{ steps.config.outputs.target-setup-cmd }}
98           && python setup.py --use-mypyc bdist_wheel
99           && python -m pip install dist/*.whl
100
101       - name: Analyze target revision
102         run: >
103           diff-shades analyze -v --work-dir projects-cache/
104           ${{ steps.config.outputs.target-analysis }} --repeat-projects-from
105           ${{ steps.config.outputs.baseline-analysis }} -- ${{ github.event.inputs.target-args }}
106
107       - name: Generate HTML diff report
108         run: >
109           diff-shades --dump-html diff.html compare --diff --quiet
110           ${{ steps.config.outputs.baseline-analysis }} ${{ steps.config.outputs.target-analysis }}
111
112       - name: Upload diff report
113         uses: actions/upload-artifact@v2
114         with:
115           name: diff.html
116           path: diff.html
117
118       - name: Upload baseline analysis
119         uses: actions/upload-artifact@v2
120         with:
121           name: ${{ steps.config.outputs.baseline-analysis }}
122           path: ${{ steps.config.outputs.baseline-analysis }}
123
124       - name: Upload target analysis
125         uses: actions/upload-artifact@v2
126         with:
127           name: ${{ steps.config.outputs.target-analysis }}
128           path: ${{ steps.config.outputs.target-analysis }}
129
130       - name: Generate summary file (PR only)
131         if: github.event_name == 'pull_request'
132         run: >
133           python helper.py comment-body
134           ${{ steps.config.outputs.baseline-analysis }} ${{ steps.config.outputs.target-analysis }}
135           ${{ steps.config.outputs.baseline-sha }} ${{ steps.config.outputs.target-sha }}
136           ${{ github.event.pull_request.number }}
137
138       - name: Upload summary file (PR only)
139         if: github.event_name == 'pull_request'
140         uses: actions/upload-artifact@v2
141         with:
142           name: .pr-comment.json
143           path: .pr-comment.json
144
145         # This is last so the diff-shades-comment workflow can still work even if we
146         # end up detecting failed files and failing the run.
147       - name: Check for failed files in both analyses
148         run: >
149           diff-shades show-failed --check --show-log ${{ steps.config.outputs.baseline-analysis }};
150           diff-shades show-failed --check --show-log ${{ steps.config.outputs.target-analysis }}