Skip to content

[GHA] Add unit-test workflow #297

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
64 changes: 0 additions & 64 deletions .drone.yml
Original file line number Diff line number Diff line change
@@ -1,67 +1,3 @@
---
kind: pipeline
name: unit-tests

steps:
- name: bootstrap
image: signalwire/freeswitch-public-base
pull: always
commands:
- ./autogen.sh

- name: configure
image: signalwire/freeswitch-public-base
pull: always
commands:
- apt-get -y install check
- ./configure --with-pic --without-doxygen --disable-stun

- name: build
image: signalwire/freeswitch-public-base
pull: always
commands:
- apt-get -y install check
- echo '#!/bin/bash\nmake -j`nproc --all` |& tee ./unit-tests-build-result.txt\nexitstatus=$${PIPESTATUS[0]}\necho $$exitstatus > ./build-status.txt\n' > build.sh
- chmod +x build.sh
- ./build.sh

- name: run-tests
image: signalwire/freeswitch-public-base
pull: always
commands:
- apt-get -y install check
- make install
- 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
- chmod +x run-tests.sh
- make check && exit 0 || echo 'make check failed'
- ./run-tests.sh
- cd tests/unit
- mkdir -p logs && (mv log_run-tests_*.html logs || true) && (mv backtrace_*.txt logs || true)
- ls -la ./logs
- echo 0 > run-tests-status.txt
- ./collect-test-logs.sh && exit 0 || echo 'Some tests failed'
- ls -la
- echo 1 > run-tests-status.txt
- cd logs && ls -la

- name: notify
image: signalwire/drone-notify
pull: always
environment:
SLACK_WEBHOOK_URL:
from_secret: slack_webhook_url
ENV_FILE:
from_secret: notify_env
commands:
- /root/unit-tests-notify.sh

trigger:
branch:
- master
event:
- pull_request
- push

---
kind: pipeline
name: scan-build
Expand Down
File renamed without changes.
86 changes: 86 additions & 0 deletions .github/workflows/unit-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
name: Unit tests

on:
pull_request:
push:
branches:
- master
paths:
- "**"

jobs:
unit-test:
runs-on: ubuntu-latest
container:
image: signalwire/freeswitch-public-ci-base:bookworm-amd64
options: --privileged
env:
DEBIAN_FRONTEND: noninteractive

steps:
- name: Checkout Sofia-Sip
uses: actions/checkout@v4

- name: Install dependencies
shell: bash
run: |
rm -vf /etc/apt/sources.list.d/freeswitch.list
apt-get update && apt-get -y install check

- name: Configure, Build and Install Sofia-Sip
shell: bash
run: |
./autogen.sh || exit 1
./configure --with-pic --without-doxygen --disable-stun || exit 1
make -j$(nproc --all) install || exit 1

- name: Run unit tests
shell: bash
run: |
make check

- name: Check unit tests
if: always()
shell: bash
run: |
if find ./ -name "*.trs" | xargs grep FAIL -l | grep -q .; then
exit 1
fi

- name: Collect unit test logs
if: failure()
shell: bash
run: |
find ./ -name "*.trs" | xargs grep FAIL -l | while read test; do
dir=$(dirname "$test")
file=$(basename "$test")
cat "$dir/test-suite.log" | ansi2html > "tests/unit/log_run-tests_${dir//\//!}!$file.html"
done

cd tests/unit && mkdir -p logs

mv -v log_run-tests_*.html logs || true
mv -v backtrace_*.txt logs || true

./collect-test-logs.sh || echo 'Some tests failed'

- name: Upload Unit-Test logs
if: failure()
uses: actions/upload-artifact@v4
with:
name: unit-test-logs
path: tests/unit/logs
if-no-files-found: ignore
compression-level: 9

- name: Notify run tests result to slack
if: |
failure() &&
github.event_name == 'push' &&
github.ref == 'refs/heads/master'
uses: signalwire/actions-template/.github/actions/slack@main
with:
CHANNEL: ${{ secrets.SLACK_DEVOPS_CI_CHANNEL }}
MESSAGE: Unit-Tests ${{ github.repository }} > <${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}|${{ github.run_id }}>. Some tests are failing.
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
Loading