Skip to content

Commit b3fe8d3

Browse files
Graph Learning Teamtensorflower-gardener
authored andcommitted
Switch to ML-Actions GHA workflows
PiperOrigin-RevId: 877477802
1 parent 55784fc commit b3fe8d3

30 files changed

Lines changed: 438 additions & 417 deletions

File tree

.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: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
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+
job_name:
54+
description: 'Name of the caller job'
55+
required: false
56+
type: string
57+
default: 'build-and-test'
58+
59+
permissions:
60+
contents: read
61+
62+
jobs:
63+
build-and-test:
64+
runs-on: linux-x86-n2-32
65+
defaults:
66+
run:
67+
shell: bash
68+
container:
69+
image: us-docker.pkg.dev/ml-oss-artifacts-published/ml-public-container/ml-build:latest
70+
timeout-minutes: 60
71+
steps:
72+
- name: Checkout
73+
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # ratchet:actions/checkout@v4
74+
with:
75+
ref: ${{ github.sha }}
76+
persist-credentials: false
77+
78+
- name: Bazel Version Checkup
79+
run: bazel version || sleep 5 && bazel version # work around potential flakiness on download
80+
env:
81+
USE_BAZEL_VERSION: ${{ inputs.bazel_version }}
82+
83+
- name: Build and test wheel
84+
env:
85+
PYTHON_VERSION: ${{ inputs.python_version }}
86+
USE_BAZEL_VERSION: ${{ inputs.bazel_version }}
87+
TF_VERSION: ${{ inputs.tf_version_spec }}
88+
KERAS_VERSION_SPEC: ${{ inputs.keras_version_spec }}
89+
TAG_FILTERS: ${{ inputs.tag_filters }}
90+
TF_USE_LEGACY_KERAS: ${{ inputs.legacy_keras }}
91+
TEST_TF_NIGHTLY: ${{ inputs.test_tf_nightly }}
92+
93+
run: ./ci/build-gha.sh
94+
95+
- name: Send chat on failure
96+
# Only notify when the workflow runs on a schedule (daily CI).
97+
if: ${{ failure() && github.event_name == 'schedule' }}
98+
run: |
99+
curl --location --request POST '${{ secrets.GNN_BUILD_CHAT_WEBHOOK }}' \
100+
--header 'Content-Type: application/json' \
101+
--data-raw "{
102+
'text': 'GNN CI Failure: Job \"${{ github.workflow }} / ${{ inputs.job_name }}\" failed for Python ${{ inputs.python_version }}. \nRun: $GITHUB_SERVER_URL/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID'
103+
}"

.github/workflows/ci-build.yml

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
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+
schedule:
25+
- cron: '0 8 * * *' # Run daily at 08:00 UTC
26+
27+
permissions:
28+
contents: read
29+
30+
concurrency:
31+
group: ${{ github.workflow }}-${{ github.head_ref || github.ref }}
32+
# Don't cancel in-progress jobs for main branches.
33+
cancel-in-progress: ${{ github.ref != 'main' }}
34+
35+
jobs:
36+
build-and-test-oldest:
37+
name: build-and-test-oldest
38+
uses: ./.github/workflows/build-reusable.yml
39+
secrets: inherit
40+
with:
41+
job_name: 'build-and-test-oldest'
42+
python_version: '3.11'
43+
tf_version_spec: '2.12.*'
44+
legacy_keras: '0'
45+
# Disable Vizier tests by default since vizier is now an extra dependency (b/394062744).
46+
tag_filters: ',-tf_at_least_2_13,-vizier'
47+
48+
build-and-test-newest-stable:
49+
name: build-and-test-newest-stable
50+
uses: ./.github/workflows/build-reusable.yml
51+
secrets: inherit
52+
with:
53+
job_name: 'build-and-test-newest-stable'
54+
python_version: '3.11'
55+
tf_version_spec: '2.20.*'
56+
legacy_keras: '1'
57+
# Disable Vizier tests by default since vizier is now an extra dependency (b/394062744).
58+
tag_filters: ',-vizier'
59+
60+
build-and-test-nightly:
61+
name: build-and-test-nightly
62+
uses: ./.github/workflows/build-reusable.yml
63+
secrets: inherit
64+
with:
65+
job_name: 'build-and-test-nightly'
66+
python_version: '3.11'
67+
legacy_keras: '1'
68+
test_tf_nightly: true
69+
tag_filters: ''

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: 128 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,128 @@
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 [[ "$TEST_TF_NIGHTLY" == "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 [[ "$TEST_TF_NIGHTLY" == "true" ]]; then
102+
pip install dist/tensorflow_gnn-*.whl
103+
tf_wheel=$(ls dist/tensorflow_gnn-*.whl)
104+
pip install "${tf_wheel[0]}[vizier]"
105+
pip uninstall -y tensorflow tf-keras ai-edge-litert
106+
pip install --group test-nightly --progress-bar off --upgrade
107+
108+
# Check that tf-nightly is installed but tensorflow is not
109+
# Also check that tf-keras-nightly is installed.
110+
if [[ $(pip freeze | grep -q tf_nightly=; echo $?) -eq 0 && $(pip freeze | grep -q tensorflow=; echo $?) -eq 0 ]]; then
111+
echo "Found tensorflow and tf_nightly in the environment."
112+
exit 1
113+
fi
114+
if [[ $(pip freeze | grep -q tf_keras-nightly=; echo $?) -eq 0 && $(pip freeze | grep -q tf_keras=; echo $?) -eq 0 ]]; then
115+
echo "Found tf_keras and tf_keras-nightly in the environment."
116+
exit 1
117+
fi
118+
119+
else
120+
force_tensorflow_version
121+
pip install --group test-released --progress-bar off --upgrade
122+
pip install dist/tensorflow_gnn-*.whl
123+
fi
124+
125+
echo "Final packages after all pip commands:"
126+
pip list
127+
128+
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)