mirror of https://github.com/astral-sh/ruff
151 lines
5.2 KiB
YAML
151 lines
5.2 KiB
YAML
name: ty ecosystem-analyzer
|
|
|
|
permissions: {}
|
|
|
|
on:
|
|
pull_request:
|
|
types: [labeled]
|
|
|
|
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 }}
|
|
CF_API_TOKEN_EXISTS: ${{ secrets.CF_API_TOKEN != '' }}
|
|
|
|
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.label.name, 'ecosystem-analyzer')
|
|
steps:
|
|
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
|
|
with:
|
|
path: ruff
|
|
fetch-depth: 0
|
|
persist-credentials: false
|
|
|
|
- name: Install the latest version of uv
|
|
uses: astral-sh/setup-uv@85856786d1ce8acfbcc2f13a5f3fbd6b938f9f41 # v7.1.2
|
|
with:
|
|
enable-cache: true # zizmor: ignore[cache-poisoning] acceptable risk for CloudFlare pages artifact
|
|
|
|
- uses: Swatinem/rust-cache@f13886b937689c021905a6b90929199931d60db1 # v2.8.1
|
|
with:
|
|
workspaces: "ruff"
|
|
lookup-only: false # zizmor: ignore[cache-poisoning] acceptable risk for CloudFlare pages artifact
|
|
|
|
- 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@908758da02a73ef3f3308e1dbb2248510029bbe4"
|
|
|
|
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"
|
|
|
|
- name: "Deploy to Cloudflare Pages"
|
|
if: ${{ env.CF_API_TOKEN_EXISTS == 'true' }}
|
|
id: deploy
|
|
uses: cloudflare/wrangler-action@da0e0dfe58b7a431659754fdf3f186c529afbe65 # v3.14.1
|
|
with:
|
|
apiToken: ${{ secrets.CF_API_TOKEN }}
|
|
accountId: ${{ secrets.CF_ACCOUNT_ID }}
|
|
command: pages deploy dist --project-name=ty-ecosystem --branch ${{ github.head_ref }} --commit-hash ${GITHUB_SHA}
|
|
|
|
- name: "Append deployment URL"
|
|
if: ${{ env.CF_API_TOKEN_EXISTS == 'true' }}
|
|
env:
|
|
DEPLOYMENT_URL: ${{ steps.deploy.outputs.pages-deployment-alias-url }}
|
|
run: |
|
|
echo >> comment.md
|
|
echo "**[Full report with detailed diff]($DEPLOYMENT_URL/diff)** ([timing results]($DEPLOYMENT_URL/timing))" >> comment.md
|
|
|
|
# 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@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
|
|
with:
|
|
name: comment.md
|
|
path: comment.md
|
|
|
|
- name: Upload diagnostics diff
|
|
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
|
|
with:
|
|
name: diff.html
|
|
path: dist/diff.html
|
|
|
|
- name: Upload timing diff
|
|
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
|
|
with:
|
|
name: timing.html
|
|
path: dist/timing.html
|