-
Notifications
You must be signed in to change notification settings - Fork 15
136 lines (119 loc) · 4.11 KB
/
ci.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
134
135
name: Moodle CI Runner CI
on: [push, pull_request, workflow_dispatch]
jobs:
collect:
name: Collect tests
runs-on: ubuntu-latest
outputs:
matrix: ${{steps.collect-tests.outputs.matrix }}
steps:
- name: Checking out moodl-ci-runner
uses: actions/checkout@v4
with:
submodules: true
- name: Collecting Bats tests
id: collect-tests
run: |
# Get all the test files without extension.
echo "matrix=$(cd test && find . -iname '*.bats' -not -path '*/helpers/*' -exec basename {} .bats ';' | \
jq -R -s -c 'split("\n")[:-1]')" >> $GITHUB_OUTPUT
test:
name: Test
needs: collect
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
test: ${{ fromJson(needs.collect.outputs.matrix) }}
steps:
- name: Install required packages
run: |
sudo apt-get update
sudo apt-get install uuid dc
- name: Checking out moodle-ci-runner
uses: actions/checkout@v4
with:
submodules: true
- name: Checking out Moodle
uses: actions/checkout@v4
with:
repository: moodle/moodle
fetch-depth: 0 # We need a complete clone, because we use various commits / tags.
path: moodle
- name: Checking out moodle-local_ci
uses: actions/checkout@v4
with:
repository: moodlehq/moodle-local_ci
path: local_ci
- name: Setup Bats
uses: bats-core/[email protected]
with:
bats-version: 1.11.0
# Note we don't need any of the libraries because the ones we need (support and assert)
# are bundled within test/helpers as git submodules and have been checked out above.
support-path: false
assert-path: false
detik-install: false
file-install: false
- name: Run tests
env:
MOODLE_CI_RUNNER_GITDIR: ${{ github.workspace }}/moodle
LOCAL_CI_PATH: ${{ github.workspace }}/local_ci
run: |
bats --timing test/${{ matrix.test }}.bats
coverage:
if: github.repository == 'moodlehq/moodle-ci-runner'
name: Code coverage
needs: collect
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
test: ${{ fromJson(needs.collect.outputs.matrix) }}
steps:
- name: Install required packages
run: |
sudo apt-get update
sudo apt-get install uuid dc kcov
- name: Checking out moodle-ci-runner
uses: actions/checkout@v4
with:
submodules: true
- name: Checking out Moodle
uses: actions/checkout@v4
with:
repository: moodle/moodle
fetch-depth: 0 # We need a complete clone, because we use various commits / tags.
path: moodle
- name: Checking out moodle-local_ci
uses: actions/checkout@v4
with:
repository: moodlehq/moodle-local_ci
path: local_ci
- name: Setup Bats
uses: bats-core/[email protected]
with:
bats-version: 1.11.0
# Note we don't need any of the libraries because the ones we need (support and assert)
# are bundled within test/helpers as git submodules and have been checked out above.
support-path: false
assert-path: false
detik-install: false
file-install: false
- name: Run tests (capturing code coverage)
env:
MOODLE_CI_RUNNER_GITDIR: ${{ github.workspace }}/moodle
LOCAL_CI_PATH: ${{ github.workspace }}/local_ci
run: |
kcov \
--clean \
--include-path ${{ github.workspace }}/runner/main \
--bash-parse-files-in-dir ${{ github.workspace }}/runner/main \
${{ github.workspace }}/coverage \
bats ${{ github.workspace }}/test/${{ matrix.test }}.bats
- name: Upload code coverage (codecov)
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
directory: ${{ github.workspace }}/coverage
flags: ${{ matrix.test }}