|
1 | | -# setup-lua |
2 | | -GitHub action to setup Lua. |
| 1 | +# xpol/setup-lua |
| 2 | + |
| 3 | +[](https://github.com/xpol/setup-lua/actions) |
| 4 | + |
| 5 | +Github Action to install Lua/LuaJIT on Unbutu/macOS/Windows. |
| 6 | + |
| 7 | +Builds and installs Lua into the `.lua/` directory in the working directory using [CMake](https://cmake.org/). |
| 8 | +Adds the `.lua/bin` to the `PATH` environment variable so `lua` can be called |
| 9 | +directly in workflows. |
| 10 | + |
| 11 | +This project is hightlly inspired by (and this README is initially copied from) [leafo/gh-actions-lua](https://github.com/leafo/gh-actions-lua). The difference is this project use CMake to support Unbutu/macOS/Windows. |
| 12 | + |
| 13 | +Many thanks to [leafo](https://github.com/leafo)! |
| 14 | + |
| 15 | +## Usage |
| 16 | + |
| 17 | +Install Lua: |
| 18 | + |
| 19 | +*Will install the latest stable release of PUC-Rio Lua.* |
| 20 | + |
| 21 | +```yaml |
| 22 | +- uses: xpol/setup-lua@v1 |
| 23 | +``` |
| 24 | +
|
| 25 | +Install specific version of Lua: |
| 26 | +
|
| 27 | +```yaml |
| 28 | +- uses: xpol/setup-lua@v1 |
| 29 | + with: |
| 30 | + luaVersion: "5.1.5" |
| 31 | +``` |
| 32 | +
|
| 33 | +Install specific version of LuaJIT: |
| 34 | +
|
| 35 | +```yaml |
| 36 | +- uses: xpol/setup-lua@v1 |
| 37 | + with: |
| 38 | + luaVersion: "luajit-2.0.5" |
| 39 | +``` |
| 40 | +
|
| 41 | +## Inputs |
| 42 | +
|
| 43 | +### `luaVersion` |
| 44 | + |
| 45 | +**Default**: `"5.3.5"` |
| 46 | + |
| 47 | +Specifies the version of Lua to install. The version name instructs the action |
| 48 | +where to download the source from. |
| 49 | + |
| 50 | +All supported of versions: |
| 51 | + |
| 52 | +* `"5.3.5"` |
| 53 | +* `"5.3.4"` |
| 54 | +* `"5.3.3"` |
| 55 | +* `"5.3.2"` |
| 56 | +* `"5.3.1"` |
| 57 | +* `"5.3.0"` |
| 58 | +* `"5.2.4"` |
| 59 | +* `"5.2.3"` |
| 60 | +* `"5.2.2"` |
| 61 | +* `"5.2.1"` |
| 62 | +* `"5.2.0"` |
| 63 | +* `"5.1.5"` |
| 64 | +* `"5.1.4"` |
| 65 | +* `"5.1.3"` |
| 66 | +* `"5.1.2"` |
| 67 | +* `"5.1.1"` |
| 68 | +* `"5.1.0"` |
| 69 | +* `"luajit-2.0.5"` |
| 70 | +* `"luajit-2.1.0-beta3"` |
| 71 | +* `"luajit-2.1.0-beta2"` |
| 72 | +* `"luajit-2.1.0-beta1"` |
| 73 | +* `"luajit-2.0.4"` |
| 74 | +* `"luajit-2.0.3"` |
| 75 | +* `"luajit-2.0.2"` |
| 76 | +* `"luajit-2.0.1"` |
| 77 | +* `"luajit-2.0.0"` |
| 78 | + |
| 79 | +*Note: Beta versions will removed when the stable version is released.* |
| 80 | + |
| 81 | +## Also want LuaRocks |
| 82 | + |
| 83 | +You may also need an action to install luarocks: |
| 84 | + |
| 85 | +* [`leafo/gh-actions-luarocks`](https://github.com/leafo/gh-actions-luarocks) |
| 86 | + * inputs: `luarocksVersion` |
| 87 | + |
| 88 | +## Full Example |
| 89 | + |
| 90 | +This example is for running tests on a Lua module that uses LuaRocks for |
| 91 | +dependencies and [busted](https://olivinelabs.com/busted/) for a test suite. |
| 92 | + |
| 93 | +Create `.github/workflows/test.yml` in your repository: |
| 94 | + |
| 95 | +```yaml |
| 96 | +name: test |
| 97 | +
|
| 98 | +on: [push] |
| 99 | +
|
| 100 | +jobs: |
| 101 | + test: |
| 102 | + runs-on: ubuntu-latest |
| 103 | +
|
| 104 | + steps: |
| 105 | + - uses: actions/checkout@master |
| 106 | +
|
| 107 | + - uses: xpol/setup-lua@v1 |
| 108 | + with: |
| 109 | + luaVersion: "5.1.5" |
| 110 | +
|
| 111 | + - uses: leafo/gh-actions-luarocks@v2 |
| 112 | +
|
| 113 | + - name: build |
| 114 | + run: | |
| 115 | + luarocks install busted |
| 116 | + luarocks make |
| 117 | +
|
| 118 | + - name: test |
| 119 | + run: | |
| 120 | + busted -o utfTerminal |
| 121 | +``` |
| 122 | + |
| 123 | +This example: |
| 124 | + |
| 125 | +* Uses Lua 5.1.5 — You can use another version by chaning the `luaVersion` varible. LuaJIT versions can be used by prefixing the version with `luajit-`, i.e. `luajit-2.1.0-beta3` |
| 126 | +* Uses a `.rockspec` file the root directory of your repository to install dependencies and test packaging the module via `luarocks make` |
| 127 | + |
| 128 | +View the documentation for the individual actions (linked above) to learn more about how they work. |
| 129 | + |
| 130 | +### Version build matrix |
| 131 | + |
| 132 | +You can test against multiple versions of Lua using a matrix strategy: |
| 133 | + |
| 134 | +```yaml |
| 135 | +jobs: |
| 136 | + test: |
| 137 | + strategy: |
| 138 | + matrix: |
| 139 | + luaVersion: ["5.1.5", "5.2.4", "luajit-2.1.0-beta3"] |
| 140 | +
|
| 141 | + steps: |
| 142 | + - uses: actions/checkout@master |
| 143 | + - uses: xpol/setup-lua@v1 |
| 144 | + with: |
| 145 | + luaVersion: ${{ matrix.luaVersion }} |
| 146 | +
|
| 147 | + # ... |
| 148 | +``` |
0 commit comments