-
Notifications
You must be signed in to change notification settings - Fork 6
62 lines (55 loc) · 2.1 KB
/
tests.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
name: Tests
on:
push:
pull_request:
workflow_dispatch:
jobs:
testsuite:
name: Unit Tests
runs-on: ubuntu-20.04
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Start DDEV
uses: jonaseberle/github-action-setup-ddev@v1
- name: Install composer packages
run: ddev composer install --no-interaction
- name: Run unit tests
run: ddev run-unit-tests
- name: Run code coverage
if: ${{ github.ref == 'refs/heads/main' }}
id: code-coverage
run: |
ddev xdebug on
coverage=$(ddev run-unit-tests -c | grep -oE '^\s*Lines:\s*[0-9\.]+%' | grep -oE '[0-9\.]+')
ddev xdebug off
if (( $(echo "$coverage < 50" | bc -l) )); then
color=red
elif (( $(echo "$coverage < 80" | bc -l) )); then
color=orange
else
color=green
fi
echo "::set-output name=coverage::$coverage"
echo "::set-output name=color::$color"
# Third-party GitHub action "Bring Your Own Badge"
#
# This action creates a custom badge by
# - creating a common shields.json file in the branch "shields"
# - parsing this shields.json and creating the badge on-the-fly at the own server at https://byob.yarr.is
# where the server path has to match the GitHub repository path, e.g. for badge with ID "code-coverage"
# https://byob.yarr.is/TYPO3-Documentation/t3docs-screenshots/code-coverage
# =>
# https://github.com/TYPO3-Documentation/t3docs-screenshots/blob/shields/shields.json::code-coverage
#
# Use this third-party action until GitHub provides an internal solution for adding a code coverage badge.
- name: Create code coverage badge
if: ${{ github.ref == 'refs/heads/main' }}
uses: RubbaBoy/[email protected]
with:
NAME: code-coverage
ICON: 'github'
LABEL: 'Coverage'
STATUS: ${{ steps.code-coverage.outputs.coverage }}%
COLOR: ${{ steps.code-coverage.outputs.color }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}