diff --git a/.github/workflows/e2e-tests.yaml b/.github/workflows/e2e-tests.yaml index 675d132..8044246 100644 --- a/.github/workflows/e2e-tests.yaml +++ b/.github/workflows/e2e-tests.yaml @@ -1,4 +1,4 @@ -name: Cross Browser End-to-End Testing (Cypress) 🚀 +name: End-to-End Testing (Cypress) 🚀 on: push: @@ -13,32 +13,52 @@ jobs: cypress-run: runs-on: ubuntu-latest timeout-minutes: 30 - - services: - docker: - image: docker:20.10.8 - options: --privileged + strategy: + matrix: + browser: [ chrome, electron ] + env: + - name: no-variable + NEXT_PUBLIC_REKOR_DEFAULT_DOMAIN: "" + - name: with-variable + NEXT_PUBLIC_REKOR_DEFAULT_DOMAIN: "https://this-is-a-test.com" + env: + CYPRESS_baseUrl: ${{ matrix.env.url }} steps: - name: Checkout 🛎 uses: actions/checkout@v4 - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v2 + - name: Setup Node.js + uses: actions/setup-node@v4 + with: + node-version: '18' + + - name: Install dependencies + run: npm install - - name: Build and run Docker Compose 🐳 + - name: Start Next.js app + run: npm run start & env: - NODE_ENV: production - NEXT_PUBLIC_REKOR_DEFAULT_DOMAIN: https://rekor.sigstore.dev - CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }} - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - run: docker-compose up --build -d + NODE_ENV: ${{ matrix.env.name }} + NEXT_PUBLIC_REKOR_DEFAULT_DOMAIN: ${{ matrix.env.NEXT_PUBLIC_REKOR_DEFAULT_DOMAIN }} + + - name: Wait for Next.js to start + run: npx wait-on http://localhost:3000 - - name: Wait for services to start ⏱️ - run: docker-compose logs -f --tail="all" | grep -m 1 "listening on port" + - name: Install browsers for Cypress + run: | + if [[ "${{ matrix.browser }}" == "chrome" ]]; then + sudo apt-get install -y google-chrome-stable; + elif [[ "${{ matrix.browser }}" == "firefox" ]]; then + sudo apt-get install -y firefox; + fi - name: Run Cypress tests - run: docker-compose run cypress + run: npx cypress run --browser ${{ matrix.browser }} + env: + NODE_ENV: ${{ matrix.env.name }} + NEXT_PUBLIC_REKOR_DEFAULT_DOMAIN: ${{ matrix.env.NEXT_PUBLIC_REKOR_DEFAULT_DOMAIN }} + CYPRESS_baseUrl: "http://localhost:3000" - name: Upload Electron artifacts 📸 uses: actions/upload-artifact@v4 diff --git a/cypress.Dockerfile b/cypress.Dockerfile deleted file mode 100644 index 8031b66..0000000 --- a/cypress.Dockerfile +++ /dev/null @@ -1,16 +0,0 @@ -FROM cypress/browsers:node-20.13.0-chrome-124.0.6367.155-1-ff-125.0.3-edge-124.0.2478.80-1 -ARG NEXT_PUBLIC_REKOR_DEFAULT_DOMAIN -ENV NEXT_PUBLIC_REKOR_DEFAULT_DOMAIN=${NEXT_PUBLIC_REKOR_DEFAULT_DOMAIN} - -WORKDIR /e2e - -COPY ./package.json . -COPY ./package-lock.json . -COPY ./cypress.config.ts . -COPY ./cypress ./cypress - -RUN npm install - -RUN npx cypress install - -ENTRYPOINT ["npx", "cypress", "run"] diff --git a/docker-compose.yaml b/docker-compose.yaml deleted file mode 100644 index d4cce32..0000000 --- a/docker-compose.yaml +++ /dev/null @@ -1,29 +0,0 @@ -services: - nextjs: - build: . - ports: - - "3000:3000" - volumes: - - .:/app - - /app/node_modules - command: npm start - environment: - - NODE_ENV=production - - NEXT_PUBLIC_REKOR_DEFAULT_DOMAIN=https://rekor.sigstore.dev - - cypress: - build: - context: . - dockerfile: cypress.Dockerfile - args: - NEXT_PUBLIC_REKOR_DEFAULT_DOMAIN: https://rekor.sigstore.dev - depends_on: - - nextjs - volumes: - - ./artifacts/electron/videos:/e2e/cypress/videos - - ./artifacts/electron/screenshots:/e2e/cypress/screenshots - environment: - - CYPRESS_BASE_URL=http://nextjs:3000 - - CYPRESS_RECORD_KEY=${CYPRESS_RECORD_KEY} - - GITHUB_TOKEN=${GITHUB_TOKEN} - command: npx cypress run