From f2bce68edb6b2f5f3be4cfd679a9e9bd936ca88f 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 | 45 ++++++++++++++++++++++++ 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 +++-- 7 files changed, 87 insertions(+), 6 deletions(-) create mode 100644 .github/workflows/build.yml create mode 100644 .github/workflows/test.yml 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..6343069 --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,45 @@ +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 + +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 }}' + 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/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" },