Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
114 changes: 114 additions & 0 deletions .github/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
# GitHub Actions CI/CD Configuration

This directory contains GitHub Actions workflows for continuous integration and deployment.

## PR Comment Commands

### `/run-skipped-ci` - Run Full CI Suite

When you open a PR, CI automatically runs a subset of tests for faster feedback (latest Ruby/Node versions only). To run the **complete CI suite** including all dependency combinations, add a comment to your PR:

```
/run-skipped-ci
```

This command will trigger:

- ✅ Main test suite with both latest and minimum supported versions
- ✅ All example app generator tests
- ✅ React on Rails Pro integration tests
- ✅ React on Rails Pro package tests

The bot will:

1. React with a 🚀 to your comment
2. Post a confirmation message with links to the triggered workflows
3. Start all CI jobs on your PR branch

### Why This Exists

By default, PRs run a subset of CI jobs to provide fast feedback:

- Only latest dependency versions (Ruby 3.4, Node 22)
- Skips example generator tests
- Skips some Pro package tests

This is intentional to keep PR feedback loops fast. However, before merging, you should verify compatibility across all supported versions. The `/run-skipped-ci` command makes this easy without waiting for the PR to be merged to master.

### Security & Access Control

**Only repository collaborators with write access can trigger full CI runs.** This prevents:

- Resource abuse from external contributors
- Unauthorized access to Pro package tests
- Potential DoS attacks via repeated CI runs

If an unauthorized user attempts to use `/run-skipped-ci`, they'll receive a message explaining the restriction.

### Concurrency Protection

Multiple `/run-skipped-ci` comments on the same PR will cancel in-progress runs to prevent resource waste and duplicate results.

## Testing Comment-Triggered Workflows

**Important**: Comment-triggered workflows (`issue_comment` event) only execute from the **default branch** (master). This creates a chicken-and-egg problem when developing workflow changes.

### Recommended Testing Approach

1. **Develop the workflow**: Create/modify the workflow in your feature branch
2. **Test locally**: Validate YAML syntax and logic as much as possible
3. **Merge to master**: The workflow must be in master to be triggered by comments
4. **Test on a PR**: Create a test PR and use the comment command to verify

### Why This Limitation Exists

GitHub Actions workflows triggered by `issue_comment` events always use the workflow definition from the default branch, not the PR branch. This is a security feature to prevent malicious actors from modifying workflows through PRs.

For more details, see [GitHub's documentation on issue_comment events](https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#issue_comment).

## Available Workflows

### CI Workflows (Triggered on Push/PR)

- **`main.yml`** - Main test suite (dummy app integration tests)
- **`lint-js-and-ruby.yml`** - Linting for JavaScript and Ruby code
- **`package-js-tests.yml`** - JavaScript unit tests for the package
- **`rspec-package-specs.yml`** - RSpec tests for the Ruby package
- **`examples.yml`** - Generator tests for example apps
- **`playwright.yml`** - Playwright E2E tests
- **`pro-integration-tests.yml`** - Pro package integration tests
- **`pro-package-tests.yml`** - Pro package unit tests
- **`pro-lint.yml`** - Pro package linting

### Utility Workflows

- **`run-skipped-ci.yml`** - Triggered by `/run-skipped-ci` comment on PRs
- **`pr-welcome-comment.yml`** - Auto-comments on new PRs with helpful info
- **`detect-changes.yml`** - Detects which parts of the codebase changed

### Code Review Workflows

- **`claude.yml`** - Claude AI code review
- **`claude-code-review.yml`** - Additional Claude code review checks

### Other Workflows

- **`check-markdown-links.yml`** - Validates markdown links

## Workflow Permissions

Most workflows use minimal permissions. The comment-triggered workflows require:

- `contents: read` - To read the repository code
- `pull-requests: write` - To post comments and reactions
- `actions: write` - To trigger other workflows

## Conditional Execution

Many workflows use change detection to skip unnecessary jobs:

- Runs all jobs on pushes to `master`
- Runs only relevant jobs on PRs based on changed files
- Can be overridden with `workflow_dispatch` or `/run-skipped-ci` command

See `script/ci-changes-detector` for the change detection logic.
8 changes: 6 additions & 2 deletions .github/workflows/examples.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,19 @@

examples:
needs: detect-changes
if: github.ref == 'refs/heads/master' || needs.detect-changes.outputs.run_generators == 'true'
# For regular PRs: only run latest versions
# For master/workflow_dispatch: run all versions
if: |
(github.ref == 'refs/heads/master' || github.event_name == 'workflow_dispatch' || needs.detect-changes.outputs.run_generators == 'true') &&

Check failure on line 44 in .github/workflows/examples.yml

View workflow job for this annotation

GitHub Actions / build

context "matrix" is not allowed here. available contexts are "github", "inputs", "needs", "vars". see https://docs.github.com/en/actions/learn-github-actions/contexts#context-availability for more details
(matrix.dependency-level != 'minimum' || github.ref == 'refs/heads/master' || github.event_name == 'workflow_dispatch')
strategy:
fail-fast: false
matrix:
include:
# Always run: Latest versions (fast feedback on PRs)
- ruby-version: '3.4'
dependency-level: 'latest'
# Master only: Minimum supported versions (full coverage)
# Master and workflow_dispatch: Minimum supported versions (full coverage)
- ruby-version: '3.2'
dependency-level: 'minimum'
env:
Expand Down
18 changes: 12 additions & 6 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,17 +38,20 @@

build-dummy-app-webpack-test-bundles:
needs: detect-changes
# Run on master OR when tests needed on PR (but skip minimum deps on PR)
# Run on master, workflow_dispatch, OR when tests needed on PR
# For regular PRs: only run latest versions
# For master/workflow_dispatch: run all versions
if: |
(github.ref == 'refs/heads/master' || needs.detect-changes.outputs.run_dummy_tests == 'true')
(github.ref == 'refs/heads/master' || github.event_name == 'workflow_dispatch' || needs.detect-changes.outputs.run_dummy_tests == 'true') &&

Check failure on line 45 in .github/workflows/main.yml

View workflow job for this annotation

GitHub Actions / build

context "matrix" is not allowed here. available contexts are "github", "inputs", "needs", "vars". see https://docs.github.com/en/actions/learn-github-actions/contexts#context-availability for more details
(matrix.dependency-level != 'minimum' || github.ref == 'refs/heads/master' || github.event_name == 'workflow_dispatch')
strategy:
matrix:
include:
# Always run: Latest versions (fast feedback on PRs)
- ruby-version: '3.4'
node-version: '22'
dependency-level: 'latest'
# Master only: Minimum supported versions (full coverage)
# Master and workflow_dispatch: Minimum supported versions (full coverage)
- ruby-version: '3.2'
node-version: '20'
dependency-level: 'minimum'
Expand Down Expand Up @@ -122,9 +125,12 @@

dummy-app-integration-tests:
needs: [detect-changes, build-dummy-app-webpack-test-bundles]
# Run on master OR when tests needed on PR (but skip minimum deps on PR)
# Run on master, workflow_dispatch, OR when tests needed on PR
# For regular PRs: only run latest versions
# For master/workflow_dispatch: run all versions
if: |
(github.ref == 'refs/heads/master' || needs.detect-changes.outputs.run_dummy_tests == 'true')
(github.ref == 'refs/heads/master' || github.event_name == 'workflow_dispatch' || needs.detect-changes.outputs.run_dummy_tests == 'true') &&

Check failure on line 132 in .github/workflows/main.yml

View workflow job for this annotation

GitHub Actions / build

context "matrix" is not allowed here. available contexts are "github", "inputs", "needs", "vars". see https://docs.github.com/en/actions/learn-github-actions/contexts#context-availability for more details
(matrix.dependency-level != 'minimum' || github.ref == 'refs/heads/master' || github.event_name == 'workflow_dispatch')
strategy:
fail-fast: false
matrix:
Expand All @@ -133,7 +139,7 @@
- ruby-version: '3.4'
node-version: '22'
dependency-level: 'latest'
# Master only: Minimum supported versions (full coverage)
# Master and workflow_dispatch: Minimum supported versions (full coverage)
- ruby-version: '3.2'
node-version: '20'
dependency-level: 'minimum'
Expand Down
38 changes: 38 additions & 0 deletions .github/workflows/pr-welcome-comment.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: PR Welcome Comment

on:
pull_request:
types: [opened]

jobs:
welcome:
# Skip for bots (dependabot, renovate, etc.)
if: github.event.pull_request.user.type != 'Bot'
runs-on: ubuntu-22.04
permissions:
pull-requests: write
steps:
- name: Add welcome comment with CI command info
uses: peter-evans/create-or-update-comment@v4
with:
issue-number: ${{ github.event.pull_request.number }}
body: |
👋 Thanks for opening this PR!

### 🚀 Running Full CI Suite

By default, PRs run a subset of CI jobs for faster feedback (latest Ruby/Node versions only).

To run the **complete CI suite** including all dependency combinations and skipped jobs, comment:

```
/run-skipped-ci
```

This will trigger:
- ✅ Minimum supported versions (Ruby 3.2, Node 20)
- ✅ All example app tests
- ✅ Pro package integration tests
- ✅ All test matrices

The full CI suite takes longer but ensures compatibility across all supported versions before merging.
6 changes: 3 additions & 3 deletions .github/workflows/pro-integration-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ jobs:
# Build webpack test bundles for dummy app
build-dummy-app-webpack-test-bundles:
needs: detect-changes
if: github.ref == 'refs/heads/master' || needs.detect-changes.outputs.run_pro_tests == 'true'
if: github.ref == 'refs/heads/master' || github.event_name == 'workflow_dispatch' || needs.detect-changes.outputs.run_pro_tests == 'true'
runs-on: ubuntu-22.04
env:
REACT_ON_RAILS_PRO_LICENSE: ${{ secrets.REACT_ON_RAILS_PRO_LICENSE }}
Expand Down Expand Up @@ -124,7 +124,7 @@ jobs:
needs:
- detect-changes
- build-dummy-app-webpack-test-bundles
if: github.ref == 'refs/heads/master' || needs.detect-changes.outputs.run_pro_tests == 'true'
if: github.ref == 'refs/heads/master' || github.event_name == 'workflow_dispatch' || needs.detect-changes.outputs.run_pro_tests == 'true'
runs-on: ubuntu-22.04
env:
REACT_ON_RAILS_PRO_LICENSE: ${{ secrets.REACT_ON_RAILS_PRO_LICENSE }}
Expand Down Expand Up @@ -304,7 +304,7 @@ jobs:
needs:
- detect-changes
- build-dummy-app-webpack-test-bundles
if: github.ref == 'refs/heads/master' || needs.detect-changes.outputs.run_pro_tests == 'true'
if: github.ref == 'refs/heads/master' || github.event_name == 'workflow_dispatch' || needs.detect-changes.outputs.run_pro_tests == 'true'
runs-on: ubuntu-22.04
env:
REACT_ON_RAILS_PRO_LICENSE: ${{ secrets.REACT_ON_RAILS_PRO_LICENSE }}
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/pro-package-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ jobs:
# Build webpack test bundles for dummy app
build-dummy-app-webpack-test-bundles:
needs: detect-changes
if: github.ref == 'refs/heads/master' || needs.detect-changes.outputs.run_pro_tests == 'true'
if: github.ref == 'refs/heads/master' || github.event_name == 'workflow_dispatch' || needs.detect-changes.outputs.run_pro_tests == 'true'
runs-on: ubuntu-22.04
env:
REACT_ON_RAILS_PRO_LICENSE: ${{ secrets.REACT_ON_RAILS_PRO_LICENSE }}
Expand Down Expand Up @@ -124,7 +124,7 @@ jobs:
needs:
- detect-changes
- build-dummy-app-webpack-test-bundles
if: github.ref == 'refs/heads/master' || needs.detect-changes.outputs.run_pro_tests == 'true'
if: github.ref == 'refs/heads/master' || github.event_name == 'workflow_dispatch' || needs.detect-changes.outputs.run_pro_tests == 'true'
runs-on: ubuntu-22.04
# Redis service container
services:
Expand Down Expand Up @@ -205,7 +205,7 @@ jobs:
# RSpec tests for Pro package
rspec-package-specs:
needs: detect-changes
if: github.ref == 'refs/heads/master' || needs.detect-changes.outputs.run_pro_tests == 'true'
if: github.ref == 'refs/heads/master' || github.event_name == 'workflow_dispatch' || needs.detect-changes.outputs.run_pro_tests == 'true'
strategy:
matrix:
ruby-version: ['3.3.7']
Expand Down
Loading
Loading