Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Craft medium article #1

Merged
merged 3 commits into from
Aug 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
144 changes: 144 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,144 @@
name: Tests

on:
# Triggers the workflow manually from the GitHub Actions tab
workflow_dispatch:
inputs:
sorry_cypress:
description: 'Choose whether to send results to Sorry-Cypress'
required: true
default: 'false'

env:
NODE_VERSION: 20.10.0
SORRY_CYPRESS_DIRECTOR_URL: ${{ secrets.SORRY_CYPRESS_DIRECTOR_URL}}

# 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
uses: cypress-io/github-action@v6
continue-on-error: true
if: ${{ github.event.inputs.sorry_cypress }} != 'true'
with:
install: false
build: npm run cy:info
wait-on-timeout: 180
browser: ${{ matrix.browser }}
config-file: cypress.config.js
command: |
npm run cy:run:${{ matrix.browser }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
DEBUG: 'cypress:server:args'

- name: Run Cypress Tests And send Data to Sorry-Cypress
uses: cypress-io/github-action@v6
continue-on-error: true
if: ${{ github.event.inputs.sorry_cypress }} == 'true'
with:
install: false
build: npm run cy:info
wait-on-timeout: 180
browser: ${{ matrix.browser }}
config-file: cypress.config.js
command: |
npx cypress-cloud run --browser ${{ matrix.browser }} --key ${{ secrets.SORRY_CYPRESS_RECORD_KEY }} --ci-build-id Run#${{ github.run_id }}-${{ matrix.browser }}
env:
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
9 changes: 9 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -128,3 +128,12 @@ dist
.yarn/build-state.yml
.yarn/install-state.gz
.pnp.*

#Cypress
runner-results
cypress/screenshots
cypress/videos
cypress/reports
data
docker-compose.minio.yml
.$sorry-cypress-arch.drawio.bkp
4 changes: 4 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"singleQuote": true,
"trailingComma": "all"
}
35 changes: 33 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,33 @@
# cy-sorry-cypress-dashboard
This project integrates Cypress with Sorry-Cypress dan open-source, on-premise, self-hosted alternative to Cypress Cloud
# Sorry Cypress Dashboard Implementation

## Description

This project integrates Cypress with Sorry-Cypress an open-source, on-premise, self-hosted alternative to Cypress Cloud

## Installation

```bash
$ npm install
```

## Running Cypress Tests

```bash
# Run Tests with Cypress Runner
$ npm run cypress:open

# Run Tests without Cypress Runner
$ npm run cypress:run
```

## Cypress Test Report

- [Cypress Report Home Page](https://hamza-lem.github.io/cy-sorry-cypress-dashboard/)
- [Cypress Chrome Report](https://hamza-lem.github.io/cy-sorry-cypress-dashboard/chrome/chrome-report/html/index.html)
- [Cypress Electron Report](https://hamza-lem.github.io/cy-sorry-cypress-dashboard/electron/electron-report/html/index.html)
- [Cypress Edge Report](https://hamza-lem.github.io/cy-sorry-cypress-dashboard/edge/edge-report/html/index.html)

## Documentation

- [Cypress docs](https://docs.cypress.io/guides/overview)
- [Sorry Cypress docs](https://docs.sorry-cypress.dev/guide/get-started)
10 changes: 10 additions & 0 deletions currents.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// currents.config.js
module.exports = {
// projectId should match the projectId value used in Sorry-Cypress.
projectId: 'cy-sorry-cypress-dashboard',
// Record key, can be any value.
recordKey: 'cy-key',
// Director service URL
cloudServiceUrl:
process.env.SORRY_CYPRESS_DIRECTOR_URL || 'http://localhost:1234',
};
25 changes: 25 additions & 0 deletions cypress.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
const { defineConfig } = require('cypress');
const { cloudPlugin } = require('cypress-cloud/plugin');

module.exports = defineConfig({
video: true,
videoUploadOnPasses: false,
retries: 1,
reporter: 'cypress-mochawesome-reporter',
reporterOptions: {
charts: true,
reportPageTitle: 'Cypress-report',
embeddedScreenshots: true,
inlineAssets: true,
saveAllAttempts: false,
videoOnFailOnly: true,
},
e2e: {
setupNodeEvents(on, config) {
// Register the Mochawesome reporter plugin
require('cypress-mochawesome-reporter/plugin')(on);
cloudPlugin(on, config);
return config;
},
},
});
Loading