From 20d9f2b1e5c5deb67db5d03e27a9213ab974eef6 Mon Sep 17 00:00:00 2001 From: Mantra Date: Thu, 7 Nov 2024 12:33:38 +0000 Subject: [PATCH] try with test jobs --- .github/actions/setup-and-login/action.yml | 45 +++++++++++++++ .github/workflows/test.yml | 64 ++++++++++++++++------ 2 files changed, 92 insertions(+), 17 deletions(-) create mode 100644 .github/actions/setup-and-login/action.yml diff --git a/.github/actions/setup-and-login/action.yml b/.github/actions/setup-and-login/action.yml new file mode 100644 index 00000000..07d78f81 --- /dev/null +++ b/.github/actions/setup-and-login/action.yml @@ -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 diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 419240a5..c1203cfb 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -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