From 744d3147a0a1341341cd545a9d938cef24e15faa Mon Sep 17 00:00:00 2001 From: Antoine Jaussoin Date: Sun, 5 Feb 2023 13:54:49 +0000 Subject: [PATCH] Migration from CRA to Vite (#468) --- .github/workflows/alpha.yml | 77 +- .github/workflows/canary.yml | 126 +- .github/workflows/ci.yml | 6 +- .github/workflows/master-old.yml | 76 - .github/workflows/master.yml | 125 +- backend/package.json | 2 +- docs/package.json | 2 +- frontend/.env | 1 - frontend/Dockerfile | 5 +- frontend/{public => }/index.html | 153 +- frontend/package.json | 31 +- frontend/public/index.empty.html | 68 - frontend/src/Layout.tsx | 75 +- frontend/src/auth/modal/account/Register.tsx | 2 +- .../__tests__/EditableLabel.test.tsx | 6 +- frontend/src/email/validate.ts | 5 + frontend/src/index.tsx | 7 +- frontend/src/is-production.ts | 3 + frontend/src/node.ts | 4 + frontend/src/setupProxy.js | 13 - frontend/src/setupTests.ts | 1 - frontend/src/tests/setup.ts | 9 + frontend/src/track.ts | 3 +- frontend/src/translations/i18n.ts | 3 +- frontend/src/typings.d.ts | 1 + frontend/src/utils/getConfig.ts | 6 +- frontend/src/views/account/AdminEditor.tsx | 2 +- frontend/src/views/account/MembersEditor.tsx | 2 +- frontend/src/views/admin/NewAccountModal.tsx | 2 +- .../__tests__/partcipants-notifiers.test.ts | 1 - frontend/src/views/game/board/post/Post.tsx | 1 - .../game/board/post/__tests__/Post.test.tsx | 11 +- frontend/src/views/game/useGame.ts | 3 +- frontend/src/views/policies/AcceptableUse.tsx | 4 +- frontend/src/views/policies/Cookies.tsx | 4 +- frontend/src/views/policies/Disclaimer.tsx | 4 +- frontend/src/views/policies/Privacy.tsx | 4 +- frontend/src/views/policies/Terms.tsx | 4 +- .../sections/timer/DurationSelection.tsx | 3 +- frontend/src/vite-env.d.ts | 1 + frontend/tsconfig.json | 3 +- frontend/vite.config.ts | 58 + frontend/vitest.config.ts | 14 + frontend/yarn.lock | 7669 ++++------------- integration/docker-compose.yml | 2 +- integration/package.json | 2 +- package.json | 2 +- retro-board-dev/Makefile | 2 +- 48 files changed, 2340 insertions(+), 6268 deletions(-) delete mode 100644 .github/workflows/master-old.yml rename frontend/{public => }/index.html (84%) delete mode 100644 frontend/public/index.empty.html create mode 100644 frontend/src/email/validate.ts create mode 100644 frontend/src/is-production.ts create mode 100644 frontend/src/node.ts delete mode 100644 frontend/src/setupProxy.js delete mode 100644 frontend/src/setupTests.ts create mode 100644 frontend/src/tests/setup.ts create mode 100644 frontend/src/vite-env.d.ts create mode 100644 frontend/vite.config.ts create mode 100644 frontend/vitest.config.ts diff --git a/.github/workflows/alpha.yml b/.github/workflows/alpha.yml index 354623ee0..59ef8a34b 100644 --- a/.github/workflows/alpha.yml +++ b/.github/workflows/alpha.yml @@ -2,41 +2,67 @@ name: 'Alpha Build' on: push: - branches: [v4192/ga4] + branches: [v4200/build-system] jobs: - build: + frontend: runs-on: ubuntu-latest - steps: - uses: actions/checkout@v3 - - name: Read VERSION id: package uses: martinbeentjes/npm-get-version-action@master - - name: Echo VERSION run: echo ${{ steps.package.outputs.current-version }} - - name: Setup QEMU - uses: docker/setup-qemu-action@master + uses: docker/setup-qemu-action@v2 with: platforms: all - - name: Setup BuildX - uses: docker/setup-buildx-action@v1 + uses: docker/setup-buildx-action@v2 id: buildx with: install: true - - name: Login to DockerHub - uses: docker/login-action@v1 + uses: docker/login-action@v2 with: username: ${{ secrets.DOCKER_NEW_USERNAME }} password: ${{ secrets.DOCKER_NEW_PASSWORD }} + - name: Build and push Frontend + uses: docker/build-push-action@v4 + with: + builder: ${{ steps.buildx.outputs.name }} + file: frontend/Dockerfile + context: frontend + tags: retrospected/frontend:alpha + platforms: linux/amd64 + push: true + backend: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - name: Read VERSION + id: package + uses: martinbeentjes/npm-get-version-action@master + - name: Echo VERSION + run: echo ${{ steps.package.outputs.current-version }} + - name: Setup QEMU + uses: docker/setup-qemu-action@v2 + with: + platforms: all + - name: Setup BuildX + uses: docker/setup-buildx-action@v2 + id: buildx + with: + install: true + - name: Login to DockerHub + uses: docker/login-action@v2 + with: + username: ${{ secrets.DOCKER_NEW_USERNAME }} + password: ${{ secrets.DOCKER_NEW_PASSWORD }} - name: Build and push Backend - uses: docker/build-push-action@v2 + uses: docker/build-push-action@v4 with: builder: ${{ steps.buildx.outputs.name }} file: backend/Dockerfile @@ -45,19 +71,25 @@ jobs: platforms: linux/amd64 push: true - - name: Build and push Frontend - uses: docker/build-push-action@v2 - with: - builder: ${{ steps.buildx.outputs.name }} - file: frontend/Dockerfile - context: frontend - tags: retrospected/frontend:alpha - platforms: linux/amd64 - push: true - + integration: + runs-on: ubuntu-latest + needs: [frontend, backend] + + steps: + - uses: actions/checkout@v3 - name: Run Integration Tests run: docker-compose -f ./integration/docker-compose.ci.alpha.yml up --exit-code-from cypress + - uses: actions/upload-artifact@v3 + if: always() + with: + name: Test videos + path: integration/cypress/videos + retention-days: 14 + trivy: + runs-on: ubuntu-latest + needs: [frontend, backend] + steps: - name: Trivy - Frontend uses: aquasecurity/trivy-action@master with: @@ -67,7 +99,6 @@ jobs: ignore-unfixed: true vuln-type: 'os,library' severity: 'CRITICAL' - - name: Trivy - Backend uses: aquasecurity/trivy-action@master with: diff --git a/.github/workflows/canary.yml b/.github/workflows/canary.yml index dde84994a..ab9ccde8e 100644 --- a/.github/workflows/canary.yml +++ b/.github/workflows/canary.yml @@ -5,48 +5,64 @@ on: branches: [develop] jobs: - build: + frontend: runs-on: ubuntu-latest - steps: - uses: actions/checkout@v3 - - name: Read VERSION id: package uses: martinbeentjes/npm-get-version-action@master - - name: Echo VERSION run: echo ${{ steps.package.outputs.current-version }} - - name: Setup QEMU - uses: docker/setup-qemu-action@master + uses: docker/setup-qemu-action@v2 with: platforms: all - - name: Setup BuildX - uses: docker/setup-buildx-action@v1 + uses: docker/setup-buildx-action@v2 id: buildx with: install: true - - name: Login to DockerHub - uses: docker/login-action@v1 + uses: docker/login-action@v2 with: username: ${{ secrets.DOCKER_NEW_USERNAME }} password: ${{ secrets.DOCKER_NEW_PASSWORD }} - - - name: Build and push Documentation - uses: docker/build-push-action@v2 + - name: Build and push Frontend + uses: docker/build-push-action@v4 with: builder: ${{ steps.buildx.outputs.name }} - file: docs/Dockerfile - context: docs - tags: retrospected/docs:canary + file: frontend/Dockerfile + context: frontend + tags: retrospected/frontend:canary platforms: linux/amd64,linux/arm64,linux/arm/v7 push: true + backend: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - name: Read VERSION + id: package + uses: martinbeentjes/npm-get-version-action@master + - name: Echo VERSION + run: echo ${{ steps.package.outputs.current-version }} + - name: Setup QEMU + uses: docker/setup-qemu-action@v2 + with: + platforms: all + - name: Setup BuildX + uses: docker/setup-buildx-action@v2 + id: buildx + with: + install: true + - name: Login to DockerHub + uses: docker/login-action@v2 + with: + username: ${{ secrets.DOCKER_NEW_USERNAME }} + password: ${{ secrets.DOCKER_NEW_PASSWORD }} - name: Build and push Backend - uses: docker/build-push-action@v2 + uses: docker/build-push-action@v4 with: builder: ${{ steps.buildx.outputs.name }} file: backend/Dockerfile @@ -55,18 +71,64 @@ jobs: platforms: linux/amd64,linux/arm64,linux/arm/v7 push: true - - name: Build and push Frontend - uses: docker/build-push-action@v2 + documentation: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - name: Read VERSION + id: package + uses: martinbeentjes/npm-get-version-action@master + - name: Echo VERSION + run: echo ${{ steps.package.outputs.current-version }} + - name: Setup QEMU + uses: docker/setup-qemu-action@v2 + with: + platforms: all + - name: Setup BuildX + uses: docker/setup-buildx-action@v2 + id: buildx + with: + install: true + - name: Login to DockerHub + uses: docker/login-action@v2 + with: + username: ${{ secrets.DOCKER_NEW_USERNAME }} + password: ${{ secrets.DOCKER_NEW_PASSWORD }} + - name: Build and push Documentation + uses: docker/build-push-action@v4 with: builder: ${{ steps.buildx.outputs.name }} - file: frontend/Dockerfile - context: frontend - tags: retrospected/frontend:canary + file: docs/Dockerfile + context: docs + tags: retrospected/docs:canary platforms: linux/amd64,linux/arm64,linux/arm/v7 push: true + maintenance: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - name: Read VERSION + id: package + uses: martinbeentjes/npm-get-version-action@master + - name: Echo VERSION + run: echo ${{ steps.package.outputs.current-version }} + - name: Setup QEMU + uses: docker/setup-qemu-action@v2 + with: + platforms: all + - name: Setup BuildX + uses: docker/setup-buildx-action@v2 + id: buildx + with: + install: true + - name: Login to DockerHub + uses: docker/login-action@v2 + with: + username: ${{ secrets.DOCKER_NEW_USERNAME }} + password: ${{ secrets.DOCKER_NEW_PASSWORD }} - name: Build and push Maintenance - uses: docker/build-push-action@v2 + uses: docker/build-push-action@v4 with: builder: ${{ steps.buildx.outputs.name }} file: maintenance/Dockerfile @@ -75,9 +137,25 @@ jobs: platforms: linux/amd64,linux/arm64,linux/arm/v7 push: true + integration: + runs-on: ubuntu-latest + needs: [frontend, backend] + + steps: + - uses: actions/checkout@v3 - name: Run Integration Tests run: docker-compose -f ./integration/docker-compose.ci.canary.yml up --exit-code-from cypress + - uses: actions/upload-artifact@v3 + if: always() + with: + name: Test videos + path: integration/cypress/videos + retention-days: 14 + trivy: + runs-on: ubuntu-latest + needs: [frontend, backend] + steps: - name: Trivy - Frontend uses: aquasecurity/trivy-action@master with: @@ -87,7 +165,6 @@ jobs: ignore-unfixed: true vuln-type: 'os,library' severity: 'CRITICAL' - - name: Trivy - Backend uses: aquasecurity/trivy-action@master with: @@ -97,3 +174,4 @@ jobs: ignore-unfixed: true vuln-type: 'os,library' severity: 'CRITICAL' + \ No newline at end of file diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e86939ae3..5ec2a8b4a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -2,7 +2,7 @@ name: 'Tests & Linting' on: push: - branches: [master, develop, v4] + branches: [master, develop] pull_request: branches: [] @@ -16,7 +16,7 @@ jobs: - uses: actions/checkout@v3 - uses: actions/setup-node@v3 with: - node-version: 16 + node-version: 18 - run: yarn - run: yarn ci-test - run: yarn lint @@ -30,7 +30,7 @@ jobs: - uses: actions/checkout@v3 - uses: actions/setup-node@v3 with: - node-version: 16 + node-version: 18 - run: yarn - run: yarn ci-test - run: yarn lint diff --git a/.github/workflows/master-old.yml b/.github/workflows/master-old.yml deleted file mode 100644 index 90165f34c..000000000 --- a/.github/workflows/master-old.yml +++ /dev/null @@ -1,76 +0,0 @@ -name: 'Master Build (Old Docker)' - -on: - push: - branches: [master] - -jobs: - build: - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v3 - - - name: Read VERSION - id: package - uses: martinbeentjes/npm-get-version-action@master - - - name: Echo VERSION - run: echo ${{ steps.package.outputs.current-version }} - - - name: Setup QEMU - uses: docker/setup-qemu-action@master - with: - platforms: all - - - name: Setup BuildX - uses: docker/setup-buildx-action@v1 - id: buildx - with: - install: true - - - name: Login to DockerHub - uses: docker/login-action@v1 - with: - username: ${{ secrets.DOCKER_USERNAME }} - password: ${{ secrets.DOCKER_PASSWORD }} - - - name: Build and push Documentation - uses: docker/build-push-action@v2 - with: - builder: ${{ steps.buildx.outputs.name }} - file: docs/Dockerfile - context: docs - tags: antoinejaussoin/retro-board-docs:latest,antoinejaussoin/retro-board-docs:${{ steps.package.outputs.current-version }} - platforms: linux/amd64,linux/arm64,linux/arm/v7 - push: true - - - name: Build and push Backend - uses: docker/build-push-action@v2 - with: - builder: ${{ steps.buildx.outputs.name }} - file: backend/Dockerfile - context: backend - tags: antoinejaussoin/retro-board-backend:latest,antoinejaussoin/retro-board-backend:${{ steps.package.outputs.current-version }} - platforms: linux/amd64,linux/arm64,linux/arm/v7 - push: true - - - name: Build and push Frontend - uses: docker/build-push-action@v2 - with: - builder: ${{ steps.buildx.outputs.name }} - file: frontend/Dockerfile - context: frontend - tags: antoinejaussoin/retro-board-frontend:latest,antoinejaussoin/retro-board-frontend:${{ steps.package.outputs.current-version }} - platforms: linux/amd64,linux/arm64,linux/arm/v7 - push: true - - - name: Build and push Maintenance - uses: docker/build-push-action@v2 - with: - builder: ${{ steps.buildx.outputs.name }} - file: maintenance/Dockerfile - context: maintenance - tags: antoinejaussoin/maintenance:latest,antoinejaussoin/maintenance:${{ steps.package.outputs.current-version }} - platforms: linux/amd64,linux/arm64,linux/arm/v7 - push: true diff --git a/.github/workflows/master.yml b/.github/workflows/master.yml index e4f121025..d2c0e47f1 100644 --- a/.github/workflows/master.yml +++ b/.github/workflows/master.yml @@ -5,75 +5,150 @@ on: branches: [master] jobs: - build: + frontend: runs-on: ubuntu-latest - steps: - uses: actions/checkout@v3 - - name: Read VERSION id: package uses: martinbeentjes/npm-get-version-action@master - - name: Echo VERSION run: echo ${{ steps.package.outputs.current-version }} - - name: Setup QEMU - uses: docker/setup-qemu-action@master + uses: docker/setup-qemu-action@v2 with: platforms: all - - name: Setup BuildX - uses: docker/setup-buildx-action@v1 + uses: docker/setup-buildx-action@v2 id: buildx with: install: true - - name: Login to DockerHub - uses: docker/login-action@v1 + uses: docker/login-action@v2 with: username: ${{ secrets.DOCKER_NEW_USERNAME }} password: ${{ secrets.DOCKER_NEW_PASSWORD }} - - - name: Build and push Documentation - uses: docker/build-push-action@v2 + - name: Build and push Frontend + uses: docker/build-push-action@v4 with: builder: ${{ steps.buildx.outputs.name }} - file: docs/Dockerfile - context: docs - tags: retrospected/docs:latest,retrospected/docs:${{ steps.package.outputs.current-version }} + file: frontend/Dockerfile + context: frontend + tags: retrospected/frontend:${{ steps.package.outputs.current-version }} platforms: linux/amd64,linux/arm64,linux/arm/v7 push: true + backend: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - name: Read VERSION + id: package + uses: martinbeentjes/npm-get-version-action@master + - name: Echo VERSION + run: echo ${{ steps.package.outputs.current-version }} + - name: Setup QEMU + uses: docker/setup-qemu-action@v2 + with: + platforms: all + - name: Setup BuildX + uses: docker/setup-buildx-action@v2 + id: buildx + with: + install: true + - name: Login to DockerHub + uses: docker/login-action@v2 + with: + username: ${{ secrets.DOCKER_NEW_USERNAME }} + password: ${{ secrets.DOCKER_NEW_PASSWORD }} - name: Build and push Backend - uses: docker/build-push-action@v2 + uses: docker/build-push-action@v4 with: builder: ${{ steps.buildx.outputs.name }} file: backend/Dockerfile context: backend - tags: retrospected/backend:latest,retrospected/backend:${{ steps.package.outputs.current-version }} + tags: retrospected/backend:${{ steps.package.outputs.current-version }} platforms: linux/amd64,linux/arm64,linux/arm/v7 push: true - - name: Build and push Frontend - uses: docker/build-push-action@v2 + documentation: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - name: Read VERSION + id: package + uses: martinbeentjes/npm-get-version-action@master + - name: Echo VERSION + run: echo ${{ steps.package.outputs.current-version }} + - name: Setup QEMU + uses: docker/setup-qemu-action@v2 + with: + platforms: all + - name: Setup BuildX + uses: docker/setup-buildx-action@v2 + id: buildx + with: + install: true + - name: Login to DockerHub + uses: docker/login-action@v2 + with: + username: ${{ secrets.DOCKER_NEW_USERNAME }} + password: ${{ secrets.DOCKER_NEW_PASSWORD }} + - name: Build and push Documentation + uses: docker/build-push-action@v4 with: builder: ${{ steps.buildx.outputs.name }} - file: frontend/Dockerfile - context: frontend - tags: retrospected/frontend:latest,retrospected/frontend:${{ steps.package.outputs.current-version }} + file: docs/Dockerfile + context: docs + tags: retrospected/docs:${{ steps.package.outputs.current-version }} platforms: linux/amd64,linux/arm64,linux/arm/v7 push: true + maintenance: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - name: Read VERSION + id: package + uses: martinbeentjes/npm-get-version-action@master + - name: Echo VERSION + run: echo ${{ steps.package.outputs.current-version }} + - name: Setup QEMU + uses: docker/setup-qemu-action@v2 + with: + platforms: all + - name: Setup BuildX + uses: docker/setup-buildx-action@v2 + id: buildx + with: + install: true + - name: Login to DockerHub + uses: docker/login-action@v2 + with: + username: ${{ secrets.DOCKER_NEW_USERNAME }} + password: ${{ secrets.DOCKER_NEW_PASSWORD }} - name: Build and push Maintenance - uses: docker/build-push-action@v2 + uses: docker/build-push-action@v4 with: builder: ${{ steps.buildx.outputs.name }} file: maintenance/Dockerfile context: maintenance - tags: retrospected/maintenance:latest,retrospected/maintenance:${{ steps.package.outputs.current-version }} + tags: retrospected/maintenance:${{ steps.package.outputs.current-version }} platforms: linux/amd64,linux/arm64,linux/arm/v7 push: true + integration: + runs-on: ubuntu-latest + needs: [frontend, backend] + + steps: + - uses: actions/checkout@v3 - name: Run Integration Tests run: docker-compose -f ./integration/docker-compose.ci.master.yml up --exit-code-from cypress + - uses: actions/upload-artifact@v3 + if: always() + with: + name: Test videos + path: integration/cypress/videos + retention-days: 14 + diff --git a/backend/package.json b/backend/package.json index 9f1167cf2..4517a41bc 100644 --- a/backend/package.json +++ b/backend/package.json @@ -1,6 +1,6 @@ { "name": "@retrospected/backend", - "version": "4.19.3", + "version": "5.0.0", "license": "GNU GPLv3", "private": true, "type": "module", diff --git a/docs/package.json b/docs/package.json index 70471bcf2..40120cc49 100644 --- a/docs/package.json +++ b/docs/package.json @@ -1,6 +1,6 @@ { "name": "docs", - "version": "4.19.3", + "version": "5.0.0", "private": true, "scripts": { "docusaurus": "docusaurus", diff --git a/frontend/.env b/frontend/.env index 1bfdf6326..e69de29bb 100644 --- a/frontend/.env +++ b/frontend/.env @@ -1 +0,0 @@ -REACT_APP_VERSION=$npm_package_version \ No newline at end of file diff --git a/frontend/Dockerfile b/frontend/Dockerfile index cbd7b9beb..85d820d83 100644 --- a/frontend/Dockerfile +++ b/frontend/Dockerfile @@ -21,6 +21,9 @@ RUN yarn --network-timeout 1000000 install COPY --chown=node:node ./src ./src COPY --chown=node:node ./public ./public COPY --chown=node:node ./tsconfig.json ./tsconfig.json +COPY --chown=node:node ./vite.config.ts ./vite.config.ts +COPY --chown=node:node ./vitest.config.ts ./vitest.config.ts +COPY --chown=node:node ./index.html ./index.html COPY --chown=node:node ./.env ./.env RUN yarn build @@ -30,7 +33,7 @@ FROM nginx:latest RUN apt update RUN apt -y remove libfreetype6 -COPY --from=Node /home/node/app/build /usr/share/nginx/html +COPY --from=Node /home/node/app/dist /usr/share/nginx/html COPY ./docker/nginx.conf.template /etc/nginx/conf.d/default.conf.template COPY ./docker/frontend-entrypoint.sh / diff --git a/frontend/public/index.html b/frontend/index.html similarity index 84% rename from frontend/public/index.html rename to frontend/index.html index 5630675cc..566529bb3 100644 --- a/frontend/public/index.html +++ b/frontend/index.html @@ -14,7 +14,6 @@ - @@ -29,34 +28,30 @@ GIPHY_API_KEY: 'NO_GIPHY', STRIPE_KEY: 'NO_STRIPE', DEFAULT_LANGUAGE: 'NO_DEFAULT_LANGUAGE', - VERSION: '%REACT_APP_VERSION%', }; - <% if (process.env.NODE_ENV === 'development') { %> - - <% } %> - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + - + - - + + @@ -65,13 +60,13 @@ - - - - - - - + + + + + + + @@ -104,7 +99,7 @@ - +
- - - Retrospected screenshot + + + Retrospected screenshot
@@ -228,7 +223,7 @@

- icon image + icon image

Compatible with all modern browsers.

@@ -236,7 +231,7 @@

- icon image + icon image

No, Internet Explorer 6 is not a modern browser. @@ -247,7 +242,7 @@

- icon image + icon image

Entirely responsive, you can participate vith your iPhone @@ -259,7 +254,7 @@

- icon image + icon image

The app feels native, because you deserve it. @@ -272,9 +267,9 @@

- - - About us + + + About us
@@ -288,9 +283,9 @@

- - - iPad mockup + + + iPad mockup
@@ -537,7 +532,7 @@

Administration Panel
- Image placeholder + Image placeholder
@@ -607,7 +602,7 @@

Retrospected Pro
For complete data safety and privacy

Basic
- pricing img + pricing img
Free
@@ -631,7 +626,7 @@

Retrospected Pro
For complete data safety and privacy

Pro Team
- pricing img + pricing img
$12.90
@@ -655,7 +650,7 @@

Retrospected Pro
For complete data safety and privacy