From aeeaec50f196cc8c1922cb99258339a60aae3050 Mon Sep 17 00:00:00 2001 From: Martijn Dirkse Date: Mon, 3 Jun 2024 12:22:52 +0200 Subject: [PATCH] The GitHub Actions workflow for one specific config --- .github/workflows/no-console-warnings.js.yml | 43 ++++++++++---------- .github/workflows/waitForUrl.sh | 21 ++++++++++ cypress/cypress.config_cicd.ts | 10 +++++ 3 files changed, 53 insertions(+), 21 deletions(-) create mode 100644 .github/workflows/waitForUrl.sh create mode 100644 cypress/cypress.config_cicd.ts diff --git a/.github/workflows/no-console-warnings.js.yml b/.github/workflows/no-console-warnings.js.yml index a95d2150..b1bd196e 100644 --- a/.github/workflows/no-console-warnings.js.yml +++ b/.github/workflows/no-console-warnings.js.yml @@ -3,11 +3,12 @@ on: push: branches: - master + - testConfigsNoWarnings pull_request: workflow_dispatch: jobs: testing: - name: Cypress tests of ladybug + Frank!Framework + name: Test that Frank config has no warnings runs-on: ubuntu-latest steps: - name: Checkout Frank!Runner @@ -22,31 +23,32 @@ jobs: run: echo "tomcat.connector.port=8090" > frank-runner/build.properties - name: Set debug to true run: echo "debug=true" >> frank-runner/build.properties - - name: Checkout ladybug-ff-cypress-test + - name: Set projects.dir + run: echo "projects.dir=.." >> frank-runner/build.properties + - name: Select the configuration in the manual we want to test + run: echo "project.dir=frank-manual/srcSteps/Frank2Hermes/v560" >> frank-runner/build.properties + - name: Checkout frank-manual uses: actions/checkout@v4 with: - path: ladybug-ff-cypress-test - - name: Copy cypress.config_cicd.ts to cypress.config.ts to listen to correct port + path: frank-manual + - name: Copy cypress/cypress.config_cicd.ts to cypress/cypress.config.ts to listen to correct port run: cp cypress.config_cicd.ts cypress.config.ts - working-directory: ladybug-ff-cypress-test + working-directory: frank-manual/cypress - name: Use Node.js 20.x uses: actions/setup-node@v2 with: node-version: 20.x cache: "yarn" cache-dependency-path: "**/yarn.lock" - - name: Update yarn - run: corepack enable - working-directory: "ladybug-ff-cypress-test" - name: Show node version run: node -v - working-directory: "ladybug-ff-cypress-test" + working-directory: "frank-manual/cypress" - name: Show yarn version run: yarn -v - working-directory: "ladybug-ff-cypress-test" + working-directory: "frank-manual/cypress" - name: Install packages run: yarn install --immutable - working-directory: ladybug-ff-cypress-test + working-directory: frank-manual/cypress - name: Cache Frank!Runner dependencies - build uses: actions/cache@v3 with: @@ -64,8 +66,8 @@ jobs: - name: Show current time, allows you to check that logs are not old run: date - name: Let Frank!Runner do its downloads - run: yarn run installFrankRunnerEnv - working-directory: ladybug-ff-cypress-test + run: run env.sh > installFrankRunnerEnv.log + working-directory: frank-runner - name: Show apache-tomcat directories run: find . -path './build/*' -name 'apache-tomcat*' working-directory: frank-runner @@ -79,14 +81,14 @@ jobs: run: find . -path './build/apache-tomcat*/catalina.out' -delete working-directory: frank-runner - name: Start server using Frank!Runner in background - run: yarn run startServer & - working-directory: ladybug-ff-cypress-test + run: ./restart.sh > serverStartLog.log & + working-directory: frank-runner - name: Wait for server to be available run: ./waitForUrl.sh http://localhost:8090 240 - working-directory: ladybug-ff-cypress-test/.github/workflows + working-directory: frank-manual/.github/workflows - name: Run the tests - run: yarn batch - working-directory: ladybug-ff-cypress-test + run: yarn run cypress run + working-directory: frank-manual/cypress - name: Try to access server directly with curl run: curl -v -i -X DELETE http://localhost:8090/iaf/ladybug/api/report/all/Test if: always() @@ -122,11 +124,10 @@ jobs: if: always() with: name: screenshots - path: ladybug-ff-cypress-test/cypress/screenshots/ + path: frank-manual/cypress/cypress/screenshots/ - name: Store Cypress videos uses: actions/upload-artifact@v2 if: always() - with: name: videos - path: ladybug-ff-cypress-test/cypress/videos/ + path: frank-manual/cypress/cypress/videos/ diff --git a/.github/workflows/waitForUrl.sh b/.github/workflows/waitForUrl.sh new file mode 100644 index 00000000..de00c6f5 --- /dev/null +++ b/.github/workflows/waitForUrl.sh @@ -0,0 +1,21 @@ +#!/bin/bash + +url=$1 +numTries=$2 +triesSoFar=0 +result=1000 +while [[ ${triesSoFar} -le ${numTries} ]]; do + let triesSoFar++ + curl -s ${url} + result=$? + if [[ ${result} -eq 0 ]]; then + break + else + sleep 1 + fi +done +# We want to see the output of this command only once +curl ${url} +result=$? +echo "Curl return code: ${result}" +exit ${result} diff --git a/cypress/cypress.config_cicd.ts b/cypress/cypress.config_cicd.ts new file mode 100644 index 00000000..22fe0a6a --- /dev/null +++ b/cypress/cypress.config_cicd.ts @@ -0,0 +1,10 @@ +module.exports = { + e2e: { + supportFile: 'cypress/support/e2e.ts', + setupNodeEvents(on, config) { + // implement node event listeners here + }, + baseUrl: 'http://localhost:8090', + video: true + }, +};