From dd6ebf664ff90627c7aa8924a9f7ba3a273cf29d Mon Sep 17 00:00:00 2001 From: aldbr Date: Thu, 28 Mar 2024 17:40:53 +0100 Subject: [PATCH] feat: add cypress in the CI --- .github/workflows/integration-test.yml | 87 ++++++++++++++------------ cypress.config.ts | 1 + cypress/fixtures/example.json | 5 -- cypress/support/commands.ts | 37 ----------- cypress/support/e2e.ts | 20 ------ cypress/tsconfig.json | 8 --- tsconfig.json | 2 +- 7 files changed, 48 insertions(+), 112 deletions(-) delete mode 100644 cypress/fixtures/example.json delete mode 100644 cypress/support/commands.ts delete mode 100644 cypress/support/e2e.ts delete mode 100644 cypress/tsconfig.json diff --git a/.github/workflows/integration-test.yml b/.github/workflows/integration-test.yml index 16a671a2..55418ea3 100644 --- a/.github/workflows/integration-test.yml +++ b/.github/workflows/integration-test.yml @@ -2,49 +2,54 @@ name: Integration Tests on: push: - branches: [main_FEAT_integrationtests] + branches: [main] pull_request: - branches: [main_FEAT_integrationtests] + branches: [main] defaults: - run: - shell: bash -el {0} + run: + shell: bash -el {0} jobs: - run-demo: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - name: Clone source - run: | - cd .. - git clone -b main_FEAT_update-node-image --single-branch https://github.com/aldbr/diracx-charts.git - - name: Start demo - run: | - cd .. - diracx-charts/run_demo.sh --exit-when-done diracx-web/ - - name: Debugging information - run: | - cd ../diracx-charts - export KUBECONFIG=$PWD/.demo/kube.conf - .demo/kubectl get pods - for pod_name in $(.demo/kubectl get pods -o json | jq -r '.items[] | .metadata.name' | grep -vE '(dex|minio|mysql|rabbitmq|opensearch)'); do - echo "${pod_name}" - .demo/kubectl describe pod/"${pod_name}" || true - for container_name in $(.demo/kubectl get pods $pod_name -o jsonpath='{.spec.initContainers[*].name} {.spec.containers[*].name}'); do - echo $pod_name $container_name - .demo/kubectl logs "${pod_name}" -c "${container_name}" || true - done - done - - name: Check for success - run: | - cd ../diracx-charts - if [ ! -f ".demo/.success" ]; then - echo "Demo failed" - cat ".demo/.failed" - exit 1 - fi - - - name: Start integration tests - run: | - ls -la \ No newline at end of file + run-demo: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Clone source + run: | + cd .. + git clone https://github.com/DIRACGrid/diracx-charts.git + - name: Start demo + run: | + cd .. + diracx-charts/run_demo.sh --exit-when-done diracx-web/ + - name: Debugging information + run: | + cd ../diracx-charts + export KUBECONFIG=$PWD/.demo/kube.conf + .demo/kubectl get pods + for pod_name in $(.demo/kubectl get pods -o json | jq -r '.items[] | .metadata.name' | grep -vE '(dex|minio|mysql|rabbitmq|opensearch)'); do + echo "${pod_name}" + .demo/kubectl describe pod/"${pod_name}" || true + for container_name in $(.demo/kubectl get pods $pod_name -o jsonpath='{.spec.initContainers[*].name} {.spec.containers[*].name}'); do + echo $pod_name $container_name + .demo/kubectl logs "${pod_name}" -c "${container_name}" || true + done + done + - name: Check for success + run: | + cd ../diracx-charts + if [ ! -f ".demo/.success" ]; then + echo "Demo failed" + cat ".demo/.failed" + exit 1 + fi + + - name: Set BASE_URL + run: echo "BASE_URL=$(hostname)" >> $GITHUB_ENV + + - name: Start Cypress + uses: cypress-io/github-action@v6 + with: + browser: chrome + env: BASE_URL=${{ env.BASE_URL }} diff --git a/cypress.config.ts b/cypress.config.ts index 996da2ff..1f7c7b0d 100644 --- a/cypress.config.ts +++ b/cypress.config.ts @@ -3,6 +3,7 @@ import { defineConfig } from "cypress"; export default defineConfig({ e2e: { specPattern: "test/e2e/**/*.cy.ts", + supportFile: false, setupNodeEvents(on, config) { // implement node event listeners here }, diff --git a/cypress/fixtures/example.json b/cypress/fixtures/example.json deleted file mode 100644 index 02e42543..00000000 --- a/cypress/fixtures/example.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "name": "Using fixtures to represent data", - "email": "hello@cypress.io", - "body": "Fixtures are a great way to mock data for responses to routes" -} diff --git a/cypress/support/commands.ts b/cypress/support/commands.ts deleted file mode 100644 index 95857aea..00000000 --- a/cypress/support/commands.ts +++ /dev/null @@ -1,37 +0,0 @@ -/// -// *********************************************** -// This example commands.ts shows you how to -// create various custom commands and overwrite -// existing commands. -// -// For more comprehensive examples of custom -// commands please read more here: -// https://on.cypress.io/custom-commands -// *********************************************** -// -// -// -- This is a parent command -- -// Cypress.Commands.add('login', (email, password) => { ... }) -// -// -// -- This is a child command -- -// Cypress.Commands.add('drag', { prevSubject: 'element'}, (subject, options) => { ... }) -// -// -// -- This is a dual command -- -// Cypress.Commands.add('dismiss', { prevSubject: 'optional'}, (subject, options) => { ... }) -// -// -// -- This will overwrite an existing command -- -// Cypress.Commands.overwrite('visit', (originalFn, url, options) => { ... }) -// -// declare global { -// namespace Cypress { -// interface Chainable { -// login(email: string, password: string): Chainable -// drag(subject: string, options?: Partial): Chainable -// dismiss(subject: string, options?: Partial): Chainable -// visit(originalFn: CommandOriginalFn, url: string, options: Partial): Chainable -// } -// } -// } diff --git a/cypress/support/e2e.ts b/cypress/support/e2e.ts deleted file mode 100644 index 6a173d6f..00000000 --- a/cypress/support/e2e.ts +++ /dev/null @@ -1,20 +0,0 @@ -// *********************************************************** -// This example support/e2e.ts is processed and -// loaded automatically before your test files. -// -// This is a great place to put global configuration and -// behavior that modifies Cypress. -// -// You can change the location of this file or turn off -// automatically serving support files with the -// 'supportFile' configuration option. -// -// You can read more here: -// https://on.cypress.io/configuration -// *********************************************************** - -// Import commands.js using ES2015 syntax: -import "./commands"; - -// Alternatively you can use CommonJS syntax: -// require('./commands') diff --git a/cypress/tsconfig.json b/cypress/tsconfig.json deleted file mode 100644 index 18edb199..00000000 --- a/cypress/tsconfig.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "compilerOptions": { - "target": "es5", - "lib": ["es5", "dom"], - "types": ["cypress", "node"] - }, - "include": ["**/*.ts"] -} diff --git a/tsconfig.json b/tsconfig.json index 627a4458..be05ba1f 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -24,5 +24,5 @@ } }, "include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", ".next/types/**/*.ts"], - "exclude": ["node_modules", "cyrpress", "test/*/*.ts", "test/*/*.tsx", "jest.setup.ts"] + "exclude": ["node_modules", "test/*/*.ts", "test/*/*.tsx", "jest.setup.ts"] }