-
Notifications
You must be signed in to change notification settings - Fork 627
133 lines (120 loc) · 4.91 KB
/
PR.yml
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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
name: PR-Test
on:
pull_request:
merge_group:
permissions:
contents: read
jobs:
determine-workflows-to-run:
name: Determine workflows to run
runs-on: ubuntu-latest
outputs:
run_docs: ${{ steps.check_files.outputs.run_docs }}
run_tests: ${{ steps.check_files.outputs.run_tests }}
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 2
- name: check modified files
id: check_files
run: |
echo "run_docs=false" >> $GITHUB_OUTPUT
echo "run_tests=false" >> $GITHUB_OUTPUT
echo "=============== list modified files ==============="
git diff --name-only HEAD^ HEAD
echo "========== check paths of modified files =========="
git diff --name-only HEAD^ HEAD > files.txt
while IFS= read -r file
do
echo $file
if [[ $file != documentation/* ]]; then
echo "This modified file is not under the 'documentation' folder. Will run tests."
echo "run_tests=true" >> $GITHUB_OUTPUT
else
echo "This modified file is under the 'documentation' folder. Will run docs workflow."
echo "run_docs=true" >> $GITHUB_OUTPUT
fi
done < files.txt
api_check:
needs: [ determine-workflows-to-run ]
if: ${{ github.repository == 'kotest/kotest' && needs.determine-workflows-to-run.outputs.run_tests == 'true' }}
uses: ./.github/workflows/run-gradle.yml
with:
runs-on: ubuntu-latest
ref: ${{ inputs.ref }}
task: apiCheck
test_linux:
needs: [ api_check, determine-workflows-to-run ]
if: ${{ github.repository == 'kotest/kotest' && needs.determine-workflows-to-run.outputs.run_tests == 'true' }}
strategy:
matrix:
target:
- jvmTest
- jsTest
- wasmJsTest
- linuxX64Test linuxArm64TestKlibrary
- androidNativeX86TestKlibrary androidNativeX64TestKlibrary androidNativeArm32TestKlibrary androidNativeArm64TestKlibrary
- :kotest-framework:kotest-framework-multiplatform-plugin-gradle:test
uses: ./.github/workflows/run-gradle.yml
with:
runs-on: ubuntu-latest
ref: ${{ inputs.ref }}
task: ${{ matrix.target }}
test_mac:
needs: [ test_linux, determine-workflows-to-run ]
if: ${{ github.repository == 'kotest/kotest' && needs.determine-workflows-to-run.outputs.run_tests == 'true' }}
strategy:
fail-fast: true
matrix:
target:
- macosX64Test macosArm64Test
- iosX64Test iosSimulatorArm64Test iosArm64TestKlibrary
- tvosX64Test tvosArm64TestKlibrary tvosSimulatorArm64Test
- watchosArm32TestKlibrary watchosArm64TestKlibrary watchosX64Test watchosSimulatorArm64Test watchosDeviceArm64TestKlibrary
uses: ./.github/workflows/run-gradle.yml
with:
runs-on: macos-latest
ref: ${{ inputs.ref }}
task: ${{ matrix.target }}
test_windows:
needs: [ api_check, determine-workflows-to-run ]
if: ${{ github.repository == 'kotest/kotest' && needs.determine-workflows-to-run.outputs.run_tests == 'true' }}
uses: ./.github/workflows/run-gradle.yml
with:
runs-on: windows-latest
ref: ${{ inputs.ref }}
task: mingwX64Test
test_docs:
needs: [ determine-workflows-to-run ]
if: ${{ github.repository == 'kotest/kotest' && needs.determine-workflows-to-run.outputs.run_docs == 'true' }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
ref: ${{ inputs.ref }}
- uses: actions/setup-node@v3
with:
node-version: '18.4.0'
- name: Build static docusaurus pages
run: |
npm --prefix documentation ci
npm --prefix documentation run build
finalize:
# see https://github.community/t/status-check-for-a-matrix-jobs/127354/7
name: Final PR results
needs: [ api_check, test_linux, test_mac, test_windows, test_docs ]
if: ${{ always() }}
runs-on: ubuntu-latest
steps:
- name: Check all job status
# see https://docs.github.com/en/actions/reference/context-and-expression-syntax-for-github-actions#needs-context
# see https://stackoverflow.com/a/67532120/4907315
# Note: skipped results are OK in our case, we don't run code tests if there's only docs changes
if: >-
${{
contains(needs.*.result, 'failure')
|| contains(needs.*.result, 'cancelled')
}}
run: exit 1