name: UI - Pull Request on: push: branches: - "master" - "v5.*" paths: - ".github/workflows/ui-pull-request.yml" - "ui/**" pull_request: branches: - master - "v5.*" paths: - 'ui/**' env: UI_WORKING_DIR: ./ui IMAGE_NAME: prowler-ui jobs: test-and-coverage: runs-on: ubuntu-latest strategy: matrix: os: [ubuntu-latest] node-version: [20.x] steps: - name: Checkout repository uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 with: persist-credentials: false - name: Setup Node.js ${{ matrix.node-version }} uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0 with: node-version: ${{ matrix.node-version }} cache: 'npm' cache-dependency-path: './ui/package-lock.json' - name: Install dependencies working-directory: ./ui run: npm ci - name: Run Healthcheck working-directory: ./ui run: npm run healthcheck - name: Build the application working-directory: ./ui run: npm run build e2e-tests: runs-on: ubuntu-latest env: AUTH_SECRET: 'fallback-ci-secret-for-testing' AUTH_TRUST_HOST: true NEXTAUTH_URL: http://localhost:3000 steps: - name: Checkout repository uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 with: persist-credentials: false - name: Setup Node.js uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0 with: node-version: '20.x' cache: 'npm' cache-dependency-path: './ui/package-lock.json' - name: Install dependencies working-directory: ./ui run: npm ci - name: Cache Playwright browsers uses: actions/cache@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.3 id: playwright-cache with: path: ~/.cache/ms-playwright key: ${{ runner.os }}-playwright-${{ hashFiles('ui/package-lock.json') }} restore-keys: | ${{ runner.os }}-playwright- - name: Install Playwright browsers working-directory: ./ui if: steps.playwright-cache.outputs.cache-hit != 'true' run: npm run test:e2e:install - name: Build the application working-directory: ./ui run: npm run build - name: Run Playwright tests working-directory: ./ui run: npm run test:e2e - name: Upload Playwright report uses: actions/upload-artifact@6f51ac03b9356f520e9adb1b1b7802705f340c2b # v4.5.0 if: failure() with: name: playwright-report path: ui/playwright-report/ retention-days: 30 test-container-build: runs-on: ubuntu-latest steps: - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 - name: Set up Docker Buildx uses: docker/setup-buildx-action@e468171a9de216ec08956ac3ada2f0791b6bd435 # v3.11.1 - name: Build Container uses: docker/build-push-action@263435318d21b8e681c14492fe198d362a7d2c83 # v6.18.0 with: context: ${{ env.UI_WORKING_DIR }} # Always build using `prod` target target: prod push: false tags: ${{ env.IMAGE_NAME }}:latest outputs: type=docker build-args: | NEXT_PUBLIC_STRIPE_PUBLISHABLE_KEY=pk_test_51LwpXXXX