Skip to content

Commit 0277203

Browse files
authored
Try #873: --target x
2 parents 40d6cd4 + 8889cf0 commit 0277203

File tree

6 files changed

+152
-28
lines changed

6 files changed

+152
-28
lines changed

.github/workflows/ci.yml

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -308,8 +308,31 @@ jobs:
308308
LATEST: ${{ needs.check.outputs.is-latest || 'false' }}
309309
shell: bash
310310

311+
# we should always have an artifact from a previous build.
312+
remote:
313+
needs: [shellcheck, test, check]
314+
runs-on: ubuntu-latest
315+
if: github.actor == 'bors'
316+
env:
317+
TARGET: aarch64-unknown-linux-gnu
318+
steps:
319+
- uses: actions/checkout@v3
320+
- uses: ./.github/actions/setup-rust
321+
- run: ./ci/remote.sh
322+
323+
bisect:
324+
needs: [shellcheck, test, check]
325+
runs-on: ubuntu-latest
326+
if: github.actor == 'bors'
327+
env:
328+
TARGET: aarch64-unknown-linux-gnu
329+
steps:
330+
- uses: actions/checkout@v3
331+
- uses: ./.github/actions/setup-rust
332+
- run: ./ci/bisect.sh
333+
311334
publish:
312-
needs: [build, check]
335+
needs: [build, check, fmt, clippy, cargo-deny, remote, bisect]
313336
runs-on: ubuntu-latest
314337
steps:
315338
- uses: actions/checkout@v3

ci/bisect.sh

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
#!/usr/bin/env bash
2+
# shellcheck disable=SC1091,SC1090
3+
4+
# test to see that custom toolchains work
5+
6+
set -x
7+
set -eo pipefail
8+
9+
if [[ -z "${TARGET}" ]]; then
10+
export TARGET="aarch64-unknown-linux-gnu"
11+
fi
12+
13+
source=$(dirname "${BASH_SOURCE[0]}")
14+
. "${source}"/shared.sh
15+
16+
main() {
17+
local td=
18+
local err=
19+
20+
retry cargo fetch
21+
cargo install --force --path .
22+
cargo install cargo-bisect-rustc
23+
24+
td="$(mktemp -d)"
25+
git clone --depth 1 https://github.com/cross-rs/rust-cpp-hello-word "${td}"
26+
27+
pushd "${td}"
28+
retry cargo fetch
29+
echo '#!/usr/bin/env bash
30+
export CROSS_CUSTOM_TOOLCHAIN=1
31+
exec cross run --target '"${TARGET}" > bisect.sh
32+
chmod +x bisect.sh
33+
34+
if ! err=$(cargo bisect-rustc --script=./bisect.sh --target "${TARGET}" 2>&1 >/dev/null); then
35+
if [[ "${err}" != *"does not reproduce the regression"* ]]; then
36+
echo "${err}"
37+
exit 1
38+
fi
39+
else
40+
echo "should have failed, instead succeeded" 1>&2
41+
exit 1
42+
fi
43+
popd
44+
45+
rm -rf "${td}"
46+
}
47+
48+
main

ci/remote.sh

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
#!/usr/bin/env bash
2+
# shellcheck disable=SC1091,SC1090
3+
4+
# test to see that remote docker support works.
5+
6+
set -x
7+
set -eo pipefail
8+
9+
export CROSS_REMOTE=1
10+
if [[ -z "${TARGET}" ]]; then
11+
export TARGET="aarch64-unknown-linux-gnu"
12+
fi
13+
14+
source=$(dirname "${BASH_SOURCE[0]}")
15+
. "${source}"/shared.sh
16+
17+
main() {
18+
local err=
19+
20+
retry cargo fetch
21+
cargo install --force --path .
22+
23+
# if the create volume fails, ensure it exists.
24+
if ! err=$(cross-util volumes create 2>&1 >/dev/null); then
25+
if [[ "${err}" != *"already exists"* ]]; then
26+
echo "${err}"
27+
exit 1
28+
fi
29+
fi
30+
cross_test_cpp
31+
cross-util volumes remove
32+
33+
# ensure the data volume was removed.
34+
cross_test_cpp
35+
}
36+
37+
cross_test_cpp() {
38+
local td=
39+
td="$(mktemp -d)"
40+
41+
git clone --depth 1 https://github.com/cross-rs/rust-cpp-hello-word "${td}"
42+
43+
pushd "${td}"
44+
retry cargo fetch
45+
cross run --target "${TARGET}"
46+
popd
47+
48+
rm -rf "${td}"
49+
}
50+
51+
main

ci/shared.sh

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#!/usr/bin/env bash
2+
3+
function retry {
4+
local tries="${TRIES-5}"
5+
local timeout="${TIMEOUT-1}"
6+
local try=0
7+
local exit_code=0
8+
9+
while (( try < tries )); do
10+
if "${@}"; then
11+
return 0
12+
else
13+
exit_code=$?
14+
fi
15+
16+
sleep "${timeout}"
17+
echo "Retrying ..." 1>&2
18+
try=$(( try + 1 ))
19+
timeout=$(( timeout * 2 ))
20+
done
21+
22+
return ${exit_code}
23+
}

ci/test.sh

Lines changed: 3 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#!/usr/bin/env bash
2-
# shellcheck disable=SC2086
2+
# shellcheck disable=SC2086,SC1091,SC1090
33

44
set -x
55
set -euo pipefail
@@ -8,27 +8,8 @@ set -euo pipefail
88
# installed version on macOS. likewise, "${var[@]}" is an unbound
99
# error if var is an empty array.
1010

11-
function retry {
12-
local tries="${TRIES-5}"
13-
local timeout="${TIMEOUT-1}"
14-
local try=0
15-
local exit_code=0
16-
17-
while (( try < tries )); do
18-
if "${@}"; then
19-
return 0
20-
else
21-
exit_code=$?
22-
fi
23-
24-
sleep "${timeout}"
25-
echo "Retrying ..." 1>&2
26-
try=$(( try + 1 ))
27-
timeout=$(( timeout * 2 ))
28-
done
29-
30-
return ${exit_code}
31-
}
11+
source=$(dirname "${BASH_SOURCE[0]}")
12+
. "${source}"/shared.sh
3213

3314
workspace_test() {
3415
"${CROSS[@]}" build --target "${TARGET}" --workspace "$@" ${CROSS_FLAGS}

src/bin/commands/containers.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -83,9 +83,6 @@ impl CreateVolume {
8383

8484
#[derive(Args, Debug)]
8585
pub struct RemoveVolume {
86-
/// Triple for the target platform.
87-
#[clap(long)]
88-
pub target: String,
8986
/// If cross is running inside a container.
9087
#[clap(short, long)]
9188
pub docker_in_docker: bool,
@@ -372,16 +369,17 @@ pub fn create_persistent_volume(
372369

373370
pub fn remove_persistent_volume(
374371
RemoveVolume {
375-
target,
376372
docker_in_docker,
377373
verbose,
378374
..
379375
}: RemoveVolume,
380376
engine: &docker::Engine,
381377
channel: Option<&str>,
382378
) -> cross::Result<()> {
379+
// we only need a triple that needs docker: the actual target doesn't matter.
380+
let triple = cross::Host::X86_64UnknownLinuxGnu.triple();
383381
let (_, _, dirs) =
384-
docker::get_package_info(engine, &target, channel, docker_in_docker, verbose)?;
382+
docker::get_package_info(engine, triple, channel, docker_in_docker, verbose)?;
385383
let volume = docker::remote::unique_toolchain_identifier(&dirs.sysroot)?;
386384

387385
if !docker::remote::volume_exists(engine, &volume, verbose)? {

0 commit comments

Comments
 (0)