This repository has been archived by the owner on Feb 28, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 13
Set up a smoke test pass that check if Substrate/Polkadot build using dist sccache #77
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
f28668b
Add an example Compose local sccache-dist setup
Xanewok b1623fc
Add a simple client conf for dist sccache
Xanewok 5931b93
ci: Add smoke tests to see if select projects build with dist sccache
Xanewok 981d4da
Allow to vendor `sccache-dist` binary in the container
Xanewok c876fca
ci: Re-use precompiled musl binaries when running `smoke` job
Xanewok 2c5675c
ci: Cache intermediate artifacts in the `build` job
Xanewok File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
FROM ubuntu:18.04 as bwrap-build | ||
RUN apt-get update && \ | ||
apt-get install -y wget xz-utils gcc libcap-dev make && \ | ||
apt-get clean | ||
RUN wget -q -O - https://github.com/projectatomic/bubblewrap/releases/download/v0.3.1/bubblewrap-0.3.1.tar.xz | \ | ||
tar -xJ | ||
RUN cd /bubblewrap-0.3.1 && \ | ||
./configure --disable-man && \ | ||
make | ||
|
||
FROM rust:1.52-buster as sccache-build | ||
RUN git clone https://github.com/paritytech/sccache.git --depth=1 && \ | ||
cd sccache && \ | ||
cargo build --bin sccache-dist --release --features="dist-server" | ||
|
||
FROM ubuntu:18.04 | ||
RUN apt-get update && \ | ||
apt-get install libcap2 libssl1.1 && \ | ||
apt-get clean | ||
COPY --from=bwrap-build /bubblewrap-0.3.1/bwrap /usr/bin/bwrap | ||
COPY --from=sccache-build /sccache/target/release/sccache-dist /usr/bin/sccache-dist | ||
CMD [ "sccache-dist" ] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# A version of `Dockerfile.build.sccache-dist` that skips the build stage and | ||
# instead copies over the locally pre-built `sccache-dist` binary. | ||
# TODO: Switch to BuildKit with Docker/Compose support when available, which | ||
# allows us to unify these into a single Dockerfile | ||
FROM ubuntu:18.04 as bwrap-build | ||
RUN apt-get update && \ | ||
apt-get install -y wget xz-utils gcc libcap-dev make && \ | ||
apt-get clean | ||
RUN wget -q -O - https://github.com/projectatomic/bubblewrap/releases/download/v0.3.1/bubblewrap-0.3.1.tar.xz | \ | ||
tar -xJ | ||
RUN cd /bubblewrap-0.3.1 && \ | ||
./configure --disable-man && \ | ||
make | ||
|
||
FROM ubuntu:18.04 | ||
RUN apt-get update && \ | ||
apt-get install libcap2 libssl1.1 && \ | ||
apt-get clean | ||
COPY --from=bwrap-build /bubblewrap-0.3.1/bwrap /usr/bin/bwrap | ||
ADD sccache-dist /usr/bin/sccache-dist | ||
CMD [ "sccache-dist" ] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
[dist] | ||
# The URL used to connect to the scheduler (should use https, given an ideal | ||
# setup of a HTTPS server in front of the scheduler) | ||
scheduler_url = "http://172.25.0.10:10600" | ||
# Used for mapping local toolchains to remote cross-compile toolchains. Empty in | ||
# this example where the client and build server are both Linux. | ||
toolchains = [] | ||
# Size of the local toolchain cache, in bytes (5GB here, 10GB if unspecified). | ||
toolchain_cache_size = 5368709120 | ||
|
||
[dist.auth] | ||
type = "token" | ||
# This should match the `client_auth` section of the scheduler config. | ||
token = "a concrete secret that's shared client and scheduler" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
# An example setup for a distributed sccache cluster that uses | ||
# - a single scheduler (172.25.0.10) | ||
# - a single build server (172.25.0.11) | ||
# both served from a local network. | ||
# To test this locally, make sure to set up `dist.scheduler_url` and `dist.auth` | ||
# correctly, as used by the `sccache` binary (the "client") and verify that the | ||
# connection works by running `sccache --dist-status`. | ||
# It's worth noting that the security is virtually none using this exact setup. | ||
# To correctly set everything up (e.g. set up auth across scheduler <-> server | ||
# and client <-> scheduler, use HTTPS for the scheduler) refer to the | ||
# `docs/Distributed.md` file. | ||
version: "3.6" | ||
|
||
services: | ||
scheduler: | ||
build: | ||
context: . | ||
dockerfile: Dockerfile.${SCCACHE_IN_DOCKERFILE:-build}.sccache-dist | ||
environment: | ||
RUST_LOG: | ||
SCCACHE_NO_DAEMON: 1 | ||
SCCACHE_CONFIG_TOML: | | ||
public_addr = "172.25.0.10:10600" | ||
[server_auth] | ||
type = "DANGEROUSLY_INSECURE" | ||
[client_auth] | ||
type = "token" | ||
token = "a concrete secret that's shared client and scheduler" | ||
ports: | ||
- 10600 | ||
networks: | ||
dist_network: | ||
ipv4_address: 172.25.0.10 | ||
command: /bin/sh -c "echo \"$$SCCACHE_CONFIG_TOML\" > config.toml; sccache-dist scheduler --config config.toml" | ||
server: | ||
# XXX: For the time being, due to the usage of bubblewrap and overlayfs | ||
# we are required to run this in the privileged mode (as we do in the | ||
# integration tests). Please keep that in mind when running the container. | ||
# TODO: In the future we'd like to run the build sandbox in an unprivileged | ||
# mode. | ||
privileged: true | ||
build: | ||
context: . | ||
dockerfile: Dockerfile.${SCCACHE_IN_DOCKERFILE:-build}.sccache-dist | ||
environment: | ||
RUST_LOG: | ||
SCCACHE_NO_DAEMON: 1 | ||
SCCACHE_CONFIG_TOML: | | ||
# A public IP address and port that clients will use to connect to this builder. | ||
public_addr = "172.25.0.11:10501" | ||
# The URL used to connect to the scheduler (should use https, given an ideal | ||
# setup of a HTTPS server in front of the scheduler) | ||
scheduler_url = "http://172.25.0.10:10600" | ||
# The maximum size of the toolchain cache, in bytes. | ||
# If unspecified the default is 10GB. | ||
# toolchain_cache_size = 10737418240 | ||
cache_dir="/sccache-dirs/cache/" | ||
|
||
[builder] | ||
type = "overlay" | ||
build_dir = "/sccache-dirs/builder/" | ||
# The path to the bubblewrap version 0.3.0+ `bwrap` binary. | ||
bwrap_path = "/usr/bin/bwrap" | ||
|
||
[scheduler_auth] | ||
type = "DANGEROUSLY_INSECURE" | ||
ports: | ||
- 10501 | ||
networks: | ||
dist_network: | ||
ipv4_address: 172.25.0.11 | ||
tmpfs: | ||
- /sccache-dirs | ||
command: /bin/sh -c "echo \"$$SCCACHE_CONFIG_TOML\" > config.toml; sccache-dist server --config config.toml" | ||
# We need to set static IPs for the services as scheduler/server always use it | ||
# to authorize themselves (even when using the DANGEROUSLY_INSECURE scheme) | ||
networks: | ||
dist_network: | ||
ipam: | ||
driver: default | ||
config: | ||
- subnet: 172.25.0.0/24 |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My Docker-fu is not that great and maybe there's a way to share a single Dockerfile that allows to either vendor a binary from outside or build the project if needed, without resorting to Buildkit (IIUC Compose needs a very recent version that even supports that). @drahnr @gww-parity do you have an idea if we can deduplicate
Dockerfile.{build,vendor}.sccache-dist
somehow?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The vendor one is just to save time in the CI while the build one is to provide a more self-contained example Dockerfile that can be used by others (technically vendor can be as well but the user needs to be on a compatible distro or know to compile targeting
musl
)