Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .github/workflows/unit-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@ jobs:
- name: Check Python version
run: python --version

- name: Run Ruff
uses: astral-sh/ruff-action@278981a28ce3188b1e39527901f38254bf3aac89 # v4.1.0
with:
version: '0.16.3'

- name: Run unit tests
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Expand Down
9 changes: 9 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,15 @@ requests. Feel free to reach out on the [Bytecode Alliance
Zulip](https://bytecodealliance.zulipchat.com/) as well if you'd like assistance
in contributing or would just like to say hi.

## Development

Run the Python checks before submitting a pull request:

```sh
ruff check .
python3 install.py --test-only
```

## Code of Conduct

This is a [Bytecode Alliance](https://bytecodealliance.org/) project, and follows the Bytecode Alliance's [Code of Conduct](https://github.com/bytecodealliance/governance/blob/main/CODE_OF_CONDUCT.md).
Expand Down
14 changes: 7 additions & 7 deletions install.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,14 +105,14 @@ def install(url: str, install_dir: str):
Download the file from the given URL and extract it to a directory.
"""
logging.info(f'Downloading {url}')
file = tempfile.NamedTemporaryFile(delete=False)
file.close() # Close the handle so Windows can access the file
archive_file = tempfile.NamedTemporaryFile(delete=False)
archive_file.close() # Close the handle so Windows can access the file
try:
request.urlretrieve(url, file.name)
logging.info(f'Successfully downloaded {file.name}')
request.urlretrieve(url, archive_file.name)
logging.info(f'Successfully downloaded {archive_file.name}')

os.makedirs(install_dir, exist_ok=True)
with tarfile.open(file.name, 'r:gz') as tar:
with tarfile.open(archive_file.name, 'r:gz') as tar:
for member in tar.getmembers():
# Strip off the first path component (i.e., `--strip-components=1`).
parts = member.name.split('/')
Expand All @@ -123,8 +123,8 @@ def install(url: str, install_dir: str):
tar.extract(member, path=install_dir)
logging.info(f'Extracted to {install_dir}')
finally:
os.unlink(file.name)
logging.debug(f'Cleaned up temporary file {file.name}')
os.unlink(archive_file.name)
logging.debug(f'Cleaned up temporary file {archive_file.name}')

sep = os.path.sep
ext = '.exe' if sep == '\\' else ''
Expand Down
6 changes: 6 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[tool.ruff]
target-version = "py310"
line-length = 100

[tool.ruff.lint]
select = ["A", "E4", "E7", "E9", "F", "I"]
Loading