Skip to content

Commit aa0554a

Browse files
feat: cypress allure test report (#2726)
Co-authored-by: Zack Jackson <zackary.l.jackson@gmail.com>
1 parent fb5037f commit aa0554a

File tree

173 files changed

+8669
-7817
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

173 files changed

+8669
-7817
lines changed

.github/workflows/on-pull-request.yml

Lines changed: 29 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,25 @@ jobs:
1212
with:
1313
access_token: ${{ secrets.GITHUB_TOKEN }}
1414

15+
# Save nessesary env variables to use them in next jobs
16+
save-env:
17+
runs-on: ubuntu-22.04
18+
needs: stop-previous-run
19+
steps:
20+
- name: Save env variables
21+
run: |
22+
mkdir -p ./workflow
23+
echo "${{ github.event.pull_request.number }}" > ./workflow/prNum
24+
echo "${{ github.run_number }}" > ./workflow/runNum
25+
echo "${{ github.run_id }}" > ./workflow/runId
26+
echo "${{ github.repository }}" > ./workflow/repoFullName
27+
echo "${{ github.repository_owner }}" > ./workflow/ownerName
28+
- name: Upload artifact
29+
uses: actions/upload-artifact@v3
30+
with:
31+
name: env_for_comment
32+
path: workflow/
33+
1534
# Check if forked master is up to date with origin master in module federation examples repo
1635
forked_master_status:
1736
runs-on: ubuntu-22.04
@@ -32,10 +51,8 @@ jobs:
3251
git remote add base https://github.com/${{github.repository}}
3352
git remote -v
3453
git fetch --all
35-
3654
export FORKED_MASTER_SHA=$(git log -n 1 --pretty=format:"%H" origin/${{ github.event.pull_request.base.ref}})
3755
export BASE_MASTER_SHA=$(git log -n 1 --pretty=format:"%H" base/${{ github.event.pull_request.base.ref }})
38-
3956
echo "$FORKED_MASTER_SHA"
4057
echo "$BASE_MASTER_SHA"
4158
@@ -78,8 +95,6 @@ jobs:
7895
if: ${{ needs.setup-matrix.outputs.matrix != '{"container":[]}' }}
7996
runs-on: ubuntu-22.04
8097
timeout-minutes: 30
81-
outputs:
82-
yarnHash: ${{ steps.set-matrix.outputs.matrix }}
8398
strategy:
8499
fail-fast: false
85100
matrix: ${{fromJson(needs.setup-matrix.outputs.matrix)}}
@@ -112,6 +127,12 @@ jobs:
112127
e2e-cache-
113128
e2e-
114129
130+
- name: Install main deps
131+
# TODO Uncomment when yarn will work properly from the root and install all nessessary deps. Also please, ayarn install to the run section below instead of npx lerna exec
132+
# if: steps.yarn-cache.outputs.cache-hit != 'true'
133+
run: |
134+
yarn install
135+
115136
- name: Install sample deps
116137
# TODO Uncomment when yarn will work properly from the root and install all nessessary deps. Also please, add yarn install to the run section below instead of npx lerna exec
117138
# if: steps.yarn-cache.outputs.cache-hit != 'true'
@@ -122,18 +143,10 @@ jobs:
122143
run:
123144
npx lerna run --scope=${{ matrix.container }} e2e:ci
124145

125-
- name: Create artifacts for Cypress screenshots
126-
uses: actions/upload-artifact@v3
127-
if: failure()
128-
with:
129-
name: cypress-screenshots
130-
path: '**/${{ matrix.container }}/cypress/screenshots'
131-
retention-days: 7
132-
133-
- name: Create artifacts for Cypress videos
146+
- name: Create artifacts for Allure report
134147
uses: actions/upload-artifact@v3
135-
if: failure()
148+
if: always()
136149
with:
137-
name: cypress-videos
138-
path: '**/${{ matrix.container }}/cypress/videos'
150+
name: allure-results
151+
path: 'cypress/results/allure-results'
139152
retention-days: 7

.github/workflows/on-workflow-run.yml

Lines changed: 206 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,206 @@
1+
name: on workflow run
2+
3+
# read-write repo token
4+
# access to secrets
5+
on:
6+
workflow_run:
7+
workflows: ["on pull request"]
8+
types:
9+
- completed
10+
11+
jobs:
12+
13+
stop-previous-run:
14+
runs-on: ubuntu-22.04
15+
steps:
16+
- name: Cancel Previous Runs
17+
uses: styfle/cancel-workflow-action@0.11.0
18+
with:
19+
access_token: ${{ secrets.GITHUB_TOKEN }}
20+
21+
22+
generate-allure-report:
23+
runs-on: ubuntu-22.04
24+
if: always()
25+
needs: stop-previous-run
26+
steps:
27+
- name: Dowload artifacts
28+
uses: actions/github-script@v6
29+
with:
30+
script: |
31+
const artifacts = await github.rest.actions.listWorkflowRunArtifacts({
32+
owner: context.repo.owner,
33+
repo: context.repo.repo,
34+
run_id: ${{github.event.workflow_run.id }}
35+
});
36+
const matchArtifact = artifacts.data.artifacts.find(artifact => artifact.name === 'allure-results');
37+
if (!matchArtifact) {
38+
throw new Error('Artifact not found');
39+
}
40+
const download = await github.rest.actions.downloadArtifact({
41+
owner: context.repo.owner,
42+
repo: context.repo.repo,
43+
artifact_id: matchArtifact.id,
44+
archive_format: 'zip'
45+
});
46+
const fs = require('fs');
47+
fs.writeFileSync('${{github.workspace}}/allure-results.zip', Buffer.from(download.data));
48+
- run: unzip allure-results.zip
49+
50+
- name: Get Allure history
51+
uses: actions/checkout@v2
52+
if: always()
53+
continue-on-error: true
54+
with:
55+
ref: gh-pages
56+
path: gh-pages
57+
58+
- name: Allure Report action from marketplace
59+
uses: simple-elf/allure-report-action@master
60+
if: always()
61+
with:
62+
allure_results: ./
63+
allure_history: allure-history
64+
keep_reports: 20
65+
66+
- name: Deploy report to Github Pages
67+
if: always()
68+
uses: peaceiris/actions-gh-pages@v2
69+
env:
70+
PERSONAL_TOKEN: ${{ secrets.GITHUB_TOKEN }}
71+
PUBLISH_BRANCH: gh-pages
72+
PUBLISH_DIR: allure-history
73+
74+
comment-to-pr:
75+
runs-on: ubuntu-22.04
76+
needs: generate-allure-report
77+
if: >
78+
github.event.workflow_run.event == 'pull_request'
79+
steps:
80+
- name: 'Download artifact'
81+
uses: actions/github-script@v6
82+
with:
83+
script: |
84+
const artifacts = await github.rest.actions.listWorkflowRunArtifacts({
85+
owner: context.repo.owner,
86+
repo: context.repo.repo,
87+
run_id: ${{github.event.workflow_run.id }}
88+
});
89+
const matchArtifact = artifacts.data.artifacts.find(artifact => artifact.name === 'env_for_comment');
90+
if (!matchArtifact) {
91+
throw new Error('Artifact not found');
92+
}
93+
const download = await github.rest.actions.downloadArtifact({
94+
owner: context.repo.owner,
95+
repo: context.repo.repo,
96+
artifact_id: matchArtifact.id,
97+
archive_format: 'zip'
98+
});
99+
const fs = require('fs');
100+
fs.writeFileSync('${{github.workspace}}/env_for_comment.zip', Buffer.from(download.data));
101+
- run: unzip env_for_comment.zip
102+
103+
- name: 'Comment to PR -- if success'
104+
if: github.event.workflow_run.conclusion == 'success'
105+
uses: actions/github-script@v6
106+
with:
107+
script: |
108+
const fs = require('fs');
109+
const issue_number = Number(fs.readFileSync('./prNum'));
110+
const runNumber = Number(fs.readFileSync('./runNum'));
111+
const runId = Number(fs.readFileSync('./runId'));
112+
const repoFullName = fs.readFileSync('./repoFullName');
113+
const ownerName = fs.readFileSync('./ownerName');
114+
const githubPagesLink = 'https://' + ownerName.toString().toLowerCase().trim() + '.github.io/' + String(repoFullName).replace(`${ownerName.toString().trim()}/`, '') + '/';
115+
const githubRunLink = 'https://github.com/' + repoFullName + '/actions/runs/' + runId;
116+
github.rest.issues.createComment({
117+
issue_number: issue_number,
118+
owner: context.repo.owner,
119+
repo: context.repo.repo,
120+
body: 'All tests are passed ✅ \n Checkout tests results here: <a href="' + githubPagesLink + runNumber + '">Cypress e2e Test Report</a> \n Link to GitHub workflow: <a href="' + githubRunLink + '">Github Workflow Link</a> \n Take care of yourself and have a great day! 🌞 \n❕Note: Report deployment may take up to 5 minutes.'
121+
})
122+
123+
- name: 'Comment to PR -- if failed'
124+
if: github.event.workflow_run.conclusion == 'failure'
125+
uses: actions/github-script@v6
126+
with:
127+
script: |
128+
const fs = require('fs');
129+
const issue_number = Number(fs.readFileSync('./prNum'));
130+
const runNumber = Number(fs.readFileSync('./runNum'));
131+
const runId = Number(fs.readFileSync('./runId'));
132+
const repoFullName = fs.readFileSync('./repoFullName');
133+
const ownerName = fs.readFileSync('./ownerName');
134+
const githubPagesLink = 'https://' + ownerName.toString().toLowerCase().trim() + '.github.io/' + String(repoFullName).replace(`${ownerName.toString().trim()}/`, '') + '/';
135+
const githubRunLink = 'https://github.com/' + repoFullName + '/actions/runs/' + runId;
136+
github.rest.issues.createComment({
137+
issue_number: issue_number,
138+
owner: context.repo.owner,
139+
repo: context.repo.repo,
140+
body: 'Workflow is failed ❌ \n Test might not start, so please chekout workflow first \n Link to GitHub workflow: <a href="' + githubRunLink + '">Github Workflow Link</a> \n Checkout tests results here: <a href="' + githubPagesLink + runNumber + '">Cypress e2e Test Report</a> \n Take care of yourself and have a great day! 🌞 \n❕Note: Report deployment may take up to 5 minutes.'
141+
})
142+
143+
- name: 'Comment to PR -- if cancelled'
144+
if: github.event.workflow_run.conclusion == 'cancelled'
145+
uses: actions/github-script@v6
146+
with:
147+
script: |
148+
const fs = require('fs');
149+
const issue_number = Number(fs.readFileSync('./prNum'));
150+
const runNumber = Number(fs.readFileSync('./runNum'));
151+
const runId = Number(fs.readFileSync('./runId'));
152+
const repoFullName = fs.readFileSync('./repoFullName');
153+
const ownerName = fs.readFileSync('./ownerName');
154+
const githubPagesLink = 'https://' + ownerName.toString().toLowerCase().trim() + '.github.io/' + String(repoFullName).replace(`${ownerName.toString().trim()}/`, '') + '/';
155+
const githubRunLink = 'https://github.com/' + repoFullName + '/actions/runs/' + runId;
156+
github.rest.issues.createComment({
157+
issue_number: issue_number,
158+
owner: context.repo.owner,
159+
repo: context.repo.repo,
160+
body: 'Workflow is cancelled 🚫 \n Test might not start, so please chekout workflow first \n Link to GitHub workflow: <a href="' + githubRunLink + '">Github Workflow Link</a> \n Checkout tests results: <a href="' + githubPagesLink + runNumber + '">Cypress e2e Test Report</a> \n Take care of yourself and have a great day! 🌞 \n❕Note: Report deployment may take up to 5 minutes.'
161+
})
162+
163+
- name: 'Add label to PR -- if success'
164+
if: github.event.workflow_run.conclusion == 'success'
165+
uses: actions/github-script@v6
166+
with:
167+
github-token: ${{ secrets.GITHUB_TOKEN }}
168+
script: |
169+
const fs = require('fs');
170+
const issue_number = Number(fs.readFileSync('./prNum'));
171+
github.rest.issues.addLabels({
172+
issue_number: issue_number,
173+
owner: context.repo.owner,
174+
repo: context.repo.repo,
175+
labels: ['e2e-success']
176+
})
177+
178+
- name: 'Add label to PR -- if failed'
179+
if: github.event.workflow_run.conclusion == 'failure'
180+
uses: actions/github-script@v6
181+
with:
182+
github-token: ${{ secrets.GITHUB_TOKEN }}
183+
script: |
184+
const fs = require('fs');
185+
const issue_number = Number(fs.readFileSync('./prNum'));
186+
github.rest.issues.addLabels({
187+
issue_number: issue_number,
188+
owner: context.repo.owner,
189+
repo: context.repo.repo,
190+
labels: ['e2e-failure']
191+
})
192+
193+
- name: 'Add label to PR -- if cancelled'
194+
if: github.event.workflow_run.conclusion == 'cancelled'
195+
uses: actions/github-script@v6
196+
with:
197+
github-token: ${{ secrets.GITHUB_TOKEN }}
198+
script: |
199+
const fs = require('fs');
200+
const issue_number = Number(fs.readFileSync('./prNum'));
201+
github.rest.issues.addLabels({
202+
issue_number: issue_number,
203+
owner: context.repo.owner,
204+
repo: context.repo.repo,
205+
labels: ['e2e-cancelled']
206+
})

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,3 +120,5 @@ buildServer
120120
**/cypress/videos/**
121121
**/cypress/downloads/**
122122
**/cypress/screenshots/**
123+
**/cypress/results/**
124+
**/cypress/report/**
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"allure": true,
3+
"allureResultsPath": "../../cypress/results/allure-results"
4+
}

advanced-api/automatic-vendor-sharing/e2e/checkAutomaticVendorApps.cy.ts

Lines changed: 33 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -42,40 +42,42 @@ appsData.forEach(
4242
const appName = property.host === 3002 ? appsData[1].appNameText : appsData[0].appNameText;
4343
const color = property.host === 3002 ? appsData[1].buttonColor : appsData[0].buttonColor;
4444

45-
describe(`Check ${appName}`, () => {
46-
beforeEach(() => {
47-
basePage.openLocalhost(host)
48-
})
49-
50-
it(`Check ${appName} built and running`, () => {
51-
basePage.checkElementWithTextPresence({
52-
selector: property.headerSelector,
53-
text: property.headerText
45+
describe(`Automatic Vendor Sharing`, () => {
46+
context(`Check ${appName}`, () => {
47+
beforeEach(() => {
48+
basePage.openLocalhost(host)
5449
})
55-
basePage.checkElementWithTextPresence({
56-
selector: property.subHeaderSelector,
57-
text: `${appName}`
50+
51+
it(`Check ${appName} header and subheader exist on the page`, () => {
52+
basePage.checkElementWithTextPresence({
53+
selector: property.headerSelector,
54+
text: property.headerText
55+
})
56+
basePage.checkElementWithTextPresence({
57+
selector: property.subHeaderSelector,
58+
text: `${appName}`
59+
})
5860
})
59-
})
60-
61-
it(`Check buttons in ${appName} exist`, () => {
62-
basePage.checkElementWithTextPresence({
63-
selector: property.buttonSelector,
64-
text: `${appName} ${Constants.commonConstantsData.button}`
65-
})
66-
})
67-
68-
it(`Check button property in ${appName}`, () => {
69-
basePage.checkElementContainText({
70-
selector: property.buttonSelector,
71-
text: `${appName} ${Constants.commonConstantsData.button}`,
72-
index: appButtonPosition
61+
62+
it(`Check buttons in ${appName} exist`, () => {
63+
basePage.checkElementWithTextPresence({
64+
selector: property.buttonSelector,
65+
text: `${appName} ${Constants.commonConstantsData.button}`
66+
})
7367
})
74-
basePage.checkElementHaveProperty({
75-
selector: property.buttonSelector,
76-
text: `${appName} ${Constants.commonConstantsData.button}`,
77-
prop: CssAttr.background,
78-
value: color
68+
69+
it(`Check button property in ${appName}`, () => {
70+
basePage.checkElementContainText({
71+
selector: property.buttonSelector,
72+
text: `${appName} ${Constants.commonConstantsData.button}`,
73+
index: appButtonPosition
74+
})
75+
basePage.checkElementHaveProperty({
76+
selector: property.buttonSelector,
77+
text: `${appName} ${Constants.commonConstantsData.button}`,
78+
prop: CssAttr.background,
79+
value: color
80+
})
7981
})
8082
})
8183
})
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"allure": true,
3+
"allureResultsPath": "../../cypress/results/allure-results"
4+
}

0 commit comments

Comments
 (0)