Skip to content

Commit

Permalink
Merge branch 'master' into userMultiApp
Browse files Browse the repository at this point in the history
  • Loading branch information
lastpeony committed Jul 1, 2024
2 parents da00a20 + af6c0db commit 4076a52
Show file tree
Hide file tree
Showing 25 changed files with 1,594 additions and 616 deletions.
100 changes: 100 additions & 0 deletions .github/actions/build-projects/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
name: 'Build Projects'
description: 'Clone and Build directly dependent projects to package Ant Media Server'
inputs:
branch_name:
description: 'build branch name'
required: true
default: 'master'


runs:
using: "composite"
steps:

- name: Clone and build Ant Media Server Parent project
shell: bash
run: |
git clone --depth=1 -b ${{ inputs.branch_name }} https://github.com/ant-media/ant-media-server-parent.git || git clone --depth=1 https://github.com/ant-media/ant-media-server-parent.git
cd ant-media-server-parent
mvn clean install -DskipTests -Dmaven.javadoc.skip=true -Dgpg.skip=true --quiet
cd ..
- name: Build Ant Media Server project
shell: bash
run: mvn clean install -Dmaven.javadoc.skip=true -Dmaven.test.skip=true -Dgpg.skip=true --quiet

- name: Clone and build StreamApp project
shell: bash
run: |
git clone --depth=1 -b ${{ inputs.branch_name }} https://github.com/ant-media/StreamApp.git || git clone --depth=1 https://github.com/ant-media/StreamApp.git
cd StreamApp
npm install
npm run compile
cd embedded-player
npm install
npm run compile
npm run deploy
cd ..
mvn clean install -DskipTests -Dmaven.javadoc.skip=true -Dgpg.skip=true -B -V --quiet
cd ..
- name: Install NVM (Node Version Manager)
run: |
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.3/install.sh | bash
ls -la
pwd
shell: bash

- name: Cache node_modules directtory for Web Panel Angular project
uses: actions/cache@v4
with:
key: ${{ runner.os }}-node_modules-cache
path: |
~/ManagementConsole_AngularApp-node_modules-cache
- name: Clone Management Console Web Panel Angular project
shell: bash
run: git clone --depth=1 -b ${{ inputs.branch_name }} https://github.com/ant-media/ManagementConsole_AngularApp.git || git clone --depth=1 https://github.com/ant-media/ManagementConsole_AngularApp.git

- name: Copy node_modules from cache directory if exists
shell: bash
run: |
ls -la
ls ..
pwd
if [ -d "$HOME/ManagementConsole_AngularApp-node_modules-cache" ]; then
echo "Copy node_modules from cache directory to ManagementConsole_AngularApp directory"
cp -a $HOME/ManagementConsole_AngularApp-node_modules-cache/. ManagementConsole_AngularApp/node_modules/
else
echo "No cache directory found at $HOME"
fi
- name: Clone and build Management Console Web Panel Angular project
shell: bash
run: |
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
nvm install 16.20.2 # install node.js version for angular
nvm use 16.20.2 # use node.js version for angular
npm install -g @angular/[email protected]
cd ManagementConsole_AngularApp
. $NVM_DIR/nvm.sh
npm install
ng build --prod
cp -a ./dist/. ../src/main/server/webapps/root/
cd ..
- name: Copy node_modules to cache directory
shell: bash
run: |
rm -rf ~/ManagementConsole_AngularApp-node_modules-cache/
cp -a ManagementConsole_AngularApp/node_modules/. ~/ManagementConsole_AngularApp-node_modules-cache/
- name: Replace ffmpeg builds
shell: bash
run: |
wget -O ~/.m2/repository/org/bytedeco/ffmpeg/5.1.2-1.5.8/ffmpeg-5.1.2-1.5.8-linux-x86_64.jar https://storage.sbg.cloud.ovh.net/v1/AUTH_8cb28f9bc6ee43f0a3a1825efbb4311e/test-storage/ffmpeg-5.1.2-1.5.8-linux-x86_64.jar
wget -O ~/.m2/repository/org/bytedeco/ffmpeg/5.1.2-1.5.8/ffmpeg-5.1.2-1.5.8-linux-arm64.jar https://storage.sbg.cloud.ovh.net/v1/AUTH_8cb28f9bc6ee43f0a3a1825efbb4311e/test-storage/ffmpeg-5.1.2-1.5.8-linux-arm64.jar
264 changes: 264 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,264 @@

name: Ant Media Server Community Edition Test

on:
push:
branches:
- '**'
pull_request:
branches:
- '**'

env:
RUNNER: ubuntu-22.04

jobs:
run-unit-tests:
runs-on: ubuntu-22.04
env:
GPG_TTY: ${{ secrets.GPG_TTY }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
SONAR_HOST_URL: https://sonarcloud.io

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up JDK 17
uses: actions/setup-java@v4
with:
distribution: 'adopt' #openjdk
java-version: '17'
cache: 'maven'

- name: Add MongoDB 6.0 GPG key and repository
run: |
if [ ! -f /usr/share/keyrings/mongodb-server-6.0.gpg ]; then
curl -fsSL https://pgp.mongodb.com/server-6.0.asc | sudo gpg -o /usr/share/keyrings/mongodb-server-6.0.gpg --dearmor
fi
echo "deb [ arch=amd64,arm64 signed-by=/usr/share/keyrings/mongodb-server-6.0.gpg ] https://repo.mongodb.org/apt/ubuntu jammy/mongodb-org/6.0 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-6.0.list
- name: Add Redis repository
run: |
sudo rm -rf /usr/share/keyrings/redis-archive-keyring.gpg
curl -fsSL https://packages.redis.io/gpg | sudo gpg --dearmor -o /usr/share/keyrings/redis-archive-keyring.gpg
echo "deb [signed-by=/usr/share/keyrings/redis-archive-keyring.gpg] https://packages.redis.io/deb $(lsb_release -cs) main" | sudo tee /etc/apt/sources.list.d/redis.list
- name: Install dependencies
run: sudo apt-get update && sudo apt-get install -y redis redis-tools mongodb-org ffmpeg wondershaper

- name: Start Redis
run: sudo systemctl start redis-server

- name: Start MongoDB
run: sudo systemctl start mongod

- name: Install Onvif Simulator
run: sudo git clone --depth=1 https://github.com/ant-media/utilities.git /usr/local/onvif

- name: Build projects
uses: ./.github/actions/build-projects
with:
branch_name: ${{ github.ref_name }}


- name: Run tests and SonarCloud analysis
run: |
export RELEASE_VERSION="$(mvn -q -Dexec.executable="echo" -Dexec.args='${project.version}' --non-recursive exec:exec)"
echo $RELEASE_VERSION
mvn clean org.jacoco:jacoco-maven-plugin:prepare-agent package -Dtest=!*/integration/* -Dorg.bytedeco.javacpp.logger.debug=true org.jacoco:jacoco-maven-plugin:report sonar:sonar -Dmaven.javadoc.skip=true --quiet
- name: Show MongoDB Log, Crash Log and Servis Status on failure
if: failure()
run: |
if [[ -f /var/log/mongodb/mongod.log ]]; then
sudo cat /var/log/mongodb/mongod.log
fi
if [[ -f hs_err_pid*.log ]]; then
cat hs_err_pid*.log
else
echo "No hs_err_pid*.log file found"
fi
sudo service mongod status
sudo service redis-server status
check-vulnerabilities:
runs-on: ubuntu-22.04

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up JDK 17
uses: actions/setup-java@v4
with:
distribution: 'adopt' #openjdk
java-version: '17'
cache: 'maven'

- name: Build projects
uses: ./.github/actions/build-projects
with:
branch_name: ${{ github.ref_name }}

- name: Check vulnerabilities
run: mvn org.owasp:dependency-check-maven:check -DfailOnError=false


- name: Show MongoDB Log, Crash Log and Servis Status on failure
if: failure()
run: |
if [[ -f /var/log/mongodb/mongod.log ]]; then
sudo cat /var/log/mongodb/mongod.log
fi
if [[ -f hs_err_pid*.log ]]; then
cat hs_err_pid*.log
else
echo "No hs_err_pid*.log file found"
fi
sudo service mongod status
sudo service redis-server status
run-integration-tests:
runs-on: ubuntu-22.04

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up JDK 17
uses: actions/setup-java@v4
with:
distribution: 'adopt' #openjdk
java-version: '17'
cache: 'maven'


- name: Add MongoDB 6.0 GPG key and repository
run: |
if [ ! -f /usr/share/keyrings/mongodb-server-6.0.gpg ]; then
curl -fsSL https://pgp.mongodb.com/server-6.0.asc | sudo gpg -o /usr/share/keyrings/mongodb-server-6.0.gpg --dearmor
fi
echo "deb [ arch=amd64,arm64 signed-by=/usr/share/keyrings/mongodb-server-6.0.gpg ] https://repo.mongodb.org/apt/ubuntu jammy/mongodb-org/6.0 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-6.0.list
- name: Add Redis repository
run: |
sudo rm -rf /usr/share/keyrings/redis-archive-keyring.gpg
curl -fsSL https://packages.redis.io/gpg | sudo gpg --dearmor -o /usr/share/keyrings/redis-archive-keyring.gpg
echo "deb [signed-by=/usr/share/keyrings/redis-archive-keyring.gpg] https://packages.redis.io/deb $(lsb_release -cs) main" | sudo tee /etc/apt/sources.list.d/redis.list
- name: Install dependencies
run: sudo apt-get update && sudo apt-get install -y redis redis-tools mongodb-org ffmpeg wondershaper

- name: Start Redis
run: sudo systemctl start redis-server

- name: Start MongoDB
run: sudo systemctl start mongod

- name: Install Chrome
run: |
wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb
sudo apt-get install -y ./google-chrome-stable_current_amd64.deb
- name: Install Onvif Simulator
run: sudo git clone --depth=1 https://github.com/ant-media/utilities.git /usr/local/onvif

- name: Build projects
uses: ./.github/actions/build-projects
with:
branch_name: ${{ github.ref_name }}

- name: Package Ant Media Server
run: mvn clean package -U -P assemble -Dmaven.javadoc.skip=true -Dmaven.test.skip=true -DskipTests=true --quiet

- name: Install Ant Media Server
run: |
wget https://raw.githubusercontent.com/ant-media/Scripts/${{ github.ref_name }}/install_ant-media-server.sh -O target/install_ant-media-server.sh || wget https://raw.githubusercontent.com/ant-media/Scripts/master/install_ant-media-server.sh -O target/install_ant-media-server.sh
chmod 755 target/install_ant-media-server.sh
cd target
sudo ./install_ant-media-server.sh -i ant-media-server-community*.zip
cd ..
sleep 20
sudo cp src/test/resources/preset-red5-web.properties /usr/local/antmedia/webapps/LiveApp/WEB-INF/red5-web.properties
sudo cp src/test/resources/preset-red5-web.db /usr/local/antmedia/liveapp.db
sudo sed -i 's^server.cpu_limit=.*^server.cpu_limit=100^' /usr/local/antmedia/conf/red5.properties
sudo sed -i 's^server.memory_limit_percentage=.*^server.memory_limit_percentage=100^' /usr/local/antmedia/conf/red5.properties
sudo chown -R antmedia:antmedia /usr/local/antmedia/
sudo service antmedia stop
sudo service antmedia start
sleep 10
- name: Run integration tests
run: |
export RELEASE_VERSION="$(mvn -q -Dexec.executable="echo" -Dexec.args='${project.version}' --non-recursive exec:exec)"
echo $RELEASE_VERSION
mvn clean org.jacoco:jacoco-maven-plugin:prepare-agent package -Dtest=*/integration/* -Dmaven.javadoc.skip=true --quiet

- name: Show Ant Media Server Error Log on failure
if: failure()
run: cat /usr/local/antmedia/log/antmedia-error.log

- name: Show Ant Media Server Log on failure
if: failure()
run: cat /usr/local/antmedia/log/ant-media-server.log

- name: Show MongoDB Log, Crash Log and Servis Status on failure
if: failure()
run: |
if [[ -f /var/log/mongodb/mongod.log ]]; then
sudo cat /var/log/mongodb/mongod.log
fi
if [[ -f /usr/local/antmedia/hs_err_pid*.log ]]; then
cat /usr/local/antmedia/hs_err_pid*.log
fi
if [[ -f hs_err_pid*.log ]]; then
cat hs_err_pid*.log
else
echo "No hs_err_pid*.log file found"
fi
sudo service mongod status
sudo service redis-server status

deploy:
runs-on: ubuntu-22.04
needs: [run-unit-tests, check-vulnerabilities, run-integration-tests]
env:
CI_DEPLOY_USERNAME: ${{ secrets.CI_DEPLOY_USERNAME }}
CI_DEPLOY_PASSWORD: ${{ secrets.CI_DEPLOY_PASSWORD }}
GPG_KEY_NAME: ${{ secrets.GPG_KEY_NAME }}
GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up JDK 17
uses: actions/setup-java@v4
with:
distribution: 'adopt' #openjdk
java-version: '17'
cache: 'maven'
gpg-private-key: ${{ secrets.GPG_PRIVATE_KEY }}

- name: Build projects # there is low probability that if somethings has pushed to the related branch while running test and before this job, it may build something not exactly same
uses: ./.github/actions/build-projects
with:
branch_name: ${{ github.ref_name }}
- name: Deploy snapshots
if: github.ref_type != 'tag'
run: |
echo "Deploy to snapshots"
mvn deploy -P assemble -DskipTests --settings mvn-settings.xml
echo "Deploy to snapshots exited with $?"
- name: Deploy release
if: startsWith(github.ref, 'refs/tags/ams-v')
run: |
echo "Deploy to release"
mvn deploy -P assemble -DskipTests --settings mvn-settings.xml --quiet
echo "Deploy to release exited with $?"
Loading

0 comments on commit 4076a52

Please sign in to comment.