|
| 1 | +name: API Testing |
| 2 | +on: |
| 3 | + pull_request: |
| 4 | + branches: [ "main" ] |
| 5 | + |
| 6 | +jobs: |
| 7 | + build: |
| 8 | + runs-on: ubuntu-latest |
| 9 | + |
| 10 | + steps: |
| 11 | + - uses: actions/checkout@v4 |
| 12 | + |
| 13 | + - name: Set up Python 3.9 |
| 14 | + uses: actions/setup-python@v5 |
| 15 | + with: |
| 16 | + python-version: '3.9' |
| 17 | + |
| 18 | + - name: Clone nmos-testing Repository |
| 19 | + run: git clone https://github.com/AMWA-TV/nmos-testing.git nmos-testing |
| 20 | + |
| 21 | + - name: Install nmos-testing Requirements |
| 22 | + run: | |
| 23 | + python -m pip install --upgrade pip |
| 24 | + pip install -r nmos-testing/requirements.txt |
| 25 | +
|
| 26 | + - name: Verify Python and Packages |
| 27 | + run: | |
| 28 | + python --version |
| 29 | + pip --version |
| 30 | + pip list |
| 31 | +
|
| 32 | + - name: Install dependencies and build |
| 33 | + run: cargo build |
| 34 | + |
| 35 | + - name: Start App |
| 36 | + run: | |
| 37 | + cargo run & |
| 38 | + echo $! > node_pid.txt |
| 39 | +
|
| 40 | + - name: Wait for app to be ready |
| 41 | + run: | |
| 42 | + for i in {1..20}; do |
| 43 | + if nc -z localhost 3000; then |
| 44 | + echo "Server is up!" |
| 45 | + exit 0 |
| 46 | + fi |
| 47 | + echo "Waiting for server..." |
| 48 | + sleep 2 |
| 49 | + done |
| 50 | + echo "Server did not start in time." |
| 51 | + exit 1 |
| 52 | +
|
| 53 | + - name: Copy and show UserConfig.py |
| 54 | + run: | |
| 55 | + mkdir -p nmos-testing/nmostesting |
| 56 | + cp nmos-testing-config/UserConfig.py nmos-testing/nmostesting/UserConfig.py |
| 57 | + echo "Contents of copied UserConfig.py:" |
| 58 | + cat nmos-testing/nmostesting/UserConfig.py |
| 59 | +
|
| 60 | + - name: Run IS-12 Test Suite |
| 61 | + working-directory: nmos-testing |
| 62 | + run: | |
| 63 | + mkdir -p ../test_results |
| 64 | + python nmos-test.py suite IS-12-01 \ |
| 65 | + --host 127.0.0.1 127.0.0.1 null null \ |
| 66 | + --port 3000 3000 0 0 \ |
| 67 | + --version v1.3 v1.0 v1.0 v1.0 \ |
| 68 | + --urlpath null /ws null null \ |
| 69 | + --output ../test_results/is_12_01_results.json || true |
| 70 | +
|
| 71 | + - name: Check IS-12 Test Results |
| 72 | + run: | |
| 73 | + RESULTS_FILE="test_results/is_12_01_results.json" |
| 74 | + if [ ! -f "$RESULTS_FILE" ]; then |
| 75 | + echo "ERROR: Results file $RESULTS_FILE not found" |
| 76 | + exit 1 |
| 77 | + fi |
| 78 | + FAILED=$(jq -r '.results[] | select(.state=="Fail") | "\(.name): \(.state), detail: \(.detail // "")"' "$RESULTS_FILE") |
| 79 | + if [ -n "$FAILED" ]; then |
| 80 | + echo "❌ NMOS Test Failures:" |
| 81 | + echo "$FAILED" |
| 82 | + exit 1 |
| 83 | + else |
| 84 | + echo "✅ All NMOS tests passed!" |
| 85 | + fi |
| 86 | +
|
| 87 | + - name: Stop App |
| 88 | + if: always() |
| 89 | + run: | |
| 90 | + if [ -f node_pid.txt ]; then |
| 91 | + kill $(cat node_pid.txt) || true |
| 92 | + fi |
| 93 | + pkill -f 'cargo run' || true |
0 commit comments