Skip to content

Commit

Permalink
Fix build-breakers
Browse files Browse the repository at this point in the history
Fix some build-breaking issues introduced in [1].

* Update Dockerfile for new integration tests

* Update MacOS and Windows runners for new integration tests

* alpine doesn't have bash; make integration tests use sh

References

1. 7c419a7 "ci, sample: add tests for child processes"
  • Loading branch information
cbs228 committed Feb 3, 2024
1 parent 708cfa7 commit 98b4491
Show file tree
Hide file tree
Showing 9 changed files with 80 additions and 91 deletions.
28 changes: 6 additions & 22 deletions .github/workflows/rust_release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -230,17 +230,9 @@ jobs:
- name: Run integration tests
shell: bash
run: |
set -e;
"$samedec_exe" --version
for file in $(basename -s .bin sample/*.s16le.bin); do
printf '[%s]\n' "$file";
"$samedec_exe" -r 22050 <"sample/$file.bin" | tee result;
cmp result "sample/$file.txt" || {
echo "FAIL!";
exit 1;
};
echo "PASS";
done
pushd sample &&
./test.sh &&
popd
- name: Copy artifact
shell: bash
Expand Down Expand Up @@ -316,17 +308,9 @@ jobs:
- name: Run integration tests
run: |
set -e;
"$samedec_exe" --version
for file in $(basename -s .bin sample/*.s16le.bin); do
printf '[%s]\n' "$file";
"$samedec_exe" -r 22050 <"sample/$file.bin" | tee result;
cmp result "sample/$file.txt" || {
echo "FAIL!";
exit 1;
};
echo "PASS";
done
pushd sample &&
./test.sh &&
popd
- name: Copy artifact
run: |
Expand Down
22 changes: 7 additions & 15 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
### set --build-arg CARGO_NET_OFFLINE=true

# Rust version, like "1" or "1.67.0"
ARG BUILD_RUST_TAG=1.67
ARG BUILD_RUST_TAG=1.70

# Build operating system
# Use slim-buster for glibc or alpine for musl
Expand Down Expand Up @@ -100,21 +100,13 @@ RUN [ -n "$CARGO_BUILD_TARGET" ] || unset CARGO_BUILD_TARGET && \
cargo test --frozen --release --workspace && \
cargo install --frozen --path=crates/samedec

# Perform tests
RUN samedec --version
# Perform integration tests
COPY sample sample

COPY sample/*.22050.s16le.* .

RUN set -e; \
for file in $(basename -s .bin *.s16le.bin); do \
printf '[%s]\n' "$file"; \
samedec -r 22050 <"$file.bin" | tee result; \
cmp result "$file.txt" || {\
echo "FAIL!"; \
exit 1; \
}; \
echo "PASS"; \
done
RUN samedec --version && \
cd sample && \
SAMEDEC=/usr/local/bin/samedec ./test.sh && \
cd ..

###
### NON-IMAGE
Expand Down
13 changes: 0 additions & 13 deletions sample/long_message.22050.s16le.bash

This file was deleted.

15 changes: 15 additions & 0 deletions sample/long_message.22050.s16le.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/usr/bin/env sh

set -e

# close standard input to ignore it
exec 0>/dev/null

[ "$SAMEDEC_RATE" = "22050" ]
[ "$SAMEDEC_EVENT" = "Practice/Demo Warning" ]
[ "$SAMEDEC_ORG" = "EAS" ]
[ "$SAMEDEC_SIGNIFICANCE" = "W" ]
[ "$SAMEDEC_LOCATIONS" = "372088 091724 919623 645687 745748 175234 039940 955869 091611 304171 931612 334828 179485 569615 809223 830187 611340 014693 472885 084645 977764 466883 406863 390018 701741 058097 752790 311648 820127 255900 581947" ]
[ "$SAMEDEC_ISSUETIME" = "$SAMEDEC_PURGETIME" ]

echo "+OK"
14 changes: 0 additions & 14 deletions sample/npt.22050.s16le.bash

This file was deleted.

16 changes: 16 additions & 0 deletions sample/npt.22050.s16le.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/usr/bin/env sh

set -e

# close standard input to ignore it
exec 0>/dev/null

[ "$SAMEDEC_EVENT" = "National Periodic Test" ]
[ "$SAMEDEC_ORG" = "PEP" ]
[ "$SAMEDEC_SIGNIFICANCE" = "T" ]
[ "$SAMEDEC_LOCATIONS" = "000000" ]

lifetime=$(( SAMEDEC_PURGETIME - SAMEDEC_ISSUETIME))
[ "$lifetime" -eq $(( 30*60 )) ]

echo "+OK"
35 changes: 21 additions & 14 deletions sample/test.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env bash
#!/usr/bin/env sh
#
# Runs integration tests for samedec.
#
Expand All @@ -12,12 +12,13 @@
# The integration tests ensure that samedec's child process
# spawning and environment variable assignment works.

set -euo pipefail
set -eu

if [ -n "${SAMEDEC:-}" ]; then
RUNARGS=("${SAMEDEC}")
if [ -z "${SAMEDEC:-}" ]; then
SAMEDEC="cargo"
ARGS="run -q -p samedec --"
else
RUNARGS=('cargo' 'run' '-q' '-p' 'samedec' '--')
ARGS=""
fi

run_samedec() {
Expand All @@ -26,23 +27,29 @@ run_samedec() {

infile="$1"

"${RUNARGS[@]}" \
#shellcheck disable=SC2086
"$SAMEDEC" $ARGS \
--rate 22050 \
--file "${infile}.bin" \
-- \
bash \
"${infile}.bash" | tee /dev/stderr
sh \
"${infile}.sh"
}

for file in $(basename -s .bin *.s16le.bin); do
for file in $(basename -s .bin -- *.s16le.bin); do
[ -e "${file}.bin" ] || exit 1

printf '[%s]\n' "$file"

cmp <(run_samedec "$file") "$file.txt" || {
printf '[%s]: FAIL\n' "$file"
exit 1
};
output="$(run_samedec "$file")"
expect="$(cat "${file}.txt")"

printf '[%s]: PASS\n' "$file"
echo "$output"

if [ "$output" = "$expect" ]; then
printf '[%s]: PASS\n' "$file"
else
printf '[%s]: FAIL\n' "$file"
exit 1
fi
done
13 changes: 0 additions & 13 deletions sample/two_and_two.22050.s16le.bash

This file was deleted.

15 changes: 15 additions & 0 deletions sample/two_and_two.22050.s16le.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/usr/bin/env sh

set -e

# close standard input to ignore it
exec 0>/dev/null

[ "$SAMEDEC_EVENT" = "Severe Thunderstorm Warning" ]
[ "$SAMEDEC_ORIGINATOR" = "Weather Service" ]
[ "$SAMEDEC_SIGNIFICANCE" = "W" ]

lifetime=$(( SAMEDEC_PURGETIME - SAMEDEC_ISSUETIME))
[ "$lifetime" -eq $(( 1*60*60 + 30*60 )) ]

echo "+OK"

0 comments on commit 98b4491

Please sign in to comment.