-
Notifications
You must be signed in to change notification settings - Fork 15
92 lines (76 loc) · 2.65 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
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
# This is a basic workflow to help you get started with Actions
name: busted
# Controls when the workflow will run
on:
# Triggers the workflow on push or pull request events but only for the master branch
push:
branches: [ master ]
pull_request:
branches: [ master ]
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
test:
if: ${{ ( github.event_name == 'pull_request' && github.actor == github.repository_owner ) || github.ref == 'refs/heads/master' }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- uses: leafo/gh-actions-lua@v9.1.0
with:
luaVersion: "5.1"
- uses: leafo/gh-actions-luarocks@v4
- name: Prepare dependencies
id: setup
run: |
luarocks install busted
luarocks install cluacov
luarocks install luacheck
# install stylua
- uses: JohnnyMorganz/stylua-action@v2
with:
token: ${{ secrets.GITHUB_TOKEN }}
version: latest
args: --version
- name: Run Tests with busted
id: test
run: |
make test
- name: Check Test Coverage with luacov
id: coverage
run: |
make coverage
# Switch to badges to push
- uses: actions/checkout@v3
with:
ref: badges
- name: Generate coverage badge
uses: emibcn/badge-action@v1
id: badge
with:
label: "luacov"
status: ${{ steps.coverage.outputs.coverage }}%
color: ${{
steps.coverage.outputs.coverage > 90 && 'green' ||
steps.coverage.outputs.coverage > 80 && 'yellow,green' ||
steps.coverage.outputs.coverage > 70 && 'yellow' ||
steps.coverage.outputs.coverage > 60 && 'orange,yellow' ||
steps.coverage.outputs.coverage > 50 && 'orange' ||
steps.coverage.outputs.coverage > 40 && 'red,orange' ||
steps.coverage.outputs.coverage > 30 && 'red,red,orange' ||
steps.coverage.outputs.coverage > 20 && 'red,red,red,orange' ||
'red' }}
path: "coverage.svg"
- name: Upload coverage badge
id: commit
run: |
git config --local user.email "action@github.com"
git config --local user.name "GitHub Action"
git add "coverage.svg"
# ignore if the command fails due to file not changing
git commit -m "Add/Update badge" || true
- name: Push
uses: ad-m/github-push-action@master
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
branch: badges