-
Notifications
You must be signed in to change notification settings - Fork 4
136 lines (117 loc) · 4.47 KB
/
coverage.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
136
name: Coverage
on:
push:
pull_request:
issue_comment:
jobs:
build:
name: Build OpenResty ${{ matrix.openresty_version }}
runs-on: ubuntu-20.04
if: |
(github.event_name == 'push' && contains(github.event.commits[0].message, '/coverage')) ||
(github.event_name == 'issue_comment' && github.event.action == 'created' &&
github.event.issue.pull_request &&
contains('["OWNER", "COLLABORATOR", "MEMBER"]', github.event.comment.author_association) &&
startsWith(github.event.comment.body, '/coverage')
)
strategy:
matrix:
openresty_version:
- "1.19.9.1"
- "1.21.4.1"
env:
OPENRESTY_VERSION: ${{ matrix.openresty_version }}
steps:
- name: Set environment variables
run: |
echo "INSTALL_ROOT=$HOME/install-root" >> $GITHUB_ENV
echo "DOWNLOAD_ROOT=$HOME/download-root" >> $GITHUB_ENV
mkdir -p $HOME/install-root
mkdir -p $HOME/download-root
- name: Lookup build cache
uses: actions/cache@v2
id: cache-openresty
with:
path: ${{ env.INSTALL_ROOT }}
key: ${{ env.OPENRESTY_VERSION }}
- name: Download OpenResty
if: steps.cache-openresty.outputs.cache-hit != 'true'
run: |
wget https://openresty.org/download/openresty-${OPENRESTY_VERSION}.tar.gz -O openresty.tar.gz
mkdir openresty
tar zxf openresty.tar.gz --directory openresty --strip-components=1
- name: Install
if: steps.cache-openresty.outputs.cache-hit != 'true'
run: |
cd openresty
sudo ./configure --prefix=${{ env.INSTALL_ROOT }}/openresty
sudo make -j$(nproc)
sudo make install
coverage:
name: Test ${{ matrix.openresty_version }}
runs-on: ubuntu-20.04
needs: build
if: |
(github.event_name == 'push' && contains(github.event.commits[0].message, '/coverage')) ||
(github.event_name == 'issue_comment' && github.event.action == 'created' &&
github.event.issue.pull_request &&
contains('["OWNER", "COLLABORATOR", "MEMBER"]', github.event.comment.author_association) &&
startsWith(github.event.comment.body, '/coverage')
)
strategy:
matrix:
openresty_version:
- "1.19.9.1"
- "1.21.4.1"
env:
OPENRESTY_VERSION: ${{ matrix.openresty_version }}
steps:
- name: Set environment variables
run: |
echo "INSTALL_ROOT=$HOME/install-root" >> $GITHUB_ENV
echo "DOWNLOAD_ROOT=$HOME/download-root" >> $GITHUB_ENV
mkdir -p $HOME/install-root
mkdir -p $HOME/download-root
- name: Install dependencies
run: |
sudo apt-get --yes update
sudo apt-get install --yes build-essential zlib1g-dev libpcre3 libpcre3-dev libssl-dev libxslt1-dev libxml2-dev libgeoip-dev libgd-dev libperl-dev
- name: Lookup build cache
uses: actions/cache@v2
id: cache-openresty
with:
path: ${{ env.INSTALL_ROOT }}
key: ${{ env.OPENRESTY_VERSION }}
- name: Install LuaRocks
run: |
sudo ln -s ${{ env.INSTALL_ROOT }}/openresty/bin/resty /bin/resty
sudo ln -s ${{ env.INSTALL_ROOT }}/openresty/luajit/bin/luajit /bin/luajit
pushd ${{ env.DOWNLOAD_ROOT }}
wget https://luarocks.org/releases/luarocks-3.8.0.tar.gz -O luarocks.tar.gz
mkdir luarocks
tar zxf luarocks.tar.gz --directory luarocks --strip-components=1
pushd luarocks
sudo ./configure --with-lua-include=${{ env.INSTALL_ROOT }}/openresty/luajit/include/luajit-2.1 --with-lua-lib=${{ env.INSTALL_ROOT }}/openresty/luajit/lib --with-lua-interpreter=luajit
sudo make -j$(nproc)
sudo make install
popd
popd
- name: Install busted
run: |
sudo luarocks install busted
sudo luarocks install busted-htest
sudo luarocks install luacov
sudo luarocks install luacov-console
- name: Checkout source code
uses: actions/checkout@v2
- name: Tests
run: |
eval $(luarocks path)
resty -I lib -I spec spec/runner.lua --coverage --verbose -o htest --shuffle-tests spec/
- name: Show coverage
run: |
eval $(luarocks path)
luacov lib/resty/timerng
luacov-console lib/resty/timerng
luacov-console -s
luacov-console -l lib/resty/timerng/*