diff options
| author | Guillaume Gomez <guillaume1.gomez@gmail.com> | 2024-12-05 23:47:11 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-12-05 23:47:11 +0100 |
| commit | 5a9c9ef54115a27a3eac4e39feb133e33870b145 (patch) | |
| tree | 5856ef55af3f29e8f02fd6da38f4dadcf7736123 /src/ci/docker/scripts | |
| parent | e941e73368866d3ecc98f040d9f1376de7efcdf1 (diff) | |
| parent | 536516f949ff37b0e10eaed835c2d3592d03e576 (diff) | |
| download | rust-5a9c9ef54115a27a3eac4e39feb133e33870b145.tar.gz rust-5a9c9ef54115a27a3eac4e39feb133e33870b145.zip | |
Rollup merge of #133821 - Kobzol:replace-black-with-ruff, r=onur-ozkan
Replace black with ruff in `tidy` `ruff` can both lint and format Python code (in fact, it should be a mostly drop-in replacement for `black` in terms of formatting), so it's not needed to use `black` anymore. This PR removes `black` and replaces it with `ruff`, to get rid of one Python dependency, and also to make Python formatting faster (although that's a small thing). If we decide to merge this, we'll need to "reformat the world" - `ruff` is not perfectly compatible with `black`, and it also looks like `black` was actually ignoring some files before. I tried it locally (`./x test tidy --extra-checks=py:fmt --bless`) and it also reformatted some code in subtrees (e.g. `clippy` or `rustc_codegen_gcc`) - I'm not sure how to handle that.
Diffstat (limited to 'src/ci/docker/scripts')
| -rwxr-xr-x | src/ci/docker/scripts/android-sdk-manager.py | 60 | ||||
| -rwxr-xr-x | src/ci/docker/scripts/fuchsia-test-runner.py | 8 |
2 files changed, 50 insertions, 18 deletions
diff --git a/src/ci/docker/scripts/android-sdk-manager.py b/src/ci/docker/scripts/android-sdk-manager.py index 66cba58427b..6356f15a886 100755 --- a/src/ci/docker/scripts/android-sdk-manager.py +++ b/src/ci/docker/scripts/android-sdk-manager.py @@ -35,6 +35,7 @@ MIRROR_BUCKET = "rust-lang-ci-mirrors" MIRROR_BUCKET_REGION = "us-west-1" MIRROR_BASE_DIR = "rustc/android/" + class Package: def __init__(self, path, url, sha1, deps=None): if deps is None: @@ -53,18 +54,25 @@ class Package: sha1 = hashlib.sha1(f.read()).hexdigest() if sha1 != self.sha1: raise RuntimeError( - "hash mismatch for package " + self.path + ": " + - sha1 + " vs " + self.sha1 + " (known good)" + "hash mismatch for package " + + self.path + + ": " + + sha1 + + " vs " + + self.sha1 + + " (known good)" ) return file def __repr__(self): - return "<Package "+self.path+" at "+self.url+" (sha1="+self.sha1+")" + return "<Package " + self.path + " at " + self.url + " (sha1=" + self.sha1 + ")" + def fetch_url(url): page = urllib.request.urlopen(url) return page.read() + def fetch_repository(base, repo_url): packages = {} root = ET.fromstring(fetch_url(base + repo_url)) @@ -92,12 +100,14 @@ def fetch_repository(base, repo_url): return packages + def fetch_repositories(): packages = {} for repo in REPOSITORIES: packages.update(fetch_repository(BASE_REPOSITORY, repo)) return packages + class Lockfile: def __init__(self, path): self.path = path @@ -123,6 +133,7 @@ class Lockfile: for package in packages: f.write(package.path + " " + package.url + " " + package.sha1 + "\n") + def cli_add_to_lockfile(args): lockfile = Lockfile(args.lockfile) packages = fetch_repositories() @@ -130,28 +141,49 @@ def cli_add_to_lockfile(args): lockfile.add(packages, package) lockfile.save() + def cli_update_mirror(args): lockfile = Lockfile(args.lockfile) for package in lockfile.packages.values(): path = package.download(BASE_REPOSITORY) - subprocess.run([ - "aws", "s3", "mv", path, - "s3://" + MIRROR_BUCKET + "/" + MIRROR_BASE_DIR + package.url, - "--profile=" + args.awscli_profile, - ], check=True) + subprocess.run( + [ + "aws", + "s3", + "mv", + path, + "s3://" + MIRROR_BUCKET + "/" + MIRROR_BASE_DIR + package.url, + "--profile=" + args.awscli_profile, + ], + check=True, + ) + def cli_install(args): lockfile = Lockfile(args.lockfile) for package in lockfile.packages.values(): # Download the file from the mirror into a temp file - url = "https://" + MIRROR_BUCKET + ".s3-" + MIRROR_BUCKET_REGION + \ - ".amazonaws.com/" + MIRROR_BASE_DIR + url = ( + "https://" + + MIRROR_BUCKET + + ".s3-" + + MIRROR_BUCKET_REGION + + ".amazonaws.com/" + + MIRROR_BASE_DIR + ) downloaded = package.download(url) # Extract the file in a temporary directory extract_dir = tempfile.mkdtemp() - subprocess.run([ - "unzip", "-q", downloaded, "-d", extract_dir, - ], check=True) + subprocess.run( + [ + "unzip", + "-q", + downloaded, + "-d", + extract_dir, + ], + check=True, + ) # Figure out the prefix used in the zip subdirs = [d for d in os.listdir(extract_dir) if not d.startswith(".")] if len(subdirs) != 1: @@ -162,6 +194,7 @@ def cli_install(args): os.rename(os.path.join(extract_dir, subdirs[0]), dest) os.unlink(downloaded) + def cli(): parser = argparse.ArgumentParser() subparsers = parser.add_subparsers() @@ -187,5 +220,6 @@ def cli(): exit(1) args.func(args) + if __name__ == "__main__": cli() diff --git a/src/ci/docker/scripts/fuchsia-test-runner.py b/src/ci/docker/scripts/fuchsia-test-runner.py index 77e2741f9ea..4a30de5a263 100755 --- a/src/ci/docker/scripts/fuchsia-test-runner.py +++ b/src/ci/docker/scripts/fuchsia-test-runner.py @@ -588,7 +588,7 @@ class TestEnvironment: "--repo-path", self.repo_dir(), "--repository", - self.TEST_REPO_NAME + self.TEST_REPO_NAME, ], env=ffx_env, stdout_handler=self.subprocess_logger.debug, @@ -619,9 +619,7 @@ class TestEnvironment: # `facet` statement required for TCP testing via # protocol `fuchsia.posix.socket.Provider`. See # https://fuchsia.dev/fuchsia-src/development/testing/components/test_runner_framework?hl=en#legacy_non-hermetic_tests - CML_TEMPLATE: ClassVar[ - str - ] = """ + CML_TEMPLATE: ClassVar[str] = """ {{ program: {{ runner: "elf_test_runner", @@ -994,7 +992,7 @@ class TestEnvironment: "repository", "server", "stop", - self.TEST_REPO_NAME + self.TEST_REPO_NAME, ], env=self.ffx_cmd_env(), stdout_handler=self.subprocess_logger.debug, |
