Skip to content

Commit

Permalink
Switch ci_docker to a container based on ubuntu 20.04 (#1334)
Browse files Browse the repository at this point in the history
* Create a 20.04-based dockerfile with rust and all our required packages
* Use the new docker container from ci jobs, including the wheel builder
* Force manylinux_2_31
* Install newer binaryen
  • Loading branch information
jleibs authored Feb 17, 2023
1 parent 3e4c194 commit 6901c4f
Show file tree
Hide file tree
Showing 5 changed files with 109 additions and 49 deletions.
87 changes: 55 additions & 32 deletions .github/workflows/python.yml
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ jobs:
matrix+=('{"platform": "macos", "runs_on": "macos-latest"},')
fi
matrix+=('{"platform": "windows", "runs_on": "windows-latest-8-cores"},')
matrix+=('{"platform": "linux", "runs_on": "ubuntu-latest-16-cores"}')
matrix+=('{"platform": "linux", "runs_on": "ubuntu-latest-16-cores", container: {"image": "rerunio/ci_docker:0.5"}}')
echo "Matrix values: ${matrix[@]}"
Expand All @@ -105,15 +105,20 @@ jobs:

runs-on: ${{ matrix.runs_on }}

container: ${{ matrix.container }}

steps:
- uses: actions/checkout@v3

# These should already be in the docker container, but run for good measure. A no-op install
# should be fast, and this way things don't break if we add new packages without rebuilding
# docker
- name: Cache APT Packages
if: matrix.platform == 'linux'
uses: awalsh128/[email protected]
with:
packages: ${{ env.UBUNTU_REQUIRED_PKGS }}
version: 1.0
version: 2.0 # Increment this to pull newer packages
execute_install_scripts: true

- name: Set up cargo cache
Expand All @@ -125,13 +130,19 @@ jobs:
# the cache. Better cross-job sequencing would be nice here
save-if: False

# The pip-cache setup logic doesn't work in the ubuntu docker container
# That's probably fine since we bake these deps into the container already
- name: Setup python
if: matrix.platform != 'linux'
uses: actions/setup-python@v4
with:
python-version: ${{ env.PYTHON_VERSION }}
cache: "pip"
cache-dependency-path: "rerun_py/requirements-build.txt"

# These should already be in the docker container, but run for good measure. A no-op install
# should be fast, and this way things don't break if we add new packages without rebuilding
# docker
- run: pip install -r rerun_py/requirements-build.txt

# ----------------------------------------------------------------------------------
Expand All @@ -140,11 +151,13 @@ jobs:
# We have a nice script for that: ./scripts/setup_web.sh
# Unfortunately, we can't run that on Windows, because Windows doesn't come with
# a package manager like grown-up OSes do (at least not the CI version of Windows).
# So we only run the script on !Windows, and then on Windows we do the parts of the script manually.
# That way we still get to test the script on Linux and Mac.
# Also we can't run it on linux because the 20.04 Docker container will install
# an old version of binaryen/wasm-opt that barfs on the `--fast-math` flag
# So we only run the script on macos, and then on Windows we do the parts of the script manually.
# On ubuntu, the correct packages are pre-installed in our docker container.

- name: Install prerequisites for building the web-viewer Wasm (non-Windows)
if: matrix.platform != 'windows'
if: matrix.platform == 'macos'
shell: bash
run: ./scripts/setup_web.sh

Expand Down Expand Up @@ -181,30 +194,11 @@ jobs:
run: |
python scripts/version_util.py --check_version
- name: Build and install rerun
run: pip install rerun_py/

- name: Cache RRD dataset
id: dataset
uses: actions/cache@v3
with:
path: examples/python/colmap/dataset/
# TODO(jleibs): Derive this key from the invocation below
key: colmap-dataset-colmap-fiat-v0

- name: Generate Embedded RRD file
shell: bash
# If you change the line below you should almost definitely change the `key:` line above by giving it a new, unique name
run: |
pip install -r examples/python/colmap/requirements.txt
python examples/python/colmap/main.py --dataset colmap_fiat --resize 800x600 --save colmap.rrd
cp colmap.rrd rerun_py/rerun_sdk/rerun_demo/colmap.rrd
- name: Build Wheel
uses: PyO3/maturin-action@v1
with:
maturin-version: "0.14.10"
manylinux: auto
manylinux: manylinux_2_31
container: off
command: build
args: |
Expand All @@ -213,18 +207,47 @@ jobs:
--no-default-features
--features pypi
--universal2
--out dist
--out pre-dist
- name: Install built wheel
run: |
pip install rerun-sdk --find-links dist --force-reinstall
pip install pytest #TODO(john) move to requirements-build.txt
cd rerun_py/tests && pytest
pip install rerun-sdk --find-links pre-dist --force-reinstall
- name: Run tests
run: cd rerun_py/tests && pytest

- name: Unpack the wheel
shell: bash
run: |
mkdir unpack-dist
wheel unpack pre-dist/*.whl --dest unpack-dist
- name: Run Car example
- name: Get the folder name
shell: bash
run: |
echo "pkg_folder=$(ls unpack-dist)" >> $GITHUB_ENV
- name: Cache RRD dataset
id: dataset
uses: actions/cache@v3
with:
path: examples/python/colmap/dataset/
# TODO(jleibs): Derive this key from the invocation below
key: colmap-dataset-colmap-fiat-v0

- name: Generate Embedded RRD file
shell: bash
# If you change the line below you should almost definitely change the `key:` line above by giving it a new, unique name
run: |
pip install -r examples/python/colmap/requirements.txt
python3 examples/python/colmap/main.py --dataset colmap_fiat --resize 800x600 --save colmap.rrd
cp colmap.rrd unpack-dist/${{ env.pkg_folder }}/rerun_sdk/rerun_demo/colmap.rrd
- name: Repack the wheel
shell: bash
run: |
pip install -r examples/python/car/requirements.txt
python examples/python/car/main.py --headless
mkdir dist
wheel pack unpack-dist/${{ env.pkg_folder }} --dest dist/
- name: Upload wheels
uses: actions/upload-artifact@v3
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ jobs:

runs-on: ubuntu-latest-16-cores
container:
image: rerunio/ci_docker:0.4
image: rerunio/ci_docker:0.5
env:
RUSTFLAGS: ${{env.RUSTFLAGS}}
RUSTDOCFLAGS: ${{env.RUSTDOCFLAGS}}
Expand Down Expand Up @@ -89,7 +89,7 @@ jobs:
name: Rust lints (fmt, check, cranky, tests, doc)
runs-on: ubuntu-latest-16-cores
container:
image: rerunio/ci_docker:0.4
image: rerunio/ci_docker:0.5
env:
RUSTFLAGS: ${{env.RUSTFLAGS}}
RUSTDOCFLAGS: ${{env.RUSTDOCFLAGS}}
Expand Down Expand Up @@ -186,7 +186,7 @@ jobs:
name: Check Rust web build (wasm32 + wasm-bindgen)
runs-on: ubuntu-latest-16-cores
container:
image: rerunio/ci_docker:0.4
image: rerunio/ci_docker:0.5
env:
RUSTFLAGS: ${{env.RUSTFLAGS}}
RUSTDOCFLAGS: ${{env.RUSTDOCFLAGS}}
Expand Down Expand Up @@ -227,7 +227,7 @@ jobs:
name: Check Rust dependencies (cargo-deny)
runs-on: ubuntu-latest-16-cores
container:
image: rerunio/ci_docker:0.4
image: rerunio/ci_docker:0.5
env:
RUSTFLAGS: ${{env.RUSTFLAGS}}
RUSTDOCFLAGS: ${{env.RUSTDOCFLAGS}}
Expand Down
59 changes: 47 additions & 12 deletions ci_docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,19 +1,16 @@
FROM rust:1.67
FROM ubuntu:20.04
LABEL maintainer="[email protected]"
# Remember to update the version in publish.sh
# TODO(jleibs) use this version in the publish.sh script and below in the CACHE_KEY
LABEL version="0.4"
LABEL version="0.5"
LABEL description="Docker image used for the CI of https://github.com/rerun-io/rerun"

# Install some cargo tools we know we'll always need
# We do this first in its own layer because the layer is quite large (500MB+)
# And updating the crates.io index is one of the slower steps
RUN cargo install cargo-deny && \
cargo install cargo-cranky

# Install the ubuntu package dependencies
ENV DEBIAN_FRONTEND=noninteractive
RUN apt-get update && apt-get install -y --no-install-recommends \
build-essential \
curl \
git \
libatk-bridge2.0 \
libfontconfig1-dev \
libfreetype6-dev \
Expand All @@ -24,19 +21,57 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
libxcb-shape0-dev \
libxcb-xfixes0-dev \
libxkbcommon-dev \
patchelf \
python3-pip && \
lsb-release \
python3-pip \
sudo \
wget && \
rm -rf /var/lib/apt/lists/*

# Need a more recent pip for manylinux packages to work properly
RUN python3 -m pip install -U pip

# We need a more modern patchelf than ships on ubuntu-20.04
RUN curl -L https://github.com/NixOS/patchelf/releases/download/0.17.2/patchelf-0.17.2-x86_64.tar.gz | tar -xz ./bin/patchelf

ENV RUSTUP_HOME=/usr/local/rustup \
CARGO_HOME=/usr/local/cargo \
PATH=/usr/local/cargo/bin:$PATH \
RUST_VERSION=1.67 \
RUSTUP_VERSION=1.25.2

# Install Rust
# Borrowed from: https://github.com/rust-lang/docker-rust/blob/master/1.67.1/bookworm/Dockerfile
RUN set -eux; \
rustArch='x86_64-unknown-linux-gnu'; \
rustupSha256='bb31eaf643926b2ee9f4d8d6fc0e2835e03c0a60f34d324048aa194f0b29a71c'; \
url="https://static.rust-lang.org/rustup/archive/${RUSTUP_VERSION}/${rustArch}/rustup-init"; \
wget "$url"; \
echo "${rustupSha256} *rustup-init" | sha256sum -c -; \
chmod +x rustup-init; \
./rustup-init -y --no-modify-path --profile minimal --default-toolchain $RUST_VERSION --default-host ${rustArch}; \
rm rustup-init; \
chmod -R a+w $RUSTUP_HOME $CARGO_HOME; \
rustup --version; \
cargo --version; \
rustc --version;

# Install some cargo tools we know we'll always need
# We can't do this until after we've installed rust / cargo above
RUN cargo install cargo-deny && \
cargo install cargo-cranky

# Install the python build dependencies
ADD rerun_py/requirements-build.txt requirements-build.txt
RUN pip install -r requirements-build.txt

# Install some additional versioned cargo tools
# Install tools from setup_web.sh
RUN cargo install [email protected]
# Note: We need a more modern binaryen than ships on ubuntu-20.4, so we pull it from github
RUN curl -L https://github.com/WebAssembly/binaryen/releases/download/version_112/binaryen-version_112-x86_64-linux.tar.gz | tar xzk --strip-components 1

# Increment this to invalidate cache
ENV CACHE_KEY=rerun_docker_v0.4
ENV CACHE_KEY=rerun_docker_v0.5

# See: https://github.com/actions/runner-images/issues/6775#issuecomment-1410270956
RUN git config --system --add safe.directory '*'

2 changes: 1 addition & 1 deletion ci_docker/publish.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
VERSION=0.4 # Bump on each new version. Remember to update the version in the Dockerfile too.
VERSION=0.5 # Bump on each new version. Remember to update the version in the Dockerfile too.

# The build needs to run from top of repo to access the requirments.txt
cd `git rev-parse --show-toplevel`
Expand Down
2 changes: 2 additions & 0 deletions rerun_py/requirements-build.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
maturin>=0.14,<0.15
semver>=2.13,<2.14
wheel>=0.38,<0.39
pytest

1 comment on commit 6901c4f

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rust Benchmark

Benchmark suite Current: 6901c4f Previous: 3e4c194 Ratio
datastore/insert/batch/rects/insert 558217 ns/iter (± 3053) 540725 ns/iter (± 2227) 1.03
datastore/latest_at/batch/rects/query 1793 ns/iter (± 7) 1755 ns/iter (± 2) 1.02
datastore/latest_at/missing_components/primary 354 ns/iter (± 2) 353 ns/iter (± 1) 1.00
datastore/latest_at/missing_components/secondaries 424 ns/iter (± 1) 427 ns/iter (± 1) 0.99
datastore/range/batch/rects/query 148385 ns/iter (± 1561) 150206 ns/iter (± 860) 0.99
mono_points_arrow/generate_message_bundles 47221976 ns/iter (± 1465270) 49609027 ns/iter (± 943220) 0.95
mono_points_arrow/generate_messages 136195440 ns/iter (± 1614877) 136498653 ns/iter (± 2062401) 1.00
mono_points_arrow/encode_log_msg 162414955 ns/iter (± 1189441) 162033433 ns/iter (± 1165883) 1.00
mono_points_arrow/encode_total 350379018 ns/iter (± 2174970) 351528716 ns/iter (± 2442649) 1.00
mono_points_arrow/decode_log_msg 186044719 ns/iter (± 1512954) 184181248 ns/iter (± 938139) 1.01
mono_points_arrow/decode_message_bundles 72644867 ns/iter (± 1282815) 73907825 ns/iter (± 1050583) 0.98
mono_points_arrow/decode_total 256273222 ns/iter (± 2289841) 256444627 ns/iter (± 1828361) 1.00
batch_points_arrow/generate_message_bundles 338381 ns/iter (± 3477) 325834 ns/iter (± 1558) 1.04
batch_points_arrow/generate_messages 6220 ns/iter (± 59) 6079 ns/iter (± 44) 1.02
batch_points_arrow/encode_log_msg 367090 ns/iter (± 1961) 358387 ns/iter (± 1510) 1.02
batch_points_arrow/encode_total 720022 ns/iter (± 5654) 708351 ns/iter (± 3107) 1.02
batch_points_arrow/decode_log_msg 346918 ns/iter (± 1038) 349352 ns/iter (± 1130) 0.99
batch_points_arrow/decode_message_bundles 2045 ns/iter (± 13) 2011 ns/iter (± 13) 1.02
batch_points_arrow/decode_total 353741 ns/iter (± 2471) 355771 ns/iter (± 1410) 0.99
arrow_mono_points/insert 6989480303 ns/iter (± 21458978) 7030803564 ns/iter (± 19043358) 0.99
arrow_mono_points/query 1732635 ns/iter (± 16162) 1665206 ns/iter (± 13687) 1.04
arrow_batch_points/insert 2657545 ns/iter (± 30778) 2659189 ns/iter (± 15340) 1.00
arrow_batch_points/query 16797 ns/iter (± 200) 16791 ns/iter (± 85) 1.00
tuid/Tuid::random 34 ns/iter (± 0) 34 ns/iter (± 0) 1

This comment was automatically generated by workflow using github-action-benchmark.

Please sign in to comment.