name: Tests E2E on: workflow_call: inputs: node-version: required: true type: string lowercase-repo: required: true type: string rc-dockerfile: required: true type: string rc-docker-tag: required: true type: string rc-dockerfile-alpine: required: true type: string rc-docker-tag-alpine: required: true type: string gh-docker-tag: required: true type: string enterprise-license: type: string transporter: type: string mongodb-version: default: "['4.4', '6.0']" required: false type: string release: required: true type: string publish-container: default: false type: boolean shard: default: '[1]' required: false type: string total-shard: default: 1 required: false type: number type: required: true type: string secrets: CR_USER: required: true CR_PAT: required: true QASE_API_TOKEN: required: false env: MONGO_URL: mongodb://localhost:27017/rocketchat?replicaSet=rs0&directConnection=true TOOL_NODE_FLAGS: ${{ vars.TOOL_NODE_FLAGS }} LOWERCASE_REPOSITORY: ${{ inputs.lowercase-repo }} DOCKER_TAG: ${{ inputs.gh-docker-tag }} jobs: test: runs-on: ubuntu-20.04 env: RC_DOCKERFILE: ${{ matrix.mongodb-version == '6.0' && inputs.rc-dockerfile-alpine || inputs.rc-dockerfile }} RC_DOCKER_TAG: ${{ matrix.mongodb-version == '6.0' && inputs.rc-docker-tag-alpine || inputs.rc-docker-tag }} strategy: fail-fast: false matrix: mongodb-version: ${{ fromJSON(inputs.mongodb-version) }} shard: ${{ fromJSON(inputs.shard) }} name: MongoDB ${{ matrix.mongodb-version }} (${{ matrix.shard }}/${{ inputs.total-shard }}) steps: - name: Launch MongoDB uses: supercharge/mongodb-github-action@1.9.0 with: mongodb-version: ${{ matrix.mongodb-version }} mongodb-replica-set: rs0 - uses: actions/checkout@v3 - name: Setup NodeJS uses: ./.github/actions/setup-node with: node-version: ${{ inputs.node-version }} cache-modules: true install: true - uses: dtinth/setup-github-actions-caching-for-turbo@v1 - name: yarn build run: yarn build - name: Restore build uses: actions/download-artifact@v3 with: name: build path: /tmp/build - name: Unpack build run: | cd /tmp/build tar xzf Rocket.Chat.tar.gz rm Rocket.Chat.tar.gz - name: Start containers if: inputs.release == 'ce' env: MONGO_URL: 'mongodb://host.docker.internal:27017/rocketchat?replicaSet=rs0&directConnection=true' run: | docker compose -f docker-compose-ci.yml up -d --build rocketchat - name: Start containers if: inputs.release == 'ee' env: MONGO_URL: 'mongodb://host.docker.internal:27017/rocketchat?replicaSet=rs0&directConnection=true' ENTERPRISE_LICENSE: ${{ inputs.enterprise-license }} TRANSPORTER: ${{ inputs.transporter }} run: | docker compose -f docker-compose-ci.yml up -d --build - name: Login to GitHub Container Registry if: inputs.publish-container == true && (github.event.pull_request.head.repo.full_name == github.repository || github.event_name == 'release' || github.ref == 'refs/heads/develop') uses: docker/login-action@v2 with: registry: ghcr.io username: ${{ secrets.CR_USER }} password: ${{ secrets.CR_PAT }} - name: Publish Docker images to GitHub Container Registry if: inputs.publish-container == true && inputs.release == 'ce' && (github.event.pull_request.head.repo.full_name == github.repository || github.event_name == 'release' || github.ref == 'refs/heads/develop') run: | docker compose -f docker-compose-ci.yml push rocketchat if [[ '${{ matrix.mongodb-version }}' = '4.4' ]]; then IMAGE_NAME_BASE="ghcr.io/${LOWERCASE_REPOSITORY}/rocket.chat:${{ inputs.gh-docker-tag }}" echo "Push Docker image: ${IMAGE_NAME_BASE}" docker tag ${IMAGE_NAME_BASE}.official $IMAGE_NAME_BASE docker push $IMAGE_NAME_BASE fi; - name: Publish Docker images (services) to GitHub Container Registry if: inputs.publish-container == true && inputs.release == 'ee' && (github.event.pull_request.head.repo.full_name == github.repository || github.event_name == 'release' || github.ref == 'refs/heads/develop') run: | docker compose -f docker-compose-ci.yml push \ authorization-service \ account-service \ ddp-streamer-service \ presence-service \ stream-hub-service - name: Cache Playwright binaries if: inputs.type == 'ui' uses: actions/cache@v3 id: cache-playwright with: path: | ~/.cache/ms-playwright # This is the version of Playwright that we are using, if you are willing to upgrade, you should update this. key: playwright-1.23.1 - name: Install Playwright if: inputs.type == 'ui' && steps.cache-playwright.outputs.cache-hit != 'true' working-directory: ./apps/meteor run: npx playwright install --with-deps - name: Wait for Rocket.Chat to start up uses: cygnetdigital/wait_for_response@v2.0.0 with: url: 'http://localhost:3000/health' responseCode: '200' timeout: 60000 interval: 1000 - name: Wait services to start up if: inputs.release == 'ee' run: | docker ps until echo "$(docker compose -f docker-compose-ci.yml logs ddp-streamer-service)" | grep -q "NetworkBroker started successfully"; do echo "Waiting 'ddp-streamer' to start up" ((c++)) && ((c==10)) && docker compose -f docker-compose-ci.yml logs ddp-streamer-service && exit 1 sleep 10 done; - name: E2E Test API if: inputs.type == 'api' working-directory: ./apps/meteor env: IS_EE: ${{ inputs.release == 'ee' && 'true' || '' }} run: | for i in $(seq 1 2); do npm run testapi && s=0 && break || s=$? docker compose -f ../../docker-compose-ci.yml logs --tail=100 docker compose -f ../../docker-compose-ci.yml stop docker exec mongodb bash -c 'if command -v mongosh ; then mongosh --eval "use rocketchat" --eval "db.dropDatabase()" rocketchat; else mongo rocketchat --eval "db.dropDatabase()"; fi' NOW=$(date "+%Y-%m-%dT%H:%M:%S.000Z") docker compose -f ../../docker-compose-ci.yml restart until echo "$(docker compose -f ../../docker-compose-ci.yml logs rocketchat --since $NOW)" | grep -q "SERVER RUNNING"; do echo "Waiting Rocket.Chat to start up" ((c++)) && ((c==10)) && exit 1 sleep 10 done; done; exit $s - name: E2E Test UI (${{ matrix.shard }}/${{ inputs.total-shard }}) if: inputs.type == 'ui' env: E2E_COVERAGE: ${{ inputs.release == 'ee' && 'true' || '' }} IS_EE: ${{ inputs.release == 'ee' && 'true' || '' }} QASE_API_TOKEN: ${{ secrets.QASE_API_TOKEN }} QASE_REPORT: ${{ github.ref == 'refs/heads/develop' && 'true' || '' }} working-directory: ./apps/meteor run: yarn test:e2e --shard=${{ matrix.shard }}/${{ inputs.total-shard }} - name: Store playwright test trace if: inputs.type == 'ui' && always() uses: actions/upload-artifact@v3 with: name: playwright-test-trace${{ inputs.release }} path: ./apps/meteor/tests/e2e/.playwright* - name: Show server logs if E2E test failed if: failure() run: docker compose -f docker-compose-ci.yml logs rocketchat - name: Extract e2e:ee:coverage if: inputs.type == 'ui' && inputs.release == 'ee' working-directory: ./apps/meteor run: yarn test:e2e:nyc - uses: codecov/codecov-action@v3 if: inputs.type == 'ui' && inputs.release == 'ee' with: directory: ./apps/meteor flags: e2e verbose: true - name: Store e2e-ee-coverage if: inputs.type == 'ui' && inputs.release == 'ee' uses: actions/upload-artifact@v3 with: name: e2e-ee-coverage path: ./apps/meteor/coverage*