Switch to xaction for CI

This commit is contained in:
Aleksey Kladov
2020-11-11 01:29:51 +01:00
parent 2a55b68a6a
commit 4759a61755
9 changed files with 135 additions and 49 deletions
+27
View File
@@ -0,0 +1,27 @@
name: CI
on:
pull_request:
push:
branches: ["master", "staging", "trying"]
env:
CARGO_INCREMENTAL: 0
CARGO_NET_RETRY: 10
CI: 1
RUST_BACKTRACE: short
RUSTFLAGS: -D warnings
RUSTUP_MAX_RETRIES: 10
jobs:
test:
name: Rust
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0 # fetch tags for publish
- run: cargo run -p xtask -- ci
env:
CRATES_IO_TOKEN: ${{ secrets.CRATES_IO_TOKEN }}
-38
View File
@@ -1,38 +0,0 @@
branches:
only:
- staging
- master
- trying
language: rust
matrix:
include:
- name: "miri"
script:
- rm -rf ./target
- ./run-miri-tests.sh
- rust: stable
script:
- cargo test
- cargo test --release
- rust: beta
script:
- cargo test
- cargo test --release
- rust: stable
script:
- cargo test --no-default-features --features "std parking_lot"
- cargo test --no-default-features --features "std parking_lot" --release
- rust: stable
script:
- cargo build --no-default-features --test test
- rust: 1.31.1
script:
- mv Cargo.lock.min Cargo.lock
- cargo build
+3
View File
@@ -15,6 +15,9 @@ categories = ["rust-patterns", "memory-management"]
exclude = ["*.png", "*.svg", "/Cargo.lock.min", "/.travis.yml", "/run-miri-tests.sh", "rustfmt.toml"]
[workspace]
members = ["xtask"]
[dependencies]
# Uses parking_lot to implement once_cell::sync::OnceCell.
# This makes not speed difference, but makes each OnceCell<T>
+2
View File
@@ -0,0 +1,2 @@
status = [ "Rust" ]
delete_merged_branches = true
-11
View File
@@ -1,11 +0,0 @@
#!/usr/bin/env bash
set -e
MIRI_NIGHTLY=nightly-$(curl -s https://rust-lang.github.io/rustup-components-history/x86_64-unknown-linux-gnu/miri)
echo "Installing latest nightly with Miri: $MIRI_NIGHTLY"
rustup toolchain add "$MIRI_NIGHTLY"
rustup component add miri --toolchain "$MIRI_NIGHTLY"
rustup run "$MIRI_NIGHTLY" -- cargo miri setup
rustup run "$MIRI_NIGHTLY" -- cargo miri test
View File
+9
View File
@@ -0,0 +1,9 @@
[package]
name = "xtask"
version = "0.0.0"
publish = false
authors = ["Aleksey Kladov <aleksey.kladov@gmail.com>"]
edition = "2018"
[dependencies]
xaction = "0.2.1"
+88
View File
@@ -0,0 +1,88 @@
use std::env;
use xaction::{cargo_toml, cmd, cp, git, push_rustup_toolchain, rm_rf, section, Result};
fn main() {
if let Err(err) = try_main() {
eprintln!("error: {}", err);
std::process::exit(1)
}
}
fn try_main() -> Result<()> {
let subcommand = std::env::args().nth(1);
match subcommand {
Some(it) if it == "ci" => (),
_ => {
print_usage();
Err("invalid arguments")?
}
}
let cargo_toml = cargo_toml()?;
{
let _s = section("TEST_STABLE");
let _t = push_rustup_toolchain("stable");
cmd!("cargo test").run()?;
cmd!("cargo test --release").run()?;
// Skip doctests, they need `std`
cmd!("cargo test --no-default-features --test it").run()?;
cmd!("cargo test --no-default-features --features 'std parking_lot'").run()?;
cmd!("cargo test --no-default-features --features 'std parking_lot' --release").run()?;
}
{
let _s = section("TEST_BETA");
let _t = push_rustup_toolchain("beta");
cmd!("cargo test").run()?;
cmd!("cargo test --release").run()?;
}
{
let _s = section("TEST_MSRV");
let _t = push_rustup_toolchain("1.31.1");
cp("Cargo.lock.min", "Cargo.lock")?;
cmd!("cargo build").run()?;
}
{
let _s = section("TEST_MIRI");
rm_rf("./target")?;
let miri_nightly= cmd!("curl -s https://rust-lang.github.io/rustup-components-history/x86_64-unknown-linux-gnu/miri").read()?;
let _t = push_rustup_toolchain(&format!("nightly-{}", miri_nightly));
cmd!("rustup component add miri").run()?;
cmd!("cargo miri setup").run()?;
cmd!("cargo miri test").run()?;
}
let version = cargo_toml.version()?;
let tag = format!("v{}", version);
let dry_run =
env::var("CI").is_err() || git::has_tag(&tag)? || git::current_branch()? != "master";
xaction::set_dry_run(dry_run);
{
let _s = section("PUBLISH");
cargo_toml.publish()?;
git::tag(&tag)?;
git::push_tags()?;
}
Ok(())
}
fn print_usage() {
eprintln!(
"\
Usage: cargo run -p xtask <SUBCOMMAND>
SUBCOMMANDS:
ci
"
)
}
+6
View File
@@ -0,0 +1,6 @@
use xaction::cmd;
#[test]
fn test_formatting() {
cmd!("cargo fmt --all -- --check").run().unwrap()
}