|
| 1 | +name: Test |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: [main] |
| 6 | + paths: |
| 7 | + - 'src/**' |
| 8 | + - 'lua/**' |
| 9 | + - '**/*.rockspec' |
| 10 | + - 'tests/**' |
| 11 | + - '.busted' |
| 12 | + - '.github/workflows/test.yml' |
| 13 | + pull_request: |
| 14 | + branches: [main] |
| 15 | + paths: |
| 16 | + - 'src/**' |
| 17 | + - 'lua/**' |
| 18 | + - '**/*.rockspec' |
| 19 | + - 'tests/**' |
| 20 | + - '.busted' |
| 21 | + - '.github/workflows/test.yml' |
| 22 | + workflow_dispatch: |
| 23 | + |
| 24 | +jobs: |
| 25 | + test: |
| 26 | + name: Run Tests (${{ matrix.os }}, ${{ matrix.lua-version }}) |
| 27 | + runs-on: ${{ matrix.os }} |
| 28 | + strategy: |
| 29 | + fail-fast: false |
| 30 | + matrix: |
| 31 | + lua-version: ["5.1", "5.2", "5.3", "5.4", "5.5", "luajit"] |
| 32 | + os: ["ubuntu-latest"] |
| 33 | + steps: |
| 34 | + - name: Checkout code |
| 35 | + uses: actions/checkout@v7 |
| 36 | + |
| 37 | + - name: Setup MSVC Developer Command Prompt |
| 38 | + if: ${{ runner.os == 'Windows' && matrix['lua-version'] != 'luajit' }} |
| 39 | + uses: ilammy/msvc-dev-cmd@v1 |
| 40 | + |
| 41 | + - name: Install Lua |
| 42 | + uses: luarocks/gh-actions-lua@master |
| 43 | + with: |
| 44 | + luaVersion: ${{ matrix.lua-version }} |
| 45 | + |
| 46 | + - name: Install LuaRocks |
| 47 | + uses: luarocks/gh-actions-luarocks@master |
| 48 | + |
| 49 | + - name: Run custom setup commands |
| 50 | + shell: bash |
| 51 | + run: | |
| 52 | + SETUP_COMMANDS=$(jq -r '.["setup-commands"] // [] | join("\n")' .github/config.json) |
| 53 | + if [ -n "$SETUP_COMMANDS" ]; then |
| 54 | + bash -c "$SETUP_COMMANDS" |
| 55 | + fi |
| 56 | +
|
| 57 | + - name: Resolve Rockspec |
| 58 | + shell: bash |
| 59 | + run: | |
| 60 | + PACKAGE_NAME=$(jq -r '.package' .github/config.json) |
| 61 | + ROCKSPEC="${PACKAGE_NAME}-scm-1.rockspec" |
| 62 | + if [ ! -f "$ROCKSPEC" ]; then |
| 63 | + echo "No rockspec file found: $ROCKSPEC" >&2 |
| 64 | + exit 1 |
| 65 | + fi |
| 66 | + echo "rockspec=$ROCKSPEC" >> "$GITHUB_ENV" |
| 67 | +
|
| 68 | + - name: Install package (POSIX) |
| 69 | + if: ${{ runner.os != 'Windows' }} |
| 70 | + shell: bash |
| 71 | + run: luarocks install "$rockspec" |
| 72 | + |
| 73 | + - name: Install package (Windows) |
| 74 | + if: ${{ runner.os == 'Windows' }} |
| 75 | + shell: pwsh |
| 76 | + run: luarocks install $env:rockspec |
| 77 | + |
| 78 | + - name: Run Tests |
| 79 | + if: hashFiles('**/*.test.lua') != '' |
| 80 | + shell: bash |
| 81 | + run: | |
| 82 | + luarocks install busted |
| 83 | + busted |
0 commit comments