Skip to content

Commit f93d1c4

Browse files
committed
Initial public release
0 parents  commit f93d1c4

Some content is hidden

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

44 files changed

+14290
-0
lines changed
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
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.1
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+
# Reads the config from .config/nextest.toml
57+
if ! cargo nextest run --profile ci "$@"; then
58+
echo '::error title=Tests failed::"cargo nextest run" failed'
59+
exit 1
60+
fi
61+
;;
62+
*)
63+
echo "Unsupported command: $COMMAND"
64+
exit 1
65+
;;
66+
esac

.github/workflows/ci.yml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
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+
defaults:
13+
run:
14+
working-directory: ./trex
15+
env:
16+
RUSTFLAGS: -Dwarnings
17+
steps:
18+
- name: Check out repo
19+
uses: actions/checkout@v4
20+
- name: Set up Rust
21+
run: |
22+
rustup toolchain install stable --profile minimal --no-self-update --component rustfmt
23+
- name: Set up Nextest
24+
run: |
25+
curl -LsSf https://get.nexte.st/latest/linux | tar zxf - -C ${CARGO_HOME:-~/.cargo}/bin
26+
- uses: Swatinem/rust-cache@v2
27+
- run: ./.github/tools/github_actions_run_cargo fmt
28+
- run: ./.github/tools/github_actions_run_cargo build
29+
- run: ./.github/tools/github_actions_run_cargo nextest
30+
- run: |
31+
./.github/tools/github_actions_run_cargo test --doc
32+
# We need to run `cargo test --doc` separately because doc tests
33+
# aren't included in nextest at the moment. See relevant discussion at
34+
# https://github.com/nextest-rs/nextest/issues/16

0 commit comments

Comments
 (0)