diff --git a/.github/workflows/lint-and-test.yml b/.github/workflows/lint-and-test.yml index 8eaea31a5c9..ad1bfccfa1d 100644 --- a/.github/workflows/lint-and-test.yml +++ b/.github/workflows/lint-and-test.yml @@ -85,17 +85,36 @@ jobs: with: node-version-file: .nvmrc + - name: Extract dependencies for ${{ matrix.package }} + if: steps.check-scripts.outputs.skip != 'true' + id: extract-dependencies + run: | + DEPENDENCIES=$(node -e " + const { execSync } = require('child_process'); + const output = execSync('yarn --silent workspaces info', { encoding: 'utf-8' }); + const json = JSON.parse(output.replaceAll('@opencrvs', 'packages')); + + const getDependencies = (pkg) => + json[pkg].workspaceDependencies.concat( + json[pkg].workspaceDependencies.flatMap(getDependencies) + ); + + console.log( + getDependencies('${{ matrix.package }}').join(' ') + ); + ") + echo "DEPENDENCIES=${DEPENDENCIES}" >> $GITHUB_ENV + echo "Found dependencies: $DEPENDENCIES" + - name: Remove other package directories if: steps.check-scripts.outputs.skip != 'true' run: | for dir in packages/*; do - if [ "$dir" != "${{ matrix.package }}" ] && [ "$dir" != "packages/commons" ] && [ "$dir" != "packages/components" ]; then - if [ "${{ matrix.package }}" == "packages/client" ] && [ "$dir" == "packages/gateway" ] ; then - echo "Skipping $dir" - else - echo "Removing $dir" - rm -rf "$dir" - fi + if echo "$DEPENDENCIES" | grep -q -w "$dir"; then + echo "Skipping $dir" + else + echo "Removing $dir" + rm -rf "$dir" fi done diff --git a/packages/client/package.json b/packages/client/package.json index 3026ec3e2a7..423357215f9 100644 --- a/packages/client/package.json +++ b/packages/client/package.json @@ -108,6 +108,7 @@ "xregexp": "^4.2.0" }, "devDependencies": { + "@opencrvs/gateway": "^1.5.0", "@graphql-codegen/add": "^5.0.0", "@graphql-codegen/cli": "^5.0.0", "@graphql-codegen/introspection": "^3.0.0",