From 7857ff483ad38d66083c9f5d9ff93875a2f6aa32 Mon Sep 17 00:00:00 2001 From: Guilherme Gazzo Date: Tue, 21 Jun 2022 13:34:13 -0300 Subject: [PATCH] Chore: Improve CI cache (#25907) Co-authored-by: Diego Sampaio --- .github/workflows/build_and_test.yml | 143 ++++++++----------- .yarnrc.yml | 3 +- apps/meteor/.gitignore | 1 + apps/meteor/.meteorignore | 1 + apps/meteor/tests/end-to-end/api/25-teams.js | 8 +- yarn.lock | 2 +- 6 files changed, 70 insertions(+), 88 deletions(-) diff --git a/.github/workflows/build_and_test.yml b/.github/workflows/build_and_test.yml index aca03463336e..e62ee8217486 100644 --- a/.github/workflows/build_and_test.yml +++ b/.github/workflows/build_and_test.yml @@ -18,6 +18,8 @@ env: MONGO_URL: mongodb://localhost:27017/rocketchat MONGO_OPLOG_URL: mongodb://mongo:27017/local TOOL_NODE_FLAGS: --max_old_space_size=4096 + TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }} + TURBO_TEAM: ${{ secrets.TURBO_TEAM }} jobs: release-versions: @@ -71,12 +73,13 @@ jobs: echo "github.event_name: ${{ github.event_name }}" cat $GITHUB_EVENT_PATH + - uses: actions/checkout@v3 + - name: Use Node.js 14.18.3 uses: actions/setup-node@v3 with: node-version: '14.18.3' - - - uses: actions/checkout@v3 + cache: 'yarn' - name: Free disk space run: | @@ -86,40 +89,22 @@ jobs: docker rmi $(docker image ls -aq) df -h - # TODO is this required? - # - name: check package-lock - # run: | - # npx package-lock-check - - - uses: c-hive/gha-yarn-cache@v2 - - name: Cache turbo - id: cache-turbo - uses: actions/cache@v2 - with: - path: | - ./node_modules/.turbo - key: ${{ runner.OS }}-turbo-${{ hashFiles('**/yarn.lock') }} - restore-keys: | - ${{ runner.os }}-turbo- - ${{ runner.os }}- - - # TODO change to use turbo cache - name: Cache meteor local uses: actions/cache@v2 with: path: ./apps/meteor/.meteor/local - key: ${{ runner.OS }}-meteor_cache-${{ hashFiles('apps/meteor/.meteor/versions') }} + key: meteor-local-cache-${{ runner.OS }}-${{ hashFiles('apps/meteor/.meteor/versions') }} restore-keys: | - ${{ runner.os }}-meteor_cache- - ${{ runner.os }}- + meteor-local-cache-${{ runner.os }}- + - name: Cache meteor uses: actions/cache@v2 with: path: ~/.meteor - key: ${{ runner.OS }}-meteor-${{ hashFiles('apps/meteor/.meteor/release') }} + key: meteor-cache-${{ runner.OS }}-${{ hashFiles('apps/meteor/.meteor/release') }} restore-keys: | - ${{ runner.os }}-meteor- - ${{ runner.os }}- + meteor-cache-${{ runner.os }}- + - name: Install Meteor run: | # Restore bin from cache @@ -152,13 +137,20 @@ jobs: - name: yarn install run: yarn - - run: yarn lint + - name: TurboRepo local server + uses: felixmosh/turborepo-gh-artifacts@v1 + with: + repo-token: ${{ secrets.GITHUB_TOKEN }} + server-token: ${{ secrets.TURBO_SERVER_TOKEN }} + + - name: Lint + run: yarn lint --api="http://127.0.0.1:9080" - - run: yarn turbo run translation-check + - name: Translation check + run: yarn turbo run translation-check --api="http://127.0.0.1:9080" - name: TS typecheck - run: | - yarn turbo run typecheck + run: yarn turbo run typecheck --api="http://127.0.0.1:9080" - name: Reset Meteor if: startsWith(github.ref, 'refs/tags/') == 'true' || github.ref == 'refs/heads/develop' @@ -170,36 +162,35 @@ jobs: if: startsWith(github.ref, 'refs/pull/') == true env: METEOR_PROFILE: 1000 - run: | - yarn build:ci -- --debug --directory /tmp/build + run: yarn build:ci --api="http://127.0.0.1:9080" -- --debug --directory dist - name: Build Rocket.Chat if: startsWith(github.ref, 'refs/pull/') != true - run: | - yarn build:ci -- --directory /tmp/build + run: yarn build:ci --api="http://127.0.0.1:9080" -- --directory dist - name: Prepare build run: | - cd /tmp/build - tar czf /tmp/build/Rocket.Chat.tar.gz bundle + cd apps/meteor/dist + tar czf /tmp/Rocket.Chat.tar.gz bundle - name: Store build uses: actions/upload-artifact@v2 with: name: build - path: /tmp/build/Rocket.Chat.tar.gz + path: /tmp/Rocket.Chat.tar.gz build-docker-preview: runs-on: ubuntu-20.04 needs: [build, release-versions] if: github.event_name == 'release' || github.ref == 'refs/heads/develop' steps: + - uses: actions/checkout@v3 + - name: Use Node.js ${{ matrix.node-version }} uses: actions/setup-node@v3 with: node-version: ${{ matrix.node-version }} - - - uses: actions/checkout@v3 + cache: 'yarn' - name: Restore build uses: actions/download-artifact@v2 @@ -238,40 +229,33 @@ jobs: with: mongoDBVersion: ${{ matrix.mongodb-version }} --replSet=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: Setup Chrome - run: | - npm i chromedriver + run: npm i chromedriver - name: Configure Replica Set run: | docker exec mongo mongo --eval 'rs.initiate({_id:"rs0", members: [{"_id":1, "host":"localhost:27017"}]})' docker exec mongo mongo --eval 'rs.status()' - - uses: actions/checkout@v3 - - - uses: c-hive/gha-yarn-cache@v2 - - - name: Cache turbo - id: cache-turbo - uses: actions/cache@v2 - with: - path: | - ./node_modules/.turbo - key: ${{ runner.OS }}-turbo-${{ hashFiles('**/yarn.lock') }} - restore-keys: | - ${{ runner.os }}-turbo- - ${{ runner.os }}- - - name: yarn install run: yarn + - name: TurboRepo local server + uses: felixmosh/turborepo-gh-artifacts@v1 + with: + repo-token: ${{ secrets.GITHUB_TOKEN }} + server-token: ${{ secrets.TURBO_SERVER_TOKEN }} + - name: Unit Test - run: yarn testunit + run: yarn testunit --api="http://127.0.0.1:9080" - name: Restore build uses: actions/download-artifact@v2 @@ -407,42 +391,33 @@ jobs: - name: Launch NATS run: sudo docker run --name nats -d -p 4222:4222 nats:2.4 + - 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: Setup Chrome - run: | - npm i chromedriver + run: npm i chromedriver - name: Configure Replica Set run: | docker exec mongo mongo --eval 'rs.initiate({_id:"rs0", members: [{"_id":1, "host":"localhost:27017"}]})' docker exec mongo mongo --eval 'rs.status()' - - uses: actions/checkout@v3 - - - uses: c-hive/gha-yarn-cache@v2 - - - name: Cache turbo - id: cache-turbo - uses: actions/cache@v2 + - name: TurboRepo local server + uses: felixmosh/turborepo-gh-artifacts@v1 with: - path: | - ./node_modules/.turbo - key: ${{ runner.OS }}-turbo-${{ hashFiles('**/yarn.lock') }} - restore-keys: | - ${{ runner.os }}-turbo- - ${{ runner.os }}- + repo-token: ${{ secrets.GITHUB_TOKEN }} + server-token: ${{ secrets.TURBO_SERVER_TOKEN }} - name: yarn install run: yarn - - run: yarn build - - name: Unit Test - run: yarn testunit + run: yarn testunit --api="http://127.0.0.1:9080" - name: Restore build uses: actions/download-artifact@v2 @@ -466,7 +441,7 @@ jobs: username: ${{ secrets.CR_USER }} password: ${{ secrets.CR_PAT }} - - name: "Build Docker image: account" + - name: 'Build Docker image: account' uses: ./.github/actions/build-docker-image-service with: docker-tag: ${{ needs.release-versions.outputs.gh-docker-tag }} @@ -474,7 +449,7 @@ jobs: username: ${{ secrets.CR_USER }} password: ${{ secrets.CR_PAT }} - - name: "Build Docker image: authorization" + - name: 'Build Docker image: authorization' uses: ./.github/actions/build-docker-image-service with: docker-tag: ${{ needs.release-versions.outputs.gh-docker-tag }} @@ -482,7 +457,7 @@ jobs: username: ${{ secrets.CR_USER }} password: ${{ secrets.CR_PAT }} - - name: "Build Docker image: ddp-streamer" + - name: 'Build Docker image: ddp-streamer' uses: ./.github/actions/build-docker-image-service with: docker-tag: ${{ needs.release-versions.outputs.gh-docker-tag }} @@ -490,7 +465,7 @@ jobs: username: ${{ secrets.CR_USER }} password: ${{ secrets.CR_PAT }} - - name: "Build Docker image: presence" + - name: 'Build Docker image: presence' uses: ./.github/actions/build-docker-image-service with: docker-tag: ${{ needs.release-versions.outputs.gh-docker-tag }} @@ -498,7 +473,7 @@ jobs: username: ${{ secrets.CR_USER }} password: ${{ secrets.CR_PAT }} - - name: "Build Docker image: stream-hub" + - name: 'Build Docker image: stream-hub' uses: ./.github/actions/build-docker-image-service with: docker-tag: ${{ needs.release-versions.outputs.gh-docker-tag }} @@ -545,7 +520,7 @@ jobs: --label 'traefik.http.routers.ddp-streamer.rule=PathPrefix(`/websocket`) || PathPrefix(`/sockjs`)' \ ghcr.io/${LOWERCASE_REPOSITORY}/ddp-streamer-service:${{ needs.release-versions.outputs.gh-docker-tag }} - - name: "Start service: stream-hub" + - name: 'Start service: stream-hub' run: | LOWERCASE_REPOSITORY=$(echo "${{ github.repository_owner }}" | tr "[:upper:]" "[:lower:]") @@ -564,7 +539,7 @@ jobs: sleep 10 done - - name: "Start service: account" + - name: 'Start service: account' run: | LOWERCASE_REPOSITORY=$(echo "${{ github.repository_owner }}" | tr "[:upper:]" "[:lower:]") @@ -583,7 +558,7 @@ jobs: sleep 10 done - - name: "Start service: authorization" + - name: 'Start service: authorization' run: | LOWERCASE_REPOSITORY=$(echo "${{ github.repository_owner }}" | tr "[:upper:]" "[:lower:]") @@ -602,7 +577,7 @@ jobs: sleep 10 done - - name: "Start service: presence" + - name: 'Start service: presence' run: | LOWERCASE_REPOSITORY=$(echo "${{ github.repository_owner }}" | tr "[:upper:]" "[:lower:]") diff --git a/.yarnrc.yml b/.yarnrc.yml index 1d00b70c6e57..18948c0be5b9 100644 --- a/.yarnrc.yml +++ b/.yarnrc.yml @@ -11,4 +11,5 @@ plugins: spec: '@yarnpkg/plugin-typescript' yarnPath: .yarn/releases/yarn-3.2.0.cjs -checksumBehavior: 'ignore' +checksumBehavior: 'update' +enableImmutableInstalls: false diff --git a/apps/meteor/.gitignore b/apps/meteor/.gitignore index 3fc755f6bb5b..e8a861e58324 100644 --- a/apps/meteor/.gitignore +++ b/apps/meteor/.gitignore @@ -84,3 +84,4 @@ coverage /data tests/e2e/test-failures/ out.txt +dist diff --git a/apps/meteor/.meteorignore b/apps/meteor/.meteorignore index 9b77b349e3fd..7b2dc6e71c31 100644 --- a/apps/meteor/.meteorignore +++ b/apps/meteor/.meteorignore @@ -1,3 +1,4 @@ ee/server/services coverage data +dist diff --git a/apps/meteor/tests/end-to-end/api/25-teams.js b/apps/meteor/tests/end-to-end/api/25-teams.js index a5a57c53a088..dd4419432ddb 100644 --- a/apps/meteor/tests/end-to-end/api/25-teams.js +++ b/apps/meteor/tests/end-to-end/api/25-teams.js @@ -3,7 +3,7 @@ import { expect } from 'chai'; import { getCredentials, api, request, credentials, methodCall } from '../../data/api-data'; import { updatePermission } from '../../data/permissions.helper.js'; import { createUser, login } from '../../data/users.helper'; -import { password } from '../../data/user'; +import { adminUsername, password } from '../../data/user'; describe('[Teams]', () => { before((done) => getCredentials(done)); @@ -105,7 +105,11 @@ describe('[Teams]', () => { .expect((response) => { expect(response.body).to.have.property('success', true); expect(response.body).to.have.property('members'); - const member = response.body.members[0]; + + // remove admin user from members because it's added automatically as owner + const members = response.body.members.filter(({ user }) => user.username !== adminUsername); + + const [member] = members; expect(member.user.username).to.be.equal(testUser.username); }); }) diff --git a/yarn.lock b/yarn.lock index d1a05f057e41..78958caeabd8 100644 --- a/yarn.lock +++ b/yarn.lock @@ -7707,7 +7707,7 @@ __metadata: human-interval: ~1.0.0 moment-timezone: ~0.5.27 mongodb: ~3.5.0 - checksum: cc8c1bbba7545628d9d039c58e701ff65cf07f241f035b731716eec0d5ef906ce09d60c3b321bbfb9e6c641994d1afd23aaeb92d645b33bf7be9942f13574173 + checksum: acb4ebb7e7356f6e53e810d821eb6aa3d88bbfb9e85183e707517bee6d1eea1f189f38bdf0dd2b91360492ab7643134d510c320d2523d86596498ab98e59735b languageName: node linkType: hard