Skip to content

Cypresss Product Test Issues#2 #13

Cypresss Product Test Issues#2

Cypresss Product Test Issues#2 #13

Workflow file for this run

name: CI/CD Pipeline for Next.js
on:
push:
branches: [main] # Adjust this as needed
jobs:
build-and-test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Setup Node.js
uses: actions/setup-node@v2
with:
node-version: "20" # Next.js 14 recommends Node.js 16 or later
- name: Cache Node modules
uses: actions/cache@v2
with:
path: ~/.npm
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-
- name: Cache Next.js build
uses: actions/cache@v2
with:
path: .next/cache
key: ${{ runner.os }}-nextjs-${{ hashFiles('**/*.js', '**/*.css') }}
restore-keys: |
${{ runner.os }}-nextjs-
- name: Install Dependencies
run: npm install
- name: Run Jest Tests
run: npm test
- name: Build Next.js Project
run: npm run build
- name: Cypress run
uses: cypress-io/github-action@v2
with:
headless: true
command: npm run cypress:run
env:
# Pass the GitHub token to allow Cypress to record the test results on the Cypress dashboard
# You need to set up Cypress dashboard and add CYPRESS_RECORD_KEY in your repository secrets if you want to record the tests
CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }}
TEST_STORE_ID: ${{ secrets.TEST_STORE_ID }}
TEST_EMAIL: ${{ secrets.TEST_EMAIL }}
TEST_PASSWORD: ${{ secrets.TEST_PASSWORD }}
NEXT_PUBLIC_APP_URL: ${{ secrets.NEXT_PUBLIC_APP_URL }}
TEST_PRODUCT_ID: ${{ secrets.TEST_PRODUCT_ID }}
TEST_USER_EMAIL: ${{ secrets.TEST_USER_EMAIL }}
TEST_USER_PASSWORD: ${{ secrets.TEST_USER_PASSWORD }}
deploy:
needs: build-and-test
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/main'
steps:
- uses: actions/checkout@v2
- name: Deploy to Vercel
uses: amondnet/vercel-action@v20
with:
vercel-token: ${{ secrets.VERCEL_TOKEN }}
vercel-org-id: ${{ secrets.VERCEL_ORG_ID }} # Adjust based on your previous discussions about Account/Org ID
vercel-project-id: ${{ secrets.VERCEL_PROJECT_ID }}
# Include other options as needed