|
8 | 8 | # errors.
|
9 | 9 | #
|
10 | 10 | # This script will first clone a diverse set of (mostly) black formatted
|
11 |
| -# repositories with fixed revisions to target/progress_projects. Each project |
| 11 | +# repositories with fixed revisions to target/formatter-ecosystem. Each project |
12 | 12 | # gets formatted (without modifying the files on disk) to check how
|
13 | 13 | # similar our style is to black. It also catches common issues such as
|
14 | 14 | # unstable formatting, internal formatter errors and printing invalid syntax.
|
|
18 | 18 | set -e
|
19 | 19 |
|
20 | 20 | target=$(git rev-parse --show-toplevel)/target
|
21 |
| -dir="$target/progress_projects" |
| 21 | +dir="$target/formatter-ecosystem" |
22 | 22 | mkdir -p "$dir"
|
23 | 23 |
|
| 24 | +# Perfom an idempotent clone and checkout of a commit |
| 25 | +clone_commit() { |
| 26 | + local repo="$1" |
| 27 | + local target="$2" |
| 28 | + local ref="$3" |
| 29 | + |
| 30 | + if [ -z "$repo" ] || [ -z "$target" ] || [ -z "$ref" ]; then |
| 31 | + echo "Usage: clone_commit <repo> <dir> <ref>" |
| 32 | + return 1 |
| 33 | + fi |
| 34 | + |
| 35 | + if [ ! -d "$target/.git" ]; then |
| 36 | + echo "Cloning $repo to $target" |
| 37 | + # Perform a minimal clone, we only need a single commit |
| 38 | + git clone --filter=blob:none --depth=1 --no-tags --no-checkout --single-branch "$repo" "$target" |
| 39 | + fi |
| 40 | + |
| 41 | + echo "Using $repo at $ref" |
| 42 | + git -C "$target" fetch --filter=blob:none --depth=1 --no-tags origin "$ref" |
| 43 | + git -C "$target" checkout -q "$ref" |
| 44 | +} |
| 45 | + |
24 | 46 | # small util library
|
25 |
| -if [ ! -d "$dir/twine/.git" ]; then |
26 |
| - git clone --filter=tree:0 https://github.com/pypa/twine "$dir/twine" |
27 |
| -fi |
28 |
| -git -C "$dir/twine" checkout -q ae71822a3cb0478d0f6a0cccb65d6f8e6275ece5 |
| 47 | +clone_commit \ |
| 48 | + "https://github.com/pypa/twine" \ |
| 49 | + "$dir/twine" \ |
| 50 | + "ae71822a3cb0478d0f6a0cccb65d6f8e6275ece5" & |
29 | 51 |
|
30 | 52 | # web framework that implements a lot of magic
|
31 |
| -if [ ! -d "$dir/django/.git" ]; then |
32 |
| - git clone --filter=tree:0 https://github.com/django/django "$dir/django" |
33 |
| -fi |
34 |
| -git -C "$dir/django" checkout -q ee5147cfd7de2add74a285537a8968ec074e70cd |
| 53 | +clone_commit \ |
| 54 | + "https://github.com/django/django" \ |
| 55 | + "$dir/django" \ |
| 56 | + "ee5147cfd7de2add74a285537a8968ec074e70cd" & |
35 | 57 |
|
36 | 58 | # an ML project
|
37 |
| -if [ ! -d "$dir/transformers/.git" ]; then |
38 |
| - git clone --filter=tree:0 https://github.com/huggingface/transformers "$dir/transformers" |
39 |
| -fi |
40 |
| -git -C "$dir/transformers" checkout -q ac5a0556f14dec503b064d5802da1092e0b558ea |
| 59 | +clone_commit \ |
| 60 | + "https://github.com/huggingface/transformers" \ |
| 61 | + "$dir/transformers" \ |
| 62 | + "ac5a0556f14dec503b064d5802da1092e0b558ea" & |
41 | 63 |
|
42 | 64 | # type annotations
|
43 |
| -if [ ! -d "$dir/typeshed/.git" ]; then |
44 |
| - git clone --filter=tree:0 https://github.com/python/typeshed "$dir/typeshed" |
45 |
| -fi |
46 |
| -git -C "$dir/typeshed" checkout -q d34ef50754de993d01630883dbcd1d27ba507143 |
| 65 | +clone_commit \ |
| 66 | + "https://github.com/python/typeshed" \ |
| 67 | + "$dir/typeshed" \ |
| 68 | + "d34ef50754de993d01630883dbcd1d27ba507143" & |
47 | 69 |
|
48 | 70 | # python 3.11, typing and 100% test coverage
|
49 |
| -if [ ! -d "$dir/warehouse/.git" ]; then |
50 |
| - git clone --filter=tree:0 https://github.com/pypi/warehouse "$dir/warehouse" |
51 |
| -fi |
52 |
| -git -C "$dir/warehouse" checkout -q 5a4d2cadec641b5d6a6847d0127940e0f532f184 |
| 71 | +clone_commit \ |
| 72 | + "https://github.com/pypi/warehouse" \ |
| 73 | + "$dir/warehouse" \ |
| 74 | + "5a4d2cadec641b5d6a6847d0127940e0f532f184" & |
53 | 75 |
|
54 | 76 | # zulip, a django user
|
55 |
| -if [ ! -d "$dir/zulip/.git" ]; then |
56 |
| - git clone --filter=tree:0 https://github.com/zulip/zulip "$dir/zulip" |
57 |
| -fi |
58 |
| -git -C "$dir/zulip" checkout -q ccddbba7a3074283ccaac3bde35fd32b19faf042 |
| 77 | +clone_commit \ |
| 78 | + "https://github.com/zulip/zulip" \ |
| 79 | + "$dir/zulip" \ |
| 80 | + "ccddbba7a3074283ccaac3bde35fd32b19faf042" & |
59 | 81 |
|
60 | 82 | # home-assistant, home automation with 1ok files
|
61 |
| -if [ ! -d "$dir/home-assistant/.git" ]; then |
62 |
| - git clone --filter=tree:0 https://github.com/home-assistant/core "$dir/home-assistant" |
63 |
| -fi |
64 |
| -git -C "$dir/home-assistant" checkout -q 3601c531f400255d10b82529549e564fbe483a54 |
| 83 | +clone_commit \ |
| 84 | + "https://github.com/home-assistant/core" \ |
| 85 | + "$dir/home-assistant" \ |
| 86 | + "3601c531f400255d10b82529549e564fbe483a54" & |
65 | 87 |
|
66 | 88 | # poetry, a package manager that uses black preview style
|
67 |
| -if [ ! -d "$dir/poetry/.git" ]; then |
68 |
| - git clone --filter=tree:0 https://github.com/python-poetry/poetry "$dir/poetry" |
69 |
| -fi |
70 |
| -git -C "$dir/poetry" checkout -q 36fedb59b8e655252168055b536ead591068e1e4 |
| 89 | +clone_commit \ |
| 90 | + "https://github.com/python-poetry/poetry" \ |
| 91 | + "$dir/poetry" \ |
| 92 | + "36fedb59b8e655252168055b536ead591068e1e4" & |
71 | 93 |
|
72 | 94 | # cpython itself
|
73 |
| -if [ ! -d "$dir/cpython/.git" ]; then |
74 |
| - git clone --filter=tree:0 https://github.com/python/cpython "$dir/cpython" |
75 |
| -fi |
76 |
| -git -C "$dir/cpython" checkout -q 28aea5d07d163105b42acd81c1651397ef95ea57 |
| 95 | +clone_commit \ |
| 96 | + "https://github.com/python/cpython" \ |
| 97 | + "$dir/cpython" \ |
| 98 | + "28aea5d07d163105b42acd81c1651397ef95ea57" & |
| 99 | + |
| 100 | +# wait for the concurrent clones to complete |
| 101 | +wait |
77 | 102 |
|
78 | 103 | # Uncomment if you want to update the hashes
|
79 | 104 | #for i in "$dir"/*/; do git -C "$i" switch main && git -C "$i" pull; done
|
80 | 105 | #for i in "$dir"/*/; do echo "# $(basename "$i") $(git -C "$i" rev-parse HEAD)"; done
|
81 | 106 |
|
82 | 107 | time cargo run --bin ruff_dev -- format-dev --stability-check \
|
83 |
| - --error-file "$target/progress_projects_errors.txt" --log-file "$target/progress_projects_log.txt" --stats-file "$target/progress_projects_stats.txt" \ |
84 |
| - --files-with-errors 3 --multi-project "$dir" || ( |
| 108 | + --error-file "$target/formatter-ecosystem/errors.txt" \ |
| 109 | + --log-file "$target/formatter-ecosystem/log.txt" \ |
| 110 | + --stats-file "$target/formatter-ecosystem/stats.txt" \ |
| 111 | + --files-with-errors 3 --multi-project "$dir" \ |
| 112 | +|| ( |
85 | 113 | echo "Ecosystem check failed"
|
86 |
| - cat "$target/progress_projects_log.txt" |
| 114 | + cat "$target/formatter-ecosystem/log.txt" |
87 | 115 | exit 1
|
88 | 116 | )
|
89 |
| -cat "$target/progress_projects_stats.txt" |
| 117 | + |
| 118 | +cat "$target/formatter-ecosystem/stats.txt" |
0 commit comments