This tutorial walks you through configuring CI for your Nx workspace. You'll set up a CI pipeline, enable remote caching to speed up runs, and configure self-healing CI to automatically fix failures.
What you'll learn:
- How to connect your workspace to Nx Cloud
- How to generate a CI workflow for GitHub Actions
- How remote caching avoids redundant work across CI runs
- How self-healing CI detects and fixes failures automatically
Prerequisites
Section titled “Prerequisites”Step 1: Connect to Nx Cloud
Section titled “Step 1: Connect to Nx Cloud”Connect your workspace to Nx Cloud to enable remote caching and CI features:
npx nx connectThis creates an Nx Cloud account (if you don't have one) and connects your workspace. Once connected, you can see your workspace in your Nx Cloud organization.
Step 2: Generate a CI workflow
Section titled “Step 2: Generate a CI workflow”Generate a CI workflow configuration for GitHub Actions:
npx nx g ci-workflowThis creates a .github/workflows/ci.yml file that runs your tasks through Nx and includes the fix-ci command for self-healing:
name: CI
on: push: branches: - main pull_request:
permissions: actions: read contents: read
jobs: main: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 with: filter: tree:0 fetch-depth: 0
- uses: actions/setup-node@v4 with: node-version: 20 cache: 'npm'
- run: npm ci
- run: npx nx run-many -t lint test build
- run: npx nx-cloud fix-ci if: always()The npx nx-cloud fix-ci command at the end is responsible for enabling self-healing CI. It analyzes any failing tasks and automatically suggests fixes.
Step 3: Install Nx Console
Section titled “Step 3: Install Nx Console”You will need the Nx Console editor extension for VS Code, Cursor, or IntelliJ to receive CI notifications and apply fixes directly from your editor.
Install Nx Console for VSCodeThe official VSCode extension for Nx.
Install Nx Console for JetBrainsAvailable for WebStorm, IntelliJ IDEA Ultimate and more!
For the complete AI setup guide, see our AI integration documentation.
Step 4: Push a PR and see self-healing in action
Section titled “Step 4: Push a PR and see self-healing in action”Create a branch, make a change (or introduce an intentional test failure), and push it:
git checkout -b my-featuregit add .git commit -m 'my changes'git push origin my-feature# Don't forget to open a pull request on GitHubWhen CI runs and encounters a failure, Nx Console notifies you that the run has completed and that it has a suggested fix. You don't have to waste time babysitting your PRs — the fix can be applied directly from your editor.
Fix CI from your editor
Section titled “Fix CI from your editor”From the Nx Console notification, click the Show Suggested Fix button. Review the suggested fix and approve it by clicking Apply Fix.
You don't have to leave your editor or do any manual work to fix it. This is the power of self-healing CI with Nx Cloud.
Remote cache for faster time to green
Section titled “Remote cache for faster time to green”After the fix has been applied and committed, CI will re-run automatically, and you will be notified of the results in your editor.
When you view the results in Nx Cloud, you'll notice something interesting. Tasks for projects that weren't affected by your change were read from remote cache and did not have to run again, each taking less than a second to complete.
This happens because Nx Cloud caches the results of tasks and reuses them across different CI runs. As long as the inputs for each task have not changed (e.g. source code), then their results can be replayed from Nx Cloud's Remote Cache.
This significantly speeds up the time to green for your pull requests, because subsequent changes to them have a good chance to replay tasks from cache.
Next steps
Section titled “Next steps”- Learn more about Self-Healing CI
- Learn about Remote Cache and how it works
- Set up AI integration for enhanced AI-powered CI workflows
- Learn more about the underlying mental model of Nx
Also, make sure you
- ⭐️ Star us on GitHub to show your support and stay updated on new releases!
- Join the Official Nx Discord Server to ask questions and find out the latest news about Nx.
- Follow Nx on Twitter to stay up to date with Nx news
- Read our Nx blog
- Subscribe to our Youtube channel for demos and Nx insights