Skip to content

Optimise docker cache #2

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 10 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
91 changes: 41 additions & 50 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ name: CI
- try-perf
- automation/bors/try
- master
- optimise-docker-cache
pull_request:
branches:
- "**"
Expand Down Expand Up @@ -52,18 +53,8 @@ jobs:
strategy:
matrix:
include:
- name: mingw-check
os: ubuntu-20.04-4core-16gb
env: {}
- name: mingw-check-tidy
os: ubuntu-20.04-4core-16gb
env: {}
- name: x86_64-gnu-llvm-16
env:
ENABLE_GCC_CODEGEN: "1"
os: ubuntu-20.04-16core-64gb
- name: x86_64-gnu-tools
os: ubuntu-20.04-16core-64gb
- name: temp
os: ubuntu-20.04
env: {}
timeout-minutes: 600
runs-on: "${{ matrix.os }}"
Expand Down Expand Up @@ -194,128 +185,128 @@ jobs:
- ARM64
- linux
- name: arm-android
os: ubuntu-20.04-8core-32gb
os: ubuntu-20.04
env: {}
- name: armhf-gnu
os: ubuntu-20.04-8core-32gb
os: ubuntu-20.04
env: {}
- name: dist-aarch64-linux
env:
CODEGEN_BACKENDS: "llvm,cranelift"
os: ubuntu-20.04-8core-32gb
os: ubuntu-20.04
- name: dist-android
os: ubuntu-20.04-8core-32gb
os: ubuntu-20.04
env: {}
- name: dist-arm-linux
os: ubuntu-20.04-16core-64gb
os: ubuntu-20.04
env: {}
- name: dist-armhf-linux
os: ubuntu-20.04-8core-32gb
os: ubuntu-20.04
env: {}
- name: dist-armv7-linux
os: ubuntu-20.04-8core-32gb
os: ubuntu-20.04
env: {}
- name: dist-i586-gnu-i586-i686-musl
os: ubuntu-20.04-8core-32gb
os: ubuntu-20.04
env: {}
- name: dist-i686-linux
os: ubuntu-20.04-8core-32gb
os: ubuntu-20.04
env: {}
- name: dist-loongarch64-linux
os: ubuntu-20.04-8core-32gb
os: ubuntu-20.04
env: {}
- name: dist-powerpc-linux
os: ubuntu-20.04-8core-32gb
os: ubuntu-20.04
env: {}
- name: dist-powerpc64-linux
os: ubuntu-20.04-8core-32gb
os: ubuntu-20.04
env: {}
- name: dist-powerpc64le-linux
os: ubuntu-20.04-8core-32gb
os: ubuntu-20.04
env: {}
- name: dist-riscv64-linux
os: ubuntu-20.04-8core-32gb
os: ubuntu-20.04
env: {}
- name: dist-s390x-linux
os: ubuntu-20.04-8core-32gb
os: ubuntu-20.04
env: {}
- name: dist-various-1
os: ubuntu-20.04-8core-32gb
os: ubuntu-20.04
env: {}
- name: dist-various-2
os: ubuntu-20.04-8core-32gb
os: ubuntu-20.04
env: {}
- name: dist-x86_64-freebsd
os: ubuntu-20.04-8core-32gb
os: ubuntu-20.04
env: {}
- name: dist-x86_64-illumos
os: ubuntu-20.04-8core-32gb
os: ubuntu-20.04
env: {}
- name: dist-x86_64-linux
env:
CODEGEN_BACKENDS: "llvm,cranelift"
os: ubuntu-20.04-16core-64gb
os: ubuntu-20.04
- name: dist-x86_64-linux-alt
env:
IMAGE: dist-x86_64-linux
CODEGEN_BACKENDS: "llvm,cranelift"
os: ubuntu-20.04-16core-64gb
os: ubuntu-20.04
- name: dist-x86_64-musl
env:
CODEGEN_BACKENDS: "llvm,cranelift"
os: ubuntu-20.04-8core-32gb
os: ubuntu-20.04
- name: dist-x86_64-netbsd
os: ubuntu-20.04-8core-32gb
os: ubuntu-20.04
env: {}
- name: i686-gnu
os: ubuntu-20.04-8core-32gb
os: ubuntu-20.04
env: {}
- name: i686-gnu-nopt
os: ubuntu-20.04-8core-32gb
os: ubuntu-20.04
env: {}
- name: mingw-check
os: ubuntu-20.04-4core-16gb
os: ubuntu-20.04
env: {}
- name: test-various
os: ubuntu-20.04-8core-32gb
os: ubuntu-20.04
env: {}
- name: x86_64-gnu
os: ubuntu-20.04-4core-16gb
os: ubuntu-20.04
env: {}
- name: x86_64-gnu-stable
env:
IMAGE: x86_64-gnu
RUST_CI_OVERRIDE_RELEASE_CHANNEL: stable
CI_ONLY_WHEN_CHANNEL: nightly
os: ubuntu-20.04-4core-16gb
os: ubuntu-20.04
- name: x86_64-gnu-aux
os: ubuntu-20.04-4core-16gb
os: ubuntu-20.04
env: {}
- name: x86_64-gnu-integration
env:
CI_ONLY_WHEN_CHANNEL: nightly
os: ubuntu-20.04-8core-32gb
os: ubuntu-20.04
- name: x86_64-gnu-debug
os: ubuntu-20.04-8core-32gb
os: ubuntu-20.04
env: {}
- name: x86_64-gnu-distcheck
os: ubuntu-20.04-8core-32gb
os: ubuntu-20.04
env: {}
- name: x86_64-gnu-llvm-17
env:
RUST_BACKTRACE: 1
os: ubuntu-20.04-8core-32gb
os: ubuntu-20.04
- name: x86_64-gnu-llvm-16
env:
RUST_BACKTRACE: 1
os: ubuntu-20.04-8core-32gb
os: ubuntu-20.04
- name: x86_64-gnu-nopt
os: ubuntu-20.04-4core-16gb
os: ubuntu-20.04
env: {}
- name: x86_64-gnu-tools
env:
DEPLOY_TOOLSTATES_JSON: toolstates-linux.json
os: ubuntu-20.04-8core-32gb
os: ubuntu-20.04
- name: dist-x86_64-apple
env:
SCRIPT: "./x.py dist bootstrap --include-default-paths --host=x86_64-apple-darwin --target=x86_64-apple-darwin"
Expand Down Expand Up @@ -588,7 +579,7 @@ jobs:
- name: dist-x86_64-linux
env:
CODEGEN_BACKENDS: "llvm,cranelift"
os: ubuntu-20.04-16core-64gb
os: ubuntu-20.04
timeout-minutes: 600
runs-on: "${{ matrix.os }}"
steps:
Expand Down
29 changes: 29 additions & 0 deletions src/ci/docker/host-x86_64/temp/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
FROM ubuntu:22.04

ARG DEBIAN_FRONTEND=noninteractive
RUN apt-get update && apt-get install -y --no-install-recommends \
g++ \
make \
ninja-build \
file \
curl \
ca-certificates \
python3 \
git \
cmake \
sudo \
gdb \
libssl-dev \
pkg-config \
xz-utils \
mingw-w64 \
&& rm -rf /var/lib/apt/lists/*

COPY scripts/sccache.sh /scripts/
RUN sh /scripts/sccache.sh

ENV RUST_CONFIGURE_ARGS \
--build=x86_64-unknown-linux-gnu \
--enable-sanitizers \
--enable-profiler \
--enable-compiler-docs
74 changes: 39 additions & 35 deletions src/ci/docker/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ export MSYS_NO_PATHCONV=1
script=`cd $(dirname $0) && pwd`/`basename $0`

image=""

dev=0

while [[ $# -gt 0 ]]
Expand Down Expand Up @@ -94,7 +95,7 @@ if [ -f "$docker_dir/$image/Dockerfile" ]; then

# On non-CI or PR jobs, we don't have permissions to write to the registry cache, so we should
# not use `docker login` nor caching.
if [[ "$CI" == "" ]] || [[ "$PR_CI_JOB" == "1" ]];
if [[ "$CI" == "" ]];
then
retry docker build --rm -t rust-ci -f "$dockerfile" "$context"
else
Expand Down Expand Up @@ -132,6 +133,7 @@ if [ -f "$docker_dir/$image/Dockerfile" ]; then

# Tag the built image and push it to the registry
docker tag rust-ci "${IMAGE_TAG}"
echo ">>>>>>>>>>>>>>>>>> ${IMAGE_TAG}"
docker push "${IMAGE_TAG}"

# Record the container registry tag/url for reuse, e.g. by rustup.rs builds
Expand Down Expand Up @@ -293,37 +295,39 @@ if [ "$ENABLE_GCC_CODEGEN" = "1" ]; then
echo "Setting extra environment values for docker: $extra_env"
fi

docker \
run \
--workdir /checkout/obj \
--env SRC=/checkout \
$extra_env \
$args \
--env CARGO_HOME=/cargo \
--env DEPLOY \
--env DEPLOY_ALT \
--env CI \
--env GITHUB_ACTIONS \
--env GITHUB_REF \
--env GITHUB_STEP_SUMMARY="/checkout/obj/${SUMMARY_FILE}" \
--env TOOLSTATE_REPO_ACCESS_TOKEN \
--env TOOLSTATE_REPO \
--env TOOLSTATE_PUBLISH \
--env RUST_CI_OVERRIDE_RELEASE_CHANNEL \
--env CI_JOB_NAME="${CI_JOB_NAME-$IMAGE}" \
--env BASE_COMMIT="$BASE_COMMIT" \
--env DIST_TRY_BUILD \
--env PR_CI_JOB \
--env OBJDIR_ON_HOST="$objdir" \
--env CODEGEN_BACKENDS \
--init \
--rm \
rust-ci \
"${command[@]}"

cat $objdir/${SUMMARY_FILE} >> "${GITHUB_STEP_SUMMARY}"

if [ -f /.dockerenv ]; then
rm -rf $objdir
docker cp checkout:/checkout/obj $objdir
fi
echo "${command[@]}"

# docker \
# run \
# --workdir /checkout/obj \
# --env SRC=/checkout \
# $extra_env \
# $args \
# --env CARGO_HOME=/cargo \
# --env DEPLOY \
# --env DEPLOY_ALT \
# --env CI \
# --env GITHUB_ACTIONS \
# --env GITHUB_REF \
# --env GITHUB_STEP_SUMMARY="/checkout/obj/${SUMMARY_FILE}" \
# --env TOOLSTATE_REPO_ACCESS_TOKEN \
# --env TOOLSTATE_REPO \
# --env TOOLSTATE_PUBLISH \
# --env RUST_CI_OVERRIDE_RELEASE_CHANNEL \
# --env CI_JOB_NAME="${CI_JOB_NAME-$IMAGE}" \
# --env BASE_COMMIT="$BASE_COMMIT" \
# --env DIST_TRY_BUILD \
# --env PR_CI_JOB \
# --env OBJDIR_ON_HOST="$objdir" \
# --env CODEGEN_BACKENDS \
# --init \
# --rm \
# rust-ci \
# "${command[@]}"

# cat $objdir/${SUMMARY_FILE} >> "${GITHUB_STEP_SUMMARY}"

# if [ -f /.dockerenv ]; then
# rm -rf $objdir
# docker cp checkout:/checkout/obj $objdir
# fi
28 changes: 16 additions & 12 deletions src/ci/github-actions/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -77,15 +77,15 @@ x--expand-yaml-anchors--remove:
env: {}

- &job-linux-4c
os: ubuntu-20.04-4core-16gb
os: ubuntu-20.04
<<: *base-job

- &job-linux-8c
os: ubuntu-20.04-8core-32gb
os: ubuntu-20.04
<<: *base-job

- &job-linux-16c
os: ubuntu-20.04-16core-64gb
os: ubuntu-20.04
<<: *base-job

- &job-macos-xl
Expand Down Expand Up @@ -296,6 +296,7 @@ on:
- try-perf
- automation/bors/try
- master
- optimise-docker-cache
pull_request:
branches:
- "**"
Expand Down Expand Up @@ -330,19 +331,22 @@ jobs:
strategy:
matrix:
include:
- name: mingw-check
- name: temp
<<: *job-linux-4c

# - name: mingw-check
# <<: *job-linux-4c

- name: mingw-check-tidy
<<: *job-linux-4c
# - name: mingw-check-tidy
# <<: *job-linux-4c

- name: x86_64-gnu-llvm-16
env:
ENABLE_GCC_CODEGEN: "1"
<<: *job-linux-16c
# - name: x86_64-gnu-llvm-16
# env:
# ENABLE_GCC_CODEGEN: "1"
# <<: *job-linux-16c

- name: x86_64-gnu-tools
<<: *job-linux-16c
# - name: x86_64-gnu-tools
# <<: *job-linux-16c

auto:
<<: *base-ci-job
Expand Down