From e7283854860ae48220e2323de10a84107b4e228c Mon Sep 17 00:00:00 2001 From: BRUVRY-LAGADEC Date: Thu, 28 Nov 2024 14:59:02 +0100 Subject: [PATCH] fix: :construction_worker: Github actions shared MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Intégrate Typescript tests, publish Junit report on action summary --- .../{ts-test.yml => component-ts-test.yml} | 49 ++++++------------- .github/workflows/workflow-ts.yml | 6 ++- 2 files changed, 21 insertions(+), 34 deletions(-) rename .github/workflows/{ts-test.yml => component-ts-test.yml} (52%) diff --git a/.github/workflows/ts-test.yml b/.github/workflows/component-ts-test.yml similarity index 52% rename from .github/workflows/ts-test.yml rename to .github/workflows/component-ts-test.yml index 7011a5b..5b856c5 100644 --- a/.github/workflows/ts-test.yml +++ b/.github/workflows/component-ts-test.yml @@ -1,12 +1,12 @@ name: Typescript Test on: - push: - paths: - - typescript-demo/** - pull_request: - paths: - - 'typescript-demo/**' + workflow_call: + inputs: + context: + description: "Path to the module to lint" + default: "" + type: string jobs: test: @@ -16,57 +16,40 @@ jobs: # Checkout the repository - name: Checkout code uses: actions/checkout@v4 - # Set up Node.js environment - name: Set up Node.js uses: actions/setup-node@v3 with: node-version: "22" - - # Install dependencies in the `typescript-demo` folder + # Install dependencies in the context folder - name: Install dependencies run: npm install - working-directory: ./typescript-demo - + working-directory: ./${{ inputs.context }} # Build the application - name: Build the application run: npm run build - working-directory: ./typescript-demo - + working-directory: ./${{ inputs.context }} # Start the application - name: Start the application run: npm start & - working-directory: ./typescript-demo + working-directory: ./${{ inputs.context }} env: NODE_ENV: test - - name: Run Jest tests run: npx jest --ci - working-directory: ./typescript-demo + working-directory: ./${{ inputs.context }} env: - JEST_JUNIT_OUTPUT_DIR: test-results JEST_JUNIT_OUTPUT_NAME: junit.xml - - - name: Upload test results - uses: actions/upload-artifact@v4 - with: - name: jest-test-results - path: ./typescript-demo/test-results/junit.xml - - - name: Display test results in summary - uses: dorny/test-reporter@v1 + - name: Publish Test Report + uses: mikepenz/action-junit-report@v5 + if: success() || failure() # always run even if the previous step fails with: - name: Jest Tests - path: ./typescript-demo/test-results/junit.xml - reporter: jest-junit - fail-on-error: 'true' - use-actions-summary: 'true' - + report_paths: '**/junit.xml' # Run Cypress tests - name: Run Cypress tests uses: cypress-io/github-action@v4 with: - working-directory: ./typescript-demo + working-directory: ./${{ inputs.context }} wait-on: http://localhost:3000 wait-on-timeout: 60 spec: cypress/e2e/**/*.cy.js diff --git a/.github/workflows/workflow-ts.yml b/.github/workflows/workflow-ts.yml index 27616e2..2a29461 100644 --- a/.github/workflows/workflow-ts.yml +++ b/.github/workflows/workflow-ts.yml @@ -22,12 +22,16 @@ jobs: uses: British-Oceanographic-Data-Centre/amrit-repos/.github/workflows/component-ts-lint.yml@feature/shared-ci with: context: typescript-demo + ts-test: + uses: British-Oceanographic-Data-Centre/amrit-repos/.github/workflows/component-ts-test.yml@feature/shared-ci + with: + context: typescript-demo ts-security: uses: British-Oceanographic-Data-Centre/amrit-repos/.github/workflows/component-ts-security.yml@feature/shared-ci with: context: typescript-demo container-image-build: - needs: [ts-linting, ts-security] + needs: [ts-linting, ts-test, ts-security] uses: British-Oceanographic-Data-Centre/amrit-repos/.github/workflows/component-container-image.yml@feature/shared-ci with: context: typescript-demo