147 lines
4.8 KiB
YAML
147 lines
4.8 KiB
YAML
name: ty ecosystem-analyzer
|
|
|
|
permissions: {}
|
|
|
|
on:
|
|
pull_request:
|
|
# The default for `pull_request` is to trigger on `synchronize`, `opened` and `reopened`.
|
|
# We also add `labeled` here so that the workflow triggers when a label is initially added.
|
|
types:
|
|
- labeled
|
|
- synchronize
|
|
- opened
|
|
- reopened
|
|
|
|
concurrency:
|
|
group: ${{ github.workflow }}-${{ github.ref_name }}-${{ github.event.pull_request.number || github.sha }}
|
|
cancel-in-progress: true
|
|
|
|
env:
|
|
CARGO_INCREMENTAL: 0
|
|
CARGO_NET_RETRY: 10
|
|
CARGO_TERM_COLOR: always
|
|
RUSTUP_MAX_RETRIES: 10
|
|
RUST_BACKTRACE: 1
|
|
REF_NAME: ${{ github.ref_name }}
|
|
|
|
jobs:
|
|
ty-ecosystem-analyzer:
|
|
name: Compute diagnostic diff
|
|
runs-on: ${{ github.repository == 'astral-sh/ruff' && 'depot-ubuntu-22.04-32' || 'ubuntu-latest' }}
|
|
timeout-minutes: 20
|
|
if: contains( github.event.pull_request.labels.*.name, 'ecosystem-analyzer')
|
|
steps:
|
|
- uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
|
|
with:
|
|
path: ruff
|
|
fetch-depth: 0
|
|
persist-credentials: false
|
|
|
|
- name: Install the latest version of uv
|
|
uses: astral-sh/setup-uv@681c641aba71e4a1c380be3ab5e12ad51f415867 # v7.1.6
|
|
with:
|
|
enable-cache: true
|
|
|
|
- uses: Swatinem/rust-cache@779680da715d629ac1d338a641029a2f4372abb5 # v2.8.2
|
|
with:
|
|
workspaces: "ruff"
|
|
lookup-only: false
|
|
|
|
- name: Install Rust toolchain
|
|
run: rustup show
|
|
|
|
- name: Compute diagnostic diff
|
|
shell: bash
|
|
run: |
|
|
cd ruff
|
|
|
|
echo "Enabling configuration overloads (see .github/mypy-primer-ty.toml)"
|
|
mkdir -p ~/.config/ty
|
|
cp .github/mypy-primer-ty.toml ~/.config/ty/ty.toml
|
|
|
|
echo "new commit"
|
|
git checkout -b new_commit "$GITHUB_SHA"
|
|
git rev-list --format=%s --max-count=1 new_commit
|
|
cp crates/ty_python_semantic/resources/primer/good.txt projects_new.txt
|
|
|
|
echo "old commit (merge base)"
|
|
MERGE_BASE="$(git merge-base "$GITHUB_SHA" "origin/$GITHUB_BASE_REF")"
|
|
git checkout -b old_commit "$MERGE_BASE"
|
|
git rev-list --format=%s --max-count=1 old_commit
|
|
cp crates/ty_python_semantic/resources/primer/good.txt projects_old.txt
|
|
|
|
cd ..
|
|
|
|
uv tool install "git+https://github.com/astral-sh/ecosystem-analyzer@2e1816eac09c90140b1ba51d19afc5f59da460f5"
|
|
|
|
ecosystem-analyzer \
|
|
--repository ruff \
|
|
diff \
|
|
--profile=profiling \
|
|
--projects-old ruff/projects_old.txt \
|
|
--projects-new ruff/projects_new.txt \
|
|
--old old_commit \
|
|
--new new_commit \
|
|
--output-old diagnostics-old.json \
|
|
--output-new diagnostics-new.json
|
|
|
|
mkdir dist
|
|
|
|
ecosystem-analyzer \
|
|
generate-diff \
|
|
diagnostics-old.json \
|
|
diagnostics-new.json \
|
|
--old-name "main (merge base)" \
|
|
--new-name "$REF_NAME" \
|
|
--output-html dist/diff.html
|
|
|
|
ecosystem-analyzer \
|
|
generate-diff-statistics \
|
|
diagnostics-old.json \
|
|
diagnostics-new.json \
|
|
--old-name "main (merge base)" \
|
|
--new-name "$REF_NAME" \
|
|
--output diff-statistics.md
|
|
|
|
ecosystem-analyzer \
|
|
generate-timing-diff \
|
|
diagnostics-old.json \
|
|
diagnostics-new.json \
|
|
--old-name "main (merge base)" \
|
|
--new-name "$REF_NAME" \
|
|
--output-html dist/timing.html
|
|
|
|
echo '## `ecosystem-analyzer` results' > comment.md
|
|
echo >> comment.md
|
|
cat diff-statistics.md >> comment.md
|
|
|
|
cat diff-statistics.md >> "$GITHUB_STEP_SUMMARY"
|
|
|
|
# NOTE: astral-sh-bot uses this artifact to post comments on PRs.
|
|
# Make sure to update the bot if you rename the artifact.
|
|
- name: "Upload full report"
|
|
uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6.0.0
|
|
with:
|
|
name: full-report
|
|
path: dist/
|
|
|
|
# NOTE: astral-sh-bot uses this artifact to post comments on PRs.
|
|
# Make sure to update the bot if you rename the artifact.
|
|
- name: Upload comment
|
|
uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6.0.0
|
|
with:
|
|
name: comment.md
|
|
path: comment.md
|
|
|
|
- name: Upload diagnostics diff
|
|
uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6.0.0
|
|
with:
|
|
name: diff.html
|
|
path: dist/diff.html
|
|
|
|
- name: Upload timing diff
|
|
uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6.0.0
|
|
with:
|
|
name: timing.html
|
|
path: dist/timing.html
|