From b27197756b948e24b5e1a6959d5df100ebaf68dc Mon Sep 17 00:00:00 2001
From: hamza
Date: Sun, 4 Aug 2024 14:32:54 +0200
Subject: [PATCH] Add CI config
---
.github/workflows/build.yml | 31 +++++++
.github/workflows/test.yml | 90 +++++++++++++++++++
.../actions.cy.js | 0
.../aliasing.cy.js | 0
.../assertions.cy.js | 0
cypress/e2e/1-getting-started/todo.cy.js | 2 +-
cypress/fixtures/profile.json | 2 +-
cypress/fixtures/users.json | 2 +-
cypress/parallel-weights.json | 2 +-
package.json | 9 +-
10 files changed, 132 insertions(+), 6 deletions(-)
create mode 100644 .github/workflows/build.yml
create mode 100644 .github/workflows/test.yml
rename cypress/e2e/{2-advanced-examples => 1-getting-started}/actions.cy.js (100%)
rename cypress/e2e/{2-advanced-examples => 1-getting-started}/aliasing.cy.js (100%)
rename cypress/e2e/{2-advanced-examples => 1-getting-started}/assertions.cy.js (100%)
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
new file mode 100644
index 0000000..82283ce
--- /dev/null
+++ b/.github/workflows/build.yml
@@ -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
diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml
new file mode 100644
index 0000000..bc4bfc2
--- /dev/null
+++ b/.github/workflows/test.yml
@@ -0,0 +1,90 @@
+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 pull requests with specific events
+ pull_request:
+ types:
+ - opened
+ - synchronize
+ - closed
+ branches:
+ - master
+
+jobs:
+ # Run tests in Chrome browser
+ cy-chrome:
+ runs-on: ubuntu-22.04
+ name: Run Cypress Tests on Chrome
+ strategy:
+ # don't fail the entire matrix on failure
+ fail-fast: false
+ matrix:
+ # Run the job in parallel with different containers
+ spec:
+ - cypress/e2e/1-getting-started/*
+ - cypress/e2e/2-advanced-examples/*
+ steps:
+ - uses: actions/checkout@v4
+ - uses: cypress-io/github-action@v6
+ with:
+ build: npm run cy:info
+ wait-on-timeout: 120
+ browser: chrome
+ # record: true
+ # parallel: true
+ # group: 'Cy-Chrome'
+ spec: ${{ matrix.spec }}
+ 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'
+
+ # Run tests in Firefox browser
+ # cy-firefox:
+ # runs-on: ubuntu-22.04
+ # name: Run Cypress Tests on Firefox
+ # steps:
+ # - uses: actions/checkout@v4
+ # - uses: cypress-io/github-action@v6
+ # with:
+ # build: npm run cy:info
+ # wait-on-timeout: 120
+ # browser: firefox
+ # record: true
+ # parallel: true
+ # group: 'Cy-Firefox'
+ # spec: cypress/e2e/*
+ # 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'
+
+ # # Run tests in Edge browser
+ # cy-edge:
+ # runs-on: ubuntu-22.04
+ # name: Run Cypress Tests on Edge
+ # steps:
+ # - uses: actions/checkout@v4
+ # - uses: cypress-io/github-action@v6
+ # with:
+ # build: npm run cy:info
+ # wait-on-timeout: 120
+ # browser: edge
+ # record: true
+ # parallel: true
+ # group: 'Cy-Edge'
+ # spec: cypress/e2e/*
+ # 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'
diff --git a/cypress/e2e/2-advanced-examples/actions.cy.js b/cypress/e2e/1-getting-started/actions.cy.js
similarity index 100%
rename from cypress/e2e/2-advanced-examples/actions.cy.js
rename to cypress/e2e/1-getting-started/actions.cy.js
diff --git a/cypress/e2e/2-advanced-examples/aliasing.cy.js b/cypress/e2e/1-getting-started/aliasing.cy.js
similarity index 100%
rename from cypress/e2e/2-advanced-examples/aliasing.cy.js
rename to cypress/e2e/1-getting-started/aliasing.cy.js
diff --git a/cypress/e2e/2-advanced-examples/assertions.cy.js b/cypress/e2e/1-getting-started/assertions.cy.js
similarity index 100%
rename from cypress/e2e/2-advanced-examples/assertions.cy.js
rename to cypress/e2e/1-getting-started/assertions.cy.js
diff --git a/cypress/e2e/1-getting-started/todo.cy.js b/cypress/e2e/1-getting-started/todo.cy.js
index eb0966e..39d1dbe 100644
--- a/cypress/e2e/1-getting-started/todo.cy.js
+++ b/cypress/e2e/1-getting-started/todo.cy.js
@@ -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');
});
});
});
diff --git a/cypress/fixtures/profile.json b/cypress/fixtures/profile.json
index b6c355c..a95e88f 100644
--- a/cypress/fixtures/profile.json
+++ b/cypress/fixtures/profile.json
@@ -2,4 +2,4 @@
"id": 8739,
"name": "Jane",
"email": "jane@example.com"
-}
\ No newline at end of file
+}
diff --git a/cypress/fixtures/users.json b/cypress/fixtures/users.json
index 79b699a..82a0056 100644
--- a/cypress/fixtures/users.json
+++ b/cypress/fixtures/users.json
@@ -229,4 +229,4 @@
"bs": "target end-to-end models"
}
}
-]
\ No newline at end of file
+]
diff --git a/cypress/parallel-weights.json b/cypress/parallel-weights.json
index 9e26dfe..0967ef4 100644
--- a/cypress/parallel-weights.json
+++ b/cypress/parallel-weights.json
@@ -1 +1 @@
-{}
\ No newline at end of file
+{}
diff --git a/package.json b/package.json
index 24fa1a0..a1bc5f4 100644
--- a/package.json
+++ b/package.json
@@ -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"
},