-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
GitHub action to run integration tests (#1)
- Loading branch information
Showing
2 changed files
with
96 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
name: Test | ||
|
||
on: [pull_request] | ||
|
||
jobs: | ||
run-tests: | ||
name: Run Tests | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
python-version: | ||
- "3.8" | ||
- "3.9" | ||
- "3.10" | ||
- "3.11" | ||
fail-fast: false | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
|
||
- name: Set up Python ${{ matrix.python-version }} | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: ${{ matrix.python-version }} | ||
cache: pip | ||
cache-dependency-path: pyproject.toml | ||
|
||
- name: Install dependencies | ||
run: | | ||
python -m pip install --upgrade pip | ||
python -m pip install -e .[tests] | ||
- name: Run tests | ||
run: ./scripts/test.sh | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
#!/usr/bin/env bash | ||
|
||
# Runs user/integration tests. | ||
|
||
set -e | ||
|
||
PROJECT_ROOT="$(git rev-parse --show-toplevel)" | ||
TMP_DIRS_FILE=/tmp/p9fs-dirs | ||
PY9S_SERVER_PID=/tmp/p9fs.pid | ||
PY9S_SERVER_LOG=/tmp/p9fs.log | ||
|
||
function mymktempdir { | ||
local tmpdir="$(mktemp -d)" | ||
echo "$tmpdir" | tee -a $TMP_DIRS_FILE | ||
} | ||
|
||
function run_py9s_server { | ||
local exported_dir="$1" | ||
cd "$PROJECT_ROOT/src" | ||
python -m py9p -p 1234 -w -d -r "$exported_dir" &> $PY9S_SERVER_LOG & | ||
echo $! > $PY9S_SERVER_PID | ||
|
||
echo Waiting for 9p server ... | ||
SERVER_READY="" | ||
for i in $(seq 1 5); do | ||
if nc -d -w 1 -z 127.0.0.1 1234; then | ||
SERVER_READY="true" | ||
break | ||
fi | ||
sleep 1 | ||
done | ||
if [[ ! $SERVER_READY ]]; then | ||
echo 9p server failed to start | ||
exit 1 | ||
fi | ||
} | ||
|
||
function user_tests { | ||
local exported_dir="$1" | ||
cd "$PROJECT_ROOT/src" | ||
python -m pytest -v -rA ../tests/user --exported "$exported_dir" | ||
} | ||
|
||
function cleanup { | ||
if [[ -f $PY9S_SERVER_PID ]]; then | ||
kill "$(<$PY9S_SERVER_PID)" || true | ||
rm -f "$PY9S_SERVER_PID" | ||
fi | ||
if [[ -f $TMP_DIRS_FILE ]]; then | ||
xargs -n1 -r rm -rf < $TMP_DIRS_FILE | ||
rm -f $TMP_DIRS_FILE | ||
fi | ||
} | ||
|
||
trap cleanup EXIT | ||
|
||
rm -f "$TMP_DIRS_FILE" | ||
|
||
EXPORTED_DIR=""$(mymktempdir)"" | ||
run_py9s_server "$EXPORTED_DIR" | ||
user_tests "$EXPORTED_DIR" |