Skip to content

Commit eb02e73

Browse files
committed
Initial public release
0 parents  commit eb02e73

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+14334
-0
lines changed

.figures/trex-phases.svg

Lines changed: 1 addition & 0 deletions
Loading
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
#!/bin/bash
2+
3+
# A script that runs `cargo` commands in a way that makes GitHub actions runners
4+
# slightly nicer wherever possible. Aim is to also make it easier to run this
5+
# locally.
6+
#
7+
# Author: Jay Bosamiya
8+
# Version: 0.0.2
9+
#
10+
# Usage:
11+
# ./github_actions_run_cargo build
12+
# ...
13+
14+
set -eo pipefail
15+
16+
function to_gha {
17+
jq --raw-output '
18+
.message |
19+
select(.spans != null) |
20+
select(.level == "error" or .level == "warning") |
21+
select(.spans[].is_primary == true) |
22+
{l:.level,s:.spans[0],m:.message,r:.rendered} |
23+
"::\(.l) file=\(.s.file_name),line=\(.s.line_start),endLine=\(.s.line_end),col=\(.s.column_start),endColumn=\(.s.column_end),title=\(.m)::\(.r)" |
24+
gsub("\n";"%0A") | gsub("\r";"%0D")
25+
'
26+
}
27+
28+
if [ $# -lt 1 ]; then
29+
echo "Usage: $0 {build|check|clippy|fmt} [extra args...]"
30+
exit 1
31+
fi
32+
33+
COMMAND=$1
34+
shift
35+
36+
case "$COMMAND" in
37+
build | check | clippy)
38+
if ! cargo "$COMMAND" --message-format json --verbose "$@" | to_gha; then
39+
echo '::error title='"$COMMAND"' issue::"cargo '"$COMMAND"'" failed'
40+
exit 1
41+
fi
42+
;;
43+
fmt)
44+
if ! cargo fmt --check --verbose "$@"; then
45+
echo '::error title=Formatting issue::"cargo fmt" failed'
46+
exit 1
47+
fi
48+
;;
49+
test)
50+
if ! cargo test --verbose "$@"; then
51+
echo '::error title=Tests failed::"cargo test" failed'
52+
exit 1
53+
fi
54+
;;
55+
nextest)
56+
if ! cargo nextest run --profile ci --config-file "$(git rev-parse --show-toplevel)/.github/tools/nextest.toml" "$@"; then
57+
echo '::error title=Tests failed::"cargo nextest run" failed'
58+
exit 1
59+
fi
60+
;;
61+
*)
62+
echo "Unsupported command: $COMMAND"
63+
exit 1
64+
;;
65+
esac

.github/tools/nextest.toml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
[profile.ci]
2+
# Do not cancel the test run on the first failure.
3+
fail-fast = false
4+
# Show all tests _including_ skipped tests in output.
5+
status-level = "all"
6+
# Output failures as soon as they happen _and_ at the end of the test run;
7+
# combination of "immediate" and "final".
8+
failure-output = "immediate-final"

.github/workflows/ci.yml

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
name: CI
2+
3+
on: [push, pull_request, workflow_dispatch]
4+
5+
env:
6+
CARGO_TERM_COLOR: always
7+
8+
jobs:
9+
build_and_test:
10+
name: Build and Test
11+
runs-on: ubuntu-latest
12+
env:
13+
RUSTFLAGS: -Dwarnings
14+
steps:
15+
- name: Check out repo
16+
uses: actions/checkout@v4
17+
- name: Set up Rust
18+
run: |
19+
rustup toolchain install stable --profile minimal --no-self-update --component rustfmt
20+
- name: Set up Nextest
21+
run: |
22+
curl -LsSf https://get.nexte.st/latest/linux | tar zxf - -C ${CARGO_HOME:-~/.cargo}/bin
23+
- uses: Swatinem/rust-cache@v2
24+
with:
25+
workspaces: trex
26+
- run: ../.github/tools/github_actions_run_cargo fmt
27+
working-directory: ./trex
28+
- run: ../.github/tools/github_actions_run_cargo build
29+
working-directory: ./trex
30+
- run: ../.github/tools/github_actions_run_cargo nextest
31+
working-directory: ./trex
32+
- run: |
33+
../.github/tools/github_actions_run_cargo test --doc
34+
# We need to run `cargo test --doc` separately because doc tests
35+
# aren't included in nextest at the moment. See relevant discussion at
36+
# https://github.com/nextest-rs/nextest/issues/16
37+
working-directory: ./trex

0 commit comments

Comments
 (0)