-
Notifications
You must be signed in to change notification settings - Fork 29
Use UV #209
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Use UV #209
Changes from all commits
a17d0a4
6280f29
0b94146
436f33f
ff2418e
5c72539
7f7d362
a50add1
9e8d3eb
a573221
227b6c7
7fd9402
7425a8a
f2b5ffc
a22b2bf
98a166e
9ab942c
a0e7ce0
0f0b307
08df64d
0d62c35
f9512b6
2e636d4
24721ad
369ccd4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
| Original file line number | Diff line number | Diff line change | |||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -1,47 +1,60 @@ | |||||||||||||||||||||||
| name: release | |||||||||||||||||||||||
|
|
|||||||||||||||||||||||
| on: | |||||||||||||||||||||||
| on: | |||||||||||||||||||||||
| push: | |||||||||||||||||||||||
| tags: | |||||||||||||||||||||||
| - '*' | |||||||||||||||||||||||
| - "*" | |||||||||||||||||||||||
|
|
|||||||||||||||||||||||
| jobs: | |||||||||||||||||||||||
| release-test: | |||||||||||||||||||||||
| runs-on: ubuntu-22.04 | |||||||||||||||||||||||
| steps: | |||||||||||||||||||||||
| - uses: actions/checkout@v4 | |||||||||||||||||||||||
|
|
|||||||||||||||||||||||
| - uses: ./.github/actions/build-package | |||||||||||||||||||||||
|
|
|||||||||||||||||||||||
| - name: Set up a fresh environment and run tests | |||||||||||||||||||||||
| run: | | |||||||||||||||||||||||
| python -m venv venv | |||||||||||||||||||||||
| source venv/bin/activate | |||||||||||||||||||||||
| pip install dist/*.tar.gz | |||||||||||||||||||||||
| pip install dist/*.whl | |||||||||||||||||||||||
| pip install -e .[test] | |||||||||||||||||||||||
| pytest | |||||||||||||||||||||||
| release: | |||||||||||||||||||||||
| runs-on: ubuntu-22.04 | |||||||||||||||||||||||
| needs: release-test | |||||||||||||||||||||||
|
|
|||||||||||||||||||||||
| steps: | |||||||||||||||||||||||
| - uses: actions/checkout@v4 | |||||||||||||||||||||||
|
|
|||||||||||||||||||||||
| - name: Set up Python 3.8 | |||||||||||||||||||||||
| uses: actions/setup-python@v5 | |||||||||||||||||||||||
| with: | |||||||||||||||||||||||
| python-version: 3.8 | |||||||||||||||||||||||
|
|
|||||||||||||||||||||||
| - name: Compare tags | |||||||||||||||||||||||
| run: | | |||||||||||||||||||||||
| PKG_VERSION=`grep '__version__' mapbox_tilesets/__init__.py | sed -E "s/^.*['\"](.*)['\"].*$/\1/"` | |||||||||||||||||||||||
| echo "Checking that package version [v$PKG_VERSION] matches release tag [${{ github.ref_name }}]" | |||||||||||||||||||||||
| [ "${{ github.ref_type }}" = "tag" ] && [ "${{ github.ref_name }}" = "v$PKG_VERSION" ] | |||||||||||||||||||||||
| - uses: ./.github/actions/build-package | |||||||||||||||||||||||
|
|
|||||||||||||||||||||||
| - name: Run deployment | |||||||||||||||||||||||
| run: | |||||||||||||||||||||||
| twine upload dist/* -r pypi -u __token__ -p ${{ secrets.PYPI_PASSWORD }} | |||||||||||||||||||||||
| release-test: | |||||||||||||||||||||||
| runs-on: ubuntu-22.04 | |||||||||||||||||||||||
| steps: | |||||||||||||||||||||||
| - uses: actions/checkout@v4 | |||||||||||||||||||||||
|
|
|||||||||||||||||||||||
| - name: Set up uv | |||||||||||||||||||||||
| uses: astral-sh/setup-uv@v4 | |||||||||||||||||||||||
| with: | |||||||||||||||||||||||
| python-version: "3.10" | |||||||||||||||||||||||
|
|
|||||||||||||||||||||||
| - name: Build package | |||||||||||||||||||||||
| run: uv build | |||||||||||||||||||||||
|
|
|||||||||||||||||||||||
| - name: Set up a fresh environment and run tests | |||||||||||||||||||||||
| run: | | |||||||||||||||||||||||
| uv venv | |||||||||||||||||||||||
| uv pip install dist/*.tar.gz | |||||||||||||||||||||||
| uv pip install dist/*.whl | |||||||||||||||||||||||
| uv pip install pytest | |||||||||||||||||||||||
| uv run pytest | |||||||||||||||||||||||
| release: | |||||||||||||||||||||||
| runs-on: ubuntu-22.04 | |||||||||||||||||||||||
| needs: release-test | |||||||||||||||||||||||
|
|
|||||||||||||||||||||||
| steps: | |||||||||||||||||||||||
| - uses: actions/checkout@v4 | |||||||||||||||||||||||
|
|
|||||||||||||||||||||||
| - name: Set up uv | |||||||||||||||||||||||
| uses: astral-sh/setup-uv@v4 | |||||||||||||||||||||||
| with: | |||||||||||||||||||||||
| python-version: "3.10" | |||||||||||||||||||||||
|
|
|||||||||||||||||||||||
| - name: Compare tags | |||||||||||||||||||||||
| run: | | |||||||||||||||||||||||
| PKG_VERSION=`grep '__version__' mapbox_tilesets/__init__.py | sed -E "s/^.*['\"](.*)['\"].*$/\1/"` | |||||||||||||||||||||||
| echo "Checking that package version [v$PKG_VERSION] matches release tag [${{ github.ref_name }}]" | |||||||||||||||||||||||
| [ "${{ github.ref_type }}" = "tag" ] && [ "${{ github.ref_name }}" = "v$PKG_VERSION" ] | |||||||||||||||||||||||
| - name: Build package | |||||||||||||||||||||||
| run: uv build | |||||||||||||||||||||||
|
|
|||||||||||||||||||||||
| - name: Install Twine | |||||||||||||||||||||||
| run: | | |||||||||||||||||||||||
| uv venv | |||||||||||||||||||||||
| uv pip install twine | |||||||||||||||||||||||
| - name: Validate deployment | |||||||||||||||||||||||
| run: uv run twine check dist/* | |||||||||||||||||||||||
|
|
|||||||||||||||||||||||
| - name: Run deployment | |||||||||||||||||||||||
| run: uv run twine upload dist/* -r pypi -u __token__ -p ${{ secrets.PYPI_PASSWORD }} | |||||||||||||||||||||||
|
Comment on lines
+31
to
+60
Check warningCode scanning / CodeQL Workflow does not contain permissions Medium
Actions job or workflow does not limit the permissions of the GITHUB_TOKEN. Consider setting an explicit permissions block, using the following as a minimal starting point: {contents: read}
Copilot AutofixAI 5 days ago In general, the fix is to explicitly declare The best, least-intrusive fix is to add a workflow-level permissions:
contents: readNo other steps, secrets, or environment variables rely on elevated
Suggested changeset
1
.github/workflows/release.yaml
Copilot is powered by AI and may make mistakes. Always verify output.
Refresh and try again.
|
|||||||||||||||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,20 +1,6 @@ | ||
| repos: | ||
| - | ||
| repo: 'https://github.com/ambv/black' | ||
| # 18.6b1 | ||
| rev: 22.3.0 | ||
| - repo: https://github.com/astral-sh/ruff-pre-commit | ||
| rev: v0.14.10 | ||
| hooks: | ||
| - id: black | ||
| args: ['--safe'] | ||
| - | ||
| repo: 'https://github.com/PyCQA/flake8' | ||
| rev: 5.0.4 | ||
| hooks: | ||
| - id: flake8 | ||
| args: [ | ||
| # E501 let black handle all line length decisions | ||
| # W503 black conflicts with "line break before operator" rule | ||
| # E203 black conflicts with "whitespace before ':'" rule | ||
| # E231 black conflicts with "whitespace after ':'" rule | ||
| # E722 bare excepts need to be addressed | ||
| '--ignore=E501,W503,E203,E722,E231'] | ||
| - id: ruff | ||
| - id: ruff-format |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3,60 +3,40 @@ | |
| Hi there! Welcome to the tilesets-cli contributing document. Issues, comments, and pull requests are welcome. Please tag @mapbox/maps-api for any questions or reviews. | ||
|
|
||
| ## Installation | ||
| First, clone the repo and `cd` into the folder: | ||
| ```shell | ||
|
|
||
| Install uv (https://docs.astral.sh/uv/) and then clone the repo and `cd` into the folder: | ||
|
|
||
| ```bash | ||
| # clone | ||
| git clone [email protected]:mapbox/tilesets-cli.git | ||
| cd tilesets-cli | ||
|
|
||
| # virtual env (optional) | ||
| mkvirtualenv tilesets-cli | ||
| # install deps (creates .venv) | ||
| uv sync --group dev | ||
|
|
||
| # install deps | ||
| pip install -e '.[test]' | ||
| # include optional estimate-area dependencies | ||
| uv sync --group dev --extra estimate-area | ||
|
|
||
| # confirm installation was successful | ||
| tilesets --help | ||
| tilesets --version | ||
| uv run tilesets --help | ||
| uv run tilesets --version | ||
| ``` | ||
|
|
||
| ## Pre-commit hooks | ||
| We use [pre-commit hooks](https://pre-commit.com/) to auto-format and validate code before committing. `pre-commit` is included with the `[test]` extras, but you must run: | ||
| ``` | ||
| $ pre-commit install | ||
| ``` | ||
| within the repo to have the actions specified in `.pre-commit-config.yaml` registered. | ||
|
|
||
| After this, when committing, you'll see: | ||
| ``` | ||
| git commit -m 'update version' | ||
| black....................................................................Passed | ||
| Flake8...................................................................Passed | ||
| ``` | ||
| If your pre-commit hooks ran successfully. Note that `black` modifies your code, which means that if there is a syntax error you'll first see something like: | ||
| ``` | ||
| git commit -m '{message}' | ||
| black....................................................................Failed | ||
| hookid: black | ||
|
|
||
| Files were modified by this hook. Additional output: | ||
|
|
||
| reformatted this/file/was/reformatted.py | ||
| All done! ✨ 🍰 ✨ | ||
| 1 file reformatted. | ||
| We use [pre-commit hooks](https://pre-commit.com/) to auto-format and validate code before committing. `pre-commit` is included with the `dev` dependency group, but you must run: | ||
|
|
||
| Flake8...................................................................Failed | ||
| hookid: flake8 | ||
|
|
||
| this/file/was/reformatted.py:{line}:{character}: {what was incorrect} | ||
| ```bash | ||
| $ uv run pre-commit install | ||
| ``` | ||
| After which you can add these changes and commit again. Note that failing pre-commit commands mean that the commit has not taken place: you must commit again! | ||
| within the repo to have the actions specified in `.pre-commit-config.yaml` registered. | ||
|
|
||
|
|
||
| ## Release process | ||
|
|
||
| Releases to PyPi are handled via Github Actions and GitHub tags. Once changes have been merged to master: | ||
|
|
||
| 1. Update the version in mapbox_tilesets/__init__.py | ||
| 1. Update the version in `pyproject.toml` | ||
| 2. Update the changelog | ||
| 3. Commit changes to **your branch**. For example `git commit -am '0.2.0' && git push origin HEAD` | ||
| 4. Get a review and merge your changes to master. | ||
|
|
@@ -67,14 +47,14 @@ Releases to PyPi are handled via Github Actions and GitHub tags. Once changes ha | |
|
|
||
| ## Tests | ||
|
|
||
| All tests are runnable with pytest. pytest is not installed by default and can be installed with the pip test extras | ||
| All tests are runnable with pytest. pytest is installed via the `dev` dependency group: | ||
|
|
||
| ```shell | ||
| pip install -e '.[test]' | ||
| uv sync --group dev | ||
| ``` | ||
|
|
||
| Running tests | ||
|
|
||
| ``` | ||
| pytest | ||
| uv run pytest | ||
| ``` | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,9 @@ | ||
| """mapbox_tilesets package""" | ||
|
|
||
| __version__ = "1.14.0" | ||
| from importlib.metadata import PackageNotFoundError, version as _pkg_version | ||
|
|
||
| try: | ||
| __version__ = _pkg_version("mapbox-tilesets") | ||
| except PackageNotFoundError: | ||
| # Fallback for development mode | ||
| __version__ = "0.0.0.dev" |
Check warning
Code scanning / CodeQL
Workflow does not contain permissions Medium
Copilot Autofix
AI 5 days ago
In general, to fix this issue you must explicitly declare a
permissionsblock either at the workflow root (applies to all jobs) or per job, and grant only the minimal privileges required. When a workflow only checks out code and runs builds/tests and external deployments, the minimal permissions forGITHUB_TOKENare typicallycontents: read.For this specific workflow in
.github/workflows/release.yaml, none of the steps perform repository writes or use GitHub APIs that require more than read access. The safest and simplest fix is to add a top‑levelpermissions:block after thename:(or beforejobs:) specifyingcontents: read. This will apply to bothrelease-testandreleasejobs, since neither defines its ownpermissions. No other behavior will change:actions/checkout@v4works withcontents: read, and the PyPI upload uses a separate secret, unaffected byGITHUB_TOKENpermissions.Concretely:
Edit
.github/workflows/release.yaml.Insert:
between the
name: releaseline and theon:block.No imports, methods, or additional definitions are needed; this is purely a YAML configuration change.