Skip to content

feat(core): convert commands to use nx project graph instead of package graph #1345

feat(core): convert commands to use nx project graph instead of package graph

feat(core): convert commands to use nx project graph instead of package graph #1345

Workflow file for this run

name: CI
on:
push:
branches:
- main
- next
pull_request:
types: [assigned, opened, synchronize, reopened, labeled]
concurrency:
group: ${{ github.workflow }}-${{ github.event.number || github.ref }}
cancel-in-progress: true
env:
NX_CLOUD_ACCESS_TOKEN: ${{ secrets.NX_CLOUD_ACCESS_TOKEN }}
NX_CLOUD_DISTRIBUTED_EXECUTION: true
NX_BRANCH: ${{ github.event.number || github.ref_name }}
NX_VERBOSE_LOGGING: true
jobs:
main:
name: Nx Cloud - Main Job
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- uses: nrwl/nx-set-shas@v3
- name: Set NX_RUN_GROUP
shell: bash
run: echo "NX_RUN_GROUP=$GITHUB_RUN_ID-$GITHUB_RUN_ATTEMPT-linux" >> $GITHUB_ENV
- name: Log NX_RUN_GROUP
shell: bash
run: echo "NX_RUN_GROUP is ${{ env.NX_RUN_GROUP }}"
- name: Install primary node version (see volta config in package.json) and dependencies
uses: ./.github/actions/install-node-and-dependencies
- name: Run parallel distributed tasks
uses: jameshenry/parallel-bash-commands@v1
with:
cmd1: npx nx-cloud record -- npx nx format:check
cmd2: npx nx run-many -t build --parallel=3
cmd3: npx nx run-many -t lint --parallel=3
cmd4: npx nx run-many -t test --parallel=3 --ci --maxWorkers=2
cmd5: npx nx run integration:integration --ci --maxWorkers=2
# e2e tests for everything except the primary task runner
- run: PUBLISHED_VERSION=999.9.9-e2e.0 npx nx run-many --t e2e --parallel=1
- name: Stop all running agents for Nx Run Group ${{ env.NX_RUN_GROUP }}
# It's important that we always run this step, otherwise in the case of any failures in preceding non-Nx steps, the agents will keep running and waste billable minutes
if: ${{ always() }}
run: npx nx-cloud stop-all-agents
agents:
name: Nx Cloud - Agent ${{ matrix.agent }}
runs-on: ubuntu-latest
strategy:
matrix:
agent: [1, 2, 3, 4]
steps:
- uses: actions/checkout@v3
- name: Set NX_RUN_GROUP
shell: bash
run: echo "NX_RUN_GROUP=$GITHUB_RUN_ID-$GITHUB_RUN_ATTEMPT-linux" >> $GITHUB_ENV
- name: Log NX_RUN_GROUP
shell: bash
run: echo "NX_RUN_GROUP is ${{ env.NX_RUN_GROUP }}"
- name: Configure git metadata
run: |
git config --global user.email test@example.com
git config --global user.name "Tester McPerson"
- name: Install primary node version (see volta config in package.json) and dependencies
uses: ./.github/actions/install-node-and-dependencies
- name: Start Nx Agent ${{ matrix.agent }}
run: npx nx-cloud start-agent
env:
NX_AGENT_NAME: ${{ matrix.agent }}
NX_RUN_GROUP: ${{ env.NX_RUN_GROUP }}
windows-main:
name: Nx Cloud - Windows Main Job
runs-on: windows-latest
env:
LERNA_OS_TYPE: windows
steps:
- uses: actions/checkout@v3
- name: Set NX_RUN_GROUP
shell: bash
run: echo "NX_RUN_GROUP=$GITHUB_RUN_ID-$GITHUB_RUN_ATTEMPT-windows" >> $GITHUB_ENV
- name: Log NX_RUN_GROUP
shell: bash
run: echo "NX_RUN_GROUP is ${{ env.NX_RUN_GROUP }}"
- name: Install primary node version (see volta config in package.json) and dependencies
uses: ./.github/actions/install-node-and-dependencies
- name: Run parallel distributed unit and integration tests on windows
shell: bash
# From old maintainer regarding integration tests: "import is NOT TESTED in windows because pain and suffering"
run: |
pids=()
npx nx run integration:integration --ci --maxWorkers=2 --testPathIgnorePatterns=lerna-import.spec.ts &
pids+=($!)
# Ignored specs currently failing on windows
# TODO: investigate why
npx nx run-many -t test --parallel=3 --ci --maxWorkers=2 --testTimeout=60000 --testPathIgnorePatterns=import-command.spec.ts --testPathIgnorePatterns=publish-command.spec.ts --testPathIgnorePatterns=publish-licenses.spec.ts --testPathIgnorePatterns=publish-lifecycle-scripts.spec.ts --testPathIgnorePatterns=publish-tagging.spec.ts --testPathIgnorePatterns=publish-relative-file-specifiers.spec.ts &
pids+=($!)
for pid in "${pids[@]}"; do
wait "$pid"
done
- name: Stop all running agents for Nx Run Group ${{ env.NX_RUN_GROUP }}
# It's important that we always run this step, otherwise in the case of any failures in preceding non-Nx steps, the agents will keep running and waste billable minutes
if: ${{ always() }}
run: npx nx-cloud stop-all-agents
windows-agents:
name: Nx Cloud - Windows Agent ${{ matrix.agent }}
runs-on: windows-latest
strategy:
matrix:
agent: [1, 2, 3, 4]
env:
LERNA_OS_TYPE: windows
steps:
- uses: actions/checkout@v3
- name: Set NX_RUN_GROUP
shell: bash
run: echo "NX_RUN_GROUP=$GITHUB_RUN_ID-$GITHUB_RUN_ATTEMPT-windows" >> $GITHUB_ENV
- name: Log NX_RUN_GROUP
shell: bash
run: echo "NX_RUN_GROUP is ${{ env.NX_RUN_GROUP }}"
- name: Configure git metadata
run: |
git config --global user.email test@example.com
git config --global user.name "Tester McPerson"
- name: Install primary node version (see volta config in package.json) and dependencies
uses: ./.github/actions/install-node-and-dependencies
- name: Start Nx Agent ${{ matrix.agent }}
run: npx nx-cloud start-agent
env:
NX_AGENT_NAME: ${{ matrix.agent }}
NX_RUN_GROUP: ${{ env.NX_RUN_GROUP }}
# Isolated e2e tests for the task runner which become too flaky if nested through further node child processes
task-runner-e2e:
name: Task Runner E2E
runs-on: ubuntu-latest
env:
NX_CLOUD_DISTRIBUTED_EXECUTION: false
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Derive appropriate SHAs for base and head for `nx affected` commands
uses: nrwl/nx-set-shas@v3
- name: Configure git metadata
run: |
git config --global user.email test@example.com
git config --global user.name "Tester McPerson"
# TODO: figure out why uses: ./.github/actions/install-node-and-dependencies is causing pnpm to not be available in this job
- name: Install dependencies
run: npm ci
shell: bash
- name: Check if e2e-run-task-runner is affected
id: check_affected
run: |
IS_AFFECTED_STR=$(npx nx print-affected | jq '.projects | contains(["e2e-run-task-runner"])')
IS_AFFECTED=$([[ $IS_AFFECTED_STR == 'true' ]] && echo 'true' || echo '')
echo "is_affected=$IS_AFFECTED" >> $GITHUB_OUTPUT
shell: bash
- name: Install pnpm v7
run: npm install -g pnpm@7
shell: bash
- run: pnpm --version
shell: bash
- name: Prepare e2e tests for task-runner
if: ${{ steps.check_affected.outputs.is_affected }}
run: npx nx prepare-for-e2e e2e-run-task-runner
shell: bash
- name: Run e2e tests for task-runner
if: ${{ steps.check_affected.outputs.is_affected }}
run: e2e/run/task-runner/src/run-tests.sh
shell: bash