Skip to content

Commit

Permalink
CI
Browse files Browse the repository at this point in the history
  • Loading branch information
matklad committed Jan 16, 2021
1 parent da1ecae commit 866a4e2
Show file tree
Hide file tree
Showing 6 changed files with 103 additions and 30 deletions.
49 changes: 23 additions & 26 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,34 +2,31 @@ name: CI
on:
pull_request:
push:
branches:
- master
- staging
- trying
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:
tests:
name: Tests
test:
name: Rust
runs-on: ubuntu-latest

strategy:
matrix:
rust: [stable, beta]

steps:

- name: Checkout repository
uses: actions/checkout@v2
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0 # fetch tags for publish
- uses: actions-rs/toolchain@v1
with:
toolchain: stable
profile: minimal
override: true

- name: Install Rust toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: ${{ matrix.rust }}
profile: minimal
override: true

- name: Run Tests
run: cargo test --all-features --all-targets

- name: Run Tests (release)
run: cargo test --release
- run: cargo run -p xtask -- ci
env:
CRATES_IO_TOKEN: ${{ secrets.CRATES_IO_TOKEN }}
5 changes: 5 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ license = "MIT OR Apache-2.0"
description = "Library for generic lossless syntax trees"
edition = "2018"

exclude = [".github/", "bors.toml", "rustfmt.toml"]

[workspace]
members = ["xtask"]

[dependencies]
rustc-hash = "1.0.1"
smol_str = "0.1.10"
Expand Down
5 changes: 1 addition & 4 deletions bors.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,2 @@
status = [
"Tests (stable)",
"Tests (beta)",
]
status = [ "Rust" ]
delete_merged_branches = true
9 changes: 9 additions & 0 deletions xtask/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[package]
name = "xtask"
version = "0.0.0"
publish = false
authors = ["Aleksey Kladov <[email protected]>"]
edition = "2018"

[dependencies]
xaction = "0.2"
59 changes: 59 additions & 0 deletions xtask/src/main.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
use std::env;

use xaction::{cargo_toml, cmd, git, 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("BUILD");
cmd!("cargo test --workspace --no-run").run()?;
}

{
let _s = section("TEST");
cmd!("cargo test --workspace -- --nocapture").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 changes: 6 additions & 0 deletions xtask/tests/tidy.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
use xaction::cmd;

#[test]
fn test_formatting() {
cmd!("cargo fmt --all -- --check").run().unwrap()
}

0 comments on commit 866a4e2

Please sign in to comment.