Skip to content

Add Cypress tests, ESLint and Prettier to CI pipeline #1

Add Cypress tests, ESLint and Prettier to CI pipeline

Add Cypress tests, ESLint and Prettier to CI pipeline #1

Workflow file for this run

# This workflow will do a clean installation of node dependencies, cache/restore them, build the source code and run tests across different versions of node
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-nodejs
name: Node.js CI
on: [push, pull_request]
jobs:
build:
permissions:
contents: write
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [18.x]
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/
steps:
- name: Check Out Repository Code
uses: actions/checkout@v4
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
cache: 'npm'
- name: Install Dependencies
run: npm ci
- name: Run Lint
run: npm run lint
- name: Run Prettier
run: npm run prettier-write
- name: Build the Source Code
run: npm run build --if-present
- name: Run Tests
run: npm test
- name: Run Cypress Tests
uses: cypress-io/github-action@v6
with:
config-file: cypress.config.ts
start: npm run dev
video: true
screenshots: true
- name: Upload Cypress Screenshots
if: always()
uses: actions/upload-artifact@v4
with:
name: cypress-screenshots
path: cypress/screenshots
- name: Upload Cypress Videos
if: always()
uses: actions/upload-artifact@v4
with:
name: cypress-videos
path: cypress/videos
# - name: Deploy with gh-pages
# run: |
# git remote set-url origin https://git:${GITHUB_TOKEN}@github.com/${GITHUB_REPOSITORY}.git
# npx gh-pages -d dist -u "github-actions-bot <[email protected]>"
# env:
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
deploy:
needs: build
runs-on: ubuntu-latest
steps:
- name: Check Out Repository Code
uses: actions/checkout@v4
- name: Deploy with gh-pages
run: |
git remote set-url origin https://git:${GITHUB_TOKEN}@github.com/${GITHUB_REPOSITORY}.git
npx gh-pages -d dist -u "github-actions-bot <[email protected]>"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}