diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 7a49d0b..e70053e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,84 +1,70 @@ name: CI on: push: { branches: ["0.x"] } pull_request: { branches: ["0.x"] } jobs: - commits: - name: Commitlint - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v3 - with: - fetch-depth: 1000 - - - name: Lint commits - uses: docker://registry.k1.zportal.co.uk/practically-oss/conventional-tools:0.x - with: - args: conventional-tools commitlint -l1 -f39febd82e236a9c79f5b408e98cbd20410f11e9e - luacheck: name: Luacheck runs-on: ubuntu-latest steps: - name: Checkout uses: actions/checkout@v3 - name: Install luarocks run: sudo apt update && sudo apt install -y luarocks - name: Install luacheck run: sudo luarocks install luacheck - name: Run luacheck run: luacheck . stylua: name: StyLua runs-on: ubuntu-latest steps: - name: Checkout uses: actions/checkout@v3 - name: Run stylua uses: JohnnyMorganz/stylua-action@v2.0.0 with: token: ${{ secrets.GITHUB_TOKEN }} version: latest args: --check . cargo-format: name: Cargo Format runs-on: ubuntu-latest steps: - name: Checkout uses: actions/checkout@v3 - name: Run cargo format uses: actions-rs/cargo@v1 with: command: fmt args: --all -- --check test: name: Build and test runs-on: ubuntu-latest steps: - name: Checkout uses: actions/checkout@v3 - name: Install rust toolchain uses: actions-rs/toolchain@v1 with: toolchain: stable - name: Install dependencies run: sudo apt update && sudo apt install -y luajit build-essential - name: Build run: cargo build --release - name: Test run: find lua -name "*_test.lua" | xargs luajit scripts/test.lua diff --git a/.github/workflows/ct-commitlint.yml b/.github/workflows/ct-commitlint.yml new file mode 100644 index 0000000..f62f45c --- /dev/null +++ b/.github/workflows/ct-commitlint.yml @@ -0,0 +1,21 @@ +name: Conventional Tools Commitlint + +on: + push: { branches: ["0.x"] } + pull_request: { branches: ["0.x"] } + +jobs: + commits: + name: Commitlint + runs-on: ubuntu-latest + container: practically/conventional-tools:1.x@sha256:e0603c12e8b4b835c9fcceaa4ddad4077ccf223665c0180db91511e2ce168670 + steps: + - name: Checkout + uses: actions/checkout@v3 + with: {fetch-depth: 1000} + + - name: Git safe.directory + run: git config --global --add safe.directory $PWD + + - name: Lint commits + run: conventional-tools commitlint -l1 -f39febd82e236a9c79f5b408e98cbd20410f11e9e diff --git a/lua/ivy/libivy_test.lua b/lua/ivy/libivy_test.lua index 4f4426f..c7fe89b 100644 --- a/lua/ivy/libivy_test.lua +++ b/lua/ivy/libivy_test.lua @@ -1,18 +1,27 @@ local libivy = require "ivy.libivy" it("should run a simple match", function(t) local score = libivy.ivy_match("term", "I am a serch term") if score <= 0 then t.error("Score should not be less than 0 found " .. score) end end) it("should find a dot file", function(t) local current_dir = libivy.ivy_cwd() - local matches = libivy.ivy_files("ci.yml", current_dir) + local matches = libivy.ivy_files(".github/workflows/ci.yml", current_dir) - if matches ~= ".github/workflows/ci.yml\n" then - t.error("Invalid matches: " .. matches) + local results = {} + for line in string.gmatch(matches, "[^\r\n]+") do + table.insert(results, line) + end + + if #results ~= 2 then + t.error "Incorrect number of results" + end + + if results[2] ~= ".github/workflows/ci.yml" then + t.error("Invalid matches: " .. results[2]) end end)