Skip to content

Commit

Permalink
diff-shades: force --preview for PRs and pushes
Browse files Browse the repository at this point in the history
This will let us gauge the impact of a change ahead of time.
  • Loading branch information
ichard26 committed Feb 21, 2022
1 parent 07a2e6f commit 901460c
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 4 deletions.
10 changes: 6 additions & 4 deletions .github/workflows/diff_shades.yml
Expand Up @@ -3,10 +3,10 @@ name: diff-shades
on:
push:
branches: [main]
paths-ignore: ["docs/**", "tests/**", "**.md", "**.rst"]
paths: ["src/**", "setup.*", "pyproject.toml", ".github/workflows/*"]

pull_request:
paths-ignore: ["docs/**", "tests/**", "**.md", "**.rst"]
paths: ["src/**", "setup.*", "pyproject.toml", ".github/workflows/*"]

workflow_dispatch:
inputs:
Expand Down Expand Up @@ -88,7 +88,8 @@ jobs:
if: steps.baseline-cache.outputs.cache-hit != 'true'
run: >
diff-shades analyze -v --work-dir projects-cache/
${{ steps.config.outputs.baseline-analysis }} -- ${{ github.event.inputs.baseline-args }}
${{ steps.config.outputs.baseline-analysis }} --
${{ steps.config.outputs.extra-args }} ${{ github.event.inputs.baseline-args }}
- name: Build and install target revision
env:
Expand All @@ -102,7 +103,8 @@ jobs:
run: >
diff-shades analyze -v --work-dir projects-cache/
${{ steps.config.outputs.target-analysis }} --repeat-projects-from
${{ steps.config.outputs.baseline-analysis }} -- ${{ github.event.inputs.target-args }}
${{ steps.config.outputs.baseline-analysis }} --
${{ steps.config.outputs.extra-args }} ${{ github.event.inputs.target-args }}
- name: Generate HTML diff report
run: >
Expand Down
5 changes: 5 additions & 0 deletions docs/contributing/gauging_changes.md
Expand Up @@ -34,6 +34,11 @@ these rules:
| On PRs | latest commit on `main` | PR commit with `main` merged |
| On pushes (main only) | latest PyPI version | the pushed commit |

```{note}
Except for manually triggered runs, `preview=True` is forcefully set for all projects so
we can gauge the impact ahead of time (which is literally the purpose of this workflow).
```

Once finished, a PR comment will be posted embedding a summary of the changes and links
to further information. If there's a pre-existing diff-shades comment, it'll be updated
instead the next time the workflow is triggered on the same PR.
Expand Down
4 changes: 4 additions & 0 deletions scripts/diff_shades_gha_helper.py
Expand Up @@ -185,6 +185,10 @@ def config(
set_output("baseline-setup-cmd", baseline_cmd)
set_output("target-analysis", target_name + ".json")
set_output("target-setup-cmd", target_cmd)
# Except for manually triggered runs, it's more useful to force --preview for all
# projects so we can gauge the impact ahead of time (which is literally the purpose
# of this workflow).
set_output("extra-args", "" if event == "workflow_dispatch" else "--preview")

key = f"{platform.system()}-{platform.python_version()}-{diff_shades.__version__}"
key += f"-{baseline_name}-{baseline_args.encode('utf-8').hex()}"
Expand Down
3 changes: 3 additions & 0 deletions src/black/__init__.py
Expand Up @@ -682,6 +682,9 @@ def reformat_code(
report.failed(path, str(exc))


# diff-shades depends on being to monkeypatch this function to operate. I know it's
# not ideal, but this shouldn't cause any issues ... hopefully. ~ichard26
@mypyc_attr(patchable=True)
def reformat_one(
src: Path, fast: bool, write_back: WriteBack, mode: Mode, report: "Report"
) -> None:
Expand Down

0 comments on commit 901460c

Please sign in to comment.