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

Cypress Cloud integration #935

Merged
merged 29 commits into from
Jun 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
52a982b
New Cypress version + some improvements
garcanam Apr 5, 2023
c388589
Jenkins file changes: add videos + combine reports
garcanam Apr 14, 2023
1f3aa4f
Remove Dashboard + update readme
garcanam Apr 24, 2023
18226a3
Remove unneeded config
garcanam Apr 24, 2023
513fab0
Update e2e-cypress/files/cypress.config.ts
garcanam May 5, 2023
c0a639b
Update cypress.config.ts
garcanam May 5, 2023
0ebe54d
Update Jenkinsfile.template
garcanam May 5, 2023
a80810f
Update e2e.ts
garcanam May 5, 2023
9fe1d59
Update installation.spec.cy.ts
garcanam May 5, 2023
a26ac6d
improvements
roicarrera May 5, 2023
00ea41d
Update e2e-cypress/files/support/e2e.ts
roicarrera May 8, 2023
f1ca562
added changelog.md
roicarrera May 8, 2023
be997d3
Merge branch 'master' of https://github.com/garcanam/ods-quickstarters
roicarrera May 8, 2023
8e13ec9
changed junit reporter
roicarrera May 9, 2023
1863429
moved changelog
roicarrera May 10, 2023
470568b
added changes to changelog
roicarrera May 10, 2023
e7a51e4
fixed typos
roicarrera May 10, 2023
828ea1f
Merge branch 'master' into master
garcanam May 11, 2023
5e0af67
add changes for recording runs with cypress cloud
roicarrera May 15, 2023
ec393d0
changed image to node18
roicarrera Jun 28, 2023
6139c34
updated changelog
roicarrera Jun 28, 2023
1207200
Merge pull request #1 from garcanam/feature/record_runs
roicarrera Jun 29, 2023
3729751
merged changes from upstream parent
roicarrera Jun 29, 2023
7d0e4eb
Update CHANGELOG.md
BraisVQ Jun 29, 2023
c050424
Update provisioning Jenkinsfile to node18
BraisVQ Jun 29, 2023
ff358f1
Update README.md
BraisVQ Jun 29, 2023
72ece53
Set cpu request to 100m instead of 10m
BraisVQ Jun 29, 2023
666e365
updated changelog and readme
roicarrera Jun 29, 2023
642de4b
added documentation on ods page and changed readme
roicarrera Jun 29, 2023
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
- Fix oauth-proxy sidecar image ([#862](https://github.com/opendevstack/ods-quickstarters/issues/862))
- Upgrade be-gateway-nginx from fedora-rpm to rocky and from version 1.19 to 1.21 ([#880](https://github.com/opendevstack/ods-quickstarters/issues/880))
- Upgraded to Cypress 12, improve login support, add video support ([#899](https://github.com/opendevstack/ods-quickstarters/issues/899))
- Added Cypress Cloud integration to cypress QS and changed agent node version to node 18 ([#935](https://github.com/opendevstack/ods-quickstarters/pull/935))
- Fix inf-terraform-agent bundler complaining about /tmp permissions ([#903](https://github.com/opendevstack/ods-quickstarters/pull/903))
- Fix nodejs 18 build by removing option always-auth ([#905](https://github.com/opendevstack/ods-quickstarters/issues/905))
- Removed protractor-related configuration from `ini.sh` in Ionic quickstarter ([#885](https://github.com/opendevstack/ods-quickstarters/issues/885))
Expand Down
35 changes: 32 additions & 3 deletions docs/modules/quickstarters/pages/e2e-cypress.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,9 @@ A more advanced solution could be the use of a custom builder agent, where Cypre
[source,docker]
----
# The following FROM tag is informational. It is overwritten by OpenShift.
FROM ods/jenkins-agent-nodejs16:4.x
FROM ods/jenkins-agent-nodejs18:4.x

ARG cypressVersion=9.5.3
ARG cypressVersion=12.9.0
ARG cypressHash=...

USER root
Expand All @@ -94,10 +94,39 @@ RUN chgrp -R 0 $HOME && \
USER 1001
----

== Cypress Cloud

To use Cypress Cloud within the Cypress QuickSarter, follow these steps:

1. **Create a project in Cypress Cloud.** Access Cypress Cloud by following this link (https://cloud.cypress.io/), and create a project. This project will be used to store your Cypress tests and results.

2. **Change the project ID as indicated in Cypress Cloud.** After creating the project, you will need to change the project ID in the four config files, to the one indicated in Cypress Cloud. This ID is used to identify your project and ensure that your tests are associated with the correct project.

3. **Set the Cypress Record Key as an environment variable in Openshift.** To enable recording of your tests in Cypress Cloud, you will need to set the Cypress Record Key as an environment variable named CYPRESS_RECORD_KEY in Openshift. This key is provided by Cypress and is used to authenticate your tests and results. By setting it in Openshift, we ensure that the record functionality will only be used in official runs and not for local development.

4. **Modify the Jenkinsfile for using the record script.** In the Jenkinsfile, change the exeuction line:
[source,Jenkinsfile]
----
def status = sh(script: 'npm run e2e', returnStatus: true)
----
for the following block of code, which will run the record script only when in master or in a release branch:
[source,Jenkinsfile]
----
if (context.gitBranch == 'master' || context.gitBranch.startsWith('release/')) {
def status = sh(script: 'npm run e2e:jenkins:record', returnStatus: true)
} else {
def status = sh(script: 'npm run e2e', returnStatus: true)
}
----

**Only use this functionality in releases, not development.** It is important to note that Cypress Cloud is intended for use in releases, not development. This ensures that your tests are run against stable and reliable code, and that the Dashboard does not get overflooded with non-relevant tests. For the same reason, the Jenkinsfile is configured to only pass the record parameter when running in the master branch, or in a release.

You can find more information about using the Cypress Cloud in the official documentation for Cypress https://docs.cypress.io/guides/cloud/introduction.

== Builder agent used

This quickstarter uses
https://github.com/opendevstack/ods-quickstarters/tree/master/common/jenkins-agents/nodejs16[Node.js 16 builder agent] for Jenkins.
https://github.com/opendevstack/ods-quickstarters/tree/master/common/jenkins-agents/nodejs18[Node.js 18 builder agent] for Jenkins.

== Known limitations

Expand Down
2 changes: 1 addition & 1 deletion e2e-cypress/Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ node {
library("ods-jenkins-shared-library@${sharedLibraryRef}")

odsQuickstarterPipeline(
imageStreamTag: "${odsNamespace}/jenkins-agent-nodejs16:${agentImageTag}",
imageStreamTag: "${odsNamespace}/jenkins-agent-nodejs18:${agentImageTag}",
) { context ->

odsQuickstarterStageCopyFiles(context)
Expand Down
8 changes: 6 additions & 2 deletions e2e-cypress/Jenkinsfile.template
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,19 @@

node {
dockerRegistry = env.DOCKER_REGISTRY
cypressRecordKey = env.CYPRESS_RECORD_KEY
}

odsComponentPipeline(
podContainers: [
containerTemplate(
name: 'jnlp',
image: "${dockerRegistry}/ods/jenkins-agent-nodejs16:@shared_library_ref@",
image: "${dockerRegistry}/ods/jenkins-agent-nodejs18:@shared_library_ref@",
BraisVQ marked this conversation as resolved.
Show resolved Hide resolved
workingDir: '/tmp',
resourceRequestCpu: '10m',
envVars: [
envVar(key: 'CYPRESS_RECORD_KEY', value: cypressRecordKey)
],
resourceRequestCpu: '100m',
resourceLimitCpu: '300m',
resourceRequestMemory: '1Gi',
resourceLimitMemory: '2Gi',
Expand Down
8 changes: 8 additions & 0 deletions e2e-cypress/files/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,14 @@ In order to generate one xml report per test type (installation, integration and
With Cypress 12 version is now available `cy.origin()` that allows you to handle redirections. This funcionality eases the login handling.
See `./support/e2e.ts` for a generic login example.

## Cypress Cloud
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would move the whole section into the documentation of cypress (https://github.com/opendevstack/ods-quickstarters/blob/master/docs/modules/quickstarters/pages/e2e-cypress.adoc). The focus of the README.md should be more on getting started. Maybe only leave a short note about general support for Cypress Cloud with a link to the documentation.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done ;)


Cypress Cloud has been enabled as a functionality and can be used by the quickstarter users. Some configuration needs to be done in the quickstarter for the dashboard to start recording executions.

The steps for configuring this functionality are defined in (https://www.opendevstack.org/ods-documentation/opendevstack/latest/quickstarters/e2e-cypress.html).

For more information on this, please contact the support team.

#### *Obsolete*

This quickstarter provides a login command for Azure SSO with MSALv2 (`./support/msalv2-login.ts`) as well as sample code for a generic login (`./support/generic-login.ts`).
Expand Down
1 change: 1 addition & 0 deletions e2e-cypress/files/cypress-acceptance.config.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { defineConfig } from 'cypress'
import setupNodeEvents from './plugins/index.js'
export default defineConfig({
//projectId: '[Your project ID from Cypress cloud]',
reporter: 'junit',
reporterOptions: {
mochaFile: 'build/test-results/acceptance-junit-[hash].xml',
Expand Down
2 changes: 1 addition & 1 deletion e2e-cypress/files/cypress-installation.config.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { defineConfig } from 'cypress'
import setupNodeEvents from './plugins/index.js'
export default defineConfig({
//projectId: '[Define your project id for Cypress cloud]',
//projectId: '[Your project ID from Cypress cloud]',
reporter: 'junit',
reporterOptions: {
mochaFile: 'build/test-results/installation-junit-[hash].xml',
Expand Down
2 changes: 1 addition & 1 deletion e2e-cypress/files/cypress-integration.config.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { defineConfig } from 'cypress'
import setupNodeEvents from './plugins/index.js'
export default defineConfig({
//projectId: '[Define your project id for Cypress cloud]',
//projectId: '[Your project ID from Cypress cloud]',
reporter: 'junit',
reporterOptions: {
mochaFile: 'build/test-results/integration-junit-[hash].xml',
Expand Down
3 changes: 2 additions & 1 deletion e2e-cypress/files/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@
"junit-acceptance-report": "jrm build/test-results/acceptance-junit.xml 'build/test-results/acceptance-*.xml'",
"delete-junit-results": "rimraf build/test-results",
"e2e": "npm-run-all delete-junit-results cypress:run-installation cypress:run-integration cypress:run-acceptance",
"combine:reports": "npm-run-all junit-installation-report junit-integration-report junit-acceptance-report"
"combine:reports": "npm-run-all junit-installation-report junit-integration-report junit-acceptance-report",
"e2e:jenkins:record": "npm run delete-junit-results && npm run cypress:run-installation --record && npm run cypress:run-integration --record && npm run cypress:run-acceptance --record"
},
"private": true,
"devDependencies": {
Expand Down