@@ -3,54 +3,61 @@ name: diff-shades
33on :
44 push :
55 branches : [main]
6- paths-ignore : ["docs /**", "tests/** ", "**.md ", "**.rst "]
6+ paths : ["src /**", "setup.* ", "pyproject.toml ", ".github/workflows/* "]
77
88 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
9+ paths : ["src/**", "setup.*", "pyproject.toml", ".github/workflows/*"]
2910
3011concurrency :
3112 group : ${{ github.workflow }}-${{ github.event.pull_request.number || github.run_id }}
3213 cancel-in-progress : true
3314
3415jobs :
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+
3537 analysis :
36- name : analysis / linux
38+ name : analysis / ${{ matrix.mode }}
39+ needs : configure
3740 runs-on : ubuntu-latest
3841 env :
3942 # Clang is less picky with the C code it's given than gcc (and may
4043 # generate faster binaries too).
4144 CC : clang-12
45+ strategy :
46+ fail-fast : false
47+ matrix :
48+ include : ${{ fromJson(needs.configure.outputs.matrix )}}
4249
4350 steps :
4451 - name : Checkout this repository (full clone)
4552 uses : actions/checkout@v3
4653 with :
54+ # The baseline revision could be rather old so a full clone is ideal.
4755 fetch-depth : 0
4856
4957 - uses : actions/setup-python@v3
5058
5159 - name : Install diff-shades and support dependencies
5260 run : |
53- python -m pip install pip --upgrade
5461 python -m pip install https://github.com/ichard26/diff-shades/archive/stable.zip
5562 python -m pip install click packaging urllib3
5663 python -m pip install -r .github/mypyc-requirements.txt
@@ -59,92 +66,89 @@ jobs:
5966 git config user.name "diff-shades-gha"
6067 git config user.email "[email protected] " 6168
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-
7169 - name : Attempt to use cached baseline analysis
7270 id : baseline-cache
73717472 with :
75- path : ${{ steps.config.outputs .baseline-analysis }}
76- key : ${{ steps.config.outputs .baseline-cache-key }}
73+ path : ${{ matrix .baseline-analysis }}
74+ key : ${{ matrix .baseline-cache-key }}
7775
7876 - name : Build and install baseline revision
7977 if : steps.baseline-cache.outputs.cache-hit != 'true'
8078 env :
8179 GITHUB_TOKEN : ${{ github.token }}
8280 run : >
83- ${{ steps.config.outputs .baseline-setup-cmd }}
81+ ${{ matrix .baseline-setup-cmd }}
8482 && python setup.py --use-mypyc bdist_wheel
8583 && python -m pip install dist/*.whl && rm build dist -r
8684
8785 - name : Analyze baseline revision
8886 if : steps.baseline-cache.outputs.cache-hit != 'true'
8987 run : >
9088 diff-shades analyze -v --work-dir projects-cache/
91- ${{ steps.config.outputs. baseline-analysis }} -- ${{ github.event.inputs.baseline-args }}
89+ ${{ matrix. baseline-analysis }} ${{ matrix.force-flag }}
9290
9391 - name : Build and install target revision
9492 env :
9593 GITHUB_TOKEN : ${{ github.token }}
9694 run : >
97- ${{ steps.config.outputs .target-setup-cmd }}
95+ ${{ matrix .target-setup-cmd }}
9896 && python setup.py --use-mypyc bdist_wheel
9997 && python -m pip install dist/*.whl
10098
10199 - name : Analyze target revision
102100 run : >
103101 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 }}
102+ ${{ matrix .target-analysis }} --repeat-projects-from
103+ ${{ matrix. baseline-analysis }} ${{ matrix.force-flag }}
106104
107105 - name : Generate HTML diff report
108106 run : >
109- diff-shades --dump-html diff.html compare --diff --quiet
110- ${{ steps.config.outputs. baseline-analysis }} ${{ steps.config.outputs .target-analysis }}
107+ diff-shades --dump-html diff.html compare --diff
108+ ${{ matrix. baseline-analysis }} ${{ matrix .target-analysis }}
111109
112110 - name : Upload diff report
113111 uses : actions/upload-artifact@v2
114112 with :
115- name : diff.html
113+ name : ${{ matrix.mode }}- diff.html
116114 path : diff.html
117115
118116 - name : Upload baseline analysis
119117 uses : actions/upload-artifact@v2
120118 with :
121- name : ${{ steps.config.outputs .baseline-analysis }}
122- path : ${{ steps.config.outputs .baseline-analysis }}
119+ name : ${{ matrix .baseline-analysis }}
120+ path : ${{ matrix .baseline-analysis }}
123121
124122 - name : Upload target analysis
125123 uses : actions/upload-artifact@v2
126124 with :
127- name : ${{ steps.config.outputs .target-analysis }}
128- path : ${{ steps.config.outputs .target-analysis }}
125+ name : ${{ matrix .target-analysis }}
126+ path : ${{ matrix .target-analysis }}
129127
130128 - name : Generate summary file (PR only)
131- if : github.event_name == 'pull_request'
129+ if : github.event_name == 'pull_request' && matrix.mode == 'preview-changes'
132130 run : >
133131 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 }}
132+ ${{ matrix. baseline-analysis }} ${{ matrix .target-analysis }}
133+ ${{ matrix. baseline-sha }} ${{ matrix .target-sha }}
136134 ${{ github.event.pull_request.number }}
137135
138136 - name : Upload summary file (PR only)
139- if : github.event_name == 'pull_request'
137+ if : github.event_name == 'pull_request' && matrix.mode == 'preview-changes'
140138 uses : actions/upload-artifact@v2
141139 with :
142140 name : .pr-comment.json
143141 path : .pr-comment.json
144142
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
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()
148152 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 }}
153+ diff-shades show-failed --check --show-log ${{ matrix.target -analysis }}
154+ -- check-allow 'sqlalchemy:test/orm/test_relationship_criteria.py'
0 commit comments