Skip to content

Commit

Permalink
Add matrix to test every supported rancher version
Browse files Browse the repository at this point in the history
Signed-off-by: Julien ADAMEK <julien.adamek@suse.com>
  • Loading branch information
juadk committed Feb 12, 2025
1 parent a4fecc9 commit 8f81d93
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 9 deletions.
19 changes: 16 additions & 3 deletions .github/workflows/unit-tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,15 @@ on:

jobs:
unit-tests:
strategy:
fail-fast: false
max-parallel: 3
matrix:
rancher_version:
- head
- v2.9-head
- v2.10-head

runs-on: ubuntu-latest
steps:
- name: Checkout
Expand All @@ -19,20 +28,24 @@ jobs:
node-version: ${{ env.NODE_VERSION }}
registry-url: 'https://registry.npmjs.org'

- name: Deploy rancher head
- name: Deploy rancher
run: npm run start-rancher
env:
RANCHER_VERSION: ${{ matrix.rancher_version }}

- name: Build package from the current branch
run: npm run build-npm

- name: Run e2e tests
run: npm run start-unit-tests
env:
RANCHER_VERSION: ${{ matrix.rancher_version }}

- name: Upload Cypress screenshots
if: failure()
uses: actions/upload-artifact@v4
with:
name: cypress-screenshots-basics-unit-tests
name: cypress-screenshots-${{ matrix.rancher_version }}
path: cypress/screenshots
retention-days: 7
if-no-files-found: ignore
Expand All @@ -42,6 +55,6 @@ jobs:
if: always()
uses: actions/upload-artifact@v4
with:
name: cypress-videos-basics-unit-tests
name: cypress-videos-${{ matrix.rancher_version }}
path: cypress/videos
retention-days: 7
1 change: 1 addition & 0 deletions cypress.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ const username = (process.env.TEST_USERNAME || 'admin');

export default defineConfig({
defaultCommandTimeout: 10000,
video: true,
e2e: {
// We've imported your old cypress plugins here.
// You may want to clean this up later by importing these.
Expand Down
2 changes: 1 addition & 1 deletion cypress/e2e/unit-tests.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ describe('Cypress Library e2e tests', () => {
it('Check clusterStatus function', () => {
cy.login();
cypressLib.burgerMenuToggle();
cypressLib.checkClusterStatus('local', 'Active');
cypressLib.checkClusterStatus('local', 'Active', Cypress.env('RANCHER_VERSION'), 10000);
});

it('Check checkNavIcon function', () => {
Expand Down
2 changes: 1 addition & 1 deletion index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ export function burgerMenuToggle() {
export function checkClusterStatus(clusterName, clusterStatus, rancherVersion, timeout = 10000) {
cy.contains('Home')
.click();
(rancherVersion != '2.9') ?
(rancherVersion != 'v2.9-head') ?
cy.contains(clusterStatus+clusterName, {timeout: timeout}) :
cy.contains(clusterStatus+' '+clusterName, {timeout: timeout});
};
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
"lint": "eslint --ext .js,.ts .",
"test": "echo \"Error: no test specified\" && exit 1",
"build-npm": "./scripts/build-npm",
"start-rancher": "./scripts/start-rancher",
"start-unit-tests": "./scripts/start-unit-tests"
"start-rancher": "./scripts/start-rancher ${RANCHER_VERSION}",
"start-unit-tests": "./scripts/start-unit-tests ${RANCHER_VERSION}"
},
"repository": {
"type": "git",
Expand Down
2 changes: 1 addition & 1 deletion scripts/start-rancher
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ docker run -d --restart=unless-stopped -p 80:80 -p 443:443 \
-e CATTLE_PASSWORD_MIN_LENGTH=3 \
--name cypress \
--privileged \
rancher/rancher:head
rancher/rancher:$1

docker ps

Expand Down
2 changes: 1 addition & 1 deletion scripts/start-unit-tests
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@

#!/usr/bin/env bash

./node_modules/cypress/bin/cypress run
./node_modules/cypress/bin/cypress run --env RANCHER_VERSION=$1

0 comments on commit 8f81d93

Please sign in to comment.