diff --git a/.github/workflows/build_and_test.yml b/.github/workflows/build_and_test.yml index 015459e8f6fd..3c61d0519fe7 100644 --- a/.github/workflows/build_and_test.yml +++ b/.github/workflows/build_and_test.yml @@ -146,15 +146,9 @@ jobs: repo-token: ${{ secrets.RC_TURBO_GH_TOKEN }} server-token: ${{ secrets.TURBO_SERVER_TOKEN }} - - name: Lint - run: yarn lint --api="http://127.0.0.1:9080" --token="${{ secrets.TURBO_SERVER_TOKEN }}" --team='rc' - - name: Translation check run: yarn turbo run translation-check --api="http://127.0.0.1:9080" --token="${{ secrets.TURBO_SERVER_TOKEN }}" --team='rc' - - name: TS typecheck - run: yarn turbo run typecheck --api="http://127.0.0.1:9080" --token="${{ secrets.TURBO_SERVER_TOKEN }}" --team='rc' - - name: Reset Meteor if: startsWith(github.ref, 'refs/tags/') == 'true' || github.ref == 'refs/heads/develop' working-directory: ./apps/meteor @@ -181,9 +175,95 @@ jobs: name: build path: /tmp/Rocket.Chat.tar.gz + ts-typecheck: + runs-on: ubuntu-20.04 + + steps: + - name: Set Swap Space + uses: pierotofy/set-swap-space@master + with: + swap-size-gb: 4 + + - uses: actions/checkout@v3 + + - name: Use Node.js 14.21.2 + uses: actions/setup-node@v3 + with: + node-version: '14.21.2' + cache: 'yarn' + + - name: Free disk space + run: | + sudo apt clean + docker rmi $(docker image ls -aq) + df -h + + - name: Versions + run: | + npm --versions + yarn -v + node -v + git version + + - name: yarn install + run: yarn + + - name: TurboRepo local server + uses: felixmosh/turborepo-gh-artifacts@v2 + if: "${{ env.TURBO_TEAM != '' }}" + with: + repo-token: ${{ secrets.RC_TURBO_GH_TOKEN }} + server-token: ${{ secrets.TURBO_SERVER_TOKEN }} + + - name: TS typecheck + run: yarn turbo run typecheck --api="http://127.0.0.1:9080" --token="${{ secrets.TURBO_SERVER_TOKEN }}" --team='rc' + + lint: + runs-on: ubuntu-20.04 + + steps: + - name: Set Swap Space + uses: pierotofy/set-swap-space@master + with: + swap-size-gb: 4 + + - uses: actions/checkout@v3 + + - name: Use Node.js 14.21.2 + uses: actions/setup-node@v3 + with: + node-version: '14.21.2' + cache: 'yarn' + + - name: Free disk space + run: | + sudo apt clean + docker rmi $(docker image ls -aq) + df -h + + - name: Versions + run: | + npm --versions + yarn -v + node -v + git version + + - name: yarn install + run: yarn + + - name: TurboRepo local server + uses: felixmosh/turborepo-gh-artifacts@v2 + if: "${{ env.TURBO_TEAM != '' }}" + with: + repo-token: ${{ secrets.RC_TURBO_GH_TOKEN }} + server-token: ${{ secrets.TURBO_SERVER_TOKEN }} + + - name: Lint + run: yarn lint --api="http://127.0.0.1:9080" --token="${{ secrets.TURBO_SERVER_TOKEN }}" --team='rc' + build-docker-preview: runs-on: ubuntu-20.04 - needs: [build, release-versions] + needs: [build, lint, ts-typecheck, release-versions] if: github.event_name == 'release' || github.ref == 'refs/heads/develop' steps: - uses: actions/checkout@v3 @@ -216,15 +296,52 @@ jobs: username: ${{ secrets.CR_USER }} password: ${{ secrets.CR_PAT }} - test: + test-unit: runs-on: ubuntu-20.04 - needs: [build, release-versions] + needs: [build, lint, ts-typecheck, release-versions] strategy: matrix: node-version: ['14.21.2'] mongodb-version: ['4.4', '5.0', '6.0'] + steps: + - name: Launch MongoDB + uses: supercharge/mongodb-github-action@1.8.0 + with: + mongodb-version: ${{ matrix.mongodb-version }} + mongodb-replica-set: rs0 + + - uses: actions/checkout@v3 + + - name: Use Node.js ${{ matrix.node-version }} + uses: actions/setup-node@v3 + with: + node-version: ${{ matrix.node-version }} + cache: 'yarn' + + - name: yarn install + run: yarn + + - name: TurboRepo local server + uses: felixmosh/turborepo-gh-artifacts@v2 + if: "${{ env.TURBO_TEAM != '' }}" + with: + repo-token: ${{ secrets.RC_TURBO_GH_TOKEN }} + server-token: ${{ secrets.TURBO_SERVER_TOKEN }} + + - name: Unit Test + run: yarn testunit --api="http://127.0.0.1:9080" --token="${{ secrets.TURBO_SERVER_TOKEN }}" --team='rc' + + test-api: + runs-on: ubuntu-20.04 + needs: [build, lint, ts-typecheck, release-versions] + + strategy: + matrix: + node-version: ['14.21.2'] + mongodb-version: ['4.4', '6.0'] + steps: - name: Launch MongoDB uses: supercharge/mongodb-github-action@1.8.0 @@ -240,8 +357,8 @@ jobs: echo "LOWERCASE_REPOSITORY: ${LOWERCASE_REPOSITORY}" echo "::set-output name=lowercase-repo::${LOWERCASE_REPOSITORY}" - # test alpine image on mongo 5.0 (no special reason to be mongo 5.0 but we need to test alpine at least once) - if [[ '${{ matrix.mongodb-version }}' = '5.0' ]]; then + # test alpine image on mongo 6.0 (no special reason to be mongo 6.0 but we need to test alpine at least once) + if [[ '${{ matrix.mongodb-version }}' = '6.0' ]]; then RC_DOCKERFILE="${{ github.workspace }}/apps/meteor/.docker/Dockerfile.alpine" RC_DOCKER_TAG="${{ needs.release-versions.outputs.gh-docker-tag }}.alpine" else @@ -263,9 +380,6 @@ jobs: node-version: ${{ matrix.node-version }} cache: 'yarn' - - name: yarn install - run: yarn - - name: TurboRepo local server uses: felixmosh/turborepo-gh-artifacts@v2 if: "${{ env.TURBO_TEAM != '' }}" @@ -273,8 +387,11 @@ jobs: repo-token: ${{ secrets.RC_TURBO_GH_TOKEN }} server-token: ${{ secrets.TURBO_SERVER_TOKEN }} - - name: Unit Test - run: yarn testunit --api="http://127.0.0.1:9080" --token="${{ secrets.TURBO_SERVER_TOKEN }}" --team='rc' + - name: yarn install + run: yarn + + - name: yarn build + run: yarn build --api="http://127.0.0.1:9080" --token="${{ secrets.TURBO_SERVER_TOKEN }}" --team='rc' - name: Restore build uses: actions/download-artifact@v2 @@ -370,45 +487,122 @@ jobs: done; exit $s - - name: Cache Playwright binaries - uses: actions/cache@v3 - id: cache-playwright + test-ui: + runs-on: ubuntu-20.04 + needs: [build, lint, ts-typecheck, release-versions] + + strategy: + matrix: + node-version: ['14.21.2'] + mongodb-version: ['4.4', '6.0'] + shard: [1, 2, 3, 4] + + steps: + - name: Launch MongoDB + uses: supercharge/mongodb-github-action@1.8.0 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 + mongodb-version: ${{ matrix.mongodb-version }} + mongodb-replica-set: rs0 - - name: Install Playwright - if: steps.cache-playwright.outputs.cache-hit != 'true' - working-directory: ./apps/meteor - run: npx playwright install --with-deps + - name: Docker env vars + id: docker-env + run: | + LOWERCASE_REPOSITORY=$(echo "${{ github.repository_owner }}" | tr "[:upper:]" "[:lower:]") + + echo "LOWERCASE_REPOSITORY: ${LOWERCASE_REPOSITORY}" + echo "::set-output name=lowercase-repo::${LOWERCASE_REPOSITORY}" + + # test alpine image on mongo 6.0 (no special reason to be mongo 6.0 but we need to test alpine at least once) + if [[ '${{ matrix.mongodb-version }}' = '6.0' ]]; then + RC_DOCKERFILE="${{ github.workspace }}/apps/meteor/.docker/Dockerfile.alpine" + RC_DOCKER_TAG="${{ needs.release-versions.outputs.gh-docker-tag }}.alpine" + else + RC_DOCKERFILE="${{ github.workspace }}/apps/meteor/.docker/Dockerfile" + RC_DOCKER_TAG="${{ needs.release-versions.outputs.gh-docker-tag }}.official" + fi; + + echo "RC_DOCKERFILE: ${RC_DOCKERFILE}" + echo "::set-output name=rc-dockerfile::${RC_DOCKERFILE}" + + echo "RC_DOCKER_TAG: ${RC_DOCKER_TAG}" + echo "::set-output name=rc-docker-tag::${RC_DOCKER_TAG}" + + - uses: actions/checkout@v3 + + - name: Use Node.js ${{ matrix.node-version }} + uses: actions/setup-node@v3 + with: + node-version: ${{ matrix.node-version }} + cache: 'yarn' + + - name: TurboRepo local server + uses: felixmosh/turborepo-gh-artifacts@v2 + if: "${{ env.TURBO_TEAM != '' }}" + with: + repo-token: ${{ secrets.RC_TURBO_GH_TOKEN }} + server-token: ${{ secrets.TURBO_SERVER_TOKEN }} + + - name: yarn install + run: yarn + + - name: yarn build + run: yarn build --api="http://127.0.0.1:9080" --token="${{ secrets.TURBO_SERVER_TOKEN }}" --team='rc' + + - name: Restore build + uses: actions/download-artifact@v2 + 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: Reset containers + - name: Start containers env: + MONGO_URL: 'mongodb://host.docker.internal:27017/rocketchat?replicaSet=rs0&directConnection=true' + MONGO_OPLOG_URL: 'mongodb://mongodb:27017/local?replicaSet=rs0&directConnection=true' LOWERCASE_REPOSITORY: ${{ steps.docker-env.outputs.lowercase-repo }} RC_DOCKERFILE: ${{ steps.docker-env.outputs.rc-dockerfile }} RC_DOCKER_TAG: ${{ steps.docker-env.outputs.rc-docker-tag }} + DOCKER_TAG: ${{ needs.release-versions.outputs.gh-docker-tag }} run: | - docker ps - - docker compose -f docker-compose-ci.yml stop rocketchat - - 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 up -d --build rocketchat - docker compose -f docker-compose-ci.yml restart rocketchat + - name: Wait for Rocket.Chat to start up + env: + LOWERCASE_REPOSITORY: ${{ steps.docker-env.outputs.lowercase-repo }} + RC_DOCKERFILE: ${{ steps.docker-env.outputs.rc-dockerfile }} + RC_DOCKER_TAG: ${{ steps.docker-env.outputs.rc-docker-tag }} + DOCKER_TAG: ${{ needs.release-versions.outputs.gh-docker-tag }} + run: | + docker ps - until echo "$(docker compose -f docker-compose-ci.yml logs rocketchat --since $NOW)" | grep -q "SERVER RUNNING"; do + until echo "$(docker compose -f docker-compose-ci.yml logs rocketchat)" | grep -q "SERVER RUNNING"; do echo "Waiting Rocket.Chat to start up" - ((c++)) && ((c==10)) && exit 1 + ((c++)) && ((c==10)) && docker compose -f docker-compose-ci.yml logs rocketchat && exit 1 sleep 10 done; - - name: E2E Test UI + - name: Cache Playwright binaries + 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: steps.cache-playwright.outputs.cache-hit != 'true' + working-directory: ./apps/meteor + run: npx playwright install --with-deps + + - name: E2E Test UI (${{ matrix.shard }}/4) working-directory: ./apps/meteor - run: yarn test:e2e + run: yarn test:e2e --shard=${{ matrix.shard }}/4 - name: Store playwright test trace uses: actions/upload-artifact@v3 @@ -417,9 +611,9 @@ jobs: name: playwright-test-trace path: ./apps/meteor/tests/e2e/.playwright* - test-ee: + test-ee-api: runs-on: ubuntu-20.04 - needs: [build, release-versions] + needs: [build, lint, ts-typecheck, release-versions] strategy: matrix: @@ -452,7 +646,7 @@ jobs: run: yarn - name: yarn build - run: yarn build + run: yarn build --api="http://127.0.0.1:9080" --token="${{ secrets.TURBO_SERVER_TOKEN }}" --team='rc' - name: Restore build uses: actions/download-artifact@v2 @@ -559,20 +753,92 @@ jobs: done; exit $s - - name: Reset containers + test-ee-ui: + runs-on: ubuntu-20.04 + needs: [build, lint, ts-typecheck, release-versions] + + strategy: + matrix: + node-version: ['14.21.2'] + mongodb-version-ee: ['4.4'] + shard: [1, 2, 3, 4, 5] + + steps: + - name: Launch MongoDB + uses: supercharge/mongodb-github-action@1.8.0 + with: + mongodb-version: ${{ matrix.mongodb-version-ee }} + mongodb-replica-set: rs0 + + - uses: actions/checkout@v3 + + - name: Use Node.js ${{ matrix.node-version }} + uses: actions/setup-node@v3 + with: + node-version: ${{ matrix.node-version }} + cache: 'yarn' + + - name: TurboRepo local server + uses: felixmosh/turborepo-gh-artifacts@v2 + if: "${{ env.TURBO_TEAM != '' }}" + with: + repo-token: ${{ secrets.RC_TURBO_GH_TOKEN }} + server-token: ${{ secrets.TURBO_SERVER_TOKEN }} + + - name: yarn install + run: yarn + + - name: yarn build + run: yarn build --api="http://127.0.0.1:9080" --token="${{ secrets.TURBO_SERVER_TOKEN }}" --team='rc' + + - name: Restore build + uses: actions/download-artifact@v2 + 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: Docker env vars + id: docker-env + run: | + LOWERCASE_REPOSITORY=$(echo "${{ github.repository_owner }}" | tr "[:upper:]" "[:lower:]") + + echo "LOWERCASE_REPOSITORY: ${LOWERCASE_REPOSITORY}" + echo "::set-output name=lowercase-repo::${LOWERCASE_REPOSITORY}" + + - name: Start containers env: + MONGO_URL: 'mongodb://host.docker.internal:27017/rocketchat?replicaSet=rs0&directConnection=true' LOWERCASE_REPOSITORY: ${{ steps.docker-env.outputs.lowercase-repo }} RC_DOCKERFILE: '${{ github.workspace }}/apps/meteor/.docker/Dockerfile' RC_DOCKER_TAG: '${{ needs.release-versions.outputs.gh-docker-tag }}.official' DOCKER_TAG: ${{ needs.release-versions.outputs.gh-docker-tag }} + TRANSPORTER: nats://nats:4222 + # this is 100% intentional, secrets are not available for forks, so ee-tests will always fail + # to avoid this, we are using a dummy license, expiring at 2023-06-30 + ENTERPRISE_LICENSE: Z2Dg0RC3kyxjuklSE6qfqyvD2xSD+oTYcS9OesJG0523r7rSPjv59LTQqPcp5E61qQYM3MOKoW3mDrurw4h78nVbsfrF2DoJZeNjRFQfIbgwcdPwtmnqPpDvAslszHY16VzM7O7EYqAqp/9mlnRzs1iJY+W3w1r6HWBlVMb9u41bl5HBSpX6Nxw8YxL4mizwOpjxewQbPQvNTLJNAW6w0nCzF5A3CKBhD9fziadedVMLOuXBuR8kIl8zbIAfqpHmL8SvakvQAbZEjWWQshmH+C9CKA5PppkmA8Q1DNWQoVtHSiYDK8RRjAEx+0oGflklzFyhJFDvD+ohZduNtNCgrJmxP5VFrVrLSK4BXgTSwwnaSKa2N+Qx0CmuRfu7nCPc1Cf6h6+k2TXvzkE4Z0ZJnDV1khu611glAr99bHdwF+bMX3XZI66bS8KqnHEukCt5xei25iKJ2xrfmGuiAkAuKHKzBmTEmXM0pGhkfDhA9jhxG3Atoj1A5y8vdrs88voF+UuNFZ6k9sKtdvrWIWClnkatPE+41ggbzCsOhFz07BvRWaEtw2Kenipl4Vtag4qmFpUaUfsuouH99M3gDlysDZO3x5aH8yfzvFeL5WDMvsmdEHNLpHl89WsPCONvx0JjRSdwcCA1NrRuVy1Ncu0S0bRByn7HZqoY9u6HPkXKBxQ= run: | - 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' + docker compose -f docker-compose-ci.yml up -d --build - NOW=$(date "+%Y-%m-%dT%H:%M:%S.000Z") + - name: Wait services to start up + env: + LOWERCASE_REPOSITORY: ${{ steps.docker-env.outputs.lowercase-repo }} + RC_DOCKERFILE: '${{ github.workspace }}/apps/meteor/.docker/Dockerfile' + RC_DOCKER_TAG: '${{ needs.release-versions.outputs.gh-docker-tag }}.official' + DOCKER_TAG: ${{ needs.release-versions.outputs.gh-docker-tag }} + run: | + docker ps - docker compose -f docker-compose-ci.yml restart + until echo "$(docker compose -f docker-compose-ci.yml logs rocketchat)" | grep -q "SERVER RUNNING"; do + echo "Waiting Rocket.Chat to start up" + ((c++)) && ((c==10)) && docker compose -f docker-compose-ci.yml logs rocketchat && exit 1 + sleep 10 + done; 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" @@ -580,12 +846,6 @@ jobs: sleep 10 done; - until echo "$(docker compose -f docker-compose-ci.yml logs rocketchat)" | grep -q "SERVER RUNNING"; do - echo "Waiting Rocket.Chat to start up" - ((c++)) && ((c==10)) && docker compose -f docker-compose-ci.yml logs rocketchat && exit 1 - sleep 10 - done; - - name: Cache Playwright binaries uses: actions/cache@v3 id: cache-playwright @@ -599,9 +859,9 @@ jobs: working-directory: ./apps/meteor run: npx playwright install --with-deps - - name: E2E Test UI + - name: E2E Test UI (${{ matrix.shard }}/4) working-directory: ./apps/meteor - run: E2E_COVERAGE=true IS_EE=true yarn test:e2e + run: E2E_COVERAGE=true IS_EE=true yarn test:e2e --shard=${{ matrix.shard }}/5 - name: Show server logs if E2E test failed if: failure() @@ -630,10 +890,19 @@ jobs: name: e2e-ee-coverage path: ./apps/meteor/coverage* + test: + runs-on: ubuntu-20.04 + needs: [test-unit, test-api, test-ui, test-ee-api, test-ee-ui] + + steps: + - name: Test finish aggregation + run: | + echo finished + deploy: runs-on: ubuntu-20.04 if: github.event_name == 'release' || github.ref == 'refs/heads/develop' - needs: [test, test-ee, release-versions] + needs: [test, release-versions] steps: - uses: actions/checkout@v3 diff --git a/apps/meteor/package.json b/apps/meteor/package.json index 7405795e5519..3b596367a372 100644 --- a/apps/meteor/package.json +++ b/apps/meteor/package.json @@ -24,7 +24,7 @@ "migration:add": "ts-node-transpile-only --skip-project .scripts/make-migration.ts", "debug": "meteor run --inspect", "debug-brk": "meteor run --inspect-brk", - "lint": "meteor npm run stylelint && meteor npm run eslint", + "lint": "npm run stylelint && npm run eslint", "eslint": "eslint --ext .js,.jsx,.ts,.tsx .", "eslint:fix": "eslint --ext .js,.jsx,.ts,.tsx . --fix", "obj:dev": "TEST_MODE=true yarn dev",