-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtest.sh
executable file
·70 lines (57 loc) · 1.97 KB
/
test.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#!/bin/sh
printf "\033[31;1mGetting ready...\033[0m\n"
docker_ip="$(ip -4 -j a show dev docker0 | jq -r ".[] | .addr_info[] | .local")"
printf "%s" "{\"release\":{\"upload_url\":\"http://$docker_ip:8000/\",\"tag_name\":\"test\"}}" > event/event.json
cargo build --release --manifest-path ./http-post-capture/Cargo.toml
rm -rf ./output
./http-post-capture/target/release/http-post-capture -l "$docker_ip:8000" -o "output" &
listener_pid="$!"
TARGETS="$(cat targets)"
REPO="$1"
if [ -z "$REPO" ]; then
REPO="rust-build/rust-build.test"
fi
REMOTE="https://github.com/$REPO.git"
EXTRA_FILES="$3"
if [ -z "$EXTRA_FILES" ]; then
EXTRA_FILES=""
fi
if [ -d "test" ]; then
cd "test"
REPO_REMOTE=$(git remote get-url origin)
if [ "$REPO_REMOTE" != "$REMOTE" ]; then
REMOTE="$REPO_REMOTE"
fi
else
git clone "$REMOTE" "test"
cd "test"
fi
printf "\033[31;1mTesting all triples...\033[0m\n"
for target in $TARGETS; do
printf "\033[31m\033[1mTesting %s\033[0m\n" "$target"
sudo docker run \
--mount "type=bind,source=$PWD,destination=/github/$REPO" \
--mount "type=bind,source=$(readlink -f "$PWD/../event"),destination=/event,ro=true" \
-e GITHUB_EVENT_PATH="/event/event.json" \
-e GITHUB_EVENT_DATA="{\"release\":{\"upload_url\":\"http://$docker_ip:8000/\",\"tag_name\":\"test\"}}" \
-e GITHUB_REPOSITORY="$REPO" \
-e GITHUB_WORKSPACE="/github/$REPO" \
-e EXTRA_FILES="$EXTRA_FILES" \
-e RUSTTARGET="$target" \
-e SRC_DIR="$2" \
-e GITHUB_TOKEN="" \
-e TOOLCHAIN_VERSION="nightly" \
-e ARCHIVE_TYPES="zip tar.zst" \
-e GITHUB_OUTPUT="/proc/self/fd/0" \
--rm -t rust-build
done
printf "\033[31;1mCleaning up...\033[0m\n"
kill "$listener_pid"
cd -
printf "\033[31;1mChecking SHA256 sums\033[0m\n"
cd output
find ./ -maxdepth 1 -type f -name "*.sha256sum" | xargs sha256sum -c
cd -
printf "\033[31;1mChecking linux binary runs\033[0m\n"
unzip ./output/rust-build.test_test_x86_64-unknown-linux-musl.zip -d output
./output/hello-no-src