diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0d87a2e9e5..6b2760e1b9 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,7 +1,5 @@ name: ci -concurrency: - group: publish-${{ github.github.base_ref }} - cancel-in-progress: true + on: workflow_dispatch: inputs: @@ -13,9 +11,15 @@ on: - 'main' - 'alpha' - 'beta' + +concurrency: + group: ${{ github.workflow }}-${{ github.event.number || github.ref }} + cancel-in-progress: true + env: - NX_DAEMON: false NX_CLOUD_ACCESS_TOKEN: ${{ secrets.NX_CLOUD_ACCESS_TOKEN }} + NX_CLOUD_AUTH_TOKEN: ${{ secrets.NX_CLOUD_AUTH_TOKEN }} + jobs: test-and-publish: if: github.repository == 'TanStack/query' && (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/alpha' || github.ref == 'refs/heads/beta') diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index 0efc3910ab..6afe8d8551 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -7,34 +7,90 @@ concurrency: cancel-in-progress: true env: + NX_CLOUD_DISTRIBUTED_EXECUTION: true + NX_CLOUD_DISTRIBUTED_EXECUTION_AGENT_COUNT: 3 NX_CLOUD_ACCESS_TOKEN: ${{ secrets.NX_CLOUD_ACCESS_TOKEN }} + NX_CLOUD_AUTH_TOKEN: ${{ secrets.NX_CLOUD_AUTH_TOKEN }} jobs: main: - name: Nx Cloud - uses: nrwl/ci/.github/workflows/nx-cloud-main.yml@v0.13.0 - with: - node-version: 18.16.0 - pnpm-version: 8.6.0 - main-branch-name: alpha - artifacts-name: nx-cloud-artifact - artifacts-path: | - **/build/** - **/coverage/** - !**/node_modules/** - parallel-commands: | - npx nx test:format - npx nx affected --targets=test:eslint,test:types,test:build,test:lib - codecov: - name: Codecov - needs: main + name: Nx Cloud - Main Job runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 - - name: Downloading artifacts - uses: actions/download-artifact@v3 with: - name: nx-cloud-artifact - path: . + fetch-depth: 0 + - name: Setup pnpm + uses: pnpm/action-setup@v2.2.4 + with: + version: 8 + - name: Setup Node + uses: actions/setup-node@v3 + with: + node-version: 18.16.0 + cache: 'pnpm' + - name: Install dependencies + run: pnpm --filter "./packages/**" --filter query --prefer-offline install + - name: Get appropriate base and head commits for `nx affected` commands + uses: nrwl/nx-set-shas@v3 + with: + main-branch-name: 'alpha' + - run: | + echo "BASE: ${{ env.NX_BASE }}" + echo "HEAD: ${{ env.NX_HEAD }}" + - name: Start CI Orchestrator + run: npx nx-cloud start-ci-run + - name: Run Tests + uses: nick-fields/retry@v2.8.3 + with: + timeout_minutes: 5 + max_attempts: 3 + command: npx nx affected --targets=test:eslint,test:lib,test:types,test:build + - name: Stop Agents + run: npx nx-cloud stop-all-agents - name: Upload coverage to Codecov uses: codecov/codecov-action@v3 + agents: + name: Nx Cloud - Agents + runs-on: ubuntu-latest + timeout-minutes: 10 + strategy: + matrix: + agent: [1, 2, 3] + steps: + - uses: actions/checkout@v3 + with: + fetch-depth: 0 + - name: Setup pnpm + uses: pnpm/action-setup@v2.2.4 + with: + version: 8 + - name: Setup Node + uses: actions/setup-node@v3 + with: + node-version: 18.16.0 + cache: 'pnpm' + - name: Install dependencies + run: pnpm --filter "./packages/**" --filter query --prefer-offline install + - name: Start Nx Agent ${{ matrix.agent }} + run: npx nx-cloud start-agent + format: + name: Format + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + with: + fetch-depth: 0 + - name: Setup pnpm + uses: pnpm/action-setup@v2.2.4 + with: + version: 8 + - name: Setup Node + uses: actions/setup-node@v3 + with: + node-version: 18.16.0 + cache: 'pnpm' + - name: Install dependencies + run: pnpm --filter "./packages/**" --filter query --prefer-offline install + - name: Run prettier + run: pnpm run test:format diff --git a/nx.json b/nx.json index 0f11e04ef1..339b51dcf2 100644 --- a/nx.json +++ b/nx.json @@ -12,12 +12,9 @@ "test:eslint", "test:types", "test:build", - "build", - "build:rollup", - "build:codemods", - "build:types" + "build" ], - "parallel": 5, + "parallel": 3, "accessToken": "ZDdkNDA4MGEtYjNmYi00MWI4LWE1N2QtYTdlNmYxMGJlZWM2fHJlYWQ=" } } @@ -29,25 +26,23 @@ } }, "namedInputs": { - "globalBuildAffectingConfig": [ + "sharedGlobals": [ "{workspaceRoot}/.browserslistrc", + "{workspaceRoot}/.eslintrc.cjs", "{workspaceRoot}/babel.config.cjs", "{workspaceRoot}/package.json", "{workspaceRoot}/scripts/getRollupConfig.js", "{workspaceRoot}/tsconfig.json" ], - "globalNonBuildAffectingConfig": ["{workspaceRoot}/.eslintrc.cjs"], "default": [ + "sharedGlobals", "{projectRoot}/**/*", - "globalBuildAffectingConfig", - "globalNonBuildAffectingConfig", - "!{projectRoot}/**/*.md", - "!{projectRoot}/**/build/**/*" + "!{projectRoot}/**/*.md" ], "public": [ "default", - "!{workspaceRoot}/.eslintrc.cjs", - "!{projectRoot}/**/?(*.)+(spec|test).[jt]s?(x)?(.snap)", + "{projectRoot}/build", + "{projectRoot}/dist", "!{projectRoot}/.eslintrc.cjs", "!{projectRoot}/tsconfig.eslint.json" ] @@ -69,7 +64,7 @@ "build": { "dependsOn": ["^build"], "inputs": ["default", "^public"], - "outputs": ["{projectRoot}/build/**/*"] + "outputs": ["{projectRoot}/build", "{projectRoot}/dist"] }, "test:build": { "dependsOn": ["build"],