From 55bdf7794ba7f6ceac4333d7bc0aff0ba6a930f0 Mon Sep 17 00:00:00 2001 From: Zachary DeRose Date: Sun, 2 Apr 2023 00:14:26 -0700 Subject: [PATCH] chore: switching to an affected strategy (#5215) * switiching to an affected strategy * updating base affected option for ci and ci-v3 workflows * Update .github/workflows/ci-v3.yml Co-authored-by: Dominik Dorfmeister * checking github context * checking pnpm version * fix? * does not like main - let's use a sha then * checking git head * checking git in general * fix???? * fix???????? pleeeease * still in detatched head state * try checking out the pr head sha? * checking out pr branch * checking githubref * full gh ref * dumping context again * try to checkout head ref * adding repo prop * git logging * trying with sha for base * fixing other jobs * fixing other jobs again * reverting root specific projects to run many * removing special stuff from build test * testing affected * reverting change --------- Co-authored-by: Dominik Dorfmeister --- .github/workflows/ci.yml | 2 +- .github/workflows/pr.yml | 30 +++++++++++++++++++++++++----- package.json | 12 ++++++------ 3 files changed, 32 insertions(+), 12 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 8a0e0bf7a9..61c4c12904 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -39,7 +39,7 @@ jobs: - name: Run Tests uses: nick-fields/retry@v2.8.3 with: - command: pnpm run test:ci + command: pnpm run test:ci --base=${{ github.event.before }} timeout_minutes: 10 max_attempts: 3 - name: Publish diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index 95f44dcb1b..ac23264c66 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -10,6 +10,10 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 + with: + fetch-depth: 0 + ref: ${{ github.head_ref }} + repository: ${{github.event.pull_request.head.repo.full_name}} - uses: pnpm/action-setup@v2.2.4 with: version: 7 @@ -22,7 +26,7 @@ jobs: - name: Run Tests uses: nick-fields/retry@v2.8.3 with: - command: pnpm test:lib + command: pnpm test:lib --base=${{ github.event.pull_request.base.sha }} timeout_minutes: 5 max_attempts: 3 - name: Upload coverage to Codecov @@ -32,6 +36,10 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 + with: + fetch-depth: 0 + ref: ${{ github.head_ref }} + repository: ${{github.event.pull_request.head.repo.full_name}} - uses: pnpm/action-setup@v2.2.4 with: version: 7 @@ -41,12 +49,16 @@ jobs: cache: 'pnpm' - name: Install dependencies run: pnpm --filter "./packages/**" --filter query --prefer-offline install - - run: pnpm run test:eslint + - run: pnpm run test:eslint --base=${{ github.event.pull_request.base.sha }} typecheck: name: 'Typecheck' runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 + with: + fetch-depth: 0 + ref: ${{ github.head_ref }} + repository: ${{github.event.pull_request.head.repo.full_name}} - uses: pnpm/action-setup@v2.2.4 with: version: 7 @@ -56,12 +68,16 @@ jobs: cache: 'pnpm' - name: Install dependencies run: pnpm --filter "./packages/**" --filter query --prefer-offline install - - run: pnpm run test:types + - run: pnpm run test:types --base=${{ github.event.pull_request.base.sha }} format: name: 'Format' runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 + with: + fetch-depth: 0 + ref: ${{ github.head_ref }} + repository: ${{github.event.pull_request.head.repo.full_name}} - uses: pnpm/action-setup@v2.2.4 with: version: 7 @@ -71,12 +87,16 @@ jobs: cache: 'pnpm' - name: Install dependencies run: pnpm --filter "./packages/**" --filter query --prefer-offline install - - run: pnpm run test:format + - run: pnpm run test:format --base=${{ github.event.pull_request.base.sha }} test-react-17: name: 'Test React 17' runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 + with: + fetch-depth: 0 + ref: ${{ github.head_ref }} + repository: ${{github.event.pull_request.head.repo.full_name}} - uses: pnpm/action-setup@v2.2.4 with: version: 7 @@ -91,7 +111,7 @@ jobs: with: timeout_minutes: 5 max_attempts: 3 - command: pnpm run test:react:17 + command: pnpm run test:react:17 --base=${{ github.event.pull_request.base.sha }} env: REACTJS_VERSION: 17 test-build: diff --git a/package.json b/package.json index cc48e0d50a..c5fc0d2688 100644 --- a/package.json +++ b/package.json @@ -6,16 +6,16 @@ "preinstall": "node -e \"if(process.env.CI == 'true') {console.log('Skipping preinstall...'); process.exit(1)}\" || npx -y only-allow pnpm", "install:csb": "pnpm install --frozen-lockfile", "test": "pnpm run test:ci", - "test:ci": "nx run-many --targets=test:lib,test:types,test:eslint,test:format --parallel=5", - "test:react:17": "nx run-many --target=test:lib --projects=@tanstack/react-*", - "test:eslint": "nx run-many --target=test:eslint --parallel=5", + "test:ci": "nx affected --targets=test:lib,test:types,test:eslint,test:format --parallel=5", + "test:react:17": "nx affected --target=test:lib --projects=@tanstack/react-*", + "test:eslint": "nx affected --target=test:eslint --parallel=5", "test:format": "pnpm run prettier --check", - "test:lib": "nx run-many --target=test:lib --parallel=5", + "test:lib": "nx affected --target=test:lib --parallel=5", "test:lib:dev": "pnpm --filter \"./packages/**\" run test:lib:dev", "test:build": "nx run-many --target=test:build --projects=root", - "test:types": "nx run-many --target=test:types --parallel=5", + "test:types": "nx affected --target=test:types --parallel=5", "build": "nx run-many --target=build --projects=root", - "build:types": "nx run-many --target=build:types --parallel=5", + "build:types": "nx affected --target=build:types --parallel=5", "watch": "concurrently --kill-others \"rollup --config rollup.config.js -w\" \"pnpm run build:types --watch\"", "dev": "pnpm run watch", "prettier": "prettier --plugin-search-dir . \"{packages,examples}/**/src/**/*.{md,js,jsx,ts,tsx,json,vue,svelte}\"",