Merge branch 'main' into addRaiseYourHand #1065
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build Maven Project | |
on: | |
push: | |
workflow_dispatch: | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v3 | |
- name: Set up Node.js | |
uses: actions/setup-node@v3 | |
with: | |
node-version: '16.x' | |
registry-url: 'https://registry.npmjs.org' | |
- name: Setup kubectl | |
uses: azure/setup-kubectl@v3 | |
with: | |
version: 'latest' | |
- name: Create kubeconfig file | |
run: | | |
mkdir $HOME/.kube | |
echo "${{ secrets.KUBE_CONFIG_DATA }}" > $HOME/.kube/config | |
- name: Set up JDK 17 | |
uses: actions/setup-java@v3 | |
with: | |
java-version: 17 | |
distribution: 'temurin' | |
server-id: ossrh # Value of the distributionManagement/repository/id field of the pom.xml | |
server-username: MAVEN_USERNAME # env variable for username in deploy | |
server-password: MAVEN_PASSWORD # env variable for token in deploy | |
gpg-private-key: ${{ secrets.MVN_GPG_KEY }} # Value of the GPG private key to import | |
gpg-passphrase: MAVEN_GPG_PASSPHRASE # env variable for GPG private key passphrase | |
- name: Cache Maven repository | |
uses: actions/cache@v3 | |
with: | |
path: ~/.m2/repository | |
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }} | |
restore-keys: ${{ runner.os }}-m2- | |
- name: Cache Node.js modules | |
uses: actions/cache@v3 | |
with: | |
path: react/node_modules | |
key: ${{ runner.os }}-node-modules-${{ hashFiles('react/package-lock.json') }} | |
restore-keys: ${{ runner.os }}-node-modules- | |
- name: Clone ant-media-server-parent | |
run: | | |
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: Clone Ant-Media-Server | |
run: | | |
CI_COMMIT_REF_NAME=$(echo $GITHUB_REF | cut -d'/' -f 3) | |
(if [ $(git ls-remote https://github.com/ant-media/Ant-Media-Server.git $CI_COMMIT_REF_NAME | wc -l) == "1" ]; | |
then | |
echo "$CI_COMMIT_REF_NAME branch found in Ant-Media-Server"; | |
git clone --depth=1 -b $CI_COMMIT_REF_NAME https://github.com/ant-media/Ant-Media-Server.git; | |
else | |
echo "$CI_COMMIT_REF_NAME branch not. Checking out master"; | |
git clone --depth=1 https://github.com/ant-media/Ant-Media-Server.git; | |
fi) | |
cd Ant-Media-Server | |
mvn clean install -DskipTests -Dmaven.javadoc.skip=true -Dgpg.skip=true --quiet | |
cd .. | |
- name: Build React application for webinar | |
env: | |
CI: false | |
NODE_OPTIONS: '--max-old-space-size=4096' | |
run: | | |
cd react | |
mv .env.production .env.production.conferencing | |
mv .env.production.webinar .env.production | |
sed -i "s#^REACT_APP_TURN_SERVER_URL=.*#REACT_APP_TURN_SERVER_URL=\"turn:${{ secrets.STAGING_TURN_URL }}\"#" .env.production | |
sed -i "s#^REACT_APP_TURN_SERVER_USERNAME=.*#REACT_APP_TURN_SERVER_USERNAME=\"${{ secrets.STAGING_TURN_USERNAME }}\"#" .env.production | |
sed -i "s#^REACT_APP_TURN_SERVER_CREDENTIAL=.*#REACT_APP_TURN_SERVER_CREDENTIAL=\"${{ secrets.STAGING_TURN_PASSWORD }}\"#" .env.production | |
npm install | |
npm run build | |
cd .. | |
rm -r webapp/src/main/webapp/static/* | |
cp -a react/build/. webapp/src/main/webapp | |
- name: Build Maven project for webinar | |
run: | | |
cd webapp | |
mvn clean install -DskipTests -Dgpg.skip=true --quiet | |
ls -alh | |
ls -alh target/ | |
cp target/*.war /tmp/circle-webinar.war | |
cd .. | |
- name: Build React application for conferencing | |
env: | |
CI: false | |
NODE_OPTIONS: '--max-old-space-size=4096' | |
run: | | |
cd react | |
mv .env.production.conferencing .env.production | |
sed -i "s#^REACT_APP_TURN_SERVER_URL=.*#REACT_APP_TURN_SERVER_URL=\"turn:${{ secrets.STAGING_TURN_URL }}\"#" .env.production | |
sed -i "s#^REACT_APP_TURN_SERVER_USERNAME=.*#REACT_APP_TURN_SERVER_USERNAME=\"${{ secrets.STAGING_TURN_USERNAME }}\"#" .env.production | |
sed -i "s#^REACT_APP_TURN_SERVER_CREDENTIAL=.*#REACT_APP_TURN_SERVER_CREDENTIAL=\"${{ secrets.STAGING_TURN_PASSWORD }}\"#" .env.production | |
npm install | |
npm run build | |
cd .. | |
rm -r webapp/src/main/webapp/static/* | |
cp -a react/build/. webapp/src/main/webapp | |
- name: Build Maven project for conferencing | |
run: | | |
cd webapp | |
mvn clean install -DskipTests -Dgpg.skip=true --quiet | |
ls -alh | |
ls -alh target/ | |
cp target/*.war /tmp/circle-conferencing.war | |
cd .. | |
- name: Create Test Tool | |
run: | | |
sudo apt-get update | |
sudo apt-get install -y unzip iproute2 libva-drm2 libva-x11-2 libvdpau-dev ffmpeg | |
git clone https://gitlab.com/Ant-Media/webrtc-test.git | |
cd webrtc-test | |
./redeploy.sh | |
cd .. | |
- name: Cache Test Tool | |
uses: actions/cache@v3 | |
with: | |
path: webrtc-test/ | |
key: test-tool-${{ hashFiles('**/tool-source/**') }} | |
restore-keys: test-tool- | |
- name: Upload conferencing war file as artifact | |
if: always() | |
uses: actions/upload-artifact@v4 | |
with: | |
name: circle-conferencing.war | |
path: /tmp/circle-conferencing.war | |
- name: Upload webinar war file as artifact | |
if: always() | |
uses: actions/upload-artifact@v4 | |
with: | |
name: circle-webinar.war | |
path: /tmp/circle-webinar.war | |
- name: Debug WAR file paths | |
run: ls -alh /tmp | |
unit-tests: | |
needs: [build] | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v3 | |
- name: Run Unit Test | |
run: | | |
echo "pwd:" | |
pwd | |
echo "ls:" | |
ls -al | |
cd react | |
npm install --include=dev | |
npm test | |
- name: Upload coverage to Codecov | |
uses: codecov/codecov-action@v4 | |
with: | |
token: ${{ secrets.CODECOV_TOKEN }} | |
conference-integration-tests: | |
needs: [build] | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v3 | |
- name: Restore Cached Test Tool | |
uses: actions/cache@v3 | |
with: | |
path: webrtc-test/ | |
key: test-tool-${{ hashFiles('**/tool-source/**') }} | |
restore-keys: test-tool- | |
- name: Locate Test Tool | |
run: | | |
pwd | |
ls | |
cp webrtc-test/target/webrtc-load-test-tool-*.zip ../ | |
cd .. | |
unzip webrtc-load-test-tool-*.zip | |
mkdir ~/test | |
mv webrtc-load-test ~/test | |
ls -al ~/test | |
- name: Set up JDK 17 | |
uses: actions/setup-java@v3 | |
with: | |
java-version: 17 | |
distribution: 'temurin' | |
server-id: ossrh # Value of the distributionManagement/repository/id field of the pom.xml | |
server-username: MAVEN_USERNAME # env variable for username in deploy | |
server-password: MAVEN_PASSWORD # env variable for token in deploy | |
gpg-private-key: ${{ secrets.MVN_GPG_KEY }} # Value of the GPG private key to import | |
gpg-passphrase: MAVEN_GPG_PASSPHRASE # env variable for GPG private key passphrase | |
- name: Download circle-conferencing.war Artifact | |
uses: actions/download-artifact@v4 | |
with: | |
name: circle-conferencing.war | |
path: /tmp | |
- name: Debug WAR file paths | |
run: ls -alh /tmp | |
- name: Install Selenium | |
run: | | |
wget https://storage.googleapis.com/chrome-for-testing-public/130.0.6723.58/linux64/chromedriver-linux64.zip | |
unzip chromedriver-linux64.zip | |
sudo cp chromedriver-linux64/chromedriver /tmp | |
ls -al /tmp | |
pip3 install selenium==4.14 | |
pip3 install requests | |
pip3 show selenium | |
pip3 install psutil | |
- name: Run Integration Test | |
run: | | |
cd test | |
python3 test_main.py ${{ secrets.STAGING_SERVER_URL }} ${{ secrets.USER_NAME }} ${{ secrets.PASSWORD }} /tmp/circle-conferencing.war false | |
- name: Upload PNG files as artifacts | |
if: always() | |
uses: actions/upload-artifact@v4 | |
with: | |
name: screenshots | |
path: ${{ github.workspace }}/test/**/*.png | |
webinar-integration-tests: | |
needs: [build] | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v3 | |
- name: Restore Cached Test Tool | |
uses: actions/cache@v3 | |
with: | |
path: webrtc-test/ | |
key: test-tool-${{ hashFiles('**/tool-source/**') }} | |
restore-keys: test-tool- | |
- name: Locate Test Tool | |
run: | | |
pwd | |
ls | |
cp webrtc-test/target/webrtc-load-test-tool-*.zip ../ | |
cd .. | |
unzip webrtc-load-test-tool-*.zip | |
mkdir ~/test | |
mv webrtc-load-test ~/test | |
- name: Download circle-webinar.war Artifact | |
uses: actions/download-artifact@v4 | |
with: | |
name: circle-webinar.war | |
path: /tmp | |
- name: Debug WAR file paths | |
run: ls -alh /tmp | |
- name: Install Selenium | |
run: | | |
wget https://storage.googleapis.com/chrome-for-testing-public/130.0.6723.58/linux64/chromedriver-linux64.zip | |
unzip chromedriver-linux64.zip | |
sudo cp chromedriver-linux64/chromedriver /tmp | |
ls -al /tmp | |
pip3 install selenium==4.14 | |
pip3 install requests | |
pip3 show selenium | |
pip3 install psutil | |
- name: Run Integration Test for webinar | |
run: | | |
sleep 10 | |
cd test | |
python3 test_main.py ${{ secrets.STAGING_SERVER_URL }} ${{ secrets.USER_NAME }} ${{ secrets.PASSWORD }} /tmp/circle-webinar.war true | |
collect-and-upload-logs: | |
needs: [unit-tests, webinar-integration-tests , conference-integration-tests] | |
if: always() | |
runs-on: ubuntu-latest | |
steps: | |
- name: Upload PNG files as artifacts | |
if: always() | |
uses: actions/upload-artifact@v4 | |
with: | |
name: screenshots | |
path: ${{ github.workspace }}/test/**/*.png | |
- name: Copy Logs From Pods | |
if: always() | |
run: | | |
for pod in $(kubectl -n circle get pods | grep "ant-media-server" | awk '{print $1}'); do | |
node_ip=$(kubectl -n circle get pods -o wide | grep "$pod" | awk '{print $6}') | |
kubectl -n circle cp $pod:/usr/local/antmedia/log/ant-media-server.log /tmp/ant-media-server-$node_ip.log | |
kubectl -n circle cp $pod:/usr/local/antmedia/log/antmedia-error.log /tmp/antmedia-error-$node_ip.log | |
done | |
- name: Upload log files as artifacts | |
if: always() | |
uses: actions/upload-artifact@v4 | |
with: | |
name: logs | |
path: /tmp/*.log | |
deploy: | |
runs-on: ubuntu-latest | |
needs: collect-and-upload-logs | |
if: github.ref == 'refs/heads/main' | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Set up JDK 17 | |
uses: actions/setup-java@v3 | |
with: | |
java-version: 17 | |
distribution: 'temurin' | |
server-id: ossrh # Value of the distributionManagement/repository/id field of the pom.xml | |
server-username: MAVEN_USERNAME # env variable for username in deploy | |
server-password: MAVEN_PASSWORD # env variable for token in deploy | |
gpg-private-key: ${{ secrets.MVN_GPG_KEY }} # Value of the GPG private key to import | |
gpg-passphrase: MAVEN_GPG_PASSPHRASE # env variable for GPG private key passphrase | |
- name: Build React application for conferencing | |
env: | |
CI: false | |
NODE_OPTIONS: '--max-old-space-size=4096' | |
run: | | |
cd react | |
sed -i "s#^REACT_APP_TURN_SERVER_URL=.*#REACT_APP_TURN_SERVER_URL=\"turn:${{ secrets.STAGING_TURN_URL }}\"#" .env.production | |
sed -i "s#^REACT_APP_TURN_SERVER_USERNAME=.*#REACT_APP_TURN_SERVER_USERNAME=\"${{ secrets.STAGING_TURN_USERNAME }}\"#" .env.production | |
sed -i "s#^REACT_APP_TURN_SERVER_CREDENTIAL=.*#REACT_APP_TURN_SERVER_CREDENTIAL=\"${{ secrets.STAGING_TURN_PASSWORD }}\"#" .env.production | |
npm install | |
npm run build | |
cd .. | |
rm -r webapp/src/main/webapp/static/* | |
cp -a react/build/. webapp/src/main/webapp | |
- name: Publish to Maven Central | |
run: | | |
cd webapp | |
ls -alh | |
mvn -e deploy -DskipTests --quiet --settings ../mvn-settings.xml | |
sleep 60 | |
env: | |
MAVEN_USERNAME: ${{ secrets.MVN_USERNAME }} | |
MAVEN_PASSWORD: ${{ secrets.MVN_PASSWORD }} | |
MAVEN_GPG_PASSPHRASE: ${{ secrets.MVN_GPG_PASSPHRASE }} | |
- name: Get versions data from repo | |
run: wget -O maven-metadata.xml https://oss.sonatype.org/service/local/repositories/snapshots/content/io/antmedia/webrtc/ConferenceCall/maven-metadata.xml | |
- name: Install jq | |
run: sudo apt-get install jq -y | |
- name: Download war File | |
run: | | |
export LATEST_SNAPSHOT=$(cat maven-metadata.xml | grep "<version>" | tail -n 1 | xargs | grep -oP "(?<=<version>).*?(?=</version>)") | |
echo $LATEST_SNAPSHOT | |
wget -O ConferenceCall.war "https://oss.sonatype.org/service/local/artifact/maven/redirect?r=snapshots&g=io.antmedia.webrtc&a=ConferenceCall&v=${LATEST_SNAPSHOT}&e=war" | |
ls -al | |
if [ ! -f ConferenceCall.war ]; then | |
echo "War file not found." | |
exit 1 | |
fi | |
- name: Login to server | |
run: | | |
response=$(curl -X POST -H "Accept: Application/json" -H "Content-Type: application/json" ${{ secrets.STAGING_SERVER_URL }}/rest/v2/users/authenticate -d '{"email":"${{ secrets.USER_NAME }}","password":"${{ secrets.PASSWORD }}"}' -c cookie.txt) | |
success=$(echo $response | jq -r '.success') | |
if [ "$success" != "true" ]; then | |
echo "Login failed" | |
exit 1 | |
fi | |
- name: Check if Conference App Exists | |
run: | | |
response=$(curl -s -H "Accept: Application/json" -H "Content-Type: application/json" "${{ secrets.STAGING_SERVER_URL }}/rest/v2/applications" -b cookie.txt) | |
echo $response | jq . | |
app_exists=$(echo $response | jq -r '.applications | index("Conference")') | |
if [ "$app_exists" != "null" ]; then | |
echo "App exists, proceeding to delete it." | |
response=$(curl -s -X DELETE -H "Accept: Application/json" -H "Content-Type: application/json" "${{ secrets.STAGING_SERVER_URL }}/rest/v2/applications/Conference" -b cookie.txt) | |
success=$(echo $response | jq -r '.success') | |
if [ "$success" != "true" ]; then | |
echo "Conference app deletion failed" | |
exit 1 | |
fi | |
sleep 10 | |
else | |
echo "App does not exist, proceeding to create a new one." | |
fi | |
- name: Create New App | |
run: | | |
export WAR_FILE_NAME="ConferenceCall.war" | |
response=$(curl -X PUT -H "Accept: Application/json" -H "Content-Type: multipart/form-data" -F "file=@./$WAR_FILE_NAME" "${{ secrets.STAGING_SERVER_URL }}/rest/v2/applications/Conference" -b cookie.txt) | |
sleep 5 | |
success=$(echo $response | jq -r '.success') | |
if [ "$success" != "true" ]; then | |
echo "Conference app creation is failed" | |
exit 1 | |
fi | |
sleep 10 | |
- name: Update Turn Settings | |
run: | | |
curl "${{ secrets.STAGING_SERVER_URL }}/rest/v2/applications/settings/Conference" -b cookie.txt -o settings.json | |
jq '.stunServerURI = "turn:${{ secrets.STAGING_TURN_URL }}" | .turnServerUsername = "${{ secrets.STAGING_TURN_USERNAME }}" | .turnServerCredential = "${{ secrets.STAGING_TURN_PASSWORD }}"' settings.json > updated_settings.json | |
response=$(curl -X POST -H "Accept: Application/json" -H "Content-Type: application/json" -d @updated_settings.json -b cookie.txt "${{ secrets.STAGING_SERVER_URL }}/rest/v2/applications/settings/Conference") | |
success=$(echo $response | jq -r '.success') | |
if [ "$success" != "true" ]; then | |
echo "Importing setting is failed." | |
exit 1 | |
fi |