From 0bf1de098317c7177c98a15c2ff29ed900427055 Mon Sep 17 00:00:00 2001 From: Richard Baltrusch Date: Mon, 26 May 2025 23:43:00 +0200 Subject: [PATCH 1/8] Add unit testing github action --- .github/workflows/tests.yaml | 32 ++++++++++++++++++++++++ streams-scm.rockspec.lua | 47 ++++++++++++++++++++++++++++++++++++ 2 files changed, 79 insertions(+) create mode 100644 .github/workflows/tests.yaml create mode 100644 streams-scm.rockspec.lua diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml new file mode 100644 index 0000000..1697603 --- /dev/null +++ b/.github/workflows/tests.yaml @@ -0,0 +1,32 @@ +name: Test + +on: [ push, pull_request ] + +jobs: + + test: + strategy: + fail-fast: false + matrix: + lua_version: [ "5.4", "5.3", "5.2", "5.1", 'luajit-2.0', 'luajit-2.1' ] + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: Set up Lua + uses: luarocks/gh-actions-lua@master + with: + luaVersion: ${{ matrix.lua_version }} + + - name: Set up LuaRocks + uses: luarocks/gh-actions-luarocks@master + + - name: Setup dependencies + run: luarocks install luaunit + + - name: Build luarock + run: luarocks build + + - name: Run regression tests + run: luarocks test diff --git a/streams-scm.rockspec.lua b/streams-scm.rockspec.lua new file mode 100644 index 0000000..590fb7d --- /dev/null +++ b/streams-scm.rockspec.lua @@ -0,0 +1,47 @@ +rockspec_format = "3.0" +package = "streams" +version = "scm" + +source = { + url = "git+https://github.com/rbaltrusch/stream.lua", + branch = "main", -- this will be replaced by the release workflow +} + +description = { + summary = "Iterator-chaining library implementing common functional programming patterns such as `map`, `filter`, and `reduce`", + detailed = [[ + This library provides a Java-like `Stream` class that provides a fluent interface of lazily-computed and chainable iterator operations such as `map`, `filter`, and `reduce`. For example: + + ```lua + local fn = require "stream" + fn.stream{2, 3, 4, 7} + :filter(function(x) return x % 2 == 0 end) + :map(function(x) return x ^ 2 end) + :collect() -- {4, 16} + ``` + ]], + homepage = "https://github.com/rbaltrusch/stream.lua", + issues_url = "https://github.com/rbaltrusch/stream.lua/issues", + license = "MIT", + maintainer = "Richard Baltrusch", +} + +dependencies = { + "lua >= 5.1, < 5.4" +} + +test_dependencies = { + "luaunit", +} + +build = { + type = "builtin", + modules = { + stream = "stream.lua", + }, +} + +test = { + type = "command", + script = "tests/run_tests.lua", +} From 1c78b8f4a70cca29268dd197a336164c7d8777dc Mon Sep 17 00:00:00 2001 From: Richard Baltrusch Date: Mon, 26 May 2025 23:45:04 +0200 Subject: [PATCH 2/8] Add rockspec arg to testing workflow --- .github/workflows/tests.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml index 1697603..e122309 100644 --- a/.github/workflows/tests.yaml +++ b/.github/workflows/tests.yaml @@ -26,7 +26,7 @@ jobs: run: luarocks install luaunit - name: Build luarock - run: luarocks build + run: luarocks build streams-scm.rockspec.lua - name: Run regression tests run: luarocks test From 4a29da5d7fc305a0dffe0fdb39ce761fbd0265fd Mon Sep 17 00:00:00 2001 From: Richard Baltrusch Date: Mon, 2 Jun 2025 23:38:40 +0200 Subject: [PATCH 3/8] Fix test pipeline by fixing rockspec name --- .github/workflows/tests.yaml | 2 +- streams-scm.rockspec.lua => streams-scm.rockspec | 0 2 files changed, 1 insertion(+), 1 deletion(-) rename streams-scm.rockspec.lua => streams-scm.rockspec (100%) diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml index e122309..58cd891 100644 --- a/.github/workflows/tests.yaml +++ b/.github/workflows/tests.yaml @@ -26,7 +26,7 @@ jobs: run: luarocks install luaunit - name: Build luarock - run: luarocks build streams-scm.rockspec.lua + run: luarocks build streams-scm.rockspec - name: Run regression tests run: luarocks test diff --git a/streams-scm.rockspec.lua b/streams-scm.rockspec similarity index 100% rename from streams-scm.rockspec.lua rename to streams-scm.rockspec From 56a08de5fc4ebbbc1f17c86f77980536c11378dd Mon Sep 17 00:00:00 2001 From: Richard Baltrusch Date: Mon, 2 Jun 2025 23:53:04 +0200 Subject: [PATCH 4/8] Fix test pipeline by fixing rockspec name --- .github/workflows/tests.yaml | 2 +- streams-scm.rockspec => streams-scm-1.rockspec | 0 2 files changed, 1 insertion(+), 1 deletion(-) rename streams-scm.rockspec => streams-scm-1.rockspec (100%) diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml index 58cd891..541b361 100644 --- a/.github/workflows/tests.yaml +++ b/.github/workflows/tests.yaml @@ -26,7 +26,7 @@ jobs: run: luarocks install luaunit - name: Build luarock - run: luarocks build streams-scm.rockspec + run: luarocks build streams-scm-1.rockspec - name: Run regression tests run: luarocks test diff --git a/streams-scm.rockspec b/streams-scm-1.rockspec similarity index 100% rename from streams-scm.rockspec rename to streams-scm-1.rockspec From 46bc5a60d815db9cd61922b04073e8fe2b249571 Mon Sep 17 00:00:00 2001 From: Richard Baltrusch Date: Thu, 5 Jun 2025 23:00:44 +0200 Subject: [PATCH 5/8] Try fix rockspec version field --- streams-scm-1.rockspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/streams-scm-1.rockspec b/streams-scm-1.rockspec index 590fb7d..ff486c6 100644 --- a/streams-scm-1.rockspec +++ b/streams-scm-1.rockspec @@ -1,6 +1,6 @@ rockspec_format = "3.0" package = "streams" -version = "scm" +version = "scm-1" source = { url = "git+https://github.com/rbaltrusch/stream.lua", From b48881c399088facfb696fc824e52a6c8678ba8e Mon Sep 17 00:00:00 2001 From: Richard Baltrusch Date: Thu, 5 Jun 2025 23:27:05 +0200 Subject: [PATCH 6/8] Fix workflow branch --- streams-scm-1.rockspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/streams-scm-1.rockspec b/streams-scm-1.rockspec index ff486c6..addb56d 100644 --- a/streams-scm-1.rockspec +++ b/streams-scm-1.rockspec @@ -4,7 +4,7 @@ version = "scm-1" source = { url = "git+https://github.com/rbaltrusch/stream.lua", - branch = "main", -- this will be replaced by the release workflow + branch = "master", -- this will be replaced by the release workflow } description = { From 6b73ca20d48f12d150671036da4dbfd92c59d0ca Mon Sep 17 00:00:00 2001 From: Richard Baltrusch Date: Thu, 5 Jun 2025 23:49:04 +0200 Subject: [PATCH 7/8] Try add support for lua 5.4 --- streams-scm-1.rockspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/streams-scm-1.rockspec b/streams-scm-1.rockspec index addb56d..2ea2279 100644 --- a/streams-scm-1.rockspec +++ b/streams-scm-1.rockspec @@ -27,7 +27,7 @@ description = { } dependencies = { - "lua >= 5.1, < 5.4" + "lua >= 5.1" } test_dependencies = { From eaac2595034798ab667e75b4c362cedb6e623d5c Mon Sep 17 00:00:00 2001 From: Richard Baltrusch Date: Thu, 5 Jun 2025 23:56:21 +0200 Subject: [PATCH 8/8] Format test workflow file --- .github/workflows/tests.yaml | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml index 541b361..840119c 100644 --- a/.github/workflows/tests.yaml +++ b/.github/workflows/tests.yaml @@ -1,32 +1,27 @@ name: Test - -on: [ push, pull_request ] +on: +- push +- pull_request jobs: - test: strategy: fail-fast: false matrix: - lua_version: [ "5.4", "5.3", "5.2", "5.1", 'luajit-2.0', 'luajit-2.1' ] + lua_version: ["5.4", "5.3", "5.2", "5.1"] runs-on: ubuntu-latest steps: - name: Checkout uses: actions/checkout@v3 - - name: Set up Lua uses: luarocks/gh-actions-lua@master with: luaVersion: ${{ matrix.lua_version }} - - name: Set up LuaRocks uses: luarocks/gh-actions-luarocks@master - - name: Setup dependencies run: luarocks install luaunit - - name: Build luarock run: luarocks build streams-scm-1.rockspec - - - name: Run regression tests + - name: Run tests run: luarocks test