-
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
Changes from 4 commits
d68a705
9b9979a
8bd05e5
fce714d
772dd32
49893bc
01e57f7
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 |
|---|---|---|
| @@ -0,0 +1,87 @@ | ||
| # This workflow builds ArrayRecord wheels and uploads them as artifacts. | ||
|
|
||
| name: Build & Publish Template | ||
|
|
||
| on: | ||
| workflow_call: | ||
| inputs: | ||
| pypi_project_url: | ||
| required: true | ||
| type: string | ||
| is_nightly: | ||
| 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: | ||
| 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 |
| 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 | ||
| is_nightly: false |
| 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 |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -12,12 +12,9 @@ | |
| # See the License for the specific language governing permissions and | ||
| # limitations under the License. | ||
|
|
||
| # TODO(fchern): automate version string alignment with setup.py | ||
| VERSION = "0.6.0" | ||
|
|
||
| module( | ||
| name = "array_record", | ||
| version = VERSION, | ||
| version = "0.7.3", | ||
| repo_name = "com_google_array_record", | ||
| ) | ||
|
|
||
|
|
@@ -32,21 +29,52 @@ bazel_dep(name = "eigen", version = "3.4.0.bcr.3") | |
| bazel_dep(name = "riegeli", version = "0.0.0-20241218-3385e3c") | ||
| bazel_dep(name = "pybind11_bazel", version = "2.12.0") | ||
|
|
||
| PYTHON_VERSION = "3.10" | ||
| http_archive = use_repo_rule("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") | ||
|
|
||
| python = use_extension("@rules_python//python/extensions:python.bzl", "python") | ||
| python.toolchain( | ||
| ignore_root_user_error = True, # Required for our containerized CI environments. | ||
| python_version = PYTHON_VERSION, | ||
| http_archive( | ||
| name = "pybind11", | ||
|
Contributor
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. Why adding an extra pybind11 rule here?
Contributor
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. TBH I mostly followed Grain setup as that's the repo we're mainly working with: https://github.com/google/grain/blob/3bc1d2582dffdddf00b0d436a24b6313b69c617d/MODULE.bazel#L31
Contributor
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. AR is using pybind11 through pybind_bazel already. So it should work without http_archive pulled pybind11.
Contributor
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. Done! Removed pybind11 rule from here. |
||
| build_file = "@pybind11_bazel//:pybind11.BUILD", | ||
| sha256 = "201966a61dc826f1b1879a24a3317a1ec9214a918c8eb035be2f30c3e9cfbdcb", | ||
| strip_prefix = "pybind11-2.10.3", | ||
| urls = ["https://github.com/pybind/pybind11/archive/refs/tags/v2.10.3.zip"], | ||
| ) | ||
|
|
||
| SUPPORTED_PYTHON_VERSIONS = [ | ||
| "3.10", | ||
| "3.11", | ||
| "3.12", | ||
| "3.13", | ||
| ] | ||
|
|
||
| DEFAULT_PYTHON_VERSION = "3.10" | ||
|
|
||
| python_configure = use_extension("@pybind11_bazel//:python_configure.bzl", "extension") | ||
| use_repo(python_configure, "local_config_python") | ||
|
|
||
| python = use_extension("@rules_python//python/extensions:python.bzl", "python") | ||
|
|
||
| [ | ||
| python.toolchain( | ||
| ignore_root_user_error = True, | ||
| is_default = python_version == DEFAULT_PYTHON_VERSION, | ||
| python_version = python_version, | ||
| ) | ||
| for python_version in SUPPORTED_PYTHON_VERSIONS | ||
| ] | ||
|
|
||
| use_repo(python, python = "python_versions") | ||
|
|
||
| pip = use_extension("@rules_python//python/extensions:pip.bzl", "pip") | ||
|
|
||
| # requirements_lock.txt is generated by | ||
| # bazel run //:requirements.update | ||
| pip.parse( | ||
| hub_name = "pypi", | ||
| python_version = PYTHON_VERSION, | ||
| requirements_lock = "//:requirements_lock.txt", | ||
| ) | ||
| [ | ||
| pip.parse( | ||
| hub_name = "pypi", | ||
| python_version = version, | ||
| requirements_lock = "test_requirements_lock_" + version.replace(".", "_") + ".txt", | ||
| ) | ||
| for version in SUPPORTED_PYTHON_VERSIONS | ||
| ] | ||
|
|
||
| use_repo(pip, "pypi") | ||
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: