Skip to content

Commit 09a26dc

Browse files
committed
[GHA] Add unit-test workflow
1 parent 0831469 commit 09a26dc

File tree

3 files changed

+85
-64
lines changed

3 files changed

+85
-64
lines changed

.drone.yml

-64
Original file line numberDiff line numberDiff line change
@@ -1,67 +1,3 @@
1-
---
2-
kind: pipeline
3-
name: unit-tests
4-
5-
steps:
6-
- name: bootstrap
7-
image: signalwire/freeswitch-public-base
8-
pull: always
9-
commands:
10-
- ./autogen.sh
11-
12-
- name: configure
13-
image: signalwire/freeswitch-public-base
14-
pull: always
15-
commands:
16-
- apt-get -y install check
17-
- ./configure --with-pic --without-doxygen --disable-stun
18-
19-
- name: build
20-
image: signalwire/freeswitch-public-base
21-
pull: always
22-
commands:
23-
- apt-get -y install check
24-
- echo '#!/bin/bash\nmake -j`nproc --all` |& tee ./unit-tests-build-result.txt\nexitstatus=$${PIPESTATUS[0]}\necho $$exitstatus > ./build-status.txt\n' > build.sh
25-
- chmod +x build.sh
26-
- ./build.sh
27-
28-
- name: run-tests
29-
image: signalwire/freeswitch-public-base
30-
pull: always
31-
commands:
32-
- apt-get -y install check
33-
- make install
34-
- echo '#!/bin/bash\n./tests.sh |& tee ./tests/unit/unit-tests-result.txt\nexitstatus=$${PIPESTATUS[0]}\necho $$exitstatus > ./unit-tests-status.txt\n' > run-tests.sh
35-
- chmod +x run-tests.sh
36-
- make check && exit 0 || echo 'make check failed'
37-
- ./run-tests.sh
38-
- cd tests/unit
39-
- mkdir -p logs && (mv log_run-tests_*.html logs || true) && (mv backtrace_*.txt logs || true)
40-
- ls -la ./logs
41-
- echo 0 > run-tests-status.txt
42-
- ./collect-test-logs.sh && exit 0 || echo 'Some tests failed'
43-
- ls -la
44-
- echo 1 > run-tests-status.txt
45-
- cd logs && ls -la
46-
47-
- name: notify
48-
image: signalwire/drone-notify
49-
pull: always
50-
environment:
51-
SLACK_WEBHOOK_URL:
52-
from_secret: slack_webhook_url
53-
ENV_FILE:
54-
from_secret: notify_env
55-
commands:
56-
- /root/unit-tests-notify.sh
57-
58-
trigger:
59-
branch:
60-
- master
61-
event:
62-
- pull_request
63-
- push
64-
651
---
662
kind: pipeline
673
name: scan-build
File renamed without changes.

.github/workflows/unit-test.yml

+85
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
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

Comments
 (0)