-
Notifications
You must be signed in to change notification settings - Fork 1.7k
385 lines (374 loc) · 17 KB
/
ci.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
# GitHub Actions CI definition for TensorBoard.
#
# YAML schema for GitHub Actions:
# https://help.github.com/en/actions/automating-your-workflow-with-github-actions/workflow-syntax-for-github-actions
#
# Helpful YAML parser to clarify YAML syntax:
# https://yaml-online-parser.appspot.com/
name: CI
on:
push:
branches:
- master
- '[0-9]+.*'
- 'ci-*'
tags:
- '*'
pull_request: {}
workflow_call: {}
permissions:
contents: read
env:
# Keep this Bazel version in sync with the `versions.check` directive
# in our WORKSPACE file.
BAZEL_VERSION: '4.2.2'
BAZEL_SHA256SUM: '11dea6c7cfd866ed520af19a6bb1d952f3e9f4ee60ffe84e63c0825d95cb5859'
BUILDTOOLS_VERSION: '3.0.0'
BUILDIFIER_SHA256SUM: 'e92a6793c7134c5431c58fbc34700664f101e5c9b1c1fcd93b97978e8b7f88db'
BUILDOZER_SHA256SUM: '3d58a0b6972e4535718cdd6c12778170ea7382de7c75bc3728f5719437ffb84d'
TENSORFLOW_VERSION: 'tf-nightly'
TF_KERAS_VERSION: 'tf-keras-nightly' # Keras 2
jobs:
build:
runs-on: ubuntu-22.04
needs: lint-python-flake8 # fail fast in case of "undefined variable" errors
strategy:
fail-fast: false
matrix:
tf_version_id: ['tf', 'notf']
python_version: ['3.9']
steps:
- uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0
- uses: actions/setup-python@13ae5bb136fac2878aff31522b9efb785519f984 # v4.3.0
with:
python-version: ${{ matrix.python_version }}
architecture: 'x64'
- name: 'Set up Bazel'
run: |
ci/download_bazel.sh "${BAZEL_VERSION}" "${BAZEL_SHA256SUM}" ~/bazel
sudo mv ~/bazel /usr/local/bin/bazel
sudo chmod +x /usr/local/bin/bazel
cp ./ci/bazelrc ~/.bazelrc
- name: 'Configure build cache write credentials'
env:
CREDS: ${{ secrets.BAZEL_CACHE_SERVICE_ACCOUNT_CREDS }}
EVENT_TYPE: ${{ github.event_name }}
run: |
if [ -z "${CREDS}" ]; then
printf 'Using read-only cache (no credentials)\n'
exit
fi
if [ "${EVENT_TYPE}" = pull_request ]; then
printf 'Using read-only cache (PR build)\n'
exit
fi
printf 'Using writable cache\n'
creds_file=/tmp/service_account_creds.json
printf '%s\n' "${CREDS}" >"${creds_file}"
printf '%s\n' >>~/.bazelrc \
"common --google_credentials=${creds_file}" \
"common --remote_upload_local_results=true" \
;
- name: 'Install TensorFlow'
run: |
python -m pip install -U pip
pip install "${TENSORFLOW_VERSION}"
if: matrix.tf_version_id != 'notf'
# Replace the `tf-keras` with `tf-keras-nightly` in the requirements.txt
# to avoid incompatibilities when using alongside `tf-nightly`.
# TODO: Remove this after migrating to Keras 3.
- name: 'Make user to use tf-keras-nightly with tf-nightly'
run: |
sed -i "s/^tf-keras.*/${TF_KERAS_VERSION}/g" ./tensorboard/pip_package/requirements.txt
- name: 'Install Python dependencies'
run: |
python -m pip install -U pip
pip install \
-r ./tensorboard/pip_package/requirements.txt \
-r ./tensorboard/pip_package/requirements_dev.txt \
;
- name: 'Check Pip state'
run: pip freeze --all
- name: 'Bazel: fetch'
run: bazel fetch //tensorboard/...
- name: 'Bazel: build'
# Note we suppress a flood of warnings from the proto compiler.
# Googlers see b/222706811 & b/182876485 discussion and preconditions
# for removing this kludge.
run: |
( set -o pipefail;
bazel build //tensorboard/... |&\
grep -v 'external/com_google_protobuf/python: warning: directory' |&\
grep -v 'INFO: From ProtoCompile ' )
- name: 'Bazel: test (with TensorFlow support)'
run: bazel test //tensorboard/...
if: matrix.tf_version_id != 'notf'
- name: 'Bazel: test (non-TensorFlow only)'
run: bazel test //tensorboard/... --test_tag_filters="support_notf"
if: matrix.tf_version_id == 'notf'
- name: 'Bazel: run Pip package test (with TensorFlow support)'
run: |
bazel run //tensorboard/pip_package:test_pip_package -- \
--tf-version "${TENSORFLOW_VERSION}"
if: matrix.tf_version_id != 'notf'
- name: 'Bazel: run Pip package test (non-TensorFlow only)'
run: |
bazel run //tensorboard/pip_package:test_pip_package -- \
--tf-version notf
if: matrix.tf_version_id == 'notf'
- name: 'Bazel: run manual tests'
run: |
bazel test //tensorboard/compat/tensorflow_stub:gfile_s3_test &&
bazel test //tensorboard/summary/writer:event_file_writer_s3_test &&
bazel test //tensorboard/compat/tensorflow_stub:gfile_fsspec_test &&
bazel test //tensorboard/summary/writer:event_file_writer_fsspec_test
- name: 'Bazel: build Pip package (master branch TF build only)'
# This pip package is only needed if we will upload it, so run this step
# only under the same conditions as the next step (see comment below).
if: matrix.tf_version_id == 'tf' && github.repository == 'tensorflow/tensorboard' && github.ref == 'refs/heads/master'
run: |
./tensorboard/tools/set_nightly_version.sh
rm -rf /tmp/tb_nightly_pip_package && mkdir /tmp/tb_nightly_pip_package
bazel run //tensorboard/pip_package:build_pip_package -- /tmp/tb_nightly_pip_package
- name: 'Upload Pip package as an artifact (master branch TF build only)'
# Prevent uploads when running on forks or non-master branch.
if: matrix.tf_version_id == 'tf' && github.repository == 'tensorflow/tensorboard' && github.ref == 'refs/heads/master'
uses: actions/upload-artifact@83fd05a356d7e2593de66fc9913b3002723633cb # v3.1.1
with:
name: tb-nightly
path: /tmp/tb_nightly_pip_package/*
build-data-server-pip:
runs-on: ${{ matrix.platform }}
strategy:
fail-fast: false
matrix:
mode: ['native']
platform: ['ubuntu-20.04', 'macos-12']
rust_version: ['1.65.0']
include:
- mode: 'universal'
platform: 'ubuntu-20.04'
rust_version: '1.65.0'
steps:
- uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0
- uses: actions/setup-python@13ae5bb136fac2878aff31522b9efb785519f984 # v4.3.0
with:
python-version: '3.9'
architecture: 'x64'
- name: 'Cache Cargo artifacts'
if: matrix.mode == 'native'
uses: actions/cache@58c146cc91c5b9e778e71775dfe9bf1442ad9a12 # v3.2.2
with:
path: |
tensorboard/data/server/target/
# https://doc.rust-lang.org/cargo/guide/cargo-home.html#caching-the-cargo-home-in-ci
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
# Needed if we `cargo install` binaries (at time of writing, this
# job doesn't but the files are tiny, and this will mitigate
# confusion if we need to `cargo install` later)
~/.cargo/.crates.toml
~/.cargo/.crates2.json
key: build-data-server-pip-${{ runner.os }}-cargo-${{ matrix.rust_version }}-${{ hashFiles('**/Cargo.lock', '.github/workflows/ci.yml') }}
- name: 'Install Rust toolchain'
if: matrix.mode == 'native'
uses: dtolnay/rust-toolchain@5f2e2a7aff63d8cbdacb4832218a30fa7a37ee6e # current HEAD as of 1/19/2023
with:
toolchain: ${{ matrix.rust_version }}
components: rustfmt
- name: 'Install Python packaging deps'
run: |
python -m pip install -U pip
pip install \
-c ./tensorboard/pip_package/requirements.txt \
-c ./tensorboard/pip_package/requirements_dev.txt \
setuptools wheel
- name: 'Build'
if: matrix.mode == 'native'
run: cd tensorboard/data/server/ && cargo build --release
- name: 'Test'
if: matrix.mode == 'native'
run: cd tensorboard/data/server/ && cargo test --release
- name: 'Package (native)'
if: matrix.mode == 'native'
run: |
rm -rf /tmp/pip_package && mkdir /tmp/pip_package
python tensorboard/data/server/pip_package/build.py \
--server-binary tensorboard/data/server/target/release/rustboard \
--out-dir /tmp/pip_package \
;
- name: 'Package (universal)'
if: matrix.mode == 'universal'
run: |
rm -rf /tmp/pip_package && mkdir /tmp/pip_package
python tensorboard/data/server/pip_package/build.py \
--universal \
--out-dir /tmp/pip_package \
;
- name: 'Upload'
uses: actions/upload-artifact@83fd05a356d7e2593de66fc9913b3002723633cb # v3.1.1
with:
name: tensorboard-data-server
path: /tmp/pip_package/*
lint-python-flake8:
runs-on: ubuntu-22.04
strategy:
fail-fast: false
matrix:
# flake8 should run on each Python version that we target,
# because the errors and warnings can differ due to language
# changes, and we want to catch them all.
python_version: ['3.9', '3.10', '3.11']
steps:
- uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0
- uses: actions/setup-python@13ae5bb136fac2878aff31522b9efb785519f984 # v4.3.0
with:
python-version: ${{ matrix.python_version }}
architecture: 'x64'
- name: 'Install flake8'
run: |
python -m pip install -U pip
pip install flake8 -c ./tensorboard/pip_package/requirements_dev.txt
- run: pip freeze --all
- name: 'Lint Python code for errors with flake8'
# See: http://flake8.pycqa.org/en/3.7.8/user/error-codes.html
# Use the comment '# noqa: <error code>' to suppress.
run: flake8 . --count --select=E9,F63,F7,F82,F401 --show-source --statistics
lint-python-yaml-docs:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0
- uses: actions/setup-python@13ae5bb136fac2878aff31522b9efb785519f984 # v4.3.0
with:
python-version: '3.10'
architecture: 'x64'
- name: 'Install black, yamllint, and the TensorFlow docs notebook tools'
run: |
python -m pip install -U pip
nbfmt_version="84bd7bea0c468667dd0ec273d426ed50f23e1a15"
pip install black yamllint -c ./tensorboard/pip_package/requirements_dev.txt
pip install -U git+https://github.com/tensorflow/docs@${nbfmt_version}
# Workaround tensorflow incompatibility with protobuf>4.
# See: https://github.com/tensorflow/tensorboard/issues/5708.
# See: https://github.com/tensorflow/tensorflow/issues/53234.
- name: 'Downgrade to compatible protobuf version'
run: pip install -U "protobuf<3.20"
- run: pip freeze --all
- name: 'Lint Python code for style with Black'
# You can run `black .` to fix all Black complaints.
run: black --check --diff .
- name: 'Lint YAML for gotchas with yamllint'
# Use '# yamllint disable-line rule:foo' to suppress.
run: yamllint -c docs/.yamllint docs docs/.yamllint
- name: 'Lint Colab notebooks for formatting with nbfmt'
run: git ls-files -z '*.ipynb' | xargs -0 python3 -m tensorflow_docs.tools.nbfmt --test
lint-rust:
runs-on: ubuntu-22.04
strategy:
matrix:
rust_version: ['1.65.0']
cargo_raze_version: ['0.16.1']
steps:
- uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0
- name: 'Cache Cargo artifacts'
uses: actions/cache@58c146cc91c5b9e778e71775dfe9bf1442ad9a12 # v3.2.2
with:
path: |
tensorboard/data/server/target/
# https://doc.rust-lang.org/cargo/guide/cargo-home.html#caching-the-cargo-home-in-ci
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
# Needed for installing binaries (`cargo-raze`) with cache
~/.cargo/.crates.toml
~/.cargo/.crates2.json
key: lint-rust-${{ runner.os }}-cargo-${{ matrix.rust_version }}-${{ matrix.cargo_raze_version }}-${{ hashFiles('**/Cargo.lock', '.github/workflows/ci.yml') }}
- name: 'Install Rust toolchain'
uses: dtolnay/rust-toolchain@5f2e2a7aff63d8cbdacb4832218a30fa7a37ee6e # current HEAD as of 1/19/2023
with:
toolchain: ${{ matrix.rust_version }}
components: rustfmt, clippy
- name: 'Install cargo-raze'
run: cargo install cargo-raze --version ${{ matrix.cargo_raze_version }} --locked
- name: 'Run Rustfmt'
run: (cd tensorboard/data/server/ && cargo fmt -- --check)
- name: 'Run Clippy'
# You can run `cargo clippy --all-targets --manifest-path tensorboard/data/server/Cargo.toml --fix` to fix all Clippy complaints.
# This will only apply `MachineApplicable` fixes (https://doc.rust-lang.org/nightly/nightly-rustc/rustc_lint_defs/enum.Applicability.html), so some modifications may need to be done manually.
run: cargo clippy --all-targets --manifest-path tensorboard/data/server/Cargo.toml -- -D warnings
- name: 'Check cargo-raze freshness'
run: |
rm -rf third_party/rust/
(cd tensorboard/data/server/ && cargo fetch && cargo raze)
git add .
git diff --staged --exit-code
lint-frontend:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0
- uses: actions/setup-node@64ed1c7eab4cce3362f8c340dee64e5eaeef8f7c # v3.6.0
with:
node-version: 16
- run: yarn install --ignore-engines
# You can run `yarn fix-lint` to fix all Prettier complaints.
- run: yarn lint
# Make sure no tests are skipped with "focused" tests.
- run: |
! git grep -E 'f(it|describe)\(' 'tensorboard/*_test.ts'
# Make sure no one depends on Angular material and CDK directly. Please
# import the indirection in //tensorboard/webapp/angular.
- run: |
! git grep -E '"@npm//@angular/material"|"@npm//@angular/cdk"' 'tensorboard/*/BUILD' ':!tensorboard/webapp/BUILD' ':!tensorboard/webapp/angular/BUILD'
# Cannot directly depend on d3 in webapp. Must depend on
# `//tensorboard/webapp/third_party:d3` instead.
- run: |
! git grep -E '"@npm//d3"|"@npm//@types/d3"' 'tensorboard/webapp/**/*BUILD' ':!tensorboard/webapp/third_party/**'
- run: |
! git grep -E '"@npm_angular_bazel//:index.bzl"' 'tensorboard/**/BUILD'
- run: |
! git grep -E 'mat-color|$mat-' 'tensorboard/**/*.scss'
# Make sure no one depends on the numeric library directly. Please
# import the indirection in //tensorboard/webapp/third_party.
- run: |
! git grep -E '@npm//numeric' 'tensorboard/*/BUILD' ':!tensorboard/webapp/third_party/**'
lint-misc: # build, protos, etc.
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0
- name: 'Set up Buildifier'
run: |
ci/download_buildifier.sh "${BUILDTOOLS_VERSION}" "${BUILDIFIER_SHA256SUM}" ~/buildifier
sudo mv ~/buildifier /usr/local/bin/buildifier
- name: 'Set up Buildozer'
run: |
ci/download_buildozer.sh "${BUILDTOOLS_VERSION}" "${BUILDOZER_SHA256SUM}" ~/buildozer
sudo mv ~/buildozer /usr/local/bin/buildozer
- name: 'Lint BUILD files'
# TODO(tensorboard-team): address all lint warnings and remove the exemption.
run:
git ls-files -z '*BUILD' third_party/js.bzl third_party/workspace.bzl WORKSPACE | xargs -0 buildifier --mode=check --lint=warn
--warnings=-native-py,-native-java
- run: ./tensorboard/tools/mirror_urls_test.sh
- name: 'Lint for no py2 BUILD targets'
# Use | to start a literal so YAML doesn't complain about the '!' character.
run: |
! git grep 'python_version = "PY2"' '*BUILD'
- name: 'No comments on licenses rule'
# Assert buildozer error code for 'success, when no changes were made'.
# https://github.com/bazelbuild/buildtools/blob/master/buildozer/README.md#error-code
run: |
buildozer '//tensorboard/...:%licenses' remove_comment && false || test $? = 3
- name: clang-format lint
uses: DoozyX/clang-format-lint-action@0138140a2adaafd3032a3ff37f66366fd7dc88e0
with:
source: ./tensorboard
# Exclude tensorboard/compat because the source of truth is TensorFlow.
exclude: ./tensorboard/compat/proto
extensions: 'proto'
clangFormatVersion: 9
- run: ./tensorboard/tools/do_not_submit_test.sh
- run: ./tensorboard/tools/license_test.sh
- run: ./tensorboard/tools/whitespace_hygiene_test.py