please do it for https://github.com/topics/neit-programming #4248
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Test | |
on: | |
push: | |
branches: | |
- main | |
pull_request: | |
workflow_dispatch: | |
merge_group: | |
permissions: | |
contents: read | |
jobs: | |
test: | |
strategy: | |
fail-fast: false | |
matrix: | |
test_type: | |
- collections | |
- topics | |
- all | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4 | |
with: | |
fetch-depth: 0 | |
- name: Get non-topic and non-collection changed files | |
id: all | |
if: matrix.test_type == 'all' | |
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' | |
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' | |
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 }} | |
uses: ruby/setup-ruby@a2bbe5b1b236842c1cb7dd11e8e3b51e0a616acc # v1 | |
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) | |
run: bundle exec rake ${{ matrix.test_type }} | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
TOPIC_FILES: ${{ steps.topics.outputs.changed }} | |
COLLECTION_FILES: ${{ steps.collections.outputs.changed }} | |
TEST_ALL_FILES: ${{ steps.all.outputs.changed }} |