Skip to content

Commit

Permalink
Try #652:
Browse files Browse the repository at this point in the history
  • Loading branch information
bors[bot] authored Mar 16, 2022
2 parents ed729e7 + eefe413 commit 2f45fac
Show file tree
Hide file tree
Showing 11 changed files with 136 additions and 122 deletions.
156 changes: 96 additions & 60 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ jobs:
uses: actions-rs/cargo@v1
with:
command: clippy
args: --locked
args: --locked -- -D warnings

test:
runs-on: ${{ matrix.os }}
Expand All @@ -77,69 +77,107 @@ jobs:
args: --locked
timeout-minutes: 5

generate-matrix:
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.generate-matrix.outputs.matrix }}
steps:
- name: Generate matrix
id: generate-matrix
run: |
if [[ -z "${commit_message}" ]]; then
bors_args=()
else
bors_args="$(echo "${commit_message}" | sed -E 's/^Try #[0-9]+:\s+//')"
declare -a "bors_args=(${bors_args})"
fi
if [[ "${bors_args[0]-}" == --target ]]; then
echo "Only running targets matching '${bors_args[1]}'."
matrix="$(
target="${bors_args[1]}" yq --output-format json '[.[] | select(.target | test(env(target)))]' <<< "${matrix}"
)"
else
echo 'Running all targets.'
matrix="$(yq --output-format json <<< "${matrix}")"
fi
jq -C <<< "${matrix}"
echo "::set-output name=matrix::$(jq -c <<< "${matrix}")"
env:
commit_message: >
${{
((
startsWith(github.event.head_commit.message, 'Try #') &&
github.event.head_commit.author.username == 'bors[bot]'
) && github.event.head_commit.message) || ''
}}
matrix: |
- { target: x86_64-apple-darwin, os: macos-latest, cpp: 1, dylib: 1, std: 1, run: 1, deploy: true }
- { target: x86_64-unknown-linux-gnu, os: ubuntu-latest, cpp: 1, dylib: 1, std: 1, run: 1, runners: native qemu-user qemu-system, deploy: true }
- { target: x86_64-unknown-linux-musl, os: ubuntu-latest, std: 1, run: 1, deploy: true }
- { target: x86_64-pc-windows-msvc, os: windows-latest, cpp: 1, std: 1, run: 1, deploy: true }
- { target: aarch64-unknown-linux-gnu, os: ubuntu-latest, cpp: 1, dylib: 1, std: 1, run: 1, runners: qemu-user qemu-system }
- { target: arm-unknown-linux-gnueabi, os: ubuntu-latest, cpp: 1, dylib: 1, std: 1, run: 1 }
- { target: arm-unknown-linux-gnueabihf, os: ubuntu-latest, cpp: 1, dylib: 1, std: 1, run: 1 }
- { target: armv7-unknown-linux-gnueabihf, os: ubuntu-latest, cpp: 1, dylib: 1, std: 1, run: 1, runners: qemu-user qemu-system }
- { target: i586-unknown-linux-gnu, os: ubuntu-latest, cpp: 1, dylib: 1, std: 1, run: 1 }
- { target: i686-unknown-linux-gnu, os: ubuntu-latest, cpp: 1, dylib: 1, std: 1, run: 1, runners: native qemu-user qemu-system }
- { target: mips-unknown-linux-gnu, os: ubuntu-latest, cpp: 1, dylib: 1, std: 1, run: 1, runners: qemu-user qemu-system }
- { target: mipsel-unknown-linux-gnu, os: ubuntu-latest, cpp: 1, dylib: 1, std: 1, run: 1, runners: qemu-user qemu-system }
- { target: mips64-unknown-linux-gnuabi64, os: ubuntu-latest, cpp: 1, dylib: 1, std: 1, run: 1 }
- { target: mips64el-unknown-linux-gnuabi64, os: ubuntu-latest, cpp: 1, dylib: 1, std: 1, run: 1, runners: qemu-user qemu-system }
- { target: powerpc-unknown-linux-gnu, os: ubuntu-latest, cpp: 1, dylib: 1, std: 1, run: 1, runners: qemu-user qemu-system }
- { target: powerpc64-unknown-linux-gnu, os: ubuntu-latest, cpp: 1, dylib: 1, std: 1, run: 1, runners: qemu-user qemu-system }
- { target: powerpc64le-unknown-linux-gnu, os: ubuntu-latest, cpp: 1, dylib: 1, std: 1, run: 1, runners: qemu-user qemu-system }
- { target: riscv64gc-unknown-linux-gnu, os: ubuntu-latest, cpp: 1, std: 1, run: 1 }
- { target: s390x-unknown-linux-gnu, os: ubuntu-latest, cpp: 1, dylib: 1, std: 1, run: 1, runners: qemu-system }
- { target: sparc64-unknown-linux-gnu, os: ubuntu-latest, cpp: 1, dylib: 1, std: 1, run: 1, runners: qemu-system }
- { target: aarch64-unknown-linux-musl, os: ubuntu-latest, std: 1, run: 1 }
- { target: arm-unknown-linux-musleabihf, os: ubuntu-latest, std: 1, run: 1 }
- { target: arm-unknown-linux-musleabi, os: ubuntu-latest, std: 1, run: 1 }
- { target: armv5te-unknown-linux-gnueabi, os: ubuntu-latest, std: 1, run: 1 }
- { target: armv5te-unknown-linux-musleabi, os: ubuntu-latest, std: 1, run: 1 }
- { target: armv7-unknown-linux-musleabihf, os: ubuntu-latest, std: 1, run: 1 }
- { target: i586-unknown-linux-musl, os: ubuntu-latest, std: 1, run: 1 }
- { target: i686-unknown-linux-musl, os: ubuntu-latest, std: 1, run: 1 }
- { target: mips-unknown-linux-musl, os: ubuntu-latest, cpp: 1, std: 1, run: 1 }
- { target: mipsel-unknown-linux-musl, os: ubuntu-latest, cpp: 1, std: 1, run: 1 }
- { target: aarch64-linux-android, os: ubuntu-latest, cpp: 1, std: 1, run: 1 }
- { target: arm-linux-androideabi, os: ubuntu-latest, cpp: 1, std: 1, run: 1 }
- { target: armv7-linux-androideabi, os: ubuntu-latest, cpp: 1, std: 1, run: 1 }
- { target: i686-linux-android, os: ubuntu-latest, cpp: 1, std: 1, run: 1 }
- { target: x86_64-linux-android, os: ubuntu-latest, cpp: 1, std: 1, run: 1 }
- { target: x86_64-pc-windows-gnu, os: ubuntu-latest, cpp: 1, std: 1, run: 1 }
- { target: i686-pc-windows-gnu, os: ubuntu-latest, cpp: 1, std: 1, run: 1 }
# Disabled, see #396
#-{ target: x86_64-unknown-dragonfly, os: ubuntu-latest, cpp: 1, dylib: 1 }
- { target: i686-unknown-freebsd, os: ubuntu-latest, dylib: 1, std: 1 }
- { target: x86_64-unknown-freebsd, os: ubuntu-latest, dylib: 1, std: 1 }
- { target: x86_64-unknown-netbsd, os: ubuntu-latest, cpp: 1, dylib: 1, std: 1 }
# Disabled, see #534
#-{ target: sparcv9-sun-solaris, os: ubuntu-latest, cpp: 1, dylib: 1, std: 1 }
#-{ target: x86_64-sun-solaris, os: ubuntu-latest, cpp: 1, dylib: 1, std: 1 }
# Disabled, see #634
#-{ target: asmjs-unknown-emscripten, os: ubuntu-latest, std: 1, run: 1 }
# `cargo run` fails with an assertion error (https://github.com/rust-lang/cargo/issues/4689) on `wasm32-unknown-emscripten`.
#-{ target: wasm32-unknown-emscripten, os: ubuntu-latest, std: 1 }
- { target: thumbv6m-none-eabi, os: ubuntu-latest, std: 1 }
- { target: thumbv7em-none-eabi, os: ubuntu-latest, std: 1 }
- { target: thumbv7em-none-eabihf, os: ubuntu-latest, std: 1 }
- { target: thumbv7m-none-eabi, os: ubuntu-latest, std: 1 }
docker-image:
name: docker-image (${{ matrix.target }})
runs-on: ${{ matrix.os }}
needs: [shellcheck, test]
needs: [shellcheck, test, generate-matrix]
if: github.event_name == 'push'
strategy:
fail-fast: false
matrix:
include:
- { target: x86_64-apple-darwin, os: macos-latest, cpp: 1, dylib: 1, std: 1, run: 1, deploy: true }
- { target: x86_64-unknown-linux-gnu, os: ubuntu-latest, cpp: 1, dylib: 1, std: 1, run: 1, runners: native qemu-user qemu-system, deploy: true }
- { target: x86_64-unknown-linux-musl, os: ubuntu-latest, std: 1, run: 1, deploy: true }
- { target: x86_64-pc-windows-msvc, os: windows-latest, cpp: 1, std: 1, run: 1, deploy: true }

- { target: aarch64-unknown-linux-gnu, os: ubuntu-latest, cpp: 1, dylib: 1, std: 1, run: 1, runners: qemu-user qemu-system }
- { target: arm-unknown-linux-gnueabi, os: ubuntu-latest, cpp: 1, dylib: 1, std: 1, run: 1 }
- { target: arm-unknown-linux-gnueabihf, os: ubuntu-latest, cpp: 1, dylib: 1, std: 1, run: 1 }
- { target: armv7-unknown-linux-gnueabihf, os: ubuntu-latest, cpp: 1, dylib: 1, std: 1, run: 1, runners: qemu-user qemu-system }
- { target: i586-unknown-linux-gnu, os: ubuntu-latest, cpp: 1, dylib: 1, std: 1, run: 1 }
- { target: i686-unknown-linux-gnu, os: ubuntu-latest, cpp: 1, dylib: 1, std: 1, run: 1, runners: native qemu-user qemu-system }
- { target: mips-unknown-linux-gnu, os: ubuntu-latest, cpp: 1, dylib: 1, std: 1, run: 1, runners: qemu-user qemu-system }
- { target: mipsel-unknown-linux-gnu, os: ubuntu-latest, cpp: 1, dylib: 1, std: 1, run: 1, runners: qemu-user qemu-system }
- { target: mips64-unknown-linux-gnuabi64, os: ubuntu-latest, cpp: 1, dylib: 1, std: 1, run: 1 }
- { target: mips64el-unknown-linux-gnuabi64, os: ubuntu-latest, cpp: 1, dylib: 1, std: 1, run: 1, runners: qemu-user qemu-system }
- { target: powerpc-unknown-linux-gnu, os: ubuntu-latest, cpp: 1, dylib: 1, std: 1, run: 1, runners: qemu-user qemu-system }
- { target: powerpc64-unknown-linux-gnu, os: ubuntu-latest, cpp: 1, dylib: 1, std: 1, run: 1, runners: qemu-user qemu-system }
- { target: powerpc64le-unknown-linux-gnu, os: ubuntu-latest, cpp: 1, dylib: 1, std: 1, run: 1, runners: qemu-user qemu-system }
- { target: riscv64gc-unknown-linux-gnu, os: ubuntu-latest, cpp: 1, std: 1, run: 1 }
- { target: s390x-unknown-linux-gnu, os: ubuntu-latest, cpp: 1, dylib: 1, std: 1, run: 1, runners: qemu-system }
- { target: sparc64-unknown-linux-gnu, os: ubuntu-latest, cpp: 1, dylib: 1, std: 1, run: 1, runners: qemu-system }
- { target: aarch64-unknown-linux-musl, os: ubuntu-latest, std: 1, run: 1 }
- { target: arm-unknown-linux-musleabihf, os: ubuntu-latest, std: 1, run: 1 }
- { target: arm-unknown-linux-musleabi, os: ubuntu-latest, std: 1, run: 1 }
- { target: armv5te-unknown-linux-gnueabi, os: ubuntu-latest, std: 1, run: 1 }
- { target: armv5te-unknown-linux-musleabi, os: ubuntu-latest, std: 1, run: 1 }
- { target: armv7-unknown-linux-musleabihf, os: ubuntu-latest, std: 1, run: 1 }
- { target: i586-unknown-linux-musl, os: ubuntu-latest, std: 1, run: 1 }
- { target: i686-unknown-linux-musl, os: ubuntu-latest, std: 1, run: 1 }
- { target: mips-unknown-linux-musl, os: ubuntu-latest, cpp: 1, std: 1, run: 1 }
- { target: mipsel-unknown-linux-musl, os: ubuntu-latest, cpp: 1, std: 1, run: 1 }
- { target: aarch64-linux-android, os: ubuntu-latest, cpp: 1, std: 1, run: 1 }
- { target: arm-linux-androideabi, os: ubuntu-latest, cpp: 1, std: 1, run: 1 }
- { target: armv7-linux-androideabi, os: ubuntu-latest, cpp: 1, std: 1, run: 1 }
- { target: i686-linux-android, os: ubuntu-latest, cpp: 1, std: 1, run: 1 }
- { target: x86_64-linux-android, os: ubuntu-latest, cpp: 1, std: 1, run: 1 }
- { target: x86_64-pc-windows-gnu, os: ubuntu-latest, cpp: 1, std: 1, run: 1 }
- { target: i686-pc-windows-gnu, os: ubuntu-latest, cpp: 1, std: 1, run: 1 }
# Disabled, see #396
#-{ target: x86_64-unknown-dragonfly, os: ubuntu-latest, cpp: 1, dylib: 1 }
- { target: i686-unknown-freebsd, os: ubuntu-latest, dylib: 1, std: 1 }
- { target: x86_64-unknown-freebsd, os: ubuntu-latest, dylib: 1, std: 1 }
- { target: x86_64-unknown-netbsd, os: ubuntu-latest, cpp: 1, dylib: 1, std: 1 }
# Disabled, see #534
#-{ target: sparcv9-sun-solaris, os: ubuntu-latest, cpp: 1, dylib: 1, std: 1 }
#-{ target: x86_64-sun-solaris, os: ubuntu-latest, cpp: 1, dylib: 1, std: 1 }
# Disabled, see #634
#-{ target: asmjs-unknown-emscripten, os: ubuntu-latest, std: 1, run: 1 }
# `cargo run` fails with an assertion error (https://github.com/rust-lang/cargo/issues/4689) on `wasm32-unknown-emscripten`.
#-{ target: wasm32-unknown-emscripten, os: ubuntu-latest, std: 1 }
- { target: thumbv6m-none-eabi, os: ubuntu-latest, std: 1 }
- { target: thumbv7em-none-eabi, os: ubuntu-latest, std: 1 }
- { target: thumbv7em-none-eabihf, os: ubuntu-latest, std: 1 }
- { target: thumbv7m-none-eabi, os: ubuntu-latest, std: 1 }
include: ${{ fromJson(needs.generate-matrix.outputs.matrix) }}

steps:
- uses: actions/checkout@v3
Expand All @@ -149,8 +187,6 @@ jobs:
- name: Set up Docker Buildx
if: runner.os == 'Linux'
uses: docker/setup-buildx-action@v1
- name: Expose GitHub runtime
uses: crazy-max/[email protected]
- name: Build and push Docker image
id: build-docker-image
if: runner.os == 'Linux'
Expand Down Expand Up @@ -219,7 +255,7 @@ jobs:
cargo-registry-token: ${{ secrets.CARGO_REGISTRY_TOKEN }}

conclusion:
needs: [shellcheck, fmt, clippy, test, docker-image, publish]
needs: [shellcheck, fmt, clippy, test, generate-matrix, docker-image, publish]
if: always()
runs-on: ubuntu-latest
steps:
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ This project adheres to [Semantic Versioning](http://semver.org/).

## [Unreleased]

- #652 - Allow trying individual targets via bors.
- #650 - Improve Docker caching.
- #588 - fix ci: bump openssl version in freebsd again
- #552 - Added CHANGELOG.md automation
Expand Down
8 changes: 0 additions & 8 deletions build-docker-image.sh
Original file line number Diff line number Diff line change
Expand Up @@ -75,14 +75,6 @@ run() {
build_args+=(--cache-to 'type=inline')
fi

if [[ -n "${GITHUB_ACTIONS-}" ]]; then
build_args+=(--cache-from "type=gha,url=${ACTIONS_CACHE_URL},token=${ACTIONS_RUNTIME_TOKEN}")

if ! "${push}"; then
build_args+=(--cache-to "type=gha,mode=max,url=${ACTIONS_CACHE_URL},token=${ACTIONS_RUNTIME_TOKEN}")
fi
fi

for tag in "${tags[@]}"; do
build_args+=(--tag "${tag}")
done
Expand Down
4 changes: 2 additions & 2 deletions build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,12 +74,12 @@ fn docker_images() -> String {
let path = entry.path();
let file_name = path.file_name().unwrap().to_str().unwrap();
if file_name.starts_with("Dockerfile.") {
images.push_str("\"");
images.push('"');
images.push_str(&file_name.replacen("Dockerfile.", "", 1));
images.push_str("\", ");
}
}

images.push_str("]");
images.push(']');
images
}
15 changes: 3 additions & 12 deletions src/cargo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,24 +22,15 @@ pub enum Subcommand {

impl Subcommand {
pub fn needs_docker(self) -> bool {
match self {
Subcommand::Other => false,
_ => true,
}
!matches!(self, Subcommand::Other)
}

pub fn needs_interpreter(self) -> bool {
match self {
Subcommand::Run | Subcommand::Test | Subcommand::Bench => true,
_ => false,
}
matches!(self, Subcommand::Run | Subcommand::Test | Subcommand::Bench)
}

pub fn needs_target_in_command(self) -> bool {
match self {
Subcommand::Metadata => false,
_ => true,
}
!matches!(self, Subcommand::Metadata)
}
}

Expand Down
9 changes: 4 additions & 5 deletions src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,8 @@ pub fn parse(target_list: &TargetList) -> Args {
}
} else if arg.starts_with("--target=") {
target = arg
.splitn(2, '=')
.nth(1)
.map(|s| Target::from(&*s, target_list));
.split_once('=')
.map(|(_, t)| Target::from(t, target_list));
all.push(arg);
} else if arg == "--target-dir" {
all.push(arg);
Expand All @@ -49,9 +48,9 @@ pub fn parse(target_list: &TargetList) -> Args {
all.push("/target".to_string());
}
} else if arg.starts_with("--target-dir=") {
if let Some(td) = arg.splitn(2, '=').nth(1) {
if let Some((_, td)) = arg.split_once('=') {
target_dir = Some(PathBuf::from(&td));
all.push(format!("--target-dir=/target"));
all.push("--target-dir=/target".into());
}
} else {
if !arg.starts_with('-') && sc.is_none() {
Expand Down
9 changes: 4 additions & 5 deletions src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,13 @@ impl Environment {
}

fn build_var_name(&self, name: &str) -> String {
format!("{}_{}", self.0, name.to_ascii_uppercase().replace("-", "_"))
format!("{}_{}", self.0, name.to_ascii_uppercase().replace('-', "_"))
}

fn get_var(&self, name: &str) -> Option<String> {
self.1
.as_ref()
.map(|internal_map| internal_map.get(name).map(|v| v.to_string()))
.flatten()
.and_then(|internal_map| internal_map.get(name).map(|v| v.to_string()))
.or_else(|| env::var(name).ok())
}

Expand Down Expand Up @@ -186,9 +185,9 @@ impl Config {
) -> Result<Vec<String>> {
let mut collect = vec![];
if let Some(mut vars) = env_values {
collect.extend(vars.drain(..));
collect.append(&mut vars);
} else if let Some(toml_values) = toml_getter() {
collect.extend(toml_values?.drain(..).map(|v| v.to_string()));
collect.extend(toml_values?.into_iter().map(|v| v.to_string()));
}

Ok(collect)
Expand Down
Loading

0 comments on commit 2f45fac

Please sign in to comment.