Repository navigation
Modernize CI: uv lock file, Dependabot, lowest-dependency testing, workflow hardening #805
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
Changes from 8 commits
f100d7e
2c77b8b
9ff84f2
fb89edd
806881a
9bd5a32
0e376a3
a97b41e
785c643
9717ea4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| version: 2 | ||
|
|
||
| updates: | ||
| # Refresh the versions pinned in uv.lock, which CI tests against. `widen` edits pyproject.toml only | ||
| # when a release falls above an upper cap: it raises the cap and leaves the lower bound untouched. | ||
| - package-ecosystem: "uv" | ||
| directory: "/" | ||
| target-branch: "develop" | ||
| schedule: | ||
| interval: "weekly" | ||
| versioning-strategy: "widen" | ||
| groups: | ||
| uv-dependencies: | ||
| # Minor and patch releases of everything, in one weekly PR. Major releases get a PR each: | ||
| # for dash, plotly and pandas they raise the upper cap, which needs manual checks first. | ||
| patterns: ["*"] | ||
| update-types: ["minor", "patch"] | ||
| cooldown: | ||
| default-days: 7 # Keep in sync with `exclude-newer` in pyproject.toml | ||
|
|
||
| # Keep the third-party GitHub Actions used by the workflows up to date. | ||
| - package-ecosystem: "github-actions" | ||
| directory: "/" | ||
| target-branch: "develop" | ||
| schedule: | ||
| interval: "weekly" | ||
| groups: | ||
| actions-dependencies: | ||
| patterns: | ||
| - "*" | ||
| cooldown: | ||
| default-days: 7 |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -10,26 +10,28 @@ concurrency: | |
| cancel-in-progress: false | ||
|
|
||
|
|
||
| permissions: | ||
| contents: read | ||
|
|
||
| jobs: | ||
| build: | ||
| name: Build | ||
| runs-on: ubuntu-latest | ||
| timeout-minutes: 15 | ||
|
|
||
| steps: | ||
| - uses: actions/checkout@v6 | ||
| - uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803 # v6.1.0 | ||
| with: | ||
| fetch-depth: 0 | ||
| - name: Set up Python | ||
| uses: actions/setup-python@v6 | ||
| persist-credentials: false | ||
| - name: Set up uv | ||
| uses: astral-sh/setup-uv@1c37ad07a6a961277cf70c0d37d6f313000f5884 # v10.3.0 | ||
| with: | ||
| python-version: "3.13" | ||
| - name: Build package | ||
| run: | | ||
| python -m pip install --upgrade build | ||
| python -m build | ||
| run: uv build | ||
| - name: Store the distribution packages | ||
| uses: actions/upload-artifact@v4 | ||
| uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2 | ||
| with: | ||
| name: python-package-distributions | ||
| path: dist/ | ||
|
|
@@ -47,12 +49,12 @@ jobs: | |
|
|
||
| steps: | ||
| - name: Download all the dists | ||
| uses: actions/download-artifact@v4 | ||
| uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0 | ||
| with: | ||
| name: python-package-distributions | ||
| path: dist/ | ||
| - name: Publish distribution to TestPyPI | ||
| uses: pypa/gh-action-pypi-publish@release/v1 | ||
| uses: pypa/gh-action-pypi-publish@dc37677b2e1c63e2034f94d8a5b11f265b73ba33 # v1.14.2 | ||
| with: | ||
| repository-url: https://test.pypi.org/legacy/ | ||
|
|
||
|
|
@@ -64,12 +66,12 @@ jobs: | |
| permissions: {} | ||
|
|
||
| steps: | ||
| - uses: actions/download-artifact@v4 | ||
| - uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0 | ||
| with: | ||
| name: python-package-distributions | ||
| path: dist/ | ||
| - name: Setup Python | ||
| uses: actions/setup-python@v6 | ||
| uses: actions/setup-python@ece7cb06caefa5fff74198d8649806c4678c61a1 # v6.3.0 | ||
| with: | ||
| python-version: "3.13" | ||
| - name: Resolve package version from tag | ||
|
|
@@ -86,8 +88,9 @@ jobs: | |
| run: | | ||
| python3 -m venv .venv-smoke | ||
| . .venv-smoke/bin/activate | ||
| # Only shapash comes from TestPyPI: anyone can upload there, so dependencies must come from PyPI. | ||
| for attempt in 1 2 3 4 5; do | ||
| if pip install --pre -i https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple/ "shapash==${RELEASE_VERSION}"; then | ||
| if pip install --no-deps -i https://test.pypi.org/simple/ "shapash==${RELEASE_VERSION}"; then | ||
| break | ||
| fi | ||
| if [ "${attempt}" -eq 5 ]; then | ||
|
|
@@ -97,4 +100,6 @@ jobs: | |
| echo "Install not available yet on TestPyPI, retrying in 30s (attempt ${attempt}/5)..." | ||
| sleep 30 | ||
| done | ||
| # Already installed, so pip keeps it and installs its dependencies from PyPI. | ||
| pip install "shapash==${RELEASE_VERSION}" | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Does this works?
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. When shapash==X is already installed (here the release candidate from test.pypi), pip's resolver takes the installed copy ("Requirement already satisfied"). It doesn't need that version to exist on PyPI. It reads the installed package's metadata and fetches only its dependencies from PyPI. |
||
| python -c "import shapash; print(shapash.__version__)" | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it best pratice to target a commit hash instead of a tag?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, it's the practice GitHub recommends in its security hardening guide for Actions: pinning to a full-length commit SHA is the only way to reference an action immutably.
A tag like v4 is a movable pointer. Whoever controls the action's repo (or an attacker who compromises it) can repoint the tag to different code, and our workflows would run it on the next trigger with no change on our side. A SHA, on the contrary can't be moved.