Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test job and upgrade version job in workflow #24

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
116 changes: 116 additions & 0 deletions .github/workflows/run-test-and-publish.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
name: Run test and publish

on:
pull_request:
types: [closed]
branches:
- develop
- main

permissions:
contents: write
actions: read
checks: write

jobs:
unit_tests:
if: github.event.pull_request.merged == true # Condition
name: Unit Test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-node@v4
with:
node-version: 18
cache: npm

- name: Install dependencies
run: npm ci

- name: Run Unit Tests
run: npm run test

- name: Debug
run: ls -la

- name: Debug report
run: ls -la report

- name: Unit Test Report
uses: dorny/test-reporter@v1
if: success() || failure() # run this step even if previous step failed
with:
name: Unit Tests Reporter # Name of the check run which will be created
path: report/unit.xml # Path to test results
reporter: jest-junit # Format of test results
fail-on-error: 'true' # Set action as failed if test report contains any failed test

e2e_tests:
name: E2e Test For Core package
needs: unit_tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-node@v4
with:
node-version: 18
cache: npm

- name: Install dependencies
run: npm ci

- name: Build test
run: npx lerna run build:test --scope=@mbc-cqrs-severless/core

- name: Run e2e Tests
run: npx lerna run test:e2e --scope=@mbc-cqrs-severless/core

- uses: actions/upload-artifact@v4
name: 'upload artfact'
if: success() || failure()
with:
name: my-artifacts
path: ./packages/core/test/scripts/*.out.txt

- name: E2E Test Report
uses: dorny/test-reporter@v1
if: success() || failure() # run this step even if previous step failed
with:
name: E2E Core Tests Reporter # Name of the check run which will be created
path: report/e2e-core.xml # Path to test results
reporter: jest-junit # Format of test results
fail-on-error: 'true' # Set action as failed if test report contains any failed test

publish:
if: github.event.pull_request.merged == true # Condition
name: Publish
needs: e2e_tests
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-node@v4
with:
node-version: 18
cache: npm
- name: Authenticate with npm
run: echo "//registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}" > ~/.npmrc

- name: 'Version and publish'
run: |
git config user.name "${{ github.actor }}"
git config user.email "${{ github.actor}}@users.noreply.github.com"

if [[ "${{ github.base_ref }}" == "development" ]]; then
npx lerna version prepatch --force-publish --no-changelog --yes
else
npx lerna version prepatch --conventional-graduate --no-changelog --yes
fi

npx lerna publish from-git --yes
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,20 @@ name: Run test

on:
pull_request:
types: [opened, synchronize]
branches:
- develop
push:
branches:
- develop
- main

permissions:
contents: write
actions: read
checks: write

jobs:
unit_tests:
name: Unit Test
permissions: write-all
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
Expand All @@ -26,18 +32,24 @@ jobs:
- name: Run Unit Tests
run: npm run test

- name: Debug
run: ls -la

- name: Debug report
run: ls -la report

- name: Unit Test Report
uses: dorny/test-reporter@v1
if: success() || failure() # run this step even if previous step failed
with:
name: Unit Tests Reporter # Name of the check run which will be created
path: report/*.xml # Path to test results
path: report/unit.xml # Path to test results
reporter: jest-junit # Format of test results
fail-on-error: 'true' # Set action as failed if test report contains any failed test

e2e_tests:
name: E2e Test For Core package
# needs: unit_tests
needs: unit_tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
Expand Down
Loading