|
| 1 | +name: Run tests |
| 2 | + |
| 3 | +on: [push] |
| 4 | + |
| 5 | +jobs: |
| 6 | + test-sh: |
| 7 | + name: Test files and run coverage |
| 8 | + runs-on: ubuntu-latest |
| 9 | + services: |
| 10 | + mysql: |
| 11 | + image: mysql:5.7 |
| 12 | + env: |
| 13 | + MYSQL_ROOT_PASSWORD: testbench |
| 14 | + ports: |
| 15 | + - "3308:3306" |
| 16 | + options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3 |
| 17 | + 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.7 |
| 24 | + key: ${{ runner.os }}-shunit2-2.1.7 |
| 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.7.tar.gz -O shunit2-2.1.7.tar.gz && tar zxf shunit2-2.1.7.tar.gz && rm shunit2-2.1.7.tar.gz |
| 29 | + chmod +x ./shunit2-2.1.7/shunit2 |
| 30 | + - name: Cache apt |
| 31 | + id: cache-apt |
| 32 | + uses: actions/cache@v1 |
| 33 | + with: |
| 34 | + path: /var/cache/apt/ |
| 35 | + key: ${{ runner.os }}-apt |
| 36 | + - name: Install needed packages |
| 37 | + run: sudo apt-get install mysql-client libcurl4-openssl-dev libelf-dev libdw-dev cmake -y --no-install-recommends |
| 38 | + - name: Cache kcov |
| 39 | + id: cache-kcov-37 |
| 40 | + uses: actions/cache@v1 |
| 41 | + with: |
| 42 | + path: kcov-37 |
| 43 | + key: ${{ runner.os }}-kcov-37 |
| 44 | + - name: Install kcov |
| 45 | + if: steps.cache-kcov-37.outputs.cache-hit != 'true' |
| 46 | + run: | |
| 47 | + wget https://github.com/SimonKagstrom/kcov/archive/v37.tar.gz && |
| 48 | + tar xzf v37.tar.gz && cd kcov-37 && mkdir build && cd build && |
| 49 | + cmake -DCMAKE_INSTALL_PREFIX=/usr .. && make && |
| 50 | + sudo make install && cd ../.. && |
| 51 | + kcov --version |
| 52 | + - name: Run tests and coverage |
| 53 | + env: |
| 54 | + TEST_MYSQL_HOST: "127.0.0.1" |
| 55 | + TEST_MYSQL_USER: root |
| 56 | + TEST_MYSQL_PASS: testbench |
| 57 | + TEST_MYSQL_PORT: ${{ job.services.mysql.ports['3306'] }} |
| 58 | + run: | |
| 59 | + 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;" |
| 60 | + ./tests.sh |
| 61 | + kcov --include-pattern=backup.sh,tests.sh --exclude-pattern=coverage coverage ./tests.sh |
| 62 | + sleep 2 |
| 63 | + - name: Send coverage |
| 64 | + uses: codecov/codecov-action@v1 |
| 65 | + with: |
| 66 | + token: ${{ secrets.CODECOV_TOKEN }} |
0 commit comments