Skip to content

Commit 83ce2a2

Browse files
authored
ci: enable GitHub actions for tests (#2953)
Summary: This commit adds a GitHub Actions workflow definition for our main CI build and tests. This new workflow will replace our use of Travis CI. GitHub Actions has much better latency, on the order of seconds instead of Travis’s minutes (usually) or hours (recently); better concurrency; comparable incremental build times; and notably faster (30%) clean build times. Travis is also turning down travis-ci.org in favor of travis-ci.com, which requires overly broad repository permissions, so we couldn’t continue with Travis even if we wanted to. Build artifacts are cached with [Bazel remote caching] talking to a GCS bucket, `gs://tensorboard-build-cache`. This bucket is publicly readable, so PRs from untrusted forks may freely read from it. Only trusted commits will be authorized to write to the build cache. Commits to master are always trusted, so most of the time, the cache should be fairly fresh. [Bazel remote caching]: https://docs.bazel.build/versions/master/remote-caching.html To proceed, we should merge this commit, make sure that its master build works, then make it required and make Travis not required. After a few days of soaking, disable Travis entirely. If something goes wrong, we can just roll back by making Travis required again. This does not yet have daily scheduled runs. Test Plan: Note that this commit triggers a GitHub Actions workflow that succeeds. wchargin-branch: gh-actions
1 parent c22d00c commit 83ce2a2

File tree

6 files changed

+128
-19
lines changed

6 files changed

+128
-19
lines changed

.github/workflows/ci.yml

+75-3
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,6 @@
66
# Helpful YAML parser to clarify YAML syntax:
77
# https://yaml-online-parser.appspot.com/
88

9-
# For now, we only use GitHub Actions for lint checks, pending better
10-
# support for hermetic-style caching. See:
11-
# https://github.com/actions/cache/issues/109
129
name: CI
1310

1411
on:
@@ -20,11 +17,86 @@ on:
2017
pull_request: {}
2118

2219
env:
20+
# Keep this Bazel version in sync with the `versions.check` directive
21+
# in our WORKSPACE file.
22+
BAZEL_VERSION: '3.7.0'
23+
BAZEL_SHA256SUM: 'b7583eec83cc38302997098a40b8c870c37e0ab971a83cb3364c754a178b74ec'
2324
BUILDTOOLS_VERSION: '3.0.0'
2425
BUILDIFIER_SHA256SUM: 'e92a6793c7134c5431c58fbc34700664f101e5c9b1c1fcd93b97978e8b7f88db'
2526
BUILDOZER_SHA256SUM: '3d58a0b6972e4535718cdd6c12778170ea7382de7c75bc3728f5719437ffb84d'
2627

2728
jobs:
29+
build:
30+
runs-on: ubuntu-16.04
31+
needs: lint-python-flake8 # fail fast in case of "undefined variable" errors
32+
strategy:
33+
fail-fast: false
34+
matrix:
35+
tf_version_id: ['tf-nightly', 'notf']
36+
python_version: ['3.7']
37+
steps:
38+
- uses: actions/checkout@v1
39+
- uses: actions/setup-python@v1
40+
with:
41+
python-version: ${{ matrix.python_version }}
42+
architecture: 'x64'
43+
- name: 'Set up Bazel'
44+
run: |
45+
ci/download_bazel.sh "${BAZEL_VERSION}" "${BAZEL_SHA256SUM}" ~/bazel
46+
sudo mv ~/bazel /usr/local/bin/bazel
47+
sudo chmod +x /usr/local/bin/bazel
48+
cp ./ci/bazelrc ~/.bazelrc
49+
- name: 'Configure build cache write credentials'
50+
env:
51+
CREDS: ${{ secrets.BAZEL_CACHE_SERVICE_ACCOUNT_CREDS }}
52+
EVENT_TYPE: ${{ github.event_name }}
53+
run: |
54+
if [ -z "${CREDS}" ]; then
55+
printf 'Using read-only cache (no credentials)\n'
56+
exit
57+
fi
58+
if [ "${EVENT_TYPE}" = pull_request ]; then
59+
printf 'Using read-only cache (PR build)\n'
60+
exit
61+
fi
62+
printf 'Using writable cache\n'
63+
creds_file=/tmp/service_account_creds.json
64+
printf '%s\n' "${CREDS}" >"${creds_file}"
65+
printf '%s\n' >>~/.bazelrc \
66+
"common --google_credentials=${creds_file}" \
67+
"common --remote_upload_local_results=true" \
68+
;
69+
- name: 'Install Python dependencies'
70+
run: |
71+
python -m pip install -U pip
72+
pip install \
73+
-r ./tensorboard/pip_package/requirements.txt \
74+
-r ./tensorboard/pip_package/requirements_dev.txt \
75+
;
76+
- name: 'Install TensorFlow'
77+
run: pip install "${{ matrix.tf_version_id }}"
78+
if: matrix.tf_version_id != 'notf'
79+
- name: 'Check Pip state'
80+
run: pip freeze --all
81+
- name: 'Bazel: fetch'
82+
run: bazel fetch //tensorboard/...
83+
- name: 'Bazel: build'
84+
run: bazel build //tensorboard/...
85+
- name: 'Bazel: test (with TensorFlow support)'
86+
run: bazel test //tensorboard/...
87+
if: matrix.tf_version_id != 'notf'
88+
- name: 'Bazel: test (non-TensorFlow only)'
89+
run: bazel test //tensorboard/... --test_tag_filters="support_notf"
90+
if: matrix.tf_version_id == 'notf'
91+
- name: 'Bazel: run Pip package test'
92+
run: |
93+
bazel run //tensorboard/pip_package:test_pip_package -- \
94+
--tf-version "${{ matrix.tf_version_id }}"
95+
- name: 'Bazel: run manual tests'
96+
run: |
97+
bazel test //tensorboard/compat/tensorflow_stub:gfile_s3_test &&
98+
bazel test //tensorboard/summary/writer:event_file_writer_s3_test
99+
28100
lint-python-flake8:
29101
runs-on: ubuntu-16.04
30102
strategy:

.travis.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ cache:
2222
# every day, and Pip caches are never evicted, so this quickly bloats
2323
# to many gigabytes and adds minutes to the CI time.
2424
pip: false
25-
# Cache directories for Bazel. See ci/bazelrc for details.
25+
# Cache directories for Bazel. See ci/bazelrc_travis for details.
2626
directories:
2727
- $HOME/.cache/tb-bazel-repo
2828
- $HOME/.cache/tb-bazel-disk
@@ -44,7 +44,7 @@ before_install:
4444
- export BAZEL_SHA256SUM=b7583eec83cc38302997098a40b8c870c37e0ab971a83cb3364c754a178b74ec
4545
- ci/download_bazel.sh "${BAZEL}" "${BAZEL_SHA256SUM}" ~/bazel
4646
- sudo mv ~/bazel /usr/local/bin/bazel
47-
- cp ci/bazelrc ~/.bazelrc
47+
- cp ci/bazelrc_travis ~/.bazelrc
4848
- elapsed "before_install (done)"
4949

5050
install:

WORKSPACE

+1-1
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ tf_workspace()
8888

8989
load("@bazel_skylib//lib:versions.bzl", "versions")
9090
# Keep this version in sync with the BAZEL environment variable defined
91-
# in our .travis.yml config.
91+
# in our .travis.yml and .github/workflows/ci.yml configs.
9292
versions.check(minimum_bazel_version = "3.7.0")
9393

9494
load("@io_bazel_rules_sass//:package.bzl", "rules_sass_dependencies")

ci/bazelrc

+11-12
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Limit resources since Travis Trusty GCE VMs have 2 cores and 7.5 GB RAM.
1+
# Limit resources since GitHub Actions VMs have 2 cores and 7 GB RAM.
22
build --local_cpu_resources=2
33
build --local_ram_resources=4000
44
build --worker_max_instances=2
@@ -18,18 +18,17 @@ build --worker_sandboxing
1818
# https://github.com/bazelbuild/bazel/issues/7026 (future of action_env)
1919
build --action_env=PATH
2020

21-
# Set up caching on local disk so incremental builds are faster.
22-
# See https://bazel.build/designs/2016/09/30/repository-cache.html
23-
build --repository_cache=~/.cache/tb-bazel-repo
24-
fetch --repository_cache=~/.cache/tb-bazel-repo
25-
query --repository_cache=~/.cache/tb-bazel-repo
26-
# See https://docs.bazel.build/versions/master/remote-caching.html#disk-cache
27-
build --disk_cache=~/.cache/tb-bazel-disk
28-
29-
# Log more information to help with debugging, and disable curses output which
30-
# just adds more clutter to the log. (Travis spoofs an interactive terminal.)
31-
common --curses=no
21+
# Log more information to help with debugging.
3222
build --verbose_failures
3323
build --worker_verbose
3424
test --test_output=errors
3525
test --test_verbose_timeout_warnings
26+
27+
# Enable remote caching. This cache is publicly readable, but only writable on
28+
# trusted commits (e.g., commits to master). We don't write the actual test
29+
# statuses (or read them if they happen to be there) because not all tests are
30+
# actually hermetic, and they run pretty quickly, anyway.
31+
common --remote_cache=https://storage.googleapis.com/tensorboard-build-cache
32+
common --remote_upload_local_results=false
33+
test --remote_upload_local_results=false
34+
test --cache_test_results=false

ci/bazelrc_travis

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# Limit resources since Travis Trusty GCE VMs have 2 cores and 7.5 GB RAM.
2+
build --local_cpu_resources=2
3+
build --local_ram_resources=4000
4+
build --worker_max_instances=2
5+
6+
# Ensure sandboxing is on to increase hermeticity.
7+
build --spawn_strategy=sandboxed
8+
build --worker_sandboxing
9+
10+
# Ensure the PATH env var from our virtualenv propagates into tests, which is
11+
# no longer on by default in Bazel 0.21.0 and possibly again in the future.
12+
# We set this flag for "build" since "test" inherits it, but if we don't set
13+
# it for build too, this causes a rebuild at test time, and if we set it for
14+
# both we hit https://github.com/bazelbuild/bazel/issues/8237.
15+
#
16+
# See also:
17+
# https://github.com/bazelbuild/bazel/issues/7095 (protobuf PATH sensitivity)
18+
# https://github.com/bazelbuild/bazel/issues/7026 (future of action_env)
19+
build --action_env=PATH
20+
21+
# Set up caching on local disk so incremental builds are faster.
22+
# See https://bazel.build/designs/2016/09/30/repository-cache.html
23+
build --repository_cache=~/.cache/tb-bazel-repo
24+
fetch --repository_cache=~/.cache/tb-bazel-repo
25+
query --repository_cache=~/.cache/tb-bazel-repo
26+
# See https://docs.bazel.build/versions/master/remote-caching.html#disk-cache
27+
build --disk_cache=~/.cache/tb-bazel-disk
28+
29+
# Log more information to help with debugging, and disable curses output which
30+
# just adds more clutter to the log. (Travis spoofs an interactive terminal.)
31+
common --curses=no
32+
build --verbose_failures
33+
build --worker_verbose
34+
test --test_output=errors
35+
test --test_verbose_timeout_warnings

tensorboard/pip_package/test_pip_package.sh

+4-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ Test pre-built TensorBoard Pip packages.
2424
Options:
2525
--tf-version VERSION: Test against the provided version of TensorFlow,
2626
given as a Pip package specifier like "tensorflow==2.0.0a0" or
27-
"tf-nightly". If empty, will test without installing TensorFlow.
27+
"tf-nightly". If empty or "notf", will test without installing TensorFlow.
2828
Defaults to "tf-nightly".
2929
EOF
3030
}
@@ -104,6 +104,9 @@ smoke() (
104104
smoke_venv="${virtualenvs_root}/venv-${smoke_python}/"
105105
set +x
106106
printf '\n\n%70s\n' '' | tr ' ' '='
107+
if [ "${tf_version}" = notf ]; then
108+
tf_version=
109+
fi
107110
if [ -z "${tf_version}" ]; then
108111
echo "Smoke testing with ${smoke_python} and no tensorflow..."
109112
else

0 commit comments

Comments
 (0)