name: Unit Tests

on:
  push:
    branches:
      - '*'
  pull_request:
    branches:
      - '*'

jobs:
  busted_unit_test:
    runs-on: ubuntu-latest
    steps:
      # Cache all installation files for faster workflow
      - name: Cache Lua
        uses: actions/cache@v2
        with:
          path: |
            /usr/lib/lua
            /usr/local/lib/lua
            /usr/local/share/lua
            /usr/bin/lua
          key: lua

      - name: Cache Luarocks
        uses: actions/cache@v2
        with:
          path: |
            /usr/local/bin/luarocks
            /usr/local/share/lua/5.1/luarocks
          key: luarocks

      - name: Install Lua and Luarocks
        run: |
          sudo apt-get update
          sudo apt-get install -y lua5.1 luarocks

      - name: Checkout
        uses: actions/checkout@v4

      - name: Install Busted
        run: luarocks install busted

      - name: Run Busted
        run: busted .