Skip to content

Commit

Permalink
fix: 👷 Github actions shared
Browse files Browse the repository at this point in the history
Intégrate Typescript tests, publish Junit report on action summary
  • Loading branch information
BRUVRY-LAGADEC committed Nov 28, 2024
1 parent 63ef604 commit e728385
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 34 deletions.
Original file line number Diff line number Diff line change
@@ -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:
Expand All @@ -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
Expand Down
6 changes: 5 additions & 1 deletion .github/workflows/workflow-ts.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit e728385

Please sign in to comment.