Repository navigation
Add GitHub Actions CI and PyPI release workflows for tpu-info - #13
Conversation
|
Note Gemini is unable to generate a review for this pull request due to the file types involved not being currently supported. |
97ebcad to
3ec337a
Compare
6064aef to
da63e87
Compare
| on: | ||
| push: | ||
| tags: | ||
| - "v*" |
There was a problem hiding this comment.
We can remove this bare v*
There was a problem hiding this comment.
Removed. Only tpu-info-v* triggers the release now.
| if: startsWith(github.ref, 'refs/tags/') | ||
| run: | | ||
| RAW_TAG="${GITHUB_REF#refs/tags/}" | ||
| # Strip either 'tpu-info-v' or 'v' prefix |
There was a problem hiding this comment.
With tags standardized on tpu-info-v*, we can strip tpu-info-v directly here:
| # Strip either 'tpu-info-v' or 'v' prefix | |
| # Strip 'tpu-info-v' prefix | |
| TAG_VERSION="${RAW_TAG#tpu-info-v}" |
There was a problem hiding this comment.
Done, applied this and removed the two old TAG_VERSION lines.
| - name: Publish distribution to TestPyPI | ||
| uses: pypa/gh-action-pypi-publish@dc37677b2e1c63e2034f94d8a5b11f265b73ba33 # v1.14.2 | ||
| with: | ||
| password: ${{ secrets.TEST_PYPI_API_TOKEN }} |
There was a problem hiding this comment.
Let's use PyPI Trusted Publishing (OIDC) instead of API tokens. Since permissions: id-token: write and environment: testpypi are already configured above, please remove the password: line so gh-action-pypi-publish uses OIDC directly (keeping skip-existing: true here is great for repeated workflow_dispatch dry runs!)
There was a problem hiding this comment.
Removed password: and kept skip-existing: true.
| with: | ||
| password: ${{ secrets.PYPI_API_TOKEN }} |
There was a problem hiding this comment.
Same here — let's remove with: password: so production PyPI publishing uses OIDC Trusted Publishing exclusively via the pypi environment
There was a problem hiding this comment.
Removed with: password:.
| # TODO: Remove the skip once the *_test.py files are exported from google3 | ||
| # (cl/999946781), so missing tests fail CI instead of passing silently. | ||
| - name: Run unit tests (absltest runner) | ||
| run: | | ||
| shopt -s nullglob | ||
| tests=(tpu_info/*_test.py) | ||
| if [ ${#tests[@]} -eq 0 ]; then | ||
| echo "::warning::No tpu_info/*_test.py files found; skipping unit tests." | ||
| exit 0 | ||
| fi | ||
| for test_file in "${tests[@]}"; do | ||
| echo "=== Running ${test_file} ===" | ||
| python "${test_file}" | ||
| done | ||
|
|
||
| - name: Run unit tests (pytest runner) | ||
| run: | | ||
| shopt -s nullglob | ||
| tests=(tpu_info/*_test.py) | ||
| if [ ${#tests[@]} -eq 0 ]; then | ||
| echo "::warning::No tpu_info/*_test.py files found; skipping unit tests." | ||
| exit 0 |
There was a problem hiding this comment.
Once the unit tests are exported to main, please rebase this PR, remove the internal cl/ comment, and change the empty-test check in both test steps from ::warning:: / exit 0 to ::error:: / exit 1 (matching release.yml line 70) so CI runs all 522 tests on this PR and can never silently skip tests in the future.
There was a problem hiding this comment.
Done: removed the internal comment and switched both checks to ::error:: / exit 1.
79408f6 to
9d1e3e8
Compare
9d1e3e8 to
124e2bc
Compare
Description
This PR adds CI and automated PyPI release workflows for
tpu-infounder.github/workflows/.1. CI (
.github/workflows/ci.yml)mainthat touchtpu_info/**orci.yml, plus manualworkflow_dispatch.grpcio-tools>=1.65.5,<1.72.0, the same cap as the[build-system]requirement intpu_info/pyproject.toml.py_compile).tpu_info/*_test.pyunit tests with bothpython <file>_test.py(absltest) andpytest. CI fails if no test files are found, so tests can't be skipped silently.python -m build) and validate the metadata (twine check).tpu-info --help,--version, andquery --list-metricsfrom outside the source tree. Locally generated proto files are removed first, so the wheel must bundle them.grpcio==1.75.0,protobuf==6.32.1), and check that the proto modules import and the CLI runs.2. Release (
.github/workflows/release.yml)tpu-info-v*tags (e.g.tpu-info-v0.14.3), plus manualworkflow_dispatchfor TestPyPI dry runs.project.versionintpu_info/pyproject.toml(e.g. tagtpu-info-v0.14.3requires version0.14.3).pypa/gh-action-pypi-publishv1.14.3, pinned to a commit SHA. No API tokens or secrets are stored in GitHub.Security
actions/checkoutusespersist-credentials: false.Setup needed before the first release
A project owner needs to add a trusted publisher on both PyPI and TestPyPI:
AI-Hypercomputercloud-accelerator-diagnosticsrelease.ymlpypi(PyPI) /testpypi(TestPyPI)Note
CI is expected to fail until the unit tests are exported to
mainvia Copybara. After that, this PR will be rebased so CI runs all 522 tests.