Problem Description
The validation jobs in check_build_test.yml use github.event.pull_request.changed_files.*.filename for conditional execution, which only works for pull request events. These jobs fail or are skipped when pushing directly to the main branch.
Affected Jobs
validate_dockerfile_debug
validate_dockerfile
validate_homebrew
shellcheck
Current Code
validate_dockerfile_debug:
name: Validate Debug Dockerfile
runs-on: ubuntu-latest
needs: check_changes
if: ${{ contains(github.event.pull_request.changed_files.*.filename, 'docker/DockerfileDebug') }}
timeout-minutes: 30
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Validate Debug Docker files
run: docker build -f docker/DockerfileDebug -t rooch-test-debug .
Issue
When triggered by push event (not pull_request), github.event.pull_request is undefined, causing these jobs to fail with:
Error: Cannot read property 'changed_files' of undefined
Proposed Solutions
Option 1: Use dorny/paths-filter (Recommended)
Use the same dorny/paths-filter@v3 action that's already used in the check_changes job:
check_changes:
# ... existing filters ...
filters: |
core: ...
sdk_web: ...
scripts: ...
# Add new filters
dockerfile_debug:
- 'docker/DockerfileDebug'
dockerfile:
- 'docker/Dockerfile'
homebrew:
- 'Formula/**'
Then update validation jobs:
validate_dockerfile_debug:
name: Validate Debug Dockerfile
runs-on: ubuntu-latest
needs: check_changes
if: ${{ needs.check_changes.outputs.dockerfile_debug == 'true' }}
timeout-minutes: 30
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Validate Debug Docker files
run: docker build -f docker/DockerfileDebug -t rooch-test-debug .
Option 2: Split to Separate Workflow File
Create a new workflow file .github/workflows/validation.yml:
name: Validation Checks
on:
pull_request:
branches: ['main']
push:
branches: ['main']
jobs:
check_validation_changes:
name: Check Validation Changes
runs-on: ubuntu-latest
outputs:
dockerfile_debug: ${{ steps.changes.outputs.dockerfile_debug }}
dockerfile: ${{ steps.changes.outputs.dockerfile }}
homebrew: ${{ steps.changes.outputs.homebrew }}
shell_scripts: ${{ steps.changes.outputs.shell_scripts }}
timeout-minutes: 5
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Filter Changed Files
uses: dorny/paths-filter@v3
id: changes
with:
filters: |
dockerfile_debug:
- 'docker/DockerfileDebug'
dockerfile:
- 'docker/Dockerfile'
homebrew:
- 'Formula/**'
shell_scripts:
- 'scripts/**'
validate_dockerfile_debug:
name: Validate Debug Dockerfile
runs-on: ubuntu-latest
needs: check_validation_changes
if: ${{ needs.check_validation_changes.outputs.dockerfile_debug == 'true' }}
timeout-minutes: 30
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Validate Debug Docker files
run: docker build -f docker/DockerfileDebug -t rooch-test-debug .
validate_dockerfile:
name: Validate Dockerfile
runs-on: ubuntu-latest
needs: check_validation_changes
if: ${{ needs.check_validation_changes.outputs.dockerfile == 'true' }}
timeout-minutes: 30
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Validate Docker files
run: docker build -f docker/Dockerfile -t rooch-test .
validate_homebrew:
name: Validate Homebrew Formula
runs-on: ubuntu-latest
needs: check_validation_changes
if: ${{ needs.check_validation_changes.outputs.homebrew == 'true' }}
timeout-minutes: 15
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Validate Homebrew formula
run: |
brew audit --strict --online Formula/rooch.rb
shellcheck:
name: ShellCheck
runs-on: ubuntu-latest
needs: check_validation_changes
if: ${{ needs.check_validation_changes.outputs.shell_scripts == 'true' }}
timeout-minutes: 15
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Run ShellCheck
uses: Azbagheri/shell-linter@v0.8.0
with:
path: 'scripts/*.sh'
severity: 'error'
Benefits of Separate Workflow
- Separation of Concerns: Main workflow focuses on build/test, validation workflow focuses on file format validation
- Independent Execution: Validation jobs can run independently without blocking main CI
- Easier Maintenance: Clear distinction between testing and validation logic
- Faster Feedback: Validation jobs can complete independently
- Better Organization: Related validation checks grouped together
Recommendation
Use Option 2 (separate workflow) because:
- Better organizational structure
- Validation checks are conceptually different from build/test
- Allows independent execution and maintenance
- Prevents bloating the already complex
check_build_test.yml file
- Makes it easier to add more validation checks in the future
Related Issues
Problem Description
The validation jobs in
check_build_test.ymlusegithub.event.pull_request.changed_files.*.filenamefor conditional execution, which only works for pull request events. These jobs fail or are skipped when pushing directly to the main branch.Affected Jobs
validate_dockerfile_debugvalidate_dockerfilevalidate_homebrewshellcheckCurrent Code
Issue
When triggered by
pushevent (notpull_request),github.event.pull_requestis undefined, causing these jobs to fail with:Proposed Solutions
Option 1: Use dorny/paths-filter (Recommended)
Use the same
dorny/paths-filter@v3action that's already used in thecheck_changesjob:Then update validation jobs:
Option 2: Split to Separate Workflow File
Create a new workflow file
.github/workflows/validation.yml:Benefits of Separate Workflow
Recommendation
Use Option 2 (separate workflow) because:
check_build_test.ymlfileRelated Issues