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

[trivial] Use proper test cases on `unittest` (#2775)
[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"]
7
8   pull_request:
9     path-ignore: ["docs/**", "tests/**", "*.md"]
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 jobs:
31   analysis:
32     name: analysis / linux
33     runs-on: ubuntu-latest
34
35     steps:
36       - name: Checkout this repository (full clone)
37         uses: actions/checkout@v2
38         with:
39           fetch-depth: 0
40
41       - uses: actions/setup-python@v2
42
43       - name: Install diff-shades and support dependencies
44         run: |
45           python -m pip install pip --upgrade
46           python -m pip install https://github.com/ichard26/diff-shades/archive/stable.zip
47           python -m pip install click packaging urllib3
48           # After checking out old revisions, this might not exist so we'll use a copy.
49           cat scripts/diff_shades_gha_helper.py > helper.py
50           git config user.name "diff-shades-gha"
51           git config user.email "diff-shades-gha@example.com"
52
53       - name: Calculate run configuration & metadata
54         id: config
55         env:
56           GITHUB_TOKEN: ${{ github.token }}
57         run: >
58           python helper.py config ${{ github.event_name }}
59           ${{ github.event.inputs.baseline }} ${{ github.event.inputs.target }}
60           --baseline-args "${{ github.event.inputs.baseline-args }}"
61
62       - name: Attempt to use cached baseline analysis
63         id: baseline-cache
64         uses: actions/cache@v2.1.7
65         with:
66           path: ${{ steps.config.outputs.baseline-analysis }}
67           key: ${{ steps.config.outputs.baseline-cache-key }}
68
69       - name: Install baseline revision
70         if: steps.baseline-cache.outputs.cache-hit != 'true'
71         env:
72           GITHUB_TOKEN: ${{ github.token }}
73         run: ${{ steps.config.outputs.baseline-setup-cmd }} && python -m pip install .
74
75       - name: Analyze baseline revision
76         if: steps.baseline-cache.outputs.cache-hit != 'true'
77         run: >
78           diff-shades analyze -v --work-dir projects-cache/
79           ${{ steps.config.outputs.baseline-analysis }} -- ${{ github.event.inputs.baseline-args }}
80
81       - name: Install target revision
82         env:
83           GITHUB_TOKEN: ${{ github.token }}
84         run: ${{ steps.config.outputs.target-setup-cmd }} && python -m pip install .
85
86       - name: Analyze target revision
87         run: >
88           diff-shades analyze -v --work-dir projects-cache/
89           ${{ steps.config.outputs.target-analysis }} --repeat-projects-from
90           ${{ steps.config.outputs.baseline-analysis }} -- ${{ github.event.inputs.target-args }}
91
92       - name: Generate HTML diff report
93         run: >
94           diff-shades --dump-html diff.html compare --diff --quiet
95           ${{ steps.config.outputs.baseline-analysis }} ${{ steps.config.outputs.target-analysis }}
96
97       - name: Upload diff report
98         uses: actions/upload-artifact@v2
99         with:
100           name: diff.html
101           path: diff.html
102
103       - name: Upload baseline analysis
104         uses: actions/upload-artifact@v2
105         with:
106           name: ${{ steps.config.outputs.baseline-analysis }}
107           path: ${{ steps.config.outputs.baseline-analysis }}
108
109       - name: Upload target analysis
110         uses: actions/upload-artifact@v2
111         with:
112           name: ${{ steps.config.outputs.target-analysis }}
113           path: ${{ steps.config.outputs.target-analysis }}
114
115       - name: Generate summary file (PR only)
116         if: github.event_name == 'pull_request'
117         run: >
118           python helper.py comment-body
119           ${{ steps.config.outputs.baseline-analysis }} ${{ steps.config.outputs.target-analysis }}
120           ${{ steps.config.outputs.baseline-sha }} ${{ steps.config.outputs.target-sha }}
121
122       - name: Upload summary file (PR only)
123         if: github.event_name == 'pull_request'
124         uses: actions/upload-artifact@v2
125         with:
126           name: .pr-comment-body.md
127           path: .pr-comment-body.md
128
129         # This is last so the diff-shades-comment workflow can still work even if we
130         # end up detecting failed files and failing the run.
131       - name: Check for failed files in both analyses
132         run: >
133           diff-shades show-failed --check --show-log ${{ steps.config.outputs.baseline-analysis }};
134           diff-shades show-failed --check --show-log ${{ steps.config.outputs.target-analysis }}