## Description 1. Move everything related to client from app folder to client folder (`.yarn`, `yarn.lock`, package.json, .gitignore) 2. Move `ast` and `rst` to client packages 3. Fix running scripts in packages 4. Add running unit tests in packages in CI TODO: It is necessary to consider enabling the `nmHoistingLimits: workspaces` option, since now all packages are hoisted to the root, there may be issues with dependencies in workspaces. Also, there is a possibility of implicit use of packages. https://yarnpkg.com/configuration/yarnrc#nmHoistingLimits #### PR fixes following issue(s) Fixes #23333 #### Type of change - Chore (housekeeping or task changes that don't impact user perception) ## Testing #### How Has This Been Tested? - [x] Manual - [x] Jest - [x] Cypress ## Checklist: #### Dev activity - [x] My code follows the style guidelines of this project - [x] I have performed a self-review of my own code - [ ] I have commented my code, particularly in hard-to-understand areas - [ ] I have made corresponding changes to the documentation - [x] My changes generate no new warnings - [ ] I have added tests that prove my fix is effective or that my feature works - [ ] New and existing unit tests pass locally with my changes - [ ] PR is being merged under a feature flag Co-authored-by: Valera Melnikov <melnikov.vv@greendatasoft.ru>
110 lines
3.6 KiB
YAML
110 lines
3.6 KiB
YAML
# This workflow is responsible for testing shared modules.
|
||
name: Test Shared Modules Workflow
|
||
|
||
on:
|
||
# This line enables manual triggering of this workflow.
|
||
workflow_dispatch:
|
||
# A workflow can be called by another workflow
|
||
workflow_call:
|
||
inputs:
|
||
pr:
|
||
description: "This is the PR number in case the workflow is being called in a pull request"
|
||
required: false
|
||
type: number
|
||
|
||
pull_request:
|
||
branches: [release, master]
|
||
paths:
|
||
- "app/client/packages/ast/**"
|
||
|
||
# Change the working directory for all the jobs in this workflow
|
||
defaults:
|
||
run:
|
||
working-directory: app/client/packages/ast
|
||
|
||
jobs:
|
||
test:
|
||
runs-on: ubuntu-latest
|
||
# Only run this workflow for internally triggered events
|
||
if: |
|
||
github.event.pull_request.head.repo.full_name == github.repository ||
|
||
github.event_name == 'push' ||
|
||
github.event_name == 'workflow_dispatch' ||
|
||
github.event_name == 'repository_dispatch'
|
||
|
||
steps:
|
||
# Check out merge commit with the base branch in case this workflow is invoked via pull request
|
||
- name: Checkout the merged commit from PR and base branch
|
||
if: inputs.pr != 0
|
||
uses: actions/checkout@v3
|
||
with:
|
||
fetch-depth: 0
|
||
ref: refs/pull/${{ inputs.pr }}/merge
|
||
|
||
# Checkout the code in the current branch in case the workflow is called because of a branch push event
|
||
- name: Checkout the head commit of the branch
|
||
if: inputs.pr == 0
|
||
uses: actions/checkout@v3
|
||
with:
|
||
fetch-depth: 0
|
||
|
||
# Logging some params
|
||
- name: Figure out the PR number
|
||
run: echo ${{ inputs.pr }}
|
||
|
||
- name: Print the Github event
|
||
run: echo ${{ github.event_name }}
|
||
|
||
# Depot CLI helps building Docker images via Depot's remote builder infrastructure, faster.
|
||
- name: Set up Depot CLI
|
||
uses: depot/setup-action@v1
|
||
|
||
# In case this is second attempt try restoring status of the prior attempt from cache
|
||
- name: Restore the previous run result
|
||
uses: actions/cache@v3
|
||
with:
|
||
path: |
|
||
~/run_result
|
||
key: ${{ github.run_id }}-${{ github.job }}-shared-modules
|
||
|
||
# Fetch prior run result
|
||
- name: Get the previous run result
|
||
id: run_result
|
||
run: cat ~/run_result 2>/dev/null || echo 'default'
|
||
|
||
# In case of prior failure run the job
|
||
- if: steps.run_result.outputs.run_result != 'success'
|
||
run: echo "I'm alive!" && exit 0
|
||
|
||
- name: Use Node.js 16.14.0
|
||
if: steps.run_result.outputs.run_result != 'success'
|
||
uses: actions/setup-node@v3
|
||
with:
|
||
node-version: "16.14.0"
|
||
|
||
# actions/setup-node@v3 doesn’t work properly with Yarn 3
|
||
# when the project lives in a subdirectory: https://github.com/actions/setup-node/issues/488
|
||
# Restoring the cache manually instead
|
||
- name: Restore Yarn cache
|
||
if: steps.run_result.outputs.run_result != 'success'
|
||
uses: actions/cache@v3
|
||
with:
|
||
path: app/.yarn/cache
|
||
key: v1-yarn3-${{ hashFiles('app/yarn.lock') }}
|
||
restore-keys: |
|
||
v1-yarn3-
|
||
|
||
# Install all the dependencies
|
||
- name: Install dependencies
|
||
if: steps.run_result.outputs.run_result != 'success'
|
||
run: yarn install --immutable
|
||
|
||
# Runs the test cases
|
||
- name: Run the jest tests
|
||
if: steps.run_result.outputs.run_result != 'success'
|
||
run: REACT_APP_ENVIRONMENT=${{steps.vars.outputs.REACT_APP_ENVIRONMENT}} yarn run test:unit
|
||
|
||
# Set status = success
|
||
- name: Save the status of the run
|
||
run: echo "run_result=success" >> $GITHUB_OUTPUT > ~/run_result
|