Skip to content

Commit

Permalink
Add CI config
Browse files Browse the repository at this point in the history
  • Loading branch information
hamza-lem committed Aug 4, 2024
1 parent 0f04ec6 commit 7846744
Show file tree
Hide file tree
Showing 7 changed files with 170 additions and 6 deletions.
31 changes: 31 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: Validate

on:
pull_request:
types:
- opened
- synchronize
- closed
branches:
- master

env:
NODE_VERSION: 20.14.0
RUN_ID: ${{ github.run_id }}

jobs:
validate:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION}}

- name: Install dependencies and validate linting and formatting
run: |
npm ci
npm run validate
128 changes: 128 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
name: Tests

on:
# Triggers the workflow manually from the GitHub Actions tab
workflow_dispatch:
# Runs the workflow on every push to the repository
push:
# Runs the workflow on every push to the repository
pull_request:
types:
- opened
- synchronize
- closed
branches:
- master

# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
permissions:
contents: write
pages: write
id-token: write

# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued.
# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete.
concurrency:
group: 'pages'
cancel-in-progress: false

jobs:
cy-test:
runs-on: ubuntu-22.04
name: Run Cypress Tests
strategy:
# don't fail the entire matrix on failure
fail-fast: false
matrix:
# Run the job in parallel on different browser
browser:
- chrome
- firefox
- edge

steps:
- uses: actions/checkout@v4
- uses: cypress-io/github-action@v6
with:
build: npm run cy:info
wait-on-timeout: 120
browser: ${{ matrix.browser }}
# record: true
# parallel: true
# group: 'Cy-${{ matrix.browser }}'
spec: cypress/e2e/1-getting-started
config-file: cypress.config.js
env:
# CYPRESS_PROJECT_ID: ${{ secrets.SORRY_CYPRESS_PROJECT_ID }}
# CYPRESS_RECORD_KEY: ${{ secrets.SORRY_CYPRESS_RECORD_KEY }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
DEBUG: 'cypress:server:args'
# - name: Upload Cypress Html Reports
# uses: actions/upload-pages-artifact@v3
# with:
# # Upload reports
# name: cypress-report
# path: 'cypress/reports'
# retention-days: 3
# - name: Deploy to GitHub Pages
# id: deployment
# uses: actions/deploy-pages@v4.0.5
- name: Upload Cypress HTML Reports
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.browser }}-report
path: 'cypress/reports'
retention-days: 3

deploy-reports:
runs-on: ubuntu-22.04
needs: cy-test
steps:
- uses: actions/checkout@v4
name: Checkout Repository

- name: Download Chrome Report
uses: actions/download-artifact@v4
with:
name: chrome-report
path: chrome-report
- name: Display structure of downloaded files
run: |
pwd
ls -l
- name: Download Firefox Report
uses: actions/download-artifact@v4
with:
name: firefox-report
path: firefox-report
- name: Display structure of downloaded files
run: |
pwd
ls -l
- name: Download Edge Report
uses: actions/download-artifact@v4
with:
name: edge-report
path: edge-report
- name: Display structure of downloaded files
run: |
pwd
ls -l
- name: Copy Reports to Specific Directories
run: |
mkdir -p gh-pages/chrome
mkdir -p gh-pages/firefox
mkdir -p gh-pages/edge
cp -r chrome-report gh-pages/chrome/
cp -r firefox-report gh-pages/firefox/
cp -r edge-report gh-pages/edge/
- name: Deploy to GitHub Pages
uses: peaceiris/actions-gh-pages@v4
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./gh-pages
publish_branch: gh-pages
2 changes: 1 addition & 1 deletion cypress/e2e/1-getting-started/todo.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ describe('example to-do app', () => {
.should('not.have.text', 'Pay electric bill');

// Finally, make sure that the clear button no longer exists.
cy.contains('Clear completed').should('exist');
cy.contains('Clear completed').should('not.exist');
});
});
});
2 changes: 1 addition & 1 deletion cypress/fixtures/profile.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
"id": 8739,
"name": "Jane",
"email": "jane@example.com"
}
}
2 changes: 1 addition & 1 deletion cypress/fixtures/users.json
Original file line number Diff line number Diff line change
Expand Up @@ -229,4 +229,4 @@
"bs": "target end-to-end models"
}
}
]
]
2 changes: 1 addition & 1 deletion cypress/parallel-weights.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{}
{}
9 changes: 7 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,21 @@
"description": "This project integrates Cypress with Sorry-Cypress, an open-source, on-premise, self-hosted alternative to Cypress Cloud.",
"main": "cypress.config.js",
"scripts": {
"build": "cypress install",
"lint": "eslint --report-unused-disable-directives --max-warnings 0",
"lint:fix": "npm run lint --fix",
"format": "npx prettier --write --ignore-path .gitignore \"*.{js,json,yml,md}\" \"cypress/**/*.{js,json}\" \".github/workflows/**/*.yml\" \"*.yml\" \".github/ISSUE_TEMPLATE/**/*.md\" \"*.md\" \"*.prettierrc\" ",
"format": "npx prettier --write --ignore-path .gitignore \"*.{js,json,yml,md}\" \"cypress/**/*.{js,json}\" \".github/workflows/**/*.yml\" \"*.yml\" \"*.md\" \"*.prettierrc\" ",
"check-format": "npx prettier --check .",
"validate": "npm-run-all --parallel lint check-format",
"clean": "npm run clean:results && npm run clean:modules",
"clean:modules": "rimraf ./node_modules",
"clean:results": "rimraf ./cypress/reports ./cypress/videos ./cypress/screenshots ./cypress/downloads",
"cy:info": "cypress info",
"cy:open": "cypress open",
"cy:run": "cypress run ",
"cy:run": "cypress run",
"cy:run:chrome": "cypress run --browser chrome",
"cy:run:edge": "cypress run --browser edge",
"cy:run:firefox": "cypress run --browser firefox",
"cy:run:parallel": "cypress-parallel -s cypress run -t 2 -d 'cypress/e2e/**/*.cy.js' -o 'cypressParallel=true'",
"cy:open-report": "open cypress/reports/html/index.html"
},
Expand Down

0 comments on commit 7846744

Please sign in to comment.