Skip to content

Commit ffa2cb1

Browse files
committed
Move to sudo-bot/action-shunit2
1 parent 387810d commit ffa2cb1

File tree

3 files changed

+20
-48
lines changed

3 files changed

+20
-48
lines changed

.gitattributes

+1
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,6 @@
33
.github export-ignore
44
postTest.sh export-ignore
55
tests.sh export-ignore
6+
run-tests.sh export-ignore
67
samples export-ignore
78
LICENSE.sig export-ignore

.github/workflows/tests.yml

+13-48
Original file line numberDiff line numberDiff line change
@@ -15,60 +15,25 @@ jobs:
1515
- "3308:3306"
1616
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3
1717
steps:
18-
- uses: actions/checkout@v1
19-
- name: Cache shunit2
20-
id: cache-shunit2-2_1_7
21-
uses: actions/cache@v1
22-
with:
23-
path: shunit2-2.1.8
24-
key: ${{ runner.os }}-shunit2-2.1.8
25-
- name: Install shunit
26-
if: steps.cache-shunit2-2_1_7.outputs.cache-hit != 'true'
27-
run: |
28-
wget https://github.com/kward/shunit2/archive/v2.1.8.tar.gz -O shunit2-2.1.8.tar.gz && tar zxf shunit2-2.1.8.tar.gz && rm shunit2-2.1.8.tar.gz
29-
chmod +x ./shunit2-2.1.8/shunit2
30-
- name: Cache apt
31-
id: cache-apt
32-
uses: actions/cache@v1
33-
with:
34-
path: ~/.apt-cache
35-
key: ${{ runner.os }}-apt
36-
- name: Install needed packages
37-
run: |
38-
sudo rm -rf /var/cache/apt/archives && sudo ln -s ~/.apt-cache /var/cache/apt/archives && mkdir -p ~/.apt-cache/partial
39-
sudo apt-get install mysql-client libcurl4-openssl-dev libelf-dev libdw-dev cmake -y --no-install-recommends
40-
sudo chmod -R 777 ~/.apt-cache
41-
- name: Cache kcov
42-
id: cache-kcov-38
43-
uses: actions/cache@v1
18+
- uses: actions/checkout@v2
19+
- name: prepare mysql server
20+
env:
21+
TEST_MYSQL_HOST: "127.0.0.1"
22+
TEST_MYSQL_USER: root
23+
TEST_MYSQL_PASS: testbench
24+
TEST_MYSQL_PORT: ${{ job.services.mysql.ports['3306'] }}
25+
run: mysql --host ${TEST_MYSQL_HOST} -u${TEST_MYSQL_USER} -p${TEST_MYSQL_PASS} --port ${TEST_MYSQL_PORT} -e "use mysql; delete from user where User != 'root' OR host != '%'; update user set authentication_string=PASSWORD('testbench'), host='%', password_last_changed=FROM_UNIXTIME(1523829600) where User='root'; update user set plugin='mysql_native_password'; delete from user where User = 'sys'; FLUSH PRIVILEGES;"
26+
- name: run my tests
27+
uses: sudo-bot/action-shunit2@latest
4428
with:
45-
path: kcov-38
46-
key: ${{ runner.os }}-kcov-38
47-
- name: Install kcov
48-
if: steps.cache-kcov-38.outputs.cache-hit != 'true'
49-
run: |
50-
wget https://github.com/SimonKagstrom/kcov/archive/v38.tar.gz &&
51-
tar xzf v38.tar.gz && cd kcov-38 && mkdir build && cd build &&
52-
cmake -DCMAKE_INSTALL_PREFIX=/usr .. && make &&
53-
sudo make install && cd ../.. &&
54-
kcov --version
55-
- name: Install kcov from cache
56-
if: steps.cache-kcov-38.outputs.cache-hit == 'true'
57-
run: |
58-
cd kcov-38/build && sudo make install && cd ../.. &&
59-
kcov --version
60-
- name: Run tests and coverage
29+
cli: "./run-tests.sh"
6130
env:
6231
TEST_MYSQL_HOST: "127.0.0.1"
6332
TEST_MYSQL_USER: root
6433
TEST_MYSQL_PASS: testbench
6534
TEST_MYSQL_PORT: ${{ job.services.mysql.ports['3306'] }}
66-
run: |
67-
mysql --host ${TEST_MYSQL_HOST} -u${TEST_MYSQL_USER} -p${TEST_MYSQL_PASS} --port ${TEST_MYSQL_PORT} -e "use mysql; delete from user where User != 'root' OR host != '%'; update user set authentication_string=PASSWORD('testbench'), host='%', password_last_changed=FROM_UNIXTIME(1523829600) where User='root'; update user set plugin='mysql_native_password'; delete from user where User = 'sys'; FLUSH PRIVILEGES;"
68-
./tests.sh
69-
kcov --include-pattern=backup.sh,tests.sh --exclude-pattern=coverage $(pwd)/coverage ./tests.sh
70-
mv $(pwd)/coverage/tests.sh/cov.xml $(pwd)/cov.xml
71-
sleep 2
35+
- name: move coverage
36+
run: mv $(pwd)/coverage/tests.sh/cov.xml $(pwd)/cov.xml
7237
- name: Send coverage
7338
uses: codecov/codecov-action@v1
7439
with:

run-tests.sh

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#!/bin/sh
2+
3+
apk add --no-cache mysql-client
4+
5+
./tests.sh
6+
kcov --include-pattern=backup.sh,tests.sh --exclude-pattern=coverage ./coverage ./tests.sh

0 commit comments

Comments
 (0)