Skip to content

Commit d4f6a19

Browse files
Graph Learning Teamtensorflower-gardener
authored andcommitted
Initial changes for moving to ML-Actions GHA workflows
PiperOrigin-RevId: 876173278
1 parent 55784fc commit d4f6a19

File tree

23 files changed

+477
-167
lines changed

23 files changed

+477
-167
lines changed

.bazelversion

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
7.7.0
2+
# TODO: b/390391579 - Upgrade once bazel 8+ works.
Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
# Copyright 2026 The TensorFlow GNN Authors. All Rights Reserved.
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
# ==============================================================================
15+
name: Reusable Build
16+
on:
17+
workflow_call:
18+
inputs:
19+
20+
python_version:
21+
description: 'Python version (overridden by kokoro_config if set)'
22+
required: false
23+
type: string
24+
default: '3.11'
25+
bazel_version:
26+
description: 'Bazel version (overridden by kokoro_config if set)'
27+
required: false
28+
type: string
29+
default: '7.4.1'
30+
tf_version_spec:
31+
description: 'TensorFlow version specifier'
32+
required: false
33+
type: string
34+
keras_version_spec:
35+
description: 'Keras version specifier'
36+
required: false
37+
type: string
38+
nightly_build:
39+
description: 'Whether to use tf-nightly'
40+
required: false
41+
type: boolean
42+
default: false
43+
legacy_keras:
44+
description: 'Value for TF_USE_LEGACY_KERAS'
45+
required: false
46+
type: string
47+
default: '0'
48+
tag_filters:
49+
description: 'Bazel test tag filters'
50+
required: false
51+
type: string
52+
default: ''
53+
nightly_env:
54+
description: 'Whether to run checks for tf-nightly'
55+
required: false
56+
type: boolean
57+
default: false
58+
run_tests:
59+
description: 'Whether to run tests after building'
60+
required: false
61+
type: boolean
62+
default: false
63+
64+
permissions:
65+
contents: read
66+
67+
jobs:
68+
build-and-test:
69+
runs-on: linux-x86-n2-32
70+
defaults:
71+
run:
72+
shell: bash
73+
container:
74+
image: us-docker.pkg.dev/ml-oss-artifacts-published/ml-public-container/ml-build:latest
75+
timeout-minutes: 60
76+
steps:
77+
- name: Checkout
78+
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # ratchet:actions/checkout@v4
79+
with:
80+
ref: ${{ github.sha }}
81+
persist-credentials: false
82+
83+
- name: Bazel Version Checkup
84+
run: bazel version || sleep 5 && bazel version # work around potential flakiness on download
85+
env:
86+
USE_BAZEL_VERSION: ${{ inputs.bazel_version }}
87+
88+
- name: Build and test wheel
89+
env:
90+
PYTHON_VERSION: ${{ inputs.python_version }}
91+
USE_BAZEL_VERSION: ${{ inputs.bazel_version }}
92+
TF_VERSION: ${{ inputs.tf_version_spec }}
93+
KERAS_VERSION_SPEC: ${{ inputs.keras_version_spec }}
94+
TAG_FILTERS: ${{ inputs.tag_filters }}
95+
TF_USE_LEGACY_KERAS: ${{ inputs.legacy_keras }}
96+
NIGHTLY_BUILD: ${{ inputs.nightly_build }}
97+
NIGHTLY_ENV: ${{ inputs.nightly_env }}
98+
99+
run: ./ci/build-gha.sh

.github/workflows/ci-build.yml

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
# Copyright 2026 The TensorFlow GNN Authors. All Rights Reserved.
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
# ==============================================================================
15+
name: CI
16+
17+
on:
18+
push:
19+
branches:
20+
- main
21+
pull_request:
22+
branches:
23+
- main
24+
25+
permissions:
26+
contents: read
27+
28+
concurrency:
29+
group: ${{ github.workflow }}-${{ github.head_ref || github.ref }}
30+
# Don't cancel in-progress jobs for main branches.
31+
cancel-in-progress: ${{ github.ref != 'main' }}
32+
33+
jobs:
34+
build-and-test-oldest-py311-tf212:
35+
uses: ./.github/workflows/build-reusable.yml
36+
with:
37+
python_version: '3.11'
38+
tf_version_spec: '2.12.*'
39+
legacy_keras: '0'
40+
tag_filters: ',-tf_at_least_2_13'
41+
42+
build-and-test-newest-py311-tf220:
43+
uses: ./.github/workflows/build-reusable.yml
44+
with:
45+
python_version: '3.11'
46+
tf_version_spec: '2.20.*'
47+
legacy_keras: '1'
48+
49+
build-and-test-nightly-py311:
50+
uses: ./.github/workflows/build-reusable.yml
51+
with:
52+
python_version: '3.11'
53+
legacy_keras: '1'
54+
nightly_build: true

BUILD

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ py_library(
33
# This is a dummy rule used as a absl dependency in open-source.
44
# We expect absl to already be installed on the system, e.g. via
55
# `pip install absl`
6+
# strict_deps = False,
67
visibility = ["//visibility:public"],
78
deps = [],
89
)
@@ -12,6 +13,7 @@ py_library(
1213
# This is a dummy rule used as a absl dependency in open-source.
1314
# We expect absl to already be installed on the system, e.g. via
1415
# `pip install absl`
16+
# strict_deps = False,
1517
visibility = ["//visibility:public"],
1618
deps = [],
1719
)
@@ -21,6 +23,7 @@ py_library(
2123
# This is a dummy rule used as a absl dependency in open-source.
2224
# We expect absl to already be installed on the system, e.g. via
2325
# `pip install absl`
26+
# strict_deps = False,
2427
visibility = ["//visibility:public"],
2528
deps = [],
2629
)
@@ -30,6 +33,7 @@ py_library(
3033
# This is a dummy rule used as a numpy dependency in open-source.
3134
# We expect numpy to already be installed on the system, e.g. via
3235
# `pip install numpy`
36+
# strict_deps = False,
3337
visibility = ["//visibility:public"],
3438
deps = [],
3539
)
@@ -39,6 +43,7 @@ py_library(
3943
# This is a dummy rule used as a tensorflow dependency in open-source.
4044
# We expect tensorflow to already be installed on the system, e.g. via
4145
# `pip install tensorflow`
46+
# strict_deps = False,
4247
visibility = ["//visibility:public"],
4348
deps = [],
4449
)
@@ -48,6 +53,7 @@ py_library(
4853
# This is a dummy rule used as a ai-edge-litert dependency in open-source.
4954
# We expect ai-edge-litert to already be installed on the system, e.g. via
5055
# `pip install ai-edge-litert`
56+
# strict_deps = False,
5157
visibility = ["//visibility:public"],
5258
deps = [],
5359
)
@@ -57,6 +63,7 @@ py_library(
5763
# This is a dummy rule used as a tensorflow dependency in open-source.
5864
# We expect tensorflow to already be installed on the system, e.g. via
5965
# `pip install tensorflow`
66+
# strict_deps = False,
6067
visibility = ["//visibility:public"],
6168
deps = [],
6269
)
@@ -66,6 +73,7 @@ py_library(
6673
# This is a dummy rule used as a dependency on vizier.service.pyvizier in open-source.
6774
# We expect Vizier to already be installed on the system, e.g. via
6875
# `pip install google-vizier` and extra steps if needed (b/254806045).
76+
# strict_deps = False,
6977
visibility = ["//visibility:public"],
7078
deps = [],
7179
)
@@ -75,6 +83,7 @@ py_library(
7583
# This is a dummy rule used as a mock dependency in open-source tests.
7684
# We expect mock to already be installed on the system, e.g. via
7785
# `pip install mock`
86+
# strict_deps = False,
7887
visibility = ["//visibility:public"],
7988
deps = [],
8089
)

ci/build-gha.sh

Lines changed: 132 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,132 @@
1+
#!/bin/bash
2+
# Copyright 2026 Google LLC
3+
#
4+
# Licensed under the Apache License, Version 2.0 (the "License");
5+
# you may not use this file except in compliance with the License.
6+
# You may obtain a copy of the License at
7+
#
8+
# http://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# Unless required by applicable law or agreed to in writing, software
11+
# distributed under the License is distributed on an "AS IS" BASIS,
12+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
# See the License for the specific language governing permissions and
14+
# limitations under the License.
15+
16+
set -e
17+
set -x
18+
19+
# For pyenv python installation on ml-build image
20+
sudo apt-get update
21+
sudo apt-get install -y libbz2-dev liblzma-dev libncurses-dev libffi-dev libssl-dev libreadline-dev libsqlite3-dev zlib1g-dev
22+
23+
PYENV_ROOT="$HOME/.pyenv"
24+
PYTHON_VERSION=${PYTHON_VERSION:-"3.11"}
25+
26+
function force_tensorflow_version() {
27+
if [[ -z "${TF_VERSION}" ]]; then
28+
echo "TF_VERSION is not set. Not forcing tensorflow version."
29+
return
30+
fi
31+
32+
pip install tensorflow=="${TF_VERSION}" --progress-bar off --upgrade
33+
if [[ "$TF_USE_LEGACY_KERAS" == 1 ]]; then
34+
pip install tf-keras=="${TF_VERSION}" --progress-bar off --upgrade
35+
fi
36+
}
37+
38+
echo "Installing pyenv.."
39+
git clone https://github.com/pyenv/pyenv.git "$PYENV_ROOT"
40+
export PATH="$HOME/.local/bin:$PYENV_ROOT/bin:$PATH"
41+
eval "$(pyenv init --path)"
42+
43+
echo "Python setup..."
44+
pyenv install -s "$PYTHON_VERSION"
45+
pyenv global "$PYTHON_VERSION"
46+
47+
PIP_TEST_PREFIX=bazel_pip
48+
49+
python -m venv build_venv
50+
source build_venv/bin/activate
51+
52+
# Debug messages to indicate the python version
53+
python --version
54+
55+
# update pip
56+
pip install --upgrade pip
57+
58+
# Install build
59+
pip install build
60+
61+
TEST_ROOT=$(pwd)/${PIP_TEST_PREFIX}
62+
rm -rf "$TEST_ROOT"
63+
mkdir -p "$TEST_ROOT"
64+
ln -s "$(pwd)"/tensorflow_gnn "$TEST_ROOT"/tensorflow_gnn
65+
66+
# Print the OS version
67+
cat /etc/os-release
68+
69+
# Prepend common tag filters to a defined env_var
70+
# For example, tests for TF 2.8 shouldn't run RNG-dependent tests
71+
# These tag filters are enforced to start with a comma for separation
72+
tag_filters="-no_oss,-oss_excluded${TAG_FILTERS}"
73+
74+
# Check that `bazel` does version selection as expected.
75+
if [[ -n "${USE_BAZEL_VERSION}" && $(bazel --version) != *${USE_BAZEL_VERSION}* ]]; then
76+
echo "Mismatch of configured and actual bazel version (see logged [[ command)"
77+
exit 1
78+
fi
79+
80+
bazel clean
81+
82+
if [[ "$NIGHTLY_BUILD" == "true" ]]; then
83+
pip install --group test-nightly --progress-bar off --upgrade
84+
else
85+
force_tensorflow_version
86+
fi
87+
88+
python3 -m build --wheel
89+
deactivate
90+
91+
# Start the test environment.
92+
python3 -m venv test_venv
93+
source test_venv/bin/activate
94+
95+
# Check the python version
96+
python --version
97+
98+
# update pip
99+
pip install --upgrade pip
100+
101+
if [[ "$NIGHTLY_BUILD" == "true" ]]; then
102+
pip install dist/tensorflow_gnn-*.whl
103+
pip uninstall -y tensorflow tf-keras ai-edge-litert
104+
pip install --group test-nightly --progress-bar off --upgrade
105+
106+
# Check that tf-nightly is installed but tensorflow is not
107+
# Also check that tf-keras-nightly is installed.
108+
if [[ $(pip freeze | grep -q tf_nightly=; echo $?) -eq 0 && $(pip freeze | grep -q tensorflow=; echo $?) -eq 0 ]]; then
109+
echo "Found tensorflow and tf_nightly in the environment."
110+
exit 1
111+
fi
112+
if [[ $(pip freeze | grep -q tf_keras-nightly=; echo $?) -eq 0 && $(pip freeze | grep -q tf_keras=; echo $?) -eq 0 ]]; then
113+
echo "Found tf_keras and tf_keras-nightly in the environment."
114+
exit 1
115+
fi
116+
117+
else
118+
force_tensorflow_version
119+
120+
if [[ "$TF_USE_LEGACY_KERAS" == 1 ]]; then
121+
pip install --group test-tf216plus --progress-bar off --upgrade
122+
else
123+
pip install --group test-pre-tf216 --progress-bar off --upgrade
124+
fi
125+
126+
pip install dist/tensorflow_gnn-*.whl
127+
fi
128+
129+
echo "Final packages after all pip commands:"
130+
pip list
131+
132+
bazel test --test_env=TF_USE_LEGACY_KERAS --build_tag_filters="${tag_filters}" --test_tag_filters="${tag_filters}" --test_output=errors --verbose_failures=true --build_tests_only --define=no_tfgnn_py_deps=true --keep_going --experimental_repo_remote_exec //bazel_pip/tensorflow_gnn/...

0 commit comments

Comments
 (0)