-
Notifications
You must be signed in to change notification settings - Fork 14.2k
71 lines (62 loc) · 2.77 KB
/
test.yml
File metadata and controls
71 lines (62 loc) · 2.77 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
name: Test
on:
push:
branches:
- main
pull_request:
workflow_dispatch:
merge_group:
schedule:
- cron: "0 */6 * * *"
permissions:
contents: read
jobs:
test:
strategy:
fail-fast: false
matrix:
test_type:
- collections
- topics
- all
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6.0.1
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' && 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' && 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' && 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 || 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 || 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'))
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 }}