Skip to content
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
27 changes: 17 additions & 10 deletions .github/workflows/cypress.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,39 +24,46 @@ jobs:
with:
node-version: '20'

# Step 3: Install dependencies
# Step 3: Inject environment variables from GitHub Secrets
- name: Set environment variables from GitHub Secrets
run: |
echo "CYPRESS_baseUrl=${{ secrets.CYPRESS_baseUrl }}" >> $GITHUB_ENV
echo "CYPRESS_baseUrlAPI=${{ secrets.CYPRESS_baseUrlAPI }}" >> $GITHUB_ENV
echo "CYPRESS_allureResultsPath=${{ secrets.CYPRESS_allureResultsPath }}" >> $GITHUB_ENV

# Step 4: Install dependencies
- name: Install dependencies
run: |
npm ci
npx cypress install # Ensure Cypress is installed

# Step 4: Set up Allure commandline
# Step 5: Set up Allure commandline
- name: Set up Allure commandline
run: npm install -g allure-commandline

# Step 5: Install additional dependencies for Allure and Cypress
# Step 6: Install additional dependencies for Allure and Cypress
- name: Install additional dependencies
run: |
npm install mocha-allure-reporter allure-cypress --save-dev
npm install @bahmutov/cypress-esbuild-preprocessor @badeball/cypress-cucumber-preprocessor cypress-file-upload --save-dev

# Step 6: Run Cypress tests and generate Allure results (ensure it doesn't fail the workflow)
# Step 7: Run Cypress tests and generate Allure results
- name: Run Cypress tests
run: |
npx cypress run --reporter mocha-allure-reporter --reporter-options allureResults=allure-results || true
echo "Cypress tests completed (even with failures)"

# Step 7: Always generate Allure report, even if tests failed
# Step 8: Generate Allure report (even if tests fail)
- name: Generate Allure report
run: |
allure generate allure-results --clean
if: always() # Ensures it runs even if the previous step fails
if: always() # Ensures this step runs even if the previous step fails

# Step 8: Deploy Allure Report to GitHub Pages
# Step 9: Deploy Allure Report to GitHub Pages
- name: Deploy Allure Report to GitHub Pages
uses: peaceiris/actions-gh-pages@v3
with:
personal_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./allure-report # Folder where the Allure report is generated
publish_branch: gh-pages # Deploy to gh-pages branch
publish_dir: ./allure-report # Folder where the Allure report is generated
publish_branch: gh-pages # Deploy to gh-pages branch
if: always() # Ensures this step runs even if tests fail
11 changes: 7 additions & 4 deletions cypress.config.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// cypress.config.js
require("dotenv").config(); // Load environment variables from .env

const { defineConfig } = require("cypress");
const createBundler = require("@bahmutov/cypress-esbuild-preprocessor");
const {
Expand Down Expand Up @@ -27,11 +30,11 @@ module.exports = defineConfig({
e2e: {
specPattern: "**/*.feature",
setupNodeEvents,
baseUrl: "https://opensource-demo.orangehrmlive.com/",
baseUrlAPI: "http://localhost:7081",
baseUrl: process.env.CYPRESS_baseUrl,
baseUrlAPI: process.env.CYPRESS_baseUrlAPI,
chromeWebSecurity: false,
env: {
allureResultsPath: "cypress/results/allure",
allureResultsPath: process.env.CYPRESS_allureResultsPath,
},
},
});
});
15 changes: 14 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
"mocha-allure-reporter": "^1.4.0"
},
"dependencies": {
"cypress-xpath": "^2.0.1"
"cypress-xpath": "^2.0.1",
"dotenv": "^16.4.7"
}
}
Loading