Skip to content

Commit 9fc8ff0

Browse files
Add CI; pre-emptively bump version
1 parent b0a458a commit 9fc8ff0

File tree

8 files changed

+194
-11
lines changed

8 files changed

+194
-11
lines changed

.github/workflows/full_ci.yaml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
name: full CI
2+
3+
on:
4+
merge_group:
5+
pull_request:
6+
types: [opened, synchronize, reopened]
7+
8+
jobs:
9+
style_check:
10+
name: Style check
11+
runs-on: ubuntu-22.04
12+
steps:
13+
- uses: actions/checkout@v4
14+
- name: Setup Rust toolchain
15+
run: sh ./ci/install-rust.sh
16+
- name: Check style
17+
run: sh ci/style.sh
18+
19+
build_channels_linux:
20+
name: Build Channels Linux
21+
runs-on: ubuntu-22.04
22+
env:
23+
OS: linux
24+
strategy:
25+
fail-fast: true
26+
max-parallel: 2
27+
matrix:
28+
toolchain:
29+
- stable
30+
- 1.66.0
31+
steps:
32+
- uses: actions/checkout@v4
33+
- name: Setup Rust toolchain
34+
run: TOOLCHAIN=${{ matrix.toolchain }} sh ./ci/install-rust.sh
35+
- name: Execute run.sh
36+
run: TOOLCHAIN=${{ matrix.toolchain }} sh ./ci/run.sh

ci/install-rust.sh

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
#!/usr/bin/env sh
2+
# This is intended to be used in CI only.
3+
4+
set -ex
5+
6+
echo "Setup toolchain"
7+
toolchain=
8+
if [ -n "$TOOLCHAIN" ]; then
9+
toolchain=$TOOLCHAIN
10+
else
11+
toolchain=stable
12+
fi
13+
if [ "$OS" = "windows" ]; then
14+
: "${TARGET?The TARGET environment variable must be set.}"
15+
rustup set profile minimal
16+
rustup update --force "$toolchain-$TARGET"
17+
rustup default "$toolchain-$TARGET"
18+
else
19+
rustup set profile minimal
20+
rustup update --force "$toolchain"
21+
rustup default "$toolchain"
22+
fi
23+
24+
if [ -n "$TARGET" ]; then
25+
echo "Install target"
26+
rustup target add "$TARGET"
27+
fi
28+
29+
if [ -n "$INSTALL_RUST_SRC" ]; then
30+
echo "Install rust-src"
31+
rustup component add rust-src
32+
fi
33+
34+
if [ "$OS" = "windows" ]; then
35+
if [ "$ARCH_BITS" = "i686" ]; then
36+
echo "Install MinGW32"
37+
choco install mingw --x86 --force
38+
fi
39+
40+
echo "Find GCC libraries"
41+
gcc -print-search-dirs
42+
/usr/bin/find "C:\ProgramData\Chocolatey" -name "crt2*"
43+
/usr/bin/find "C:\ProgramData\Chocolatey" -name "dllcrt2*"
44+
/usr/bin/find "C:\ProgramData\Chocolatey" -name "libmsvcrt*"
45+
46+
if [ -n "$ARCH_BITS" ]; then
47+
echo "Fix MinGW"
48+
for i in crt2.o dllcrt2.o libmingwex.a libmsvcrt.a ; do
49+
cp -f "/C/ProgramData/Chocolatey/lib/mingw/tools/install/mingw$ARCH_BITS/$ARCH-w64-mingw32/lib/$i" "$(rustc --print sysroot)/lib/rustlib/$TARGET/lib"
50+
done
51+
fi
52+
53+
# Install Wintun
54+
echo "Install Wintun"
55+
curl.exe -o wintun.zip https://www.wintun.net/builds/wintun-0.14.1.zip
56+
powershell.exe -NoP -NonI -Command "Expand-Archive './wintun.zip' './'"
57+
cp -f "./wintun/bin/amd64/wintun.dll" "./"
58+
rm -rf "./wintun"
59+
fi
60+
61+
echo "Query rust and cargo versions"
62+
command -v rustc
63+
command -v cargo
64+
command -v rustup
65+
rustc -Vv
66+
cargo -V
67+
rustup -Vv
68+
rustup show
69+
70+
echo "Generate lockfile"
71+
N=5
72+
n=0
73+
until [ $n -ge $N ]
74+
do
75+
if cargo generate-lockfile; then
76+
break
77+
fi
78+
n=$((n+1))
79+
sleep 1
80+
done

ci/run.sh

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
#!/usr/bin/env sh
2+
3+
# Builds and runs tests for a particular target passed as an argument to this
4+
# script.
5+
6+
set -ex
7+
8+
: "${TOOLCHAIN?The TOOLCHAIN environment variable must be set.}"
9+
: "${OS?The OS environment variable must be set.}"
10+
11+
RUST=${TOOLCHAIN}
12+
13+
echo "Testing Rust ${RUST} on ${OS}"
14+
15+
# FIXME: rustup often fails to download some artifacts due to network
16+
# issues, so we retry this N times.
17+
N=5
18+
n=0
19+
until [ $n -ge $N ]
20+
do
21+
if rustup override set "${RUST}" ; then
22+
break
23+
fi
24+
n=$((n+1))
25+
sleep 1
26+
done
27+
28+
case "${OS}" in
29+
windows*)
30+
cargo test --features wintun
31+
32+
cargo test --features wintun-runtime
33+
34+
cargo test --features tapwin6
35+
36+
cargo test --features tapwin6-runtime
37+
;;
38+
*)
39+
# No extra features in any platform other than windows
40+
41+
cargo test
42+
;;
43+
esac

ci/style.sh

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#!/usr/bin/env sh
2+
3+
set -ex
4+
5+
rustup toolchain install nightly -c rustfmt --allow-downgrade
6+
rustup override set nightly
7+
command -v rustfmt
8+
rustfmt -V
9+
cargo fmt --all -- --check
10+
11+
if shellcheck --version ; then
12+
# GHA's shellcheck is too old (0.4.6) and cannot handle SC2153 correctly.
13+
shellcheck -e SC2103 -e SC2153 ci/*.sh
14+
else
15+
echo "shellcheck not found"
16+
exit 1
17+
fi

pkts-common/Cargo.toml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,11 @@ name = "pkts-common"
33
authors = ["Nathaniel Bennett <me[at]nathanielbennett[dotcom]>"]
44
description = "helper library for shared types/utilities among rscap and pkts"
55
license = "MIT OR Apache-2.0"
6-
version = "0.1.0"
6+
version = "0.2.0"
77
edition = "2021"
8-
repository = "https://github.com/pkts-rs/rscap"
8+
repository = "https://github.com/pkts-rs/pkts"
9+
keywords = ["packets", "network", "scapy", "parsing"]
10+
categories = ["network-programming", "encoding", "parsing"]
911

1012
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
1113

pkts-macros/Cargo.toml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,11 @@ name = "pkts-macros"
33
description = "procedural macros for deriving `pkts` library traits"
44
authors = ["Nathaniel Bennett <me[at]nathanielbennett[dotcom]>"]
55
license = "MIT OR Apache-2.0"
6-
version = "0.1.3"
6+
version = "0.2.0"
77
edition = "2021"
8-
repository = "https://github.com/pkts-rs/rscap"
8+
repository = "https://github.com/pkts-rs/pkts"
9+
keywords = ["packets", "network", "scapy", "parsing"]
10+
categories = ["network-programming", "encoding", "parsing"]
911

1012
[lib]
1113
proc-macro = true

pkts/Cargo.toml

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,14 @@
22
name = "pkts"
33
authors = ["Nathaniel Bennett <me[at]nathanielbennett[dotcom]>"]
44
description = "tools for building, inspecting and modifying network protocol packets"
5-
rust-version = "1.65" # GATs stabilized in this version; required for `Sequence` types
5+
# GATs stabilized in this version; required for `Sequence` types
6+
rust-version = "1.66"
67
license = "MIT OR Apache-2.0"
7-
version = "0.1.3"
8+
version = "0.2.0"
89
edition = "2021"
9-
repository = "https://github.com/pkts-rs/rscap"
10+
repository = "https://github.com/pkts-rs/pkts"
11+
keywords = ["packets", "network", "scapy", "parsing"]
12+
categories = ["network-programming", "encoding", "parsing"]
1013

1114
[features]
1215
default = ["std", "custom_layer_selection", "error_string"]
@@ -16,6 +19,6 @@ error_string = []
1619
custom_layer_selection = ["pkts-macros/custom_layer_selection"]
1720

1821
[dependencies]
19-
bitflags = { version = "2.6" }
20-
pkts-macros = { path = "../pkts-macros", version = "0.1.3" }
21-
pkts-common = { path = "../pkts-common", version = "0.1.0" }
22+
bitflags = { version = "2.6.0" }
23+
pkts-macros = { path = "../pkts-macros", version = "0.2.0" }
24+
pkts-common = { path = "../pkts-common", version = "0.2.0" }

pktspec/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
22
name = "pktspec"
33
authors = ["Nathaniel Bennett <me[at]nathanielbennett[dotcom]>"]
4-
version = "0.1.1"
4+
version = "0.1.0"
55
edition = "2021"
66

77
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

0 commit comments

Comments
 (0)