Skip to content

Commit

Permalink
Try using bazelbuild/setup-bazelisk everywhere.
Browse files Browse the repository at this point in the history
This should hopefully mean that the `bazel`
command found first in the path is actually
Bazelisk.

Revert various previous attempts to get all
this working...

Change-Id: I9a6267aff334de3dc55c7333d83e67ad2ad4ef05
Reviewed-on: https://code-review.googlesource.com/c/re2/+/61610
Reviewed-by: Perry Lorier <[email protected]>
Reviewed-by: Paul Wankadia <[email protected]>
  • Loading branch information
junyer committed Jul 28, 2023
1 parent c20f76e commit 44277d2
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 17 deletions.
12 changes: 6 additions & 6 deletions .github/bazel.sh
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
#!/bin/bash
set -eux

bazelisk clean
bazelisk build --compilation_mode=dbg -- //:all
bazelisk test --compilation_mode=dbg -- //:all \
bazel clean
bazel build --compilation_mode=dbg -- //:all
bazel test --compilation_mode=dbg -- //:all \
-//:dfa_test \
-//:exhaustive1_test \
-//:exhaustive2_test \
-//:exhaustive3_test \
-//:exhaustive_test \
-//:random_test

bazelisk clean
bazelisk build --compilation_mode=opt -- //:all
bazelisk test --compilation_mode=opt -- //:all \
bazel clean
bazel build --compilation_mode=opt -- //:all
bazel test --compilation_mode=opt -- //:all \
-//:dfa_test \
-//:exhaustive1_test \
-//:exhaustive2_test \
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/ci-bazel.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,7 @@ jobs:
BAZELISK_GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
steps:
- uses: actions/checkout@v3
# TODO(junyer): Use `v2` whenever a new release is tagged.
- uses: bazelbuild/setup-bazelisk@6244971d4f7ba9aca943c2f3ede2bbd813fcca51
- run: .github/bazel.sh
shell: bash
10 changes: 7 additions & 3 deletions .github/workflows/python.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ jobs:
shell: bash
- name: Build wheel
run: |
BAZELISK="$(which bazelisk)" python setup.py bdist_wheel
python setup.py bdist_wheel
python -m auditwheel repair --wheel-dir=. dist/*
shell: bash
working-directory: python
Expand Down Expand Up @@ -70,6 +70,8 @@ jobs:
SYSTEM_VERSION_COMPAT: 0
steps:
- uses: actions/checkout@v3
# TODO(junyer): Use `v2` whenever a new release is tagged.
- uses: bazelbuild/setup-bazelisk@6244971d4f7ba9aca943c2f3ede2bbd813fcca51
- uses: actions/setup-python@v4
with:
python-version: ${{ matrix.ver }}
Expand All @@ -81,7 +83,7 @@ jobs:
shell: bash
- name: Build wheel
run: |
BAZELISK="$(which bazelisk)" python setup.py bdist_wheel \
python setup.py bdist_wheel \
--plat-name=macosx-${{ matrix.os }}.0-${{ matrix.arch.python-name }}
python -m delocate.cmd.delocate_wheel --wheel-dir=. dist/*
shell: bash
Expand Down Expand Up @@ -117,6 +119,8 @@ jobs:
BAZEL_CPU: ${{ matrix.arch.bazel-name }}_windows
steps:
- uses: actions/checkout@v3
# TODO(junyer): Use `v2` whenever a new release is tagged.
- uses: bazelbuild/setup-bazelisk@6244971d4f7ba9aca943c2f3ede2bbd813fcca51
- uses: actions/setup-python@v4
with:
python-version: ${{ matrix.ver }}
Expand All @@ -128,7 +132,7 @@ jobs:
shell: bash
- name: Build wheel
run: |
BAZELISK="$(which bazelisk)" python setup.py bdist_wheel \
python setup.py bdist_wheel \
--plat-name=${{ matrix.arch.python-name }}
python -m delvewheel --wheel-dir=. dist/*
shell: bash
Expand Down
10 changes: 5 additions & 5 deletions app/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ set -eux
SRCDIR=$(readlink --canonicalize $(dirname $0))
DSTDIR=$(mktemp --directory --tmpdir $(basename $0).XXXXXXXXXX)

BAZELISK=/tmp/bazelisk
BAZEL=/tmp/bazel
BAZELISK_RELEASE=v1.17.0

if [[ ${UID} -ne 0 ]]; then
Expand All @@ -16,18 +16,18 @@ if [[ ${UID} -ne 0 ]]; then
sudo docker run -i -t --pull always --rm -v ${SRCDIR}/..:/src -v ${PWD}:/dst emscripten/emsdk /src/app/$(basename $0)
ls -l deploy
else
wget -O ${BAZELISK} https://github.com/bazelbuild/bazelisk/releases/download/${BAZELISK_RELEASE}/bazelisk-linux-amd64
chmod +x ${BAZELISK}
wget -O ${BAZEL} https://github.com/bazelbuild/bazelisk/releases/download/${BAZELISK_RELEASE}/bazelisk-linux-amd64
chmod +x ${BAZEL}

cd ${SRCDIR}
# Emscripten doesn't support `-fstack-protector`.
AR=emar CC=emcc \
${BAZELISK} build --compilation_mode=opt \
${BAZEL} build --compilation_mode=opt \
--copt=-fno-stack-protector \
-- :all
cp ../bazel-bin/app/_re2.js ${DSTDIR}
# Clean up the sundry Bazel output directories.
${BAZELISK} clean --expunge
${BAZEL} clean --expunge
cp app.ts index.html _re2.d.ts ${DSTDIR}
cp package.json rollup.config.js tsconfig.json ${DSTDIR}

Expand Down
6 changes: 3 additions & 3 deletions python/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,13 @@
class BuildExt(setuptools.command.build_ext.build_ext):

def build_extension(self, ext):
if 'BAZELISK' not in os.environ:
if 'GITHUB_ACTIONS' not in os.environ:
return super().build_extension(ext)

# For @pybind11_bazel's `python_configure()`.
os.environ['PYTHON_BIN_PATH'] = sys.executable

cmd = [os.environ['BAZELISK'], 'build']
cmd = ['bazel', 'build']
if 'BAZEL_CPU' in os.environ:
cmd.append(f'--cpu={os.environ["BAZEL_CPU"].lower()}')
cmd += ['--compilation_mode=opt', '--', ':all']
Expand All @@ -62,7 +62,7 @@ def build_extension(self, ext):
shutil.copyfile('../bazel-bin/python/_re2.so',
self.get_ext_fullpath(ext.name))

cmd = [os.environ['BAZELISK'], 'clean', '--expunge']
cmd = ['bazel', 'clean', '--expunge']
self.spawn(cmd)


Expand Down

0 comments on commit 44277d2

Please sign in to comment.