name: ocelot.social webapp test CI on: push jobs: files-changed: name: Detect File Changes - Webapp runs-on: ubuntu-latest outputs: docker: ${{ steps.changes.outputs.docker }} webapp: ${{ steps.changes.outputs.webapp }} steps: - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 - name: Check for frontend file changes uses: dorny/paths-filter@de90cc6fb38fc0963ad72b210f1f284cd68cea36 # v3.0.2 id: changes with: token: ${{ github.token }} filters: .github/file-filters.yml list-files: shell prepare: name: Prepare if: needs.files-changed.outputs.webapp == 'true' needs: files-changed runs-on: ubuntu-latest steps: - name: Checkout code uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 - name: Setup Node.js uses: actions/setup-node@6044e13b5dc448c55e2357c09f80417699197238 # v6.2.0 with: node-version-file: 'webapp/.nvmrc' - name: Check translation files run: | scripts/translations/sort.sh scripts/translations/missing-keys.sh build_test_webapp: name: Docker Build Test - Webapp if: needs.files-changed.outputs.docker == 'true' || needs.files-changed.outputs.webapp == 'true' needs: files-changed runs-on: ubuntu-latest steps: - name: Checkout code uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 - name: Set up Docker Buildx uses: docker/setup-buildx-action@8d2750c68a42422c14e847fe6c8ac0403b4cbd6f # v3 - name: Webapp | Build 'test' image uses: docker/build-push-action@10e90e3645eae34f1e60eeb005ba3a3d33f178e8 # v6 with: context: . file: webapp/Dockerfile target: test load: true tags: ghcr.io/ocelot-social-community/ocelot-social/webapp:test cache-from: type=gha,scope=webapp-test cache-to: type=gha,mode=max,scope=webapp-test - name: Save image for test job run: docker save "ghcr.io/ocelot-social-community/ocelot-social/webapp:test" > /tmp/webapp.tar - name: Cache docker image uses: actions/cache@cdf6c1fa76f9f475f3d7449005a359c84ca0f306 # v4.0.2 with: path: /tmp/webapp.tar key: ${{ github.run_id }}-webapp-cache lint_webapp: name: Lint Webapp if: needs.files-changed.outputs.webapp == 'true' needs: files-changed runs-on: ubuntu-latest steps: - name: Checkout code uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 - name: Setup Node.js uses: actions/setup-node@6044e13b5dc448c55e2357c09f80417699197238 # v6.2.0 with: node-version-file: 'webapp/.nvmrc' cache: 'yarn' cache-dependency-path: 'webapp/yarn.lock' - name: webapp | Lint run: cd webapp && yarn --frozen-lockfile && yarn run lint unit_test_webapp: name: Unit Tests - Webapp if: needs.files-changed.outputs.docker == 'true' || needs.files-changed.outputs.webapp == 'true' needs: [files-changed, build_test_webapp] runs-on: ubuntu-latest permissions: checks: write steps: - name: Checkout code uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 - name: Restore webapp cache uses: actions/cache@cdf6c1fa76f9f475f3d7449005a359c84ca0f306 # v4.0.2 with: path: /tmp/webapp.tar key: ${{ github.run_id }}-webapp-cache - name: Load Docker Image run: docker load < /tmp/webapp.tar - name: Copy env files run: | cp webapp/.env.template webapp/.env cp backend/.env.template backend/.env - name: Start webapp container run: docker compose -f docker-compose.yml -f docker-compose.test.yml up --detach --no-deps webapp - name: webapp | Unit tests incl. coverage check run: docker compose exec -T webapp yarn test