From 606909580403208cd3209316e9fc68e135aabf90 Mon Sep 17 00:00:00 2001 From: cruizba Date: Tue, 27 Dec 2022 22:01:16 +0100 Subject: [PATCH] ci: Common building scripts to commons.sh --- .github/workflows/openvidu-ce-test.yml | 14 +- ci-scripts/commons.sh | 91 ++++++++++++- ci-scripts/openvidu-e2e-tests.sh | 181 ++----------------------- 3 files changed, 105 insertions(+), 181 deletions(-) diff --git a/.github/workflows/openvidu-ce-test.yml b/.github/workflows/openvidu-ce-test.yml index 7396d6ef..4fbb9a51 100644 --- a/.github/workflows/openvidu-ce-test.yml +++ b/.github/workflows/openvidu-ce-test.yml @@ -71,18 +71,20 @@ jobs: - uses: actions/checkout@v3 - name: Setting up CI run: ci-scripts/commons.sh --prepare + - name: Prepare Kurento Snapshots + run: ci-scripts/commons.sh --prepare-kurento-snapshot - name: OpenVidu Browser build - run: ci-scripts/openvidu-e2e-tests.sh --build-openvidu-browser + run: ci-scripts/commons.sh --build-openvidu-browser - name: OpenVidu Node Client build - run: ci-scripts/openvidu-e2e-tests.sh --build-openvidu-node-client + run: ci-scripts/commons.sh --build-openvidu-node-client - name: OpenVidu Java Client build - run: ci-scripts/openvidu-e2e-tests.sh --build-openvidu-java-client + run: ci-scripts/commons.sh --build-openvidu-java-client + - name: OpenVidu Server pre-build + run: ci-scripts/commons.sh --build-openvidu-parent - name: OpenVidu TestApp build - run: ci-scripts/openvidu-e2e-tests.sh --build-openvidu-testapp + run: ci-scripts/commons.sh --build-openvidu-testapp - name: OpenVidu Server dashboard build run: ci-scripts/openvidu-e2e-tests.sh --build-dashboard - - name: OpenVidu Server pre-build - run: ci-scripts/openvidu-e2e-tests.sh --openvidu-server-pre-build - name: OpenVidu Server unit tests run: ci-scripts/openvidu-e2e-tests.sh --openvidu-server-unit-tests - name: OpenVidu Server integration tests diff --git a/ci-scripts/commons.sh b/ci-scripts/commons.sh index f62ee1aa..03ffaca8 100755 --- a/ci-scripts/commons.sh +++ b/ci-scripts/commons.sh @@ -7,6 +7,11 @@ GITHUB_ACTIONS_WORKING_DIR="${GITHUB_ACTIONS_WORKING_DIR:-}" PREPARE=false PREPARE_KURENTO_SNAPSHOT=false EXECUTE_ALL=false +BUILD_OV_BROWSER=false +BUILD_OV_NODE_CLIENT=false +BUILD_OV_JAVA_CLIENT=false +BUILD_OV_PARENT=false +BUILD_OV_TESTAPP=false # cd to directory if GITHUB_ACTIONS_WORKING_DIR is set if [[ -n "${GITHUB_ACTIONS_WORKING_DIR:-}" ]]; then @@ -26,6 +31,26 @@ if [[ -n ${1:-} ]]; then PREPARE_KURENTO_SNAPSHOT=true shift 1 ;; + --build-openvidu-browser ) + BUILD_OV_BROWSER=true + shift 1 + ;; + --build-openvidu-node-client ) + BUILD_OV_NODE_CLIENT=true + shift 1 + ;; + --build-openvidu-java-client ) + BUILD_OV_JAVA_CLIENT=true + shift 1 + ;; + --build-openvidu-parent ) + BUILD_OV_PARENT=true + shift 1 + ;; + --build-openvidu-testapp ) + BUILD_OV_TESTAPP=true + shift 1 + ;; *) break ;; @@ -36,7 +61,7 @@ else fi # ------------- -# 1. Prepare build +# Prepare build # ------------- if [[ "${PREPARE}" == true || "${EXECUTE_ALL}" == true ]]; then @@ -126,7 +151,7 @@ if [[ "${PREPARE}" == true || "${EXECUTE_ALL}" == true ]]; then fi # ------------- -# 2. Prepare Kurento Snapshots +# Prepare Kurento Snapshots # ------------- if [[ "${PREPARE_KURENTO_SNAPSHOT}" == true || "${EXECUTE_ALL}" == true ]]; then @@ -134,9 +159,69 @@ if [[ "${PREPARE_KURENTO_SNAPSHOT}" == true || "${EXECUTE_ALL}" == true ]]; then if [[ $KURENTO_JAVA_COMMIT != "default" ]]; then git clone https://github.com/Kurento/kurento-java.git pushd kurento-java - git checkout -f "$KURENTO_JAVA_COMMIT" + git checkout -f "${KURENTO_JAVA_COMMIT}" + MVN_VERSION="$(grep -oPm1 "(?<=)[^<]+" "pom.xml")" mvn -B -Dmaven.artifact.threads=1 clean install popd + rm -rf kurento-java + mvn -B versions:set-property \ + -Dproperty=version.kurento \ + -DnewVersion="${MVN_VERSION}" fi +fi + +# ------------- +# OpenVidu Browser build +# ------------- +if [[ "${BUILD_OV_BROWSER}" == true || "${EXECUTE_ALL}" == true ]]; then + pushd openvidu-browser || exit 1 + npm install + npm run build + npm link + popd +fi + +# ------------- +# OpenVidu Node client build +# ------------- +if [[ "${BUILD_OV_NODE_CLIENT}" == true || "${EXECUTE_ALL}" == true ]]; then + pushd openvidu-node-client + npm install + npm run build + npm link + popd +fi + +# ------------- +# OpenVidu Java client build +# ------------- +if [[ "${BUILD_OV_JAVA_CLIENT}" == true || "${EXECUTE_ALL}" == true ]]; then + pushd openvidu-java-client + mvn -B versions:set -DnewVersion=TEST + mvn -B clean compile package + mvn -B install:install-file -Dfile=target/openvidu-java-client-TEST.jar \ + -DgroupId=io.openvidu \ + -DartifactId=openvidu-java-client \ + -Dversion=TEST -Dpackaging=jar + popd +fi + +# ------------- +# OpenVidu Parent build +# ------------- +if [[ "${BUILD_OV_PARENT}" == true || "${EXECUTE_ALL}" == true ]]; then + mvn -B versions:set-property -Dproperty=version.openvidu.java.client -DnewVersion=TEST + mvn -B -DskipTests=true -Dmaven.artifact.threads=1 clean install +fi + +# ------------- +# OpenVidu Test App build +# ------------- +if [[ "${BUILD_OV_TESTAPP}" == true || "${EXECUTE_ALL}" == true ]]; then + pushd openvidu-testapp + npm install + npm link openvidu-browser openvidu-node-client + export NG_CLI_ANALYTICS="false" && ./node_modules/@angular/cli/bin/ng.js build --configuration production --output-path=/opt/openvidu/testapp + popd fi \ No newline at end of file diff --git a/ci-scripts/openvidu-e2e-tests.sh b/ci-scripts/openvidu-e2e-tests.sh index 5912d477..8b37a567 100755 --- a/ci-scripts/openvidu-e2e-tests.sh +++ b/ci-scripts/openvidu-e2e-tests.sh @@ -2,13 +2,7 @@ set -eu -o pipefail # Ci flags -PREPARE=false -BUILD_OV_BROWSER=false -BUILD_OV_NODE_CLIENT=false -BUILD_OV_JAVA_CLIENT=false -BUILD_OV_TESTAPP=false BUILD_OV_DASHBOARD=false -OV_PRE_BUILD=false OV_INTEGRATION_TESTS=false OV_UNIT_TESTS=false OV_E2E_TESTS_BUILD=false @@ -176,34 +170,10 @@ if [[ -n ${1:-} ]]; then while : do case "${1:-}" in - --prepare ) - PREPARE=true - shift 1 - ;; - --build-openvidu-browser ) - BUILD_OV_BROWSER=true - shift 1 - ;; - --build-openvidu-node-client ) - BUILD_OV_NODE_CLIENT=true - shift 1 - ;; - --build-openvidu-java-client ) - BUILD_OV_JAVA_CLIENT=true - shift 1 - ;; - --build-openvidu-testapp ) - BUILD_OV_TESTAPP=true - shift 1 - ;; --build-dashboard ) BUILD_OV_DASHBOARD=true shift 1 ;; - --openvidu-server-pre-build ) - OV_PRE_BUILD=true - shift 1 - ;; --openvidu-server-unit-tests ) OV_UNIT_TESTS=true shift 1 @@ -245,121 +215,8 @@ else EXECUTE_ALL=true fi - # ------------- -# 1. Prepare build -# ------------- -if [[ "${PREPARE}" == true || "${EXECUTE_ALL}" == true ]]; then - - # Connect e2e test container to network bridge so it is vissible for browser and media server containers - E2E_CONTAINER_ID="$(docker ps | grep 'openvidu/openvidu-test-e2e:*' | awk '{ print $1 }')" - docker network connect bridge "${E2E_CONTAINER_ID}" - - # Pull browser images - docker pull selenium/standalone-chrome:"${CHROME_VERSION}" - docker pull selenium/standalone-firefox:"${FIREFOX_VERSION}" - docker pull selenium/standalone-opera:"${OPERA_VERSION}" - docker pull selenium/standalone-edge:"${EDGE_VERSION}" - - # Pull mediasoup and kurento - docker pull openvidu/mediasoup-controller:"${MEDIASOUP_CONTROLLER_VERSION}" - docker pull "${KURENTO_MEDIA_SERVER_IMAGE}" - - # Prepare directory Openvidu - sudo mkdir -p /opt/openvidu/recordings && sudo chmod 777 /opt/openvidu/recordings - - - # Configure Snapshots repository - if [[ -n "${KURENTO_SNAPSHOTS_URL}" ]]; then - pushd ci-scripts - sed -i "s|KURENTO_SNAPSHOTS_URL|${KURENTO_SNAPSHOTS_URL}|g" kurento-snapshots.xml - rm /etc/maven/settings.xml - mv kurento-snapshots.xml /etc/maven/settings.xml - popd - fi - - # Download fake videos - FAKE_VIDEO1=/opt/openvidu/barcode.y4m - FAKE_VIDEO2=/opt/openvidu/girl.mjpeg - if [ ! -f ${FAKE_VIDEO1} ]; then - sudo curl --location https://github.com/OpenVidu/openvidu/raw/master/openvidu-test-e2e/docker/barcode.y4m --create-dirs --output /opt/openvidu/barcode.y4m - else - echo "File ${FAKE_VIDEO1} already exists" - fi - if [ ! -f ${FAKE_VIDEO2} ]; then - sudo curl --location https://github.com/OpenVidu/openvidu/raw/master/openvidu-test-e2e/docker/girl.mjpeg --create-dirs --output /opt/openvidu/girl.mjpeg - else - echo "File ${FAKE_VIDEO2} already exists" - fi - - # Download fake audios - FAKE_AUDIO1=/opt/openvidu/fakeaudio.wav - FAKE_AUDIO2=/opt/openvidu/stt-test.wav - if [ ! -f ${FAKE_AUDIO1} ]; then - sudo curl --location https://github.com/OpenVidu/openvidu/raw/master/openvidu-test-e2e/docker/fakeaudio.wav --create-dirs --output /opt/openvidu/fakeaudio.wav - else - echo "File ${FAKE_AUDIO1} already exists" - fi - if [ ! -f ${FAKE_AUDIO2} ]; then - sudo curl --location https://github.com/OpenVidu/openvidu/raw/master/openvidu-test-e2e/docker/stt-test.wav --create-dirs --output /opt/openvidu/stt-test.wav - else - echo "File ${FAKE_AUDIO2} already exists" - fi - - # Download recording custom layout - sudo curl --location https://raw.githubusercontent.com/OpenVidu/openvidu/master/openvidu-test-e2e/docker/my-custom-layout/index.html --create-dirs --output /opt/openvidu/test-layouts/layout1/index.html - - # Open permissions for /opt/openvidu folder - chmod -R 777 /opt/openvidu - -fi - -# ------------- -# 2. OpenVidu Browser build -# ------------- -if [[ "${BUILD_OV_BROWSER}" == true || "${EXECUTE_ALL}" == true ]]; then - pushd openvidu-browser || exit 1 - npm install - npm run build - npm link - popd -fi - -# ------------- -# 3. OpenVidu Node client build -# ------------- -if [[ "${BUILD_OV_NODE_CLIENT}" == true || "${EXECUTE_ALL}" == true ]]; then - pushd openvidu-node-client - npm install --legacy-peer-deps - npm run build - npm link - popd -fi - -# ------------- -# 4. OpenVidu Java client build -# ------------- -if [[ "${BUILD_OV_JAVA_CLIENT}" == true || "${EXECUTE_ALL}" == true ]]; then - pushd openvidu-java-client - mvn -B versions:set -DnewVersion=TEST - mvn -B clean compile package - mvn -B install:install-file -Dfile=target/openvidu-java-client-TEST.jar -DgroupId=io.openvidu -DartifactId=openvidu-java-client -Dversion=TEST -Dpackaging=jar - popd -fi - -# ------------- -# 5. OpenVidu Test App build -# ------------- -if [[ "${BUILD_OV_TESTAPP}" == true || "${EXECUTE_ALL}" == true ]]; then - pushd openvidu-testapp - npm install - npm link openvidu-browser openvidu-node-client - export NG_CLI_ANALYTICS="false" && ./node_modules/@angular/cli/bin/ng.js build --configuration production --output-path=/opt/openvidu/testapp - popd -fi - -# ------------- -# 6. OpenVidu Dashboard build +# OpenVidu Dashboard build # ------------- if [[ "${BUILD_OV_DASHBOARD}" == true || "${EXECUTE_ALL}" == true ]]; then pushd openvidu-server/src/dashboard @@ -370,27 +227,7 @@ if [[ "${BUILD_OV_DASHBOARD}" == true || "${EXECUTE_ALL}" == true ]]; then fi # ------------- -# 7. OpenVidu Pre build -# ------------- -if [[ "${OV_PRE_BUILD}" == true || "${EXECUTE_ALL}" == true ]]; then - if [[ ${KURENTO_JAVA_COMMIT} != "default" ]]; then - git clone https://github.com/Kurento/kurento-java.git - pushd kurento-java - git checkout -f "${KURENTO_JAVA_COMMIT}" - MVN_VERSION="$(grep -oPm1 "(?<=)[^<]+" "pom.xml")" - mvn -B -Dmaven.artifact.threads=1 clean install - popd - rm -rf kurento-java - mvn -B versions:set-property -Dproperty=version.kurento -DnewVersion="${MVN_VERSION}" - fi - - mvn -B versions:set-property -Dproperty=version.openvidu.java.client -DnewVersion=TEST - mvn -B -DskipTests=true -Dmaven.artifact.threads=1 clean install - -fi - -# ------------- -# 8. OpenVidu Unit tests +# OpenVidu Unit tests # ------------- if [[ "${OV_UNIT_TESTS}" == true || "${EXECUTE_ALL}" == true ]]; then pushd openvidu-server @@ -399,7 +236,7 @@ if [[ "${OV_UNIT_TESTS}" == true || "${EXECUTE_ALL}" == true ]]; then fi # ------------- -# 9. OpenVidu Unit tests +# OpenVidu Integration tests # ------------- if [[ "${OV_INTEGRATION_TESTS}" == true || "${EXECUTE_ALL}" == true ]]; then pushd openvidu-server @@ -408,7 +245,7 @@ if [[ "${OV_INTEGRATION_TESTS}" == true || "${EXECUTE_ALL}" == true ]]; then fi # ------------- -# 10. OpenVidu E2E Tests build +# OpenVidu E2E Tests build # ------------- if [[ "${OV_E2E_TESTS_BUILD}" == true || "${EXECUTE_ALL}" == true ]]; then pushd openvidu-test-browsers @@ -422,7 +259,7 @@ if [[ "${OV_E2E_TESTS_BUILD}" == true || "${EXECUTE_ALL}" == true ]]; then fi # ------------- -# 11. OpenVidu Server build +# OpenVidu Server build # ------------- if [[ "${OV_SERVER_BUILD}" == true || "${EXECUTE_ALL}" == true ]]; then pushd openvidu-server @@ -432,28 +269,28 @@ if [[ "${OV_SERVER_BUILD}" == true || "${EXECUTE_ALL}" == true ]]; then fi # ------------- -# 12. Environment launch Kurento +# Environment launch Kurento # ------------- if [[ "${LAUNCH_OV_KURENTO}" == true || "${EXECUTE_ALL}" == true ]]; then environmentLaunch "kurento" fi # ------------- -# 13. OpenVidu E2E Tests Kurento +# OpenVidu E2E Tests Kurento # ------------- if [[ "${OV_E2E_KURENTO}" == true || "${EXECUTE_ALL}" == true ]]; then openviduE2ETests "kurento" fi # ------------- -# 14. Environment launch mediasoup +# Environment launch mediasoup # ------------- if [[ "${LAUNCH_OV_MEDIASOUP}" == true || "${EXECUTE_ALL}" == true ]]; then environmentLaunch "mediasoup" fi # ------------- -# 15. OpenVidu E2E Tests Kurento +# OpenVidu E2E Tests Kurento # ------------- if [[ "${OV_E2E_MEDIASOUP}" == true || "${EXECUTE_ALL}" == true ]]; then openviduE2ETests "mediasoup"