Skip to content
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

Use a prebuilt copy of build-manifest #14

Merged
merged 8 commits into from
Oct 15, 2020
Merged
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
138 changes: 138 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ authors = ["Alex Crichton <[email protected]>"]
license = "MIT OR Apache-2.0"
edition = "2018"

build = "build.rs"

[dependencies]
curl = "0.4"
flate2 = "1"
Expand All @@ -21,3 +23,5 @@ sha2 = "0.9.1"
hex = "0.4.2"
pgp = "0.7.1"
chrono = "0.4.19"
git2 = "0.13.11"
tempfile = "3.1.0"
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,13 @@ environment variable while calling `rustup`:
RUSTUP_DIST_SERVER="http://localhost:9000/static"
```

You can also release a specific commit by providing its full hash as the second
argument of `./run.sh`:

```
./run.sh nightly 0000000000000000000000000000000000000000
```

### Adding additional files to the local release

To save on time and bandwidth, when running a release locally the tooling won't
Expand Down
10 changes: 10 additions & 0 deletions build.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
fn main() {
// Prevent a rebuild every time a non-Rust file is changed.
println!("cargo:rerun-if-changed=build.rs");

// Provide the current target as environment variable.
println!(
"cargo:rustc-env=TARGET={}",
std::env::var("TARGET").unwrap()
);
}
20 changes: 16 additions & 4 deletions local/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ RUSTC_DEFAULT_BRANCH="master"
DOWNLOAD_BASE="https://ci-artifacts.rust-lang.org/rustc-builds"
# Rustup components to download for each target we want to release.
DOWNLOAD_COMPONENTS=(
"build-manifest"
"cargo"
"rust"
"rust-docs"
Expand All @@ -35,6 +36,7 @@ DOWNLOAD_STANDALONE=(
)

channel="$1"
override_commit="$2"

# Nightly is on the default branch
if [[ "${channel}" = "nightly" ]]; then
Expand All @@ -46,8 +48,13 @@ fi
echo "==> overriding files to force promote-release to run"
mc cp "/src/local/channel-rust-${channel}.toml" "local/static/dist/channel-rust-${channel}.toml" >/dev/null

echo "==> detecting the last rustc commit on branch ${branch}"
commit="$(git ls-remote "${RUSTC_REPO}" | grep "refs/heads/${branch}" | awk '{print($1)}')"
if [[ "${override_commit}" = "" ]]; then
echo "==> detecting the last rustc commit on branch ${branch}"
commit="$(git ls-remote "${RUSTC_REPO}" | grep "refs/heads/${branch}" | awk '{print($1)}')"
else
echo "=>> using overridden commit ${override_commit}"
commit="${override_commit}"
fi

# While the nightly and beta channels have the channel name as the "release" in
# the archive names, the stable channel uses the actual Rust and Cargo version
Expand Down Expand Up @@ -86,8 +93,9 @@ download() {
file="$1"
if ! mc stat "local/artifacts/builds/${commit}/${file}" >/dev/null 2>&1; then
echo "==> copying ${file} from ci-artifacts.rust-lang.org"
curl -Lo /tmp/component "${DOWNLOAD_BASE}/${commit}/${file}" --fail
mc cp /tmp/component "local/artifacts/builds/${commit}/${file}" >/dev/null
if curl -Lo /tmp/component "${DOWNLOAD_BASE}/${commit}/${file}" --fail; then
mc cp /tmp/component "local/artifacts/builds/${commit}/${file}" >/dev/null
fi
else
echo "==> reusing cached ${file}"
fi
Expand Down Expand Up @@ -129,6 +137,10 @@ export PROMOTE_RELEASE_GZIP_COMPRESSION_LEVEL="1" # Faster recompressions
export PROMOTE_RELEASE_S3_ENDPOINT_URL="http://minio:9000"
export PROMOTE_RELEASE_SKIP_CLOUDFRONT_INVALIDATIONS="yes"
export PROMOTE_RELEASE_SKIP_DELETE_BUILD_DIR="yes"
# Conditional environment variables
if [[ "${override_commit}" != "" ]]; then
export PROMOTE_RELEASE_OVERRIDE_COMMIT="${override_commit}"
fi

echo "==> starting promote-release"
/src/target/release/promote-release /persistent/release "${channel}"
2 changes: 1 addition & 1 deletion prod/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ ENV PATH=/root/.cargo/bin:$PATH
# caching, and it works by copying the Cargo.{toml,lock} with dummy source code
# and doing a full build with it.
WORKDIR /tmp/source
COPY Cargo.lock Cargo.toml /tmp/source/
COPY Cargo.lock Cargo.toml build.rs /tmp/source/
RUN mkdir -p /tmp/source/src && \
echo "fn main() {}" > /tmp/source/src/main.rs
RUN cargo fetch
Expand Down
7 changes: 4 additions & 3 deletions run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,12 @@
set -euo pipefail
IFS=$'\n\t'

if [[ "$#" -ne 1 ]]; then
echo "Usage: $0 <channel>"
if [[ "$#" -lt 1 ]] || [[ "$#" -gt 2 ]]; then
echo "Usage: $0 <channel> [commit]"
exit 1
fi
channel="$1"
override_commit="${2-}"

container_id="$(docker-compose ps -q local)"
if [[ "${container_id}" == "" ]]; then
Expand All @@ -30,4 +31,4 @@ fi
cargo build --release

# Run the command inside the docker environment.
docker-compose exec -T local /src/local/run.sh "${channel}"
docker-compose exec -T local /src/local/run.sh "${channel}" "${override_commit}"
Loading