aboutsummaryrefslogtreecommitdiff
path: root/.github/workflows/ci.yml
blob: 2e8364e04ac4e7fc7d9e52d60ce2557713599b42 (plain)
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
name: ci

on:
  pull_request:
  push:
    branches:
    - master

jobs:
  TestMatrix:
    strategy:
      matrix:
        lua-version: ["5.4", "5.3", "5.2", "5.1", "luajit"]
        os: ["ubuntu-latest"]
        libflag: ["-shared --coverage"]
        include:
        - os: "macos-latest"
          lua-version: "5.4"
          libflag: "-bundle -undefined dynamic_lookup -all_load --coverage"
        - os: "windows-latest"
          toolchain: "msvc"
          lua-version: "5.4"
        - os: "windows-latest"
          lua-version: "luajit"
    runs-on: ${{ matrix.os }}

    steps:
    - uses: actions/checkout@master

    - name: Setup MSVC
      # 'luarocks/gh-actions-lua' step requires msvc to build PUC-Rio Lua
      # versions on Windows (LuaJIT will be built using MinGW/gcc).
      if: ${{ matrix.toolchain == 'msvc' }}
      uses: ilammy/msvc-dev-cmd@v1

    - uses: luarocks/gh-actions-lua@master
      with:
        luaVersion: ${{ matrix.lua-version }}

    - uses: luarocks/gh-actions-luarocks@master

    - name: Prep luacov
      run: |
        luarocks install luacov

    - name: Prep luacov-coveralls
      # TODO Windows coverage
      if: ${{ matrix.os != 'windows-latest' }}
      run: |
        pip install --user cpp-coveralls
        # install luacov-coveralls, but avoid installing luafilesystem
        luarocks install lua-path 
        luarocks install dkjson
        luarocks install luacov-coveralls --server=https://luarocks.org/dev --deps-mode=none

    - name: Unix Build
      if: ${{ matrix.os != 'windows-latest' }}
      run: |
        luarocks make CFLAGS="-O2 -fPIC -ftest-coverage -fprofile-arcs" LIBFLAG="${{ matrix.libflag }}"

    - name: Windows Build
      # TODO Windows coverage
      if: ${{ matrix.os == 'windows-latest' }}
      run: |
        luarocks make

    - name: Test
      run: |
        lua -lluacov tests/test.lua

    - name: Coverage
      # TODO Windows coverage
      if: ${{ matrix.os != 'windows-latest' }}
      run: |
        export MY_PYTHON_VER=$(python -c 'import sys; print(".".join(sys.version.split(".")[0:2]))')
        export PATH="/Users/runner/Library/Python/$MY_PYTHON_VER/bin:$PATH"
        coveralls -b . -i src --dump c.report.json
        luacov-coveralls -j c.report.json -v -t ${{ secrets.GITHUB_TOKEN }}