-
Notifications
You must be signed in to change notification settings - Fork 302
Build and publish Cypress suite #16140
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
Merged
torchiaf
merged 16 commits into
rancher:master
from
torchiaf:feature/build-cypress-suite
Dec 18, 2025
Merged
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
c99616d
rancher/cypress - init package
torchiaf bcdf5b0
rancher/cypress create base-config
torchiaf 78aa148
rancher/cypress add bin
torchiaf e590b3f
rancher/cypress build ts
torchiaf faac69e
rancher/cypress fix typescript errors which block tsc build
torchiaf 9bd5adb
rancher/cypress add CLI, init command, fix README and code documentation
torchiaf db9f68b
rancher/cypress add release workflow; add publish and move build script
torchiaf 4726358
rancher/cypress fix peerDependencies
torchiaf a90cae5
rancher/cypress nit
torchiaf 2b514e3
rancher/cypress fix template files to ready-to-use example
torchiaf c2bdccf
rancher/cypress fix README
torchiaf 6bc7785
rancher/cypress Bump sha.js; bump @cypress/rancher to v1.0.2
torchiaf c11800e
rancher/cypress add new templates; bump v1.0.3
torchiaf 55f3c22
rancher/cypress check cypress build errors
torchiaf 2c6f7ed
rancher/cypress update Rancher Cypress release to use trusted providers
torchiaf 9cb1ddb
rancher/cypress filter out README when running init command
torchiaf File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,59 @@ | ||
| name: Publish Cypress Suite Package | ||
|
|
||
| on: | ||
| push: | ||
| tags: | ||
| - 'cypress-pkg-v*' | ||
| workflow_call: | ||
| inputs: | ||
| tag: | ||
| required: false | ||
| type: string | ||
| outputs: | ||
| build-release-cypress-suite-status: | ||
| value: ${{ jobs.build.outputs.build-status }} | ||
|
|
||
| defaults: | ||
| run: | ||
| shell: bash | ||
| working-directory: ./cypress | ||
|
|
||
| permissions: | ||
| id-token: write | ||
| contents: read | ||
|
|
||
| jobs: | ||
| build: | ||
| runs-on: ubuntu-latest | ||
| if: github.repository == 'rancher/dashboard' && (github.event_name == 'workflow_call' || (github.event_name == 'push' && github.event.ref == 'refs/tags/${{ github.ref_name }}')) | ||
| outputs: | ||
| build-status: ${{ job.status }} | ||
| steps: | ||
| - name: Checkout | ||
| uses: actions/checkout@v6 | ||
| with: | ||
| fetch-depth: 0 | ||
| persist-credentials: false | ||
|
|
||
| - name: Setup Node.js | ||
| uses: actions/setup-node@v6 | ||
| with: | ||
| node-version-file: '.nvmrc' | ||
| cache: 'yarn' | ||
|
|
||
| - uses: actions/setup-node@v6 | ||
| with: | ||
| node-version-file: '.nvmrc' | ||
| registry-url: 'https://registry.npmjs.org' | ||
| scope: '@rancher' | ||
|
|
||
| - name: Install packages | ||
| run: yarn install --frozen-lockfile | ||
|
|
||
| - name: Build Cypress Package | ||
| run: yarn build-pkg | ||
|
|
||
| - name: Publish Cypress Package to npm | ||
| run: yarn publish-pkg | ||
| env: | ||
| TAG: ${{ inputs.tag || github.ref_name }} | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -324,3 +324,18 @@ jobs: | |
| - name: Check e2e tags | ||
| run: | | ||
| ./scripts/check-e2e-tests-for-tags | ||
|
|
||
| check-cypress-build: | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This will block the CI gates if there is a Typescript error in |
||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: actions/checkout@v6 | ||
| with: | ||
| fetch-depth: 1 | ||
| - uses: actions/setup-node@v6 | ||
| with: | ||
| node-version-file: '.nvmrc' | ||
| - name: Verify Cypress build | ||
| working-directory: ./cypress | ||
| run: | | ||
| yarn install --frozen-lockfile | ||
| yarn build-pkg --verify | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,144 +1,4 @@ | ||
| /* eslint-disable no-console */ | ||
| import { defineConfig } from 'cypress'; | ||
| import { removeDirectory } from 'cypress-delete-downloads-folder'; | ||
| import { getSpecPattern } from '@/scripts/cypress'; | ||
| import websocketTasks from './cypress/support/utils/webSocket-utils'; | ||
| import path from 'path'; | ||
| // Import and use the base configuration from cypress package | ||
| import baseConfig from './cypress/base-config'; | ||
|
|
||
| // Required for env vars to be available in cypress | ||
| require('dotenv').config(); | ||
|
|
||
| /** | ||
| * VARIABLES | ||
| */ | ||
| const hasCoverage = (process.env.TEST_INSTRUMENT === 'true') || false; // Add coverage if instrumented | ||
| let testDirs = ['priority', 'components', 'setup', 'pages', 'navigation', 'global-ui', 'features', 'extensions']; | ||
| const skipSetup = process.env.TEST_SKIP?.includes('setup'); | ||
| const baseUrl = (process.env.TEST_BASE_URL || 'https://localhost:8005').replace(/\/$/, ''); | ||
| const DEFAULT_USERNAME = 'admin'; | ||
| const username = process.env.TEST_USERNAME || DEFAULT_USERNAME; | ||
| const apiUrl = process.env.API || (baseUrl.endsWith('/dashboard') ? baseUrl.split('/').slice(0, -1).join('/') : baseUrl); | ||
|
|
||
| if (process.env.TEST_A11Y) { | ||
| testDirs = ['accessibility']; | ||
| } | ||
|
|
||
| /** | ||
| * LOGS: | ||
| * Summary of the environment variables that we have detected (or are going ot use) | ||
| * We won't show any passwords | ||
| */ | ||
| console.log('E2E Test Configuration'); | ||
| console.log(''); | ||
| console.log(` Username: ${ username }`); | ||
|
|
||
| if (!process.env.CATTLE_BOOTSTRAP_PASSWORD && !process.env.TEST_PASSWORD) { | ||
| console.log(' ❌ You must provide either CATTLE_BOOTSTRAP_PASSWORD or TEST_PASSWORD'); | ||
| } | ||
| if (process.env.CATTLE_BOOTSTRAP_PASSWORD && process.env.TEST_PASSWORD) { | ||
| console.log(' ❗ If both CATTLE_BOOTSTRAP_PASSWORD and TEST_PASSWORD are provided, the first will be used'); | ||
| } | ||
| if (!skipSetup && !process.env.CATTLE_BOOTSTRAP_PASSWORD) { | ||
| console.log(' ❌ You must provide CATTLE_BOOTSTRAP_PASSWORD when running setup tests'); | ||
| } | ||
| if (skipSetup && !process.env.TEST_PASSWORD) { | ||
| console.log(' ❌ You must provide TEST_PASSWORD when running the tests without the setup tests'); | ||
| } | ||
|
|
||
| console.log(` Setup tests will ${ skipSetup ? 'NOT' : '' } be run`); | ||
| console.log(` Dashboard URL: ${ baseUrl }`); | ||
| console.log(` Rancher API URL: ${ apiUrl }`); | ||
|
|
||
| // Check API - sometimes in dev, you might have API set to a different system to the base url - this won't work | ||
| // as the login cookie will be for the base url and any API requests will fail as not authenticated | ||
| if (apiUrl && !baseUrl.startsWith(apiUrl)) { | ||
| console.log('\n ❗ API variable is different to TEST_BASE_URL - tests may fail due to authentication issues'); | ||
| } | ||
|
|
||
| console.log(''); | ||
|
|
||
| /** | ||
| * CONFIGURATION | ||
| */ | ||
| export default defineConfig({ | ||
| projectId: process.env.TEST_PROJECT_ID, | ||
| defaultCommandTimeout: process.env.TEST_TIMEOUT ? +process.env.TEST_TIMEOUT : 10000, | ||
| trashAssetsBeforeRuns: true, | ||
| chromeWebSecurity: false, | ||
| retries: { | ||
| runMode: 2, | ||
| openMode: 0 | ||
| }, | ||
| env: { | ||
| grepFilterSpecs: true, | ||
| grepOmitFiltered: true, | ||
| baseUrl, | ||
| coverage: hasCoverage, | ||
| codeCoverage: { | ||
| exclude: [ | ||
| 'cypress/**/*.*', | ||
| '**/__tests__/**/*.*', | ||
| '**/__mocks__/**/*.*', | ||
| '**/shell/scripts/**/*.*', | ||
| 'docusaurus/**/*.*', | ||
| 'stories/**/*.*', | ||
| 'drone/**/*.*', | ||
| ], | ||
| include: [ | ||
| 'shell/**/*.{vue,ts,js}', | ||
| 'pkg/rancher-components/src/components/**/*.{vue,ts,js}', | ||
| ] | ||
| }, | ||
| api: apiUrl, | ||
| username, | ||
| password: process.env.CATTLE_BOOTSTRAP_PASSWORD || process.env.TEST_PASSWORD, | ||
| bootstrapPassword: process.env.CATTLE_BOOTSTRAP_PASSWORD, | ||
| grepTags: process.env.GREP_TAGS, | ||
| VAI_ENABLED: process.env.VAI_ENABLED, | ||
| // the below env vars are only available to tests that run in Jenkins | ||
| awsAccessKey: process.env.AWS_ACCESS_KEY_ID, | ||
| awsSecretKey: process.env.AWS_SECRET_ACCESS_KEY, | ||
| azureSubscriptionId: process.env.AZURE_AKS_SUBSCRIPTION_ID, | ||
| azureClientId: process.env.AZURE_CLIENT_ID, | ||
| azureClientSecret: process.env.AZURE_CLIENT_SECRET, | ||
| customNodeIp: process.env.CUSTOM_NODE_IP, | ||
| customNodeKey: process.env.CUSTOM_NODE_KEY, | ||
| accessibility: !!process.env.TEST_A11Y, // Are we running accessibility tests? | ||
| a11yFolder: path.join('.', 'cypress', 'accessibility'), | ||
| gkeServiceAccount: process.env.GKE_SERVICE_ACCOUNT, | ||
| }, | ||
| e2e: { | ||
| fixturesFolder: 'cypress/e2e/blueprints', | ||
| setupNodeEvents(on, config) { | ||
| // For more info: https://docs.cypress.io/guides/tooling/code-coverage | ||
| require('@cypress/code-coverage/task')(on, config); | ||
| require('@cypress/grep/src/plugin')(config); | ||
| // For more info: https://www.npmjs.com/package/cypress-delete-downloads-folder | ||
|
|
||
| on('task', { removeDirectory }); | ||
| websocketTasks(on, config); | ||
|
|
||
| require('cypress-terminal-report/src/installLogsPrinter')(on, { | ||
| outputRoot: `${ config.projectRoot }/browser-logs/`, | ||
| outputTarget: { 'out.html': 'html' }, | ||
| logToFilesOnAfterRun: true, | ||
| printLogsToConsole: 'never', | ||
| // printLogsToFile: 'always', // default prints on failures | ||
| }); | ||
|
|
||
| // Load Accessibility plugin if configured | ||
| // as per https://github.com/rancher/dashboard/pull/15865 load order matters | ||
| // this need to go after "cypress-terminal-report" always | ||
| if (process.env.TEST_A11Y) { | ||
| require('./cypress/support/plugins/accessibility').default(on, config); | ||
| } | ||
|
|
||
| return config; | ||
| }, | ||
| experimentalSessionAndOrigin: true, | ||
| specPattern: getSpecPattern(testDirs, process.env), | ||
| baseUrl | ||
| }, | ||
| videoCompression: 15, | ||
| videoUploadOnPasses: false, | ||
| }); | ||
| export default baseConfig; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| # Ignore node_modules | ||
| node_modules/ | ||
|
|
||
| # Ignore build artifacts | ||
| *.log | ||
| *.tmp | ||
|
|
||
| # Ignore development files | ||
| .DS_Store | ||
| Thumbs.db | ||
|
|
||
| # Ignore any local config | ||
| .env | ||
| .env.local | ||
|
|
||
| # Ignore coverage reports | ||
| coverage/ | ||
| .nyc_output/ |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you miss
--access publichttps://yarnpkg.com/cli/npm/publish#details
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, the flag is there:
https://github.com/torchiaf/dashboard/blob/9cb1ddb10e4ec608963de5524d589ce978b347df/cypress/scripts/publish.sh#L54