From 5eab8b4efa05227c117620f31da95b4121cd9455 Mon Sep 17 00:00:00 2001 From: Matt Fedderly Date: Fri, 9 Aug 2024 12:25:16 -0400 Subject: [PATCH] Rework actions for faster PR CI - Whitespace change in @turf/difference should rebuild/test difference and @turf/turf --- .github/workflows/turf.yml | 12 ++++++------ nx.json | 2 +- package.json | 2 +- packages/turf-difference/index.ts | 1 + 4 files changed, 9 insertions(+), 8 deletions(-) diff --git a/.github/workflows/turf.yml b/.github/workflows/turf.yml index ba4be27474..61bef5b587 100644 --- a/.github/workflows/turf.yml +++ b/.github/workflows/turf.yml @@ -1,14 +1,9 @@ name: CI build on: - push: - branches: - - master - - support/6.x pull_request: branches: - master - - support/6.x permissions: contents: read @@ -24,6 +19,8 @@ jobs: steps: - name: Checkout uses: actions/checkout@v4 + with: + fetch-depth: 0 - name: Install pnpm uses: pnpm/action-setup@v4 @@ -37,5 +34,8 @@ jobs: node-version: ${{ matrix.node-version }} - run: pnpm install --frozen-lockfile + - run: pnpm lerna run build --since origin/master --ignore @turf/turf - run: git diff --exit-code - - run: pnpm test + - run: pnpm lerna run test --since origin/master + # note: does not run linting + # note: does not run last-checks diff --git a/nx.json b/nx.json index 87f3cd2f1b..8bae838462 100644 --- a/nx.json +++ b/nx.json @@ -28,7 +28,7 @@ "{projectRoot}/test/**", "{projectRoot}/types.ts" ], - "dependsOn": ["build"], + "dependsOn": [], "cache": true }, "last-checks": { diff --git a/package.json b/package.json index 3521f6e877..8d28750fce 100644 --- a/package.json +++ b/package.json @@ -12,7 +12,7 @@ "lint:mrl": "mrl check", "lint:prettier": "prettier --check .", "preinstall": "npx only-allow pnpm", - "prepare": "husky && lerna run build", + "prepare": "husky", "test": "pnpm run lint && lerna run test && lerna run --scope @turf/turf last-checks" }, "lint-staged": { diff --git a/packages/turf-difference/index.ts b/packages/turf-difference/index.ts index 8629db4b0e..6203e53185 100644 --- a/packages/turf-difference/index.ts +++ b/packages/turf-difference/index.ts @@ -52,6 +52,7 @@ function difference( const properties = features.features[0].properties || {}; const differenced = polygonClipping.difference(geoms[0], ...geoms.slice(1)); + if (differenced.length === 0) return null; if (differenced.length === 1) return polygon(differenced[0], properties); return multiPolygon(differenced, properties);