Skip to content

Commit cb5938e

Browse files
committed
fix: Sccache dist tests broken after bump to tokio 1.21 and later
Signed-off-by: Xuanwo <github@xuanwo.io>
1 parent 53de1a0 commit cb5938e

File tree

11 files changed

+167
-161
lines changed

11 files changed

+167
-161
lines changed
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
name: "Upload failure Artifacts"
2+
description: "Upload failure Artifacts"
3+
inputs:
4+
name:
5+
description: ""
6+
required: true
7+
runs:
8+
using: "composite"
9+
steps:
10+
- name: pack failure artifacts
11+
shell: bash
12+
run: |
13+
killall sccache || true
14+
killall sccache-dist || true
15+
16+
tar --exclude='target' \
17+
--exclude='docs' \
18+
--exclude='bins' \
19+
--exclude='.git' \
20+
--exclude='failure-*' \
21+
-zcf failure-${{ inputs.name }}.tar.gz .
22+
- uses: actions/upload-artifact@v3
23+
with:
24+
name: ${{ inputs.name }}
25+
path: failure-${{ inputs.name }}.tar.gz

.github/workflows/ci.yml

Lines changed: 65 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ jobs:
4444
include:
4545
- os: ubuntu-20.04
4646
rustc: 1.60.0 # Oldest supported version, keep in sync with README.md
47-
- os: ubuntu-18.04
47+
- os: ubuntu-22.04
4848
rustc: 1.60.0
4949
extra_desc: dist-server
5050
extra_args: --no-default-features --features=dist-tests test_dist_ -- --test-threads 1
@@ -87,6 +87,12 @@ jobs:
8787
- name: Run tests
8888
run: cargo test --locked --all-targets --verbose ${{ matrix.extra_args }}
8989

90+
- name: Upload failure
91+
if: failure()
92+
uses: ./.github/actions/artifact_failure
93+
with:
94+
name: test-${{ matrix.os }}-${{ matrix.rustc || 'stable' }}-${{ matrix.extra_desc }}
95+
9096
build:
9197
name: build ${{ matrix.binary || 'sccache' }} ${{ matrix.target }}
9298
runs-on: ${{ matrix.os }}
@@ -182,10 +188,10 @@ jobs:
182188
extra_args: --features=unstable
183189
- os: macOS-11
184190
rustc: nightly
185-
# Disable on Windows for now as it fails with:
186-
# found invalid metadata files for crate `vte_generate_state_changes`
187-
# - os: windows-2019
188-
# rustc: nightly
191+
# Disable on Windows for now as it fails with:
192+
# found invalid metadata files for crate `vte_generate_state_changes`
193+
# - os: windows-2019
194+
# rustc: nightly
189195
env:
190196
RUST_BACKTRACE: 1
191197
steps:
@@ -207,9 +213,9 @@ jobs:
207213
- name: Execute tests
208214
run: cargo test --no-fail-fast --locked --all-targets --verbose ${{ matrix.extra_args }}
209215
env:
210-
CARGO_INCREMENTAL: '0'
211-
RUSTC_WRAPPER: ''
212-
RUSTFLAGS: '-Zprofile -Ccodegen-units=1 -Copt-level=0 -Clink-dead-code -Coverflow-checks=off'
216+
CARGO_INCREMENTAL: "0"
217+
RUSTC_WRAPPER: ""
218+
RUSTFLAGS: "-Zprofile -Ccodegen-units=1 -Copt-level=0 -Clink-dead-code -Coverflow-checks=off"
213219

214220
- name: Generate coverage data (via `grcov`)
215221
id: coverage
@@ -245,53 +251,58 @@ jobs:
245251
matrix:
246252
job:
247253
- { os: macos-12 }
248-
release: [ "13.1" ]
254+
release: ["13.1"]
249255
steps:
250-
- uses: actions/checkout@v3
251-
- name: Prepare, build and test
252-
uses: vmactions/freebsd-vm@v0
253-
with:
254-
mem: 8192
255-
usesh: true
256-
copyback: false
257-
prepare: pkg install -y ca_root_nss curl gmake gtar pot sudo
258-
run: |
259-
#####################################################################################
260-
### Prepare, build, and test
261-
#####################################################################################
262-
### based on ref: <https://github.com/rust-lang/rustup/pull/2783>
263-
### and on ref: <https://github.com/uutils/coreutils/commit/86c610a84b8b6c>
264-
### * NOTE: All steps need to be run in this block, otherwise, we are operating back
265-
### on the mac host.
266-
set -exo pipefail
267-
#
268-
### Basic user setup ################################################################
269-
TEST_USER=tester
270-
TEST_USER_HOME="/opt/$TEST_USER"
271-
REPO_NAME=${GITHUB_WORKSPACE##*/}
272-
WORKSPACE_PARENT="/Users/runner/work/${REPO_NAME}"
273-
WORKSPACE="${WORKSPACE_PARENT}/${REPO_NAME}"
274-
export WORKSPACE
275-
#
276-
mkdir -p "$TEST_USER_HOME"
277-
pw adduser -n "$TEST_USER" -d "$TEST_USER_HOME" -c "Tester" -h -
278-
chown -R "$TEST_USER":"$TEST_USER" "$TEST_USER_HOME"
279-
chown -R "$TEST_USER":"$TEST_USER" "/$WORKSPACE_PARENT"/
280-
cat > /usr/local/etc/sudoers.d/wheel<<EOF
281-
$TEST_USER ALL=(ALL) NOPASSWD: ALL
282-
EOF
283-
#
284-
### Install rust stable from rustup ################################################
285-
su "$TEST_USER" -c "/bin/sh -exo pipefail" <<"EOH"
286-
whoami
287-
echo "$HOME"
288-
fetch -o /tmp/rustup.sh https://sh.rustup.rs
289-
sh /tmp/rustup.sh -y --profile=minimal
290-
### Run tests #######################################################################
291-
. "$HOME/.cargo/env"
292-
"$WORKSPACE/scripts/freebsd-ci-test.sh"
293-
EOH
294-
# end
256+
- uses: actions/checkout@v3
257+
- name: Prepare, build and test
258+
uses: vmactions/freebsd-vm@v0
259+
with:
260+
mem: 8192
261+
usesh: true
262+
copyback: false
263+
prepare: pkg install -y ca_root_nss curl gmake gtar pot sudo
264+
run: |
265+
#####################################################################################
266+
### Prepare, build, and test
267+
#####################################################################################
268+
### based on ref: <https://github.com/rust-lang/rustup/pull/2783>
269+
### and on ref: <https://github.com/uutils/coreutils/commit/86c610a84b8b6c>
270+
### * NOTE: All steps need to be run in this block, otherwise, we are operating back
271+
### on the mac host.
272+
set -exo pipefail
273+
#
274+
### Basic user setup ################################################################
275+
TEST_USER=tester
276+
TEST_USER_HOME="/opt/$TEST_USER"
277+
REPO_NAME=${GITHUB_WORKSPACE##*/}
278+
WORKSPACE_PARENT="/Users/runner/work/${REPO_NAME}"
279+
WORKSPACE="${WORKSPACE_PARENT}/${REPO_NAME}"
280+
export WORKSPACE
281+
#
282+
mkdir -p "$TEST_USER_HOME"
283+
pw adduser -n "$TEST_USER" -d "$TEST_USER_HOME" -c "Tester" -h -
284+
chown -R "$TEST_USER":"$TEST_USER" "$TEST_USER_HOME"
285+
chown -R "$TEST_USER":"$TEST_USER" "/$WORKSPACE_PARENT"/
286+
cat > /usr/local/etc/sudoers.d/wheel<<EOF
287+
$TEST_USER ALL=(ALL) NOPASSWD: ALL
288+
EOF
289+
#
290+
### Install rust stable from rustup ################################################
291+
su "$TEST_USER" -c "/bin/sh -exo pipefail" <<"EOH"
292+
whoami
293+
echo "$HOME"
294+
fetch -o /tmp/rustup.sh https://sh.rustup.rs
295+
sh /tmp/rustup.sh -y --profile=minimal
296+
### Run tests #######################################################################
297+
. "$HOME/.cargo/env"
298+
"$WORKSPACE/scripts/freebsd-ci-test.sh"
299+
EOH
300+
# end
301+
- name: Upload failure
302+
if: failure()
303+
uses: ./.github/actions/artifact_failure
304+
with:
305+
name: test-freebsd-13.1-stable
295306

296307
release:
297308
name: release

Cargo.lock

Lines changed: 5 additions & 18 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ env_logger = "0.10"
4242
filetime = "0.2"
4343
flate2 = { version = "1.0", optional = true, default-features = false, features = ["rust_backend"] }
4444
futures = "0.3"
45-
futures-locks = "0.7"
4645
gzp = { version = "0.11.1", default-features = false, features = ["deflate_rust"] }
4746
http = "0.2"
4847
hyper = { version = "0.14.10", optional = true, features = ["server"] }

scripts/freebsd-ci-test.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,7 @@ test_sccache_dist_01()
247247
# one failed remote build.
248248
if [ "$FAILED_DIST" -gt 1 ]; then
249249
2>&1 echo "More than one distributed compilations failed"
250+
cat "$TEST_TMPDIR"/sccache_log.txt
250251
return 1
251252
fi
252253
if [ "$SUCCEEDED_DIST" -eq 0 ]; then

src/dist/http.rs

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -556,7 +556,10 @@ mod server {
556556

557557
rouille::Response {
558558
status_code: 200,
559-
headers: vec![("Content-Type".into(), "application/octet-stream".into())],
559+
headers: vec![
560+
("Content-Type".into(), "application/octet-stream".into()),
561+
("Content-Length".into(), data.len().to_string().into()),
562+
],
560563
data: rouille::ResponseBody::from_data(data),
561564
upgrade: None,
562565
}
@@ -744,6 +747,9 @@ mod server {
744747
}
745748
// Finish the client
746749
let new_client = client_builder
750+
// Disable connection pool to avoid broken connection
751+
// between runtime
752+
.pool_max_idle_per_host(0)
747753
.build()
748754
.context("failed to create a HTTP client")?;
749755
// Use the updated certificates
@@ -783,12 +789,16 @@ mod server {
783789
prepare_response(request, &res)
784790
},
785791
(GET) (/api/v1/scheduler/server_certificate/{server_id: ServerId}) => {
786-
let certs = server_certificates.lock().unwrap();
787-
let (cert_digest, cert_pem) = try_or_500_log!(req_id, certs.get(&server_id)
792+
let certs = {
793+
let guard = server_certificates.lock().unwrap();
794+
guard.get(&server_id).map(|v|v.to_owned())
795+
};
796+
797+
let (cert_digest, cert_pem) = try_or_500_log!(req_id, certs
788798
.context("server cert not available"));
789799
let res = ServerCertificateHttpResponse {
790-
cert_digest: cert_digest.clone(),
791-
cert_pem: cert_pem.clone(),
800+
cert_digest,
801+
cert_pem,
792802
};
793803
prepare_response(request, &res)
794804
},
@@ -1100,6 +1110,9 @@ mod client {
11001110
let client = reqwest::ClientBuilder::new()
11011111
.timeout(timeout)
11021112
.connect_timeout(connect_timeout)
1113+
// Disable connection pool to avoid broken connection
1114+
// between runtime
1115+
.pool_max_idle_per_host(0)
11031116
.build()
11041117
.context("failed to create an async HTTP client")?;
11051118
let client_toolchains =

0 commit comments

Comments
 (0)