Skip to content

Commit ad1363a

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

File tree

23 files changed

+440
-167
lines changed

23 files changed

+440
-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: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
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'
22+
required: false
23+
type: string
24+
default: '3.11'
25+
bazel_version:
26+
description: 'Bazel version'
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+
test_tf_nightly:
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+
54+
permissions:
55+
contents: read
56+
57+
jobs:
58+
build-and-test:
59+
runs-on: linux-x86-n2-32
60+
defaults:
61+
run:
62+
shell: bash
63+
container:
64+
image: us-docker.pkg.dev/ml-oss-artifacts-published/ml-public-container/ml-build:latest
65+
timeout-minutes: 60
66+
steps:
67+
- name: Checkout
68+
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # ratchet:actions/checkout@v4
69+
with:
70+
ref: ${{ github.sha }}
71+
persist-credentials: false
72+
73+
- name: Bazel Version Checkup
74+
run: bazel version || sleep 5 && bazel version # work around potential flakiness on download
75+
env:
76+
USE_BAZEL_VERSION: ${{ inputs.bazel_version }}
77+
78+
- name: Build and test wheel
79+
env:
80+
PYTHON_VERSION: ${{ inputs.python_version }}
81+
USE_BAZEL_VERSION: ${{ inputs.bazel_version }}
82+
TF_VERSION: ${{ inputs.tf_version_spec }}
83+
KERAS_VERSION_SPEC: ${{ inputs.keras_version_spec }}
84+
TAG_FILTERS: ${{ inputs.tag_filters }}
85+
TF_USE_LEGACY_KERAS: ${{ inputs.legacy_keras }}
86+
TEST_TF_NIGHTLY: ${{ inputs.test_tf_nightly }}
87+
88+
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:
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-stable:
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:
50+
uses: ./.github/workflows/build-reusable.yml
51+
with:
52+
python_version: '3.11'
53+
legacy_keras: '1'
54+
test_tf_nightly: 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: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
#!/bin/bash
2+
# Copyright 2022 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+
PYENV_ROOT="/home/kbuilder/.pyenv"
20+
PYTHON_VERSION=${PYTHON_VERSION:-"3.11"}
21+
22+
function force_tensorflow_version() {
23+
if [[ -z "${TF_VERSION}" ]]; then
24+
echo "TF_VERSION is not set. Not forcing tensorflow version."
25+
return
26+
fi
27+
28+
pip install tensorflow=="${TF_VERSION}" --progress-bar off --upgrade
29+
if [[ "$TF_USE_LEGACY_KERAS" == 1 ]]; then
30+
pip install tf-keras=="${TF_VERSION}" --progress-bar off --upgrade
31+
fi
32+
}
33+
34+
echo "Installing pyenv.."
35+
git clone https://github.com/pyenv/pyenv.git "$PYENV_ROOT"
36+
export PATH="/home/kbuilder/.local/bin:$PYENV_ROOT/bin:$PATH"
37+
eval "$(pyenv init --path)"
38+
39+
echo "Python setup..."
40+
pyenv install -s "$PYTHON_VERSION"
41+
pyenv global "$PYTHON_VERSION"
42+
43+
cd "${KOKORO_ARTIFACTS_DIR}/github/gnn/"
44+
45+
PIP_TEST_PREFIX=bazel_pip
46+
47+
python -m venv build_venv
48+
source build_venv/bin/activate
49+
50+
# Debug messages to indicate the python version
51+
python --version
52+
53+
# update pip
54+
pip install --upgrade pip
55+
56+
# Install build
57+
pip install build
58+
59+
TEST_ROOT=$(pwd)/${PIP_TEST_PREFIX}
60+
rm -rf "$TEST_ROOT"
61+
mkdir -p "$TEST_ROOT"
62+
ln -s "$(pwd)"/tensorflow_gnn "$TEST_ROOT"/tensorflow_gnn
63+
64+
# Print the OS version
65+
cat /etc/os-release
66+
67+
# Prepend common tag filters to a defined env_var
68+
# For example, tests for TF 2.8 shouldn't run RNG-dependent tests
69+
# These tag filters are enforced to start with a comma for separation
70+
tag_filters="-no_oss,-oss_excluded${TAG_FILTERS}"
71+
72+
# Check that `bazel` does version selection as expected.
73+
if [[ -n "${USE_BAZEL_VERSION}" && $(bazel --version) != *${USE_BAZEL_VERSION}* ]]; then
74+
echo "Mismatch of configured and actual bazel version (see logged [[ command)"
75+
exit 1
76+
fi
77+
78+
bazel clean
79+
force_tensorflow_version
80+
python3 -m build --wheel
81+
deactivate
82+
83+
# Start the test environment.
84+
python3 -m venv test_venv
85+
source test_venv/bin/activate
86+
87+
# Check the python version
88+
python --version
89+
90+
# update pip
91+
pip install --upgrade pip
92+
force_tensorflow_version
93+
94+
if [[ "$TF_USE_LEGACY_KERAS" == 1 ]]; then
95+
pip install --group test-tf216plus --progress-bar off --upgrade
96+
else
97+
pip install --group test-pre-tf216 --progress-bar off --upgrade
98+
fi
99+
100+
pip install dist/tensorflow_gnn-*.whl
101+
102+
echo "Final packages after all pip commands:"
103+
pip list
104+
105+
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/...

kokoro/github/ubuntu/cpu/build.sh

Lines changed: 27 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -32,16 +32,18 @@ cd "${KOKORO_ARTIFACTS_DIR}/github/gnn/"
3232

3333
PIP_TEST_PREFIX=bazel_pip
3434

35-
python -m venv venv
36-
source venv/bin/activate
35+
python -m venv build_venv
36+
source build_venv/bin/activate
3737

3838
# Check the python version
3939
python --version
40-
python3 --version
4140

4241
# update pip
4342
pip install --upgrade pip
4443

44+
# Install build
45+
pip install build
46+
4547
TEST_ROOT=$(pwd)/${PIP_TEST_PREFIX}
4648
rm -rf "$TEST_ROOT"
4749
mkdir -p "$TEST_ROOT"
@@ -55,25 +57,34 @@ if [[ -n "${USE_BAZEL_VERSION}" && $(bazel --version) != *${USE_BAZEL_VERSION}*
5557
fi
5658

5759
bazel clean
58-
pip install -r requirements-dev.txt --progress-bar off
59-
pip install tf-keras-nightly tf-nightly --progress-bar off --upgrade
60-
# We need to remove the dependency on tensorflow to test nightly
61-
# The dependencies will be provided by tf-nightly
62-
perl -i -lpe '$k+= s/tensorflow>=2\.[0-9]+\.[0-9]+(,<=?[0-9.]+)?;/tf-nightly;/g; END{exit($k != 1)}' setup.py
63-
# tf-nightly 2.21 lifted the protobuf version to what google-vizier 0.1.24 wants
64-
# but what google-vizier 0.1.21 together with apache-beam does not allow.
65-
# TODO: b/482003228 - Replace this patch by a proper dependency cleanup.
66-
perl -i -lpe '$k+= s/google-vizier>=0.0.13,!=0.1.23,!=0.1.24/google-vizier>=0.0.13,!=0.1.23/g; END{exit($k != 1)}' setup.py
67-
python3 setup.py bdist_wheel
68-
pip uninstall -y tensorflow_gnn
60+
pip install --group test-nightly --progress-bar off --upgrade
61+
python3 -m build --wheel
62+
deactivate
63+
64+
# Start the test environment.
65+
python3 -m venv test_venv
66+
source test_venv/bin/activate
67+
68+
# Check the python version
69+
python --version
70+
71+
pip install --upgrade pip
6972
pip install dist/tensorflow_gnn-*.whl
73+
pip uninstall -y tensorflow tf-keras ai-edge-litert
74+
pip install --group test-nightly --progress-bar off --upgrade
7075

7176
echo "Final packages after all pip commands:"
7277
pip list
7378

7479
# Check that tf-nightly is installed but tensorflow is not
7580
# Also check that tf-keras-nightly is installed.
76-
pip freeze | grep -q tf-nightly= && ! pip freeze | grep -q tensorflow=
77-
pip freeze | grep -q tf-keras-nightly= && ! pip freeze | grep -q tf-keras=
81+
if [[ $(pip freeze | grep -q tf_nightly=; echo $?) -eq 0 && $(pip freeze | grep -q tensorflow=; echo $?) -eq 0 ]]; then
82+
echo "Found tensorflow and tf_nightly in the environment."
83+
exit 1
84+
fi
85+
if [[ $(pip freeze | grep -q tf_keras-nightly=; echo $?) -eq 0 && $(pip freeze | grep -q tf_keras=; echo $?) -eq 0 ]]; then
86+
echo "Found tf_keras and tf_keras-nightly in the environment."
87+
exit 1
88+
fi
7889
# The env variable is needed to ensure that TF keras still behaves like keras 2
7990
bazel test --test_env="TF_USE_LEGACY_KERAS=1" --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)