Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Oct 2, 2025

Summary

This pull request splits the CI workflow into separate jobs: build, lint, test, and e2e. The test and e2e jobs are tested across various operating systems, CPU architectures, and Node.js versions.

This pull request introduces a new custom GitHub Action for posting commit status checks, along with supporting configuration, tests, and project setup files. It also adds two utility actions for setting Nx SHAs and setting up Node.js with package installation. Additionally, the CI workflow is updated to use the new build job and an ARM-based runner.

New GitHub Actions and Project Setup

  • Added a custom action post-status-check for posting pending or outcome status checks to commits, including robust token handling, event filtering, and error reporting (.github/actions/post-status-check/action.yml, .github/actions/post-status-check/src/main.js). [1] [2]
  • Comprehensive test suite for the post-status-check action, covering all major scenarios and error handling (.github/actions/post-status-check/src/main.spec.js).
  • Project configuration for Nx and TypeScript, including build and test targets, and linting setup (.github/actions/post-status-check/project.json, .github/actions/post-status-check/tsconfig.*.json, .github/actions/post-status-check/eslint.config.js, .github/actions/post-status-check/jest.config.js, .github/actions/post-status-check/package.json). [1] [2] [3] [4] [5] [6] [7]

Utility Actions

  • Added set-nx-shas action to derive SHAs for Nx affected commands (.github/actions/set-nx-shas/action.yml).
  • Added setup-node-and-install action for Node.js setup with caching and npm package installation (.github/actions/setup-node-and-install/action.yml).

CI Workflow Update

  • Changed the main CI job to build, set its runner to ubuntu-24.04-arm, and updated permissions for posting commit statuses (.github/workflows/ci.yml).

These changes enhance workflow automation, improve CI reliability, and provide reusable actions for future workflow development.

Changes Made

Restored Build Target for Type-Checking

Build Target:

  • Restored original @nx/esbuild:esbuild executor with bundle: false
  • Used for type-checking and validation during development
  • No custom ESBuild options or config files needed
  • Build output goes to dist/.github/actions/post-status-check
  • Not used in CI workflow (action runs directly from source)

Benefits:

  • Provides type-checking for the action code
  • Validates the code structure without bundling
  • Useful for local development and validation
  • All tests pass (8/8)

JavaScript Action with Workspace Dependencies

No Build Required in CI:

  • Action runs directly from source file (src/main.js) in CI
  • Uses npm workspace dependencies from root node_modules
  • No bundling or build step needed in CI workflows

How It Works:

  • Repository uses npm workspaces with .github/actions/* pattern
  • Dependencies (@actions/core, @actions/github) are hoisted to root node_modules
  • Node.js can find workspace dependencies from action directory automatically
  • The standard npm ci in CI installs all workspace dependencies

Benefits:

  • No build step overhead in CI (saves time and complexity)
  • Build target available locally for type-checking
  • Always uses latest source code in CI
  • Follows npm workspace best practices
  • All 8 tests continue to pass

Fixed job-status Input

Action Definition:

  • Changed job-status input from required: true to required: false in action.yml
  • Updated main.js to accept job-status as optional input
  • For pending state, job-status is not needed (job hasn't completed yet)
  • For outcome state, job-status is provided and used to determine success/failure

Converted post-status-check to JavaScript Action

Refactored Implementation:

  • Converted from shell script-based composite action to JavaScript action using node24 runtime
  • Uses @actions/core for inputs and outputs instead of environment variables
  • Uses @actions/github REST API instead of gh CLI
  • Added comprehensive Jest unit tests with conventional mocking
  • All tests pass with full coverage of success, failure, and edge cases

Package Structure:

  • Added package.json to .github/actions/post-status-check with @actions/core and @actions/github dependencies
  • Dependencies installed in workspace root via npm install
  • Jest and other dev dependencies remain in root package.json only
  • Uses npm workspaces for dependency management

Testing:

  • Created src/__tests__/main.spec.js with 8 unit tests
  • Tests cover pending/outcome states, success/failure status, token handling, error cases
  • Uses Jest conventional mocking for GitHub REST API requests
  • All tests passing

Nx Integration:

  • Project configured with build, test and lint targets via Nx
  • Build target uses @nx/esbuild:esbuild for type-checking (bundle: false)
  • ESLint configured with Jest globals for test files
  • Format check passes for all files

Benefits:

  • No dependency on gh CLI in runtime
  • Better error handling and logging
  • Testable with unit tests
  • More efficient (no shell execution overhead)
  • Type-safe with GitHub REST API client
  • No build step required in CI
  • Build target available for local type-checking
  • job-status input is optional for flexibility

Nx Output Style

CI Workflow:

  • Added --output-style=static to all Nx commands except format:check
  • This provides consistent, non-interactive output in CI environments
  • Affected commands: build, lint, test, and e2e
  • The format:check command remains unchanged (no flag added)

Benefits:

  • Better readability in CI logs
  • Consistent output format across all jobs
  • Avoids dynamic/animated output in CI

Task Dependencies and Build Artifacts

Project Configuration:

  • Restored "dependsOn": ["^build"] in workspace-e2e/project.json for local development
  • This ensures the workspace package is built before running e2e tests locally

CI Workflow:

  • Added --exclude-task-dependencies flag to the e2e command
  • This skips running dependent tasks (build) in CI since we use downloaded artifacts
  • E2E jobs still depend on build job via needs: build for proper sequencing

Benefits:

  • Local development: nx e2e automatically builds dependencies
  • CI: E2E tests use pre-built artifacts from build job (faster, consistent)
  • Best of both worlds: convenience locally, efficiency in CI

Build Artifacts for E2E Tests

The e2e jobs use build artifacts from the build job instead of rebuilding:

Build Job:

  • Uploads build artifacts (dist/) after building
  • Artifacts retained for 7 days

E2E Job:

  • Added needs: build to create dependency on build job
  • Downloads build artifacts before running tests
  • Uses --exclude-task-dependencies to skip rebuilding

Benefits:

  • Faster e2e tests (no rebuild required)
  • All e2e jobs test the exact same build artifacts
  • Reduced duplication and resource usage
  • Ensures consistency across all platforms
  • 7-day retention allows for debugging and post-merge analysis

Fixed Composite Action Issue

The composite actions couldn't be found because the repository wasn't checked out first. Fixed by:

  • Moving checkout logic back into the workflow (each job checks out first)
  • Renamed checkout-and-set-nx-shas to set-nx-shas (simplified to only set Nx SHAs)
  • Composite actions are now called after the repository is checked out

Composite Actions and JavaScript Action

The workflow now uses two composite actions and one JavaScript action:

  1. Set Nx SHAs (.github/actions/set-nx-shas) - Composite Action

    • Derives appropriate SHAs for nx affected commands
  2. Set up Node.js and install packages (.github/actions/setup-node-and-install) - Composite Action

    • Sets up Node.js with caching
    • Supports both explicit node-version and .node-version file
    • Installs dependencies (which makes workspace deps available to action)
  3. Post status check (.github/actions/post-status-check) - JavaScript Action

    • JavaScript action using node24 runtime
    • Posts pending/outcome status checks for workflow_dispatch events
    • Uses @actions/core and @actions/github
    • Fully tested with Jest unit tests
    • Supports dynamic context names
    • Runs directly from source (src/main.js) in CI
    • Uses workspace dependencies (no build required in CI)
    • Build target available for local type-checking
    • job-status input is optional (only needed for outcome state)

Workflow Structure

Each job now:

  1. Determines checkout ref (for workflow_dispatch support)
  2. Checks out repository with Nx-optimized settings
  3. Uses set-nx-shas composite action
  4. Uses setup-node-and-install composite action (installs workspace deps)
  5. Uses post-status-check action for pending status (deps available from workspace)
  6. Runs job-specific commands with appropriate flags
  7. Uses post-status-check action for outcome status (with job-status)

Fixes #31

Copilot AI changed the title [WIP] Test on all operating systems, CPU architectures, and supported Node.js versions feat: add matrix strategy for testing across OS/arch/Node versions Oct 2, 2025
Copilot AI requested a review from LayZeeDK October 2, 2025 15:32
@LayZeeDK
Copy link
Member

LayZeeDK commented Oct 2, 2025

@copilot Only use these runners:

  • ubuntu-latest
  • windows-latest
  • ubuntu-24.04-arm
  • windows-11-arm
  • macos-15-intel
  • macos-latest

Additionally, the original main job should be split into multiple separate jobs:

  • build
  • (format and) lint
  • test
  • e2e

Only test and e2e should use matrix strategies.

Copy link
Contributor Author

Copilot AI commented Oct 2, 2025

@copilot Only use these runners:

  • ubuntu-latest
  • windows-latest
    ...

Updated in commit ac12be8. The workflow now has four separate jobs:

  • build: Runs on ubuntu-latest
  • lint: Runs on ubuntu-latest (includes format check for PRs)
  • test: Matrix strategy with Node.js 18/20 on ubuntu-latest and Node.js 22 on ubuntu-24.04-arm
  • e2e: Matrix strategy across all specified runners (ubuntu-latest, windows-latest, ubuntu-24.04-arm, windows-11-arm, macos-15-intel, macos-latest)

Copilot AI changed the title feat: add matrix strategy for testing across OS/arch/Node versions feat: split CI workflow into separate jobs with matrix testing Oct 2, 2025
@LayZeeDK
Copy link
Member

LayZeeDK commented Oct 2, 2025

@copilot Extract reusable composite GitHub Actions, for example:

  • Checkout and set Nx SHAs
  • Set up Node.js and install packages
  • Post status check (pending/success/failure and context)

Copy link
Contributor Author

Copilot AI commented Oct 2, 2025

@copilot Extract reusable composite GitHub Actions, for example:

  • Checkout and set Nx SHAs
  • Set up Node.js and install packages
    ...

Extracted in commit 5962d6b. Created three composite actions:

  • .github/actions/checkout-and-set-nx-shas: Handles checkout and Nx SHA derivation
  • .github/actions/setup-node-and-install: Sets up Node.js and installs packages
  • .github/actions/post-status-check: Posts pending/outcome status checks

The CI workflow now uses these actions across all jobs, reducing ~235 lines to ~170 lines.

Copilot AI changed the title feat: split CI workflow into separate jobs with matrix testing feat: split CI workflow into separate jobs with reusable composite actions Oct 2, 2025
@LayZeeDK
Copy link
Member

LayZeeDK commented Oct 2, 2025

@copilot The composite actions need permissions or checkout

Error: Can't find 'action.yml', 'action.yaml' or 'Dockerfile' under '/home/runner/work/nxworker-19/nxworker-19/.github/actions/checkout-and-set-nx-shas'. Did you forget to run actions/checkout before running your local action?

Copy link
Contributor Author

Copilot AI commented Oct 2, 2025

@copilot The composite actions need permissions or checkout

Error: Can't find 'action.yml', 'action.yaml' or 'Dockerfile' under '/home/runner/work/nxworker-19/nxworker-19/.github/actions/checkou...

Fixed in commit 45df7ea. The repository is now checked out before using composite actions. The workflow now:

  1. Checks out the repository in each job (with proper ref handling for workflow_dispatch)
  2. Uses the set-nx-shas composite action to derive SHAs
  3. Uses setup-node-and-install and post-status-check composite actions

The checkout logic is now in the workflow itself rather than inside a composite action.

@LayZeeDK
Copy link
Member

LayZeeDK commented Oct 2, 2025

@copilot e2e jobs should use a build artifact from the build job as their package

Copy link
Contributor Author

Copilot AI commented Oct 2, 2025

@copilot e2e jobs should use a build artifact from the build job as their package

Implemented in commit d1bc953. The e2e jobs now:

  1. Depend on the build job (needs: build)
  2. Download build artifacts from the build job
  3. Use the pre-built packages instead of rebuilding

The build job uploads the dist/ directory as artifacts (retained for 1 day), and all e2e jobs download and use these same artifacts. This ensures all platforms test the exact same build and speeds up the e2e tests.

Copilot AI changed the title feat: split CI workflow into separate jobs with reusable composite actions feat: split CI workflow into separate jobs with reusable composite actions and build artifacts Oct 2, 2025
Copy link
Member

@LayZeeDK LayZeeDK left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

@LayZeeDK LayZeeDK left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot AI and others added 24 commits October 4, 2025 17:37
Co-authored-by: LayZeeDK <6364586+LayZeeDK@users.noreply.github.com>
Co-authored-by: LayZeeDK <6364586+LayZeeDK@users.noreply.github.com>
Co-authored-by: LayZeeDK <6364586+LayZeeDK@users.noreply.github.com>
Co-authored-by: LayZeeDK <6364586+LayZeeDK@users.noreply.github.com>
Co-authored-by: LayZeeDK <6364586+LayZeeDK@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: LayZeeDK <6364586+LayZeeDK@users.noreply.github.com>
Co-authored-by: LayZeeDK <6364586+LayZeeDK@users.noreply.github.com>
…lable

Co-authored-by: LayZeeDK <6364586+LayZeeDK@users.noreply.github.com>
Co-authored-by: LayZeeDK <6364586+LayZeeDK@users.noreply.github.com>
Co-authored-by: LayZeeDK <6364586+LayZeeDK@users.noreply.github.com>
Co-authored-by: LayZeeDK <6364586+LayZeeDK@users.noreply.github.com>
Co-authored-by: LayZeeDK <6364586+LayZeeDK@users.noreply.github.com>
…d action.yml

Co-authored-by: LayZeeDK <6364586+LayZeeDK@users.noreply.github.com>
- Change build job to build all projects instead of only affected ones
- Always use --excludeTaskDependencies in e2e job for consistency
- Add documentation explaining the rationale for these changes

Co-authored-by: LayZeeDK <6364586+LayZeeDK@users.noreply.github.com>
Co-authored-by: LayZeeDK <6364586+LayZeeDK@users.noreply.github.com>
Co-authored-by: LayZeeDK <6364586+LayZeeDK@users.noreply.github.com>
…us-check

Co-authored-by: LayZeeDK <6364586+LayZeeDK@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@LayZeeDK LayZeeDK force-pushed the copilot/fix-1aed1b67-1164-4160-a8f4-4a8b6243b29c branch from c5c7952 to 5db32f4 Compare October 4, 2025 15:37
@LayZeeDK LayZeeDK requested a review from Copilot October 4, 2025 15:39
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

Copilot reviewed 18 out of 20 changed files in this pull request and generated 1 comment.


Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@LayZeeDK LayZeeDK merged commit 751ee46 into main Oct 4, 2025
16 checks passed
@LayZeeDK LayZeeDK deleted the copilot/fix-1aed1b67-1164-4160-a8f4-4a8b6243b29c branch October 4, 2025 15:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Test on all operating systems, CPU architectures, and supported Node.js versions

2 participants