|
| 1 | +name: Unit tests |
| 2 | + |
| 3 | +on: |
| 4 | + pull_request: |
| 5 | + push: |
| 6 | + branches: |
| 7 | + - master |
| 8 | + paths: |
| 9 | + - "**" |
| 10 | + |
| 11 | +jobs: |
| 12 | + unit-test: |
| 13 | + runs-on: ubuntu-latest |
| 14 | + container: |
| 15 | + image: signalwire/freeswitch-public-ci-base:bookworm-amd64 |
| 16 | + options: --privileged |
| 17 | + env: |
| 18 | + DEBIAN_FRONTEND: noninteractive |
| 19 | + |
| 20 | + steps: |
| 21 | + - name: Checkout Sofia-Sip |
| 22 | + uses: actions/checkout@v4 |
| 23 | + |
| 24 | + - name: Install dependencies |
| 25 | + shell: bash |
| 26 | + run: | |
| 27 | + rm -vf /etc/apt/sources.list.d/freeswitch.list |
| 28 | + apt-get update && apt-get -y install check |
| 29 | +
|
| 30 | + - name: Configure, Build and Install Sofia-Sip |
| 31 | + shell: bash |
| 32 | + run: | |
| 33 | + ./autogen.sh || exit 1 |
| 34 | + ./configure --with-pic --without-doxygen --disable-stun || exit 1 |
| 35 | + make -j$(nproc --all) install || exit 1 |
| 36 | +
|
| 37 | + - name: Run unit tests |
| 38 | + shell: bash |
| 39 | + run: | |
| 40 | + make check |
| 41 | +
|
| 42 | + if find ./ -name "*.trs" | xargs grep FAIL -l | grep -q .; then |
| 43 | + echo "❌ Tests failed. See logs for details." |
| 44 | + exit 1 |
| 45 | + else |
| 46 | + echo "✅ All tests passed successfully." |
| 47 | + fi |
| 48 | +
|
| 49 | + - name: Collect unit test logs |
| 50 | + if: failure() |
| 51 | + shell: bash |
| 52 | + run: | |
| 53 | + find ./ -name "*.trs" | xargs grep FAIL -l | while read test; do |
| 54 | + dir=$(dirname "$test") |
| 55 | + file=$(basename "$test") |
| 56 | + cat "$dir/test-suite.log" | ansi2html > "tests/unit/log_run-tests_${dir//\//!}!$file.html" |
| 57 | + done |
| 58 | +
|
| 59 | + cd tests/unit && mkdir -p logs |
| 60 | +
|
| 61 | + mv -v log_run-tests_*.html logs || true |
| 62 | + mv -v backtrace_*.txt logs || true |
| 63 | +
|
| 64 | + ./collect-test-logs.sh || echo 'Some tests failed' |
| 65 | +
|
| 66 | + - name: Upload Unit-Test logs |
| 67 | + if: failure() |
| 68 | + uses: actions/upload-artifact@v4 |
| 69 | + with: |
| 70 | + name: unit-test-logs |
| 71 | + path: tests/unit/logs |
| 72 | + if-no-files-found: ignore |
| 73 | + compression-level: 9 |
| 74 | + |
| 75 | + - name: Notify run tests result to slack |
| 76 | + if: | |
| 77 | + failure() && |
| 78 | + github.event_name == 'push' && |
| 79 | + github.ref == 'refs/heads/master' |
| 80 | + uses: signalwire/actions-template/.github/actions/slack@main |
| 81 | + with: |
| 82 | + CHANNEL: ${{ secrets.SLACK_DEVOPS_CI_CHANNEL }} |
| 83 | + MESSAGE: Unit-Tests ${{ github.repository }} > <${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}|${{ github.run_id }}>. Some tests are failing. |
| 84 | + env: |
| 85 | + SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} |
0 commit comments