Skip to content

Commit

Permalink
test(e2e): enable running e2e tests with docker
Browse files Browse the repository at this point in the history
fix: update rekor endpoint string

fix(ci): error about deprecated husky install command

ci(e2e): add headless configuration in docker compose

test(e2e): include volumes for test artifacts

ci(e2e): add e2e github workflow
  • Loading branch information
kahboom committed May 22, 2024
1 parent 2dc6e52 commit 88f35e6
Show file tree
Hide file tree
Showing 7 changed files with 177 additions and 98 deletions.
36 changes: 36 additions & 0 deletions .github/workflows/e2e-tests.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: cross browser end-to-end testing 🚀

on:
push:
branches:
- 'main'
pull_request:
types: [opened, reopened]
schedule:
- cron: '0 2 * * FRI'

jobs:
cypress-run:
runs-on: ubuntu-latest
timeout-minutes: 5

steps:
- name: Checkout 🛎
uses: actions/checkout@v3

- name: Run docker-compose 🐳
run: docker-compose up -d cypress

- name: Wait for services to start ⏱️
run: docker-compose logs -f

- name: Upload Electron artifacts 📸
uses: actions/upload-artifact@v3
with:
name: electron-artifacts
path: |
./artifacts/electron/videos
./artifacts/electron/screenshots
if-no-files-found: ignore
retention-days: 5

16 changes: 16 additions & 0 deletions cypress.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
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"]
5 changes: 1 addition & 4 deletions cypress.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,7 @@ import { defineConfig } from "cypress";

export default defineConfig({
e2e: {
baseUrl: "http://localhost:3000",
baseUrl: "http://nextjs:3000",
experimentalStudio: true,
setupNodeEvents(_on, _config) {
// implement node event listeners here
},
},
});
1 change: 1 addition & 0 deletions cypress/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"compilerOptions": {
"baseUrl": "./",
"target": "es5",
"lib": ["es5", "dom"],
"types": ["cypress", "node"]
Expand Down
29 changes: 29 additions & 0 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
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:
# set mappings to access artifacts outside of containers
- ./artifacts/electron/videos:/e2e/cypress/videos
- ./artifacts/electron/screenshots:/e2e/cypress/screenshots
environment:
- CYPRESS_BASE_URL=http://nextjs:3000
# run electron in headless mode
command: npx cypress run
Loading

0 comments on commit 88f35e6

Please sign in to comment.