| name: test |
| |
| on: |
| push: |
| branches: [ master ] |
| pull_request: |
| branches: [ master ] |
| |
| jobs: |
| test: |
| runs-on: ubuntu-latest |
| services: |
| postgres: |
| image: postgres |
| env: |
| POSTGRES_PASSWORD: postgres |
| POSTGRES_USER: postgres |
| POSTGRES_DB: casbin |
| POSTGRES_HOST: localhost |
| ports: |
| - 5432:5432 |
| options: |
| --health-cmd pg_isready |
| --health-interval 10s |
| --health-timeout 5s |
| --health-retries 5 |
| |
| strategy: |
| fail-fast: true |
| matrix: |
| lua-version: ["5.1", "5.2", "5.3", "5.4", "luajit"] |
| |
| name: Lua ${{ matrix.lua-version }} |
| |
| steps: |
| - name: Checkout |
| uses: actions/checkout@v2 |
| |
| - name: Set up Lua ${{ matrix.lua-version }} |
| uses: leafo/gh-actions-lua@v8.0.0 |
| with: |
| luaVersion: ${{ matrix.lua-version }} |
| |
| - name: Set up luarocks |
| uses: leafo/gh-actions-luarocks@v4.0.0 |
| |
| - name: Install PCRE |
| run: | |
| sudo apt-get update |
| sudo apt-get install libpcre3 libpcre3-dev |
| |
| - name: Install Casbin, dependencies and setup environment |
| env: |
| MYSQL_DB: casbin |
| MYSQL_USER: root |
| MYSQL_PASSWORD: root |
| run: | |
| sudo /etc/init.d/mysql start |
| mysql -e 'CREATE DATABASE ${{ env.MYSQL_DB }};' -u${{ env.MYSQL_USER }} -p${{ env.MYSQL_PASSWORD }} |
| luarocks install casbin |
| sudo apt install sqlite3 libsqlite3-dev lua-sql-mysql libpq-dev |
| luarocks install luasql-mysql MYSQL_INCDIR=/usr/include/mysql/ |
| luarocks install luasql-postgres PGSQL_INCDIR=/usr/include/postgresql/ |
| luarocks install luasql-sqlite3 |
| luarocks install busted |
| luarocks install busted-htest |
| luarocks install luacov-coveralls |
| |
| - name: Run tests |
| run: | |
| sudo env "LUA_PATH=$LUA_PATH" "PATH=$PATH" "LUA_CPATH=$LUA_CPATH" busted tests -o htest |
| |
| - name: Reporting test coverage |
| run: | |
| sudo env "LUA_PATH=$LUA_PATH" "PATH=$PATH" "LUA_CPATH=$LUA_CPATH" busted tests -c -v |
| luacov-coveralls -e .luarocks -e tests |
| env: |
| COVERALLS_REPO_TOKEN: ${{ secrets.GITHUB_TOKEN }} |