Skip to content
Open
Changes from all 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
25 changes: 18 additions & 7 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ on:
pull_request:
workflow_dispatch:
merge_group:
schedule:
- cron: "0 */6 * * *"

permissions:
contents: read
Expand All @@ -26,32 +28,41 @@ jobs:
with:
fetch-depth: 0

- name: Determine if this is a scheduled or full run
id: run_type
run: |
if [[ "${{ github.event_name }}" == "schedule" || "${{ github.event_name }}" == "workflow_dispatch" ]]; then
echo "full_run=true" >> $GITHUB_OUTPUT
else
echo "full_run=false" >> $GITHUB_OUTPUT
fi

- name: Get non-topic and non-collection changed files
id: all
if: matrix.test_type == 'all'
if: matrix.test_type == 'all' && steps.run_type.outputs.full_run != 'true'
run: echo "changed=$(git diff --name-only --diff-filter=ACMRT ${{ github.event.pull_request.base.sha }} ${{ github.sha }} | grep -ve '^topics\/' -ve '^collections\/' | xargs)" >> $GITHUB_OUTPUT

- name: Get changed topic files
id: topics
if: matrix.test_type == 'topics'
if: matrix.test_type == 'topics' && steps.run_type.outputs.full_run != 'true'
run: echo "changed=$(git diff --name-only --diff-filter=ACMRT ${{ github.event.pull_request.base.sha }} ${{ github.sha }} | grep ^topics\/ | xargs)" >> $GITHUB_OUTPUT

- name: Get changed collection files
id: collections
if: matrix.test_type == 'collections'
if: matrix.test_type == 'collections' && steps.run_type.outputs.full_run != 'true'
run: echo "changed=$(git diff --name-only --diff-filter=ACMRT ${{ github.event.pull_request.base.sha }} ${{ github.sha }} | grep ^collections\/ | xargs)" >> $GITHUB_OUTPUT

- name: Setup Ruby
if: ${{ steps.topics.outputs.changed || steps.collections.outputs.changed || steps.all.outputs.changed }}
if: ${{ steps.topics.outputs.changed || steps.collections.outputs.changed || steps.all.outputs.changed || steps.run_type.outputs.full_run == 'true' }}
uses: ruby/setup-ruby@80740b3b13bf9857e28854481ca95a84e78a2bdf # v1.284.0
with:
bundler-cache: true

- name: Build and test with Rake
if: |
(matrix.test_type == 'topics' && steps.topics.outputs.changed) ||
(matrix.test_type == 'collections' && steps.collections.outputs.changed) ||
(matrix.test_type == 'all' && steps.all.outputs.changed)
(matrix.test_type == 'topics' && (steps.topics.outputs.changed || steps.run_type.outputs.full_run == 'true')) ||
(matrix.test_type == 'collections' && (steps.collections.outputs.changed || steps.run_type.outputs.full_run == 'true')) ||
(matrix.test_type == 'all' && (steps.all.outputs.changed || steps.run_type.outputs.full_run == 'true'))
Comment on lines 62 to +65
Copy link

Copilot AI Feb 13, 2026

Choose a reason for hiding this comment

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

The current implementation relies on a subtle Ruby behavior that may not be immediately obvious. When git diff steps are skipped during scheduled runs, the environment variables (TOPIC_FILES, COLLECTION_FILES, TEST_ALL_FILES) are set to empty strings. The test helpers check if ENV.fetch("TEST_ALL_FILES", false), and since empty strings are truthy in Ruby, this causes the wildcard pattern to be returned correctly.

However, this behavior is fragile and unclear:

  1. It relies on empty strings being truthy in Ruby (only nil and false are falsy)
  2. It depends on GitHub Actions evaluating undefined step outputs as empty strings
  3. The intended behavior is not explicit in the workflow

Consider making this more explicit and robust by either:

  1. Setting TEST_ALL_FILES to a clear sentinel value like "true" or "1" when full_run is true
  2. Adding a comment explaining this intentional behavior
  3. Using a dedicated full_run environment variable that the test helpers check explicitly

Copilot uses AI. Check for mistakes.
run: bundle exec rake ${{ matrix.test_type }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Expand Down
Loading