|
34 | 34 | # and which all three workers push to. |
35 | 35 | UPSTREAM_BRANCH: typeshedbot/sync-typeshed |
36 | 36 |
|
| 37 | + # The path to the directory that contains the vendored typeshed stubs, |
| 38 | + # relative to the root of the Ruff repository. |
| 39 | + VENDORED_TYPESHED: crates/ty_vendored/vendor/typeshed |
| 40 | + |
37 | 41 | jobs: |
38 | 42 | # Sync typeshed stubs, and sync all docstrings available on Linux. |
39 | 43 | # Push the changes to a new branch on the upstream repository. |
@@ -64,20 +68,20 @@ jobs: |
64 | 68 | - uses: astral-sh/setup-uv@bd01e18f51369d5a26f1651c3cb451d3417e3bba # v6.3.1 |
65 | 69 | - name: Sync typeshed stubs |
66 | 70 | run: | |
67 | | - rm -rf ruff/crates/ty_vendored/vendor/typeshed |
68 | | - mkdir ruff/crates/ty_vendored/vendor/typeshed |
69 | | - cp typeshed/README.md ruff/crates/ty_vendored/vendor/typeshed |
70 | | - cp typeshed/LICENSE ruff/crates/ty_vendored/vendor/typeshed |
| 71 | + rm -rf "ruff/${VENDORED_TYPESHED}" |
| 72 | + mkdir "ruff/${VENDORED_TYPESHED}" |
| 73 | + cp typeshed/README.md "ruff/${VENDORED_TYPESHED}" |
| 74 | + cp typeshed/LICENSE "ruff/${VENDORED_TYPESHED}" |
71 | 75 |
|
72 | 76 | # The pyproject.toml file is needed by a later job for the black configuration. |
73 | 77 | # It's deleted before creating the PR. |
74 | | - cp typeshed/pyproject.toml ruff/crates/ty_vendored/vendor/typeshed |
| 78 | + cp typeshed/pyproject.toml "ruff/${VENDORED_TYPESHED}" |
75 | 79 |
|
76 | | - cp -r typeshed/stdlib ruff/crates/ty_vendored/vendor/typeshed/stdlib |
77 | | - rm -rf ruff/crates/ty_vendored/vendor/typeshed/stdlib/@tests |
78 | | - git -C typeshed rev-parse HEAD > ruff/crates/ty_vendored/vendor/typeshed/source_commit.txt |
| 80 | + cp -r typeshed/stdlib "ruff/${VENDORED_TYPESHED}/stdlib" |
| 81 | + rm -rf "ruff/${VENDORED_TYPESHED}/stdlib/@tests" |
| 82 | + git -C typeshed rev-parse HEAD > "ruff/${VENDORED_TYPESHED}/source_commit.txt" |
79 | 83 | cd ruff |
80 | | - git checkout -b typeshedbot/sync-typeshed |
| 84 | + git checkout -b "${UPSTREAM_BRANCH}" |
81 | 85 | git add . |
82 | 86 | git commit -m "Sync typeshed. Source commit: https://github.com/python/typeshed/commit/$(git -C ../typeshed rev-parse HEAD)" --allow-empty |
83 | 87 | - name: Sync Linux docstrings |
@@ -167,17 +171,17 @@ jobs: |
167 | 171 | # consistent with the other typeshed stubs around them. |
168 | 172 | # Typeshed formats code using black in their CI, so we just invoke |
169 | 173 | # black on the stubs the same way that typeshed does. |
170 | | - uvx black crates/ty_vendored/vendor/typeshed/stdlib --config crates/ty_vendored/vendor/typeshed/pyproject.toml || true |
| 174 | + uvx black "${VENDORED_TYPESHED}/stdlib" --config "${VENDORED_TYPESHED}/pyproject.toml" || true |
171 | 175 | git commit -am "Format codemodded docstrings" --allow-empty |
172 | 176 |
|
173 | | - rm crates/ty_vendored/vendor/typeshed/pyproject.toml |
| 177 | + rm "${VENDORED_TYPESHED}/pyproject.toml" |
174 | 178 | git commit -am "Remove pyproject.toml file" |
175 | 179 |
|
176 | 180 | git push |
177 | 181 | - name: Create a PR |
178 | 182 | if: ${{ success() }} |
179 | 183 | run: | |
180 | | - gh pr list --repo "$GITHUB_REPOSITORY" --head typeshedbot/sync-typeshed --json id --jq length | grep 1 && exit 0 # exit if there is existing pr |
| 184 | + gh pr list --repo "${GITHUB_REPOSITORY}" --head "${UPSTREAM_BRANCH}" --json id --jq length | grep 1 && exit 0 # exit if there is existing pr |
181 | 185 | gh pr create --title "[ty] Sync vendored typeshed stubs" --body "Close and reopen this PR to trigger CI" --label "ty" |
182 | 186 |
|
183 | 187 | create-issue-on-failure: |
|
0 commit comments