Skip to content

Commit 3019970

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

File tree

3 files changed

+86
-64
lines changed

3 files changed

+86
-64
lines changed

.drone.yml

Lines changed: 0 additions & 64 deletions
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

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
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+
- name: Check unit tests
43+
if: always()
44+
shell: bash
45+
run: |
46+
if find ./ -name "*.trs" | xargs grep FAIL -l | grep -q .; then
47+
exit 1
48+
fi
49+
50+
- name: Collect unit test logs
51+
if: failure()
52+
shell: bash
53+
run: |
54+
find ./ -name "*.trs" | xargs grep FAIL -l | while read test; do
55+
dir=$(dirname "$test")
56+
file=$(basename "$test")
57+
cat "$dir/test-suite.log" | ansi2html > "tests/unit/log_run-tests_${dir//\//!}!$file.html"
58+
done
59+
60+
cd tests/unit && mkdir -p logs
61+
62+
mv -v log_run-tests_*.html logs || true
63+
mv -v backtrace_*.txt logs || true
64+
65+
./collect-test-logs.sh || echo 'Some tests failed'
66+
67+
- name: Upload Unit-Test logs
68+
if: failure()
69+
uses: actions/upload-artifact@v4
70+
with:
71+
name: unit-test-logs
72+
path: tests/unit/logs
73+
if-no-files-found: ignore
74+
compression-level: 9
75+
76+
- name: Notify run tests result to slack
77+
if: |
78+
failure() &&
79+
github.event_name == 'push' &&
80+
github.ref == 'refs/heads/master'
81+
uses: signalwire/actions-template/.github/actions/slack@main
82+
with:
83+
CHANNEL: ${{ secrets.SLACK_DEVOPS_CI_CHANNEL }}
84+
MESSAGE: Unit-Tests ${{ github.repository }} > <${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}|${{ github.run_id }}>. Some tests are failing.
85+
env:
86+
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}

0 commit comments

Comments
 (0)