-
Notifications
You must be signed in to change notification settings - Fork 24
GitHub Actions build refactor #162
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
Closed
Closed
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
d68a705
GitHub Actions build refactor
mtsokol 9b9979a
Fix `--find-links` option
mtsokol 8bd05e5
Python versions support in the Bazel config
mtsokol fce714d
Config update
mtsokol 772dd32
Enforce direct dependencies
mtsokol 49893bc
Skip TF import test on Darwin
mtsokol 01e57f7
Fix `python-tests.yml` workflow
mtsokol File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,88 @@ | ||
| # This workflow builds ArrayRecord wheels and uploads them as artifacts. | ||
|
|
||
| name: Build & Publish Template | ||
|
|
||
| on: | ||
| workflow_call: | ||
| inputs: | ||
| pypi_project_url: | ||
| required: false | ||
| type: string | ||
| upload_wheels: | ||
| required: true | ||
| type: boolean | ||
|
|
||
| defaults: | ||
| run: | ||
| shell: bash | ||
|
|
||
| permissions: | ||
| contents: read | ||
|
|
||
| jobs: | ||
| build-and-test: | ||
| name: "Python ${{ matrix.python-version }} on ${{ matrix.os }}" | ||
| runs-on: "${{ matrix.os }}" | ||
|
|
||
| strategy: | ||
| fail-fast: false | ||
| matrix: | ||
| python-version: ["3.10", "3.11", "3.12", "3.13"] | ||
| os: [ubuntu-22.04, ubuntu-22.04-arm, macos-14] | ||
|
|
||
| env: | ||
| USE_BAZEL_VERSION: "7.2.1" | ||
| steps: | ||
| - name: Set up Bazel | ||
| uses: bazel-contrib/setup-bazel@0.15.0 | ||
| - name: Check Bazel installation | ||
| run: | | ||
| which bazel | ||
| bazel version | ||
| - name: Set up Python | ||
| uses: actions/setup-python@v5 | ||
| with: | ||
| python-version: ${{ matrix.python-version }} | ||
| - uses: "actions/checkout@v3" | ||
| - name: Create directory | ||
| run: | | ||
| mkdir -p /tmp/array_record | ||
| cp -r . /tmp/array_record | ||
| - name: Build package | ||
| run: | | ||
| set -xe | ||
| export PYTHON_VERSION=${{ matrix.python-version }} | ||
| export PYTHON_MAJOR_VERSION=$(echo $PYTHON_VERSION | cut -d. -f1) | ||
| export PYTHON_MINOR_VERSION=$(echo $PYTHON_VERSION | cut -d. -f2) | ||
| export BAZEL_VERSION="7.2.1" | ||
| export OUTPUT_DIR="/tmp/array_record" | ||
| export SOURCE_DIR="/tmp/array_record" | ||
| . "${SOURCE_DIR}"'/oss/runner_common.sh' | ||
| build_and_test_array_record | ||
| - name: Upload ArrayRecord artifacts | ||
| uses: actions/upload-artifact@v4 | ||
| with: | ||
| name: built-array-record-wheels-${{ matrix.os }}-${{ matrix.python-version }} | ||
| path: /tmp/array_record/all_dist/*.whl | ||
|
|
||
| publish-wheel: | ||
| if: ${{ inputs.upload_wheels }} | ||
| runs-on: ubuntu-22.04 | ||
| needs: build-and-test | ||
| permissions: | ||
| id-token: write | ||
| environment: | ||
| name: pypi | ||
| url: ${{ inputs.pypi_project_url }} | ||
| steps: | ||
| - name: Download ArrayRecord artifacts | ||
| uses: actions/download-artifact@v4 | ||
| with: | ||
| pattern: built-array-record-wheels-* | ||
| path: dist/ | ||
| merge-multiple: true | ||
| - name: Publish package distributions to PyPI | ||
| uses: pypa/gh-action-pypi-publish@release/v1 | ||
| with: | ||
| attestations: false | ||
| verbose: true |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| name: Build and Publish Release | ||
|
|
||
| on: workflow_dispatch | ||
|
|
||
| jobs: | ||
| call-workflow: | ||
| uses: ./.github/workflows/build_and_publish_template.yml | ||
| permissions: | ||
| contents: read | ||
| id-token: write | ||
| with: | ||
| pypi_project_url: https://pypi.org/project/array-record | ||
| upload_wheels: true |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| # Byte-compiled / optimized / DLL files | ||
| __pycache__/ | ||
| *.py[cod] | ||
| *$py.class | ||
|
|
||
| # Bazel outputs | ||
| bazel-array_record | ||
| bazel-bin | ||
| bazel-out | ||
| bazel-testlogs | ||
|
|
||
| MODULE.bazel.lock |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,15 +1,26 @@ | ||
| # Steps to build a new array_record pip package | ||
| # Steps to build and publish a new `array_record` PyPI package | ||
|
|
||
| 1. Update the version number in setup.py | ||
| `array_record` supports automatic publishing to PyPI via GitHub Actions. | ||
| Once you're ready to create a new release you need to: | ||
|
|
||
| 2. In the root folder, run | ||
| 1. Update the version number in `setup.py`. | ||
|
|
||
| ``` | ||
| ./oss/build_whl.sh | ||
| ``` | ||
| to use the current `python3` version. Otherwise, optionally set | ||
| ``` | ||
| PYTHON_VERSION=3.9 ./oss/build_whl.sh | ||
| ``` | ||
| 2. Go to [GitHub Actions page](https://github.com/google/array_record/actions), | ||
| select `Build and Publish Release` workflow, and run it. It will spin up a few | ||
| test jobs, and once all of them complete successfully, a `publish-wheel` will start. | ||
|
|
||
| 3. Wheels are in `all_dist/`. | ||
| 3. On completion you should notice a new release on https://pypi.org/project/array-record/#history. | ||
|
|
||
| --- | ||
|
|
||
| If you want to build a wheel locally in your development environment in the root folder, run: | ||
|
|
||
| ```sh | ||
| ./oss/build_whl.sh | ||
| ``` | ||
| to use the current `python3` version. Otherwise, optionally set: | ||
| ```sh | ||
| PYTHON_VERSION=3.9 ./oss/build_whl.sh | ||
| ``` | ||
|
|
||
| Wheels are in `all_dist/`. |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
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.
Let's use actual
bazel_dep(name = "protobuf", version = ...)here and enforce errors if different is picked: