Skip to content

Commit

Permalink
try with test jobs
Browse files Browse the repository at this point in the history
  • Loading branch information
M-Kusumgar committed Nov 7, 2024
1 parent 8bf94b7 commit 20d9f2b
Show file tree
Hide file tree
Showing 2 changed files with 92 additions and 17 deletions.
45 changes: 45 additions & 0 deletions .github/actions/setup-and-login/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: Setup Node, Env and login to GHCR

inputs:
ghcr-username:
required: false
default: ''
ghcr-password:
required: false
default: ''

outputs:
CI_SHA:
description: "Short SHA of current commit"
value: ${{ steps.ci-env.outputs.CI_SHA }}
CI_BRANCH:
description: "Current branch"
value: ${{ steps.ci-env.outputs.CI_BRANCH }}

runs:
using: "composite"
steps:
- name: Login to GHCR (GitHub Packages)
if: inputs.ghcr-username != '' && inputs.ghcr-password != ''
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ inputs.ghcr-username }}
password: ${{ inputs.ghcr-password }}
- id: ci-env
name: Setup Environment
shell: bash
run: |
if [ "${{github.event_name}}" = "pull_request" ];
then
long_sha=${{ github.event.pull_request.head.sha }}
echo "CI_BRANCH=${{ github.head_ref }}" >> $GITHUB_OUTPUT
else
long_sha=${GITHUB_SHA}
echo "CI_BRANCH=${{ github.ref_name }}" >> $GITHUB_OUTPUT
fi
echo "CI_SHA=${long_sha:0:7}" >> $GITHUB_OUTPUT
- uses: actions/setup-node@v4
with:
node-version: 20
64 changes: 47 additions & 17 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,35 +1,65 @@
name: test
on: [push]
jobs:
test:
unit-tests:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
- uses: actions/checkout@v4
- name: Setup Node
uses: ./.github/actions/setup-and-login

- name: Test back end
run: npm test --prefix=app/server
- name: Test front end
run: npm run coverage --prefix=app/static
- name: Check versions
run: npm run genversion --prefix=app/server -- --check-only
- uses: codecov/codecov-action@v4
with:
node-version: 20.x
- name: Install dependencies
run: npm install -g typescript
fail_ci_if_error: true # optional (default = false)
files: ./app/server/coverage/coverage-final.json,./app/static/coverage/coverage-final.json
token: ${{ secrets.CODECOV_TOKEN }} # required

integration-tests:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup Node
uses: ./.github/actions/setup-and-login

- name: Build
run: ./scripts/build.sh
- name: Run dependencies
run: ./scripts/run-dependencies.sh
- name: Run server
run: npm run serve --prefix=app/server &
- name: Test back end
run: npm test --prefix=app/server
- name: Test back end integration
run: npm run integration-test --prefix=app/server
- name: Test front end
run: npm run coverage --prefix=app/static

playwright-tests:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup Node
uses: ./.github/actions/setup-and-login

- name: Build
run: ./scripts/build.sh
- name: Run dependencies
run: ./scripts/run-dependencies.sh
- name: Run server
run: npm run serve --prefix=app/server &
- name: Test e2e
run: npm run test:e2e --prefix=app/static

lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup Node
uses: ./.github/actions/setup-and-login

- name: Lint back end
run: npm run lint --prefix=app/server
- name: Lint front end
run: npm run lint --prefix=app/static
- name: Check versions
run: npm run genversion --prefix=app/server -- --check-only
- uses: codecov/codecov-action@v4
with:
fail_ci_if_error: true # optional (default = false)
files: ./app/server/coverage/coverage-final.json,./app/static/coverage/coverage-final.json
token: ${{ secrets.CODECOV_TOKEN }} # required

0 comments on commit 20d9f2b

Please sign in to comment.