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 cfa32ea
Show file tree
Hide file tree
Showing 28 changed files with 1,245 additions and 72 deletions.
30 changes: 30 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: Validate

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

env:
NODE_VERSION: 20.14.0

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
141 changes: 141 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,141 @@
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

env:
NODE_VERSION: 20.10.0

# 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-20.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
- electron
- edge

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

- name: Install dependencies
run: |
npm ci
- name: Unblock Cypress
run: |
echo 🕊️ Download Free Cypress
CYPRESS_DOWNLOAD_MIRROR=https://cy-cdn.currents.dev npx cypress install --force
echo ✅ Verify Cypress
npx cypress verify
echo 👀 Cypress Cache
npx cypress cache list
npx cypress cache path
- name: Run cypress tests
run: |
npm run cy:info
npm run cy:run:${{ matrix.browser }}
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'

# - 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 }}'
# 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-artifact@v4
with:
name: ${{ matrix.browser }}-report
path: 'cypress/reports'
retention-days: 3

cy-reports:
runs-on: ubuntu-20.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: Download Electron Report
uses: actions/download-artifact@v4
with:
name: electron-report
path: electron-report

- name: Download Edge Report
uses: actions/download-artifact@v4
with:
name: edge-report
path: edge-report

- name: Copy Reports to Specific Directories
run: |
mkdir -p gh-pages/chrome
mkdir -p gh-pages/electron
mkdir -p gh-pages/edge
cp report/index.html gh-pages
cp -r chrome-report gh-pages/chrome/
cp -r electron-report gh-pages/electron/
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
6 changes: 6 additions & 0 deletions currents.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
// currents.config.js
module.exports = {
projectId: 'yyy', // the projectId, can be any values for sorry-cypress users
recordKey: 'xxx', // the record key, can be any value for sorry-cypress users
cloudServiceUrl: 'http://localhost:1234', // Sorry Cypress users - set the director service URL
};
10 changes: 8 additions & 2 deletions cypress.config.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
module.exports = {
const { defineConfig } = require("cypress");
const { cloudPlugin } = require("cypress-cloud/plugin");

module.exports = defineConfig ({
video: true,
retries: 1,
reporter: 'cypress-mochawesome-reporter',
Expand All @@ -12,7 +15,10 @@ module.exports = {
},
e2e: {
setupNodeEvents(on, config) {
// Register the Mochawesome reporter plugin
require('cypress-mochawesome-reporter/plugin')(on);
cloudPlugin(on, config);
return config;
},
},
};
});
4 changes: 2 additions & 2 deletions cypress/e2e/1-getting-started/todo.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
// please read our getting started guide:
// https://on.cypress.io/introduction-to-cypress

describe('example to-do app', () => {
describe(`example to-do app - ${Cypress.browser.name}`, () => {
beforeEach(() => {
// Cypress starts out with a blank slate for each test
// so we must tell it to visit our website with the `cy.visit()` command.
Expand Down 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/e2e/2-advanced-examples/actions.cy.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/// <reference types="cypress" />

context('Actions', () => {
context(`Actions - ${Cypress.browser.name}`, () => {
beforeEach(() => {
cy.visit('https://example.cypress.io/commands/actions');
});
Expand Down
2 changes: 1 addition & 1 deletion cypress/e2e/2-advanced-examples/aliasing.cy.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/// <reference types="cypress" />

context('Aliasing', () => {
context(`Aliasing - ${Cypress.browser.name}`, () => {
beforeEach(() => {
cy.visit('https://example.cypress.io/commands/aliasing');
});
Expand Down
4 changes: 2 additions & 2 deletions cypress/e2e/2-advanced-examples/assertions.cy.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
/// <reference types="cypress" />

context('Assertions', () => {
context(`Assertions - ${Cypress.browser.name}`, () => {
beforeEach(() => {
cy.visit('https://example.cypress.io/commands/assertions');
});

describe('Implicit Assertions', () => {
describe(`Implicit Assertions - ${Cypress.browser.name}`, () => {
it('.should() - make an assertion about the current subject', () => {
// https://on.cypress.io/should
cy.get('.assertion-table')
Expand Down
2 changes: 1 addition & 1 deletion cypress/e2e/2-advanced-examples/connectors.cy.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/// <reference types="cypress" />

context('Connectors', () => {
context(`Connectors - ${Cypress.browser.name}`, () => {
beforeEach(() => {
cy.visit('https://example.cypress.io/commands/connectors');
});
Expand Down
2 changes: 1 addition & 1 deletion cypress/e2e/2-advanced-examples/cookies.cy.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/// <reference types="cypress" />

context('Cookies', () => {
context(`Cookies - ${Cypress.browser.name}`, () => {
beforeEach(() => {
Cypress.Cookies.debug(true);

Expand Down
4 changes: 2 additions & 2 deletions cypress/e2e/2-advanced-examples/cypress_api.cy.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/// <reference types="cypress" />

context('Cypress APIs', () => {
context('Cypress.Commands', () => {
context(`Cypress APIs - ${Cypress.browser.name}`, () => {
context(`Cypress.Commands - ${Cypress.browser.name}`, () => {
beforeEach(() => {
cy.visit('https://example.cypress.io/cypress-api');
});
Expand Down
2 changes: 1 addition & 1 deletion cypress/e2e/2-advanced-examples/files.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
// the built-in JavaScript bundler
const requiredExample = require('../../fixtures/example');

context('Files', () => {
context(`Files - ${Cypress.browser.name}`, () => {
beforeEach(() => {
cy.visit('https://example.cypress.io/commands/files');

Expand Down
2 changes: 1 addition & 1 deletion cypress/e2e/2-advanced-examples/location.cy.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/// <reference types="cypress" />

context('Location', () => {
context(`Location - ${Cypress.browser.name}`, () => {
beforeEach(() => {
cy.visit('https://example.cypress.io/commands/location');
});
Expand Down
2 changes: 1 addition & 1 deletion cypress/e2e/2-advanced-examples/misc.cy.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/// <reference types="cypress" />

context('Misc', () => {
context(`Misc - ${Cypress.browser.name}`, () => {
beforeEach(() => {
cy.visit('https://example.cypress.io/commands/misc');
});
Expand Down
2 changes: 1 addition & 1 deletion cypress/e2e/2-advanced-examples/navigation.cy.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/// <reference types="cypress" />

context('Navigation', () => {
context(`Navigation - ${Cypress.browser.name}`, () => {
beforeEach(() => {
cy.visit('https://example.cypress.io');
cy.get('.navbar-nav').contains('Commands').click();
Expand Down
2 changes: 1 addition & 1 deletion cypress/e2e/2-advanced-examples/network_requests.cy.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/// <reference types="cypress" />

context('Network Requests', () => {
context(`Network Requests - ${Cypress.browser.name}`, () => {
beforeEach(() => {
cy.visit('https://example.cypress.io/commands/network-requests');
});
Expand Down
2 changes: 1 addition & 1 deletion cypress/e2e/2-advanced-examples/querying.cy.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/// <reference types="cypress" />

context('Querying', () => {
context(`Querying - ${Cypress.browser.name}`, () => {
beforeEach(() => {
cy.visit('https://example.cypress.io/commands/querying');
});
Expand Down
2 changes: 1 addition & 1 deletion cypress/e2e/2-advanced-examples/spies_stubs_clocks.cy.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/// <reference types="cypress" />

context('Spies, Stubs, and Clock', () => {
context(`Spies, Stubs, and Clock - ${Cypress.browser.name}`, () => {
it('cy.spy() - wrap a method in a spy', () => {
// https://on.cypress.io/spy
cy.visit('https://example.cypress.io/commands/spies-stubs-clocks');
Expand Down
2 changes: 1 addition & 1 deletion cypress/e2e/2-advanced-examples/storage.cy.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/// <reference types="cypress" />

context('Local Storage / Session Storage', () => {
context(`Local Storage / Session Storage`, () => {
beforeEach(() => {
cy.visit('https://example.cypress.io/commands/storage');
});
Expand Down
2 changes: 1 addition & 1 deletion cypress/e2e/2-advanced-examples/traversal.cy.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/// <reference types="cypress" />

context('Traversal', () => {
context(`Traversal - ${Cypress.browser.name}`, () => {
beforeEach(() => {
cy.visit('https://example.cypress.io/commands/traversal');
});
Expand Down
2 changes: 1 addition & 1 deletion cypress/e2e/2-advanced-examples/utilities.cy.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/// <reference types="cypress" />

context('Utilities', () => {
context(`Utilities - ${Cypress.browser.name}`, () => {
beforeEach(() => {
cy.visit('https://example.cypress.io/utilities');
});
Expand Down
2 changes: 1 addition & 1 deletion cypress/e2e/2-advanced-examples/viewport.cy.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/// <reference types="cypress" />
context('Viewport', () => {
context(`Viewport - ${Cypress.browser.name}`, () => {
beforeEach(() => {
cy.visit('https://example.cypress.io/commands/viewport');
});
Expand Down
2 changes: 1 addition & 1 deletion cypress/e2e/2-advanced-examples/waiting.cy.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/// <reference types="cypress" />
context('Waiting', () => {
context(`Waiting - ${Cypress.browser.name}`, () => {
beforeEach(() => {
cy.visit('https://example.cypress.io/commands/waiting');
});
Expand Down
2 changes: 1 addition & 1 deletion cypress/e2e/2-advanced-examples/window.cy.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/// <reference types="cypress" />

context('Window', () => {
context(`Window - ${Cypress.browser.name}`, () => {
beforeEach(() => {
cy.visit('https://example.cypress.io/commands/window');
});
Expand Down
2 changes: 1 addition & 1 deletion cypress/parallel-weights.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{}
{}
Loading

0 comments on commit cfa32ea

Please sign in to comment.