From bb3729cdb82644f162fedbdfff9a4e9847bd4d2c Mon Sep 17 00:00:00 2001 From: Stephen Leitnick Date: Mon, 1 Nov 2021 18:57:40 -0400 Subject: [PATCH] CI --- .github/workflows/ci.yaml | 68 +++++++++++++++++++++++++++++++++++++++ foreman.toml | 3 ++ test/RunTests.server.lua | 5 +-- 3 files changed, 74 insertions(+), 2 deletions(-) create mode 100644 .github/workflows/ci.yaml diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml new file mode 100644 index 00000000..75262f91 --- /dev/null +++ b/.github/workflows/ci.yaml @@ -0,0 +1,68 @@ +name: CI + +on: + push: + branches: + - main + pull_request: + branches: + - main + +jobs: + + lint: + name: Lint + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v2 + + - uses: Roblox/setup-foreman@v1 + name: Install Foreman + with: + version: "^1.0.0" + token: ${{ SECRETS.GITHUB_TOKEN }} + + - name: Lint + run: | + selene ./modules + + unit-tests: + name: Unit Tests + runs-on: windows-latest + timeout-minutes: 10 + steps: + - name: Checkout code + uses: actions/checkout@v2 + + - name: Setup Python + uses: actions/setup-python@v2 + with: + python-version: '3.10' + architecture: 'x64' + + - name: Install Roblox Studio + uses: OrbitalOwen/roblox-win-installer-action@1.1 + with: + cookie: ${{ secrets.ROBLOSECURITY }} + token: ${{ secrets.GITHUB_TOKEN }} + + - name: Install Foreman + uses: rojo-rbx/setup-foreman@v1 + with: + token: ${{ secrets.GITHUB_TOKEN }} + + - name: Build tests + run: python build_tests.py + + - name: Build test place + run: rojo build default.project.json -o test.rbxl + + - name: Run tests + shell: bash + run: run-in-roblox --place test.rbxl --script test/RunTests.server.lua > test-out.txt + continue-on-error: true + + - name: Check test status + shell: bash + run: cat test-out.txt | grep "0 failed, 0 skipped" || (cat test-out.txt && exit 1) diff --git a/foreman.toml b/foreman.toml index 1bef1695..4a476db1 100644 --- a/foreman.toml +++ b/foreman.toml @@ -1,2 +1,5 @@ [tools] wally = { source = "UpliftGames/wally", version = "0.2.1" } +selene = { source = "Kampfkarren/selene", version = "x" } +rojo = { source = "rojo-rbx/rojo", version = "6.2.0" } +run-in-roblox = { source = "rojo-rbx/run-in-roblox", version = "0.3.0" } diff --git a/test/RunTests.server.lua b/test/RunTests.server.lua index 7bee50be..a38eac35 100644 --- a/test/RunTests.server.lua +++ b/test/RunTests.server.lua @@ -1,8 +1,9 @@ print("Running unit tests...") +local TestService = game:GetService("TestService") local tests = {} -for _,testFolder in ipairs(script.Parent.modules:GetChildren()) do +for _,testFolder in ipairs(TestService.modules:GetChildren()) do local name = testFolder.Name:match("(.+)_test$") local module = testFolder[name] table.insert(tests, module) end -require(script.Parent.Packages.TestEZ).TestBootstrap:run(tests) +require(TestService.Packages.TestEZ).TestBootstrap:run(tests)