Skip to content

Commit

Permalink
Add CI and iron out kinks (#1)
Browse files Browse the repository at this point in the history
  • Loading branch information
fsoikin authored Aug 2, 2024
1 parent 0053d3d commit 1e36ecd
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 8 deletions.
6 changes: 5 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@ jobs:
${{ runner.os }}-build-
${{ runner.os }}-
- name: Install global NPM packages
if: matrix.os == 'windows-latest'
run: npm i --global [email protected] spago@next purs-tidy@latest esbuild@latest

- name: Cache PureScript dependencies
uses: actions/cache@v4
with:
Expand All @@ -62,4 +66,4 @@ jobs:
run: npx spago build

- name: Run tests
run: npx spago test
run: npx spago test '--' --no-timeout
19 changes: 12 additions & 7 deletions test/Test/Main.purs
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,13 @@ import Data.String (trim)
import Data.String.Regex (replace) as Regex
import Data.String.Regex.Flags (global) as Regex
import Data.String.Regex.Unsafe (unsafeRegex) as Regex
import Debug (traceM)
import Effect (Effect)
import Node.ChildProcess.Types (Exit(..), pipe)
import Node.ChildProcess.Types (Exit(..), pipe, inherit)
import Node.Encoding (Encoding(..))
import Node.FS.Aff as FS
import Node.Library.Execa (execa)
import Node.Platform (Platform(..))
import Node.Process (platform)
import Test.Spec as Spec
import Test.Spec.Assertions (fail)
import Test.Spec.Reporter (consoleReporter)
Expand All @@ -36,7 +37,7 @@ main = runSpecAndExitProcess [consoleReporter] $
runTest ["--example", "gotham city"] >>= shouldFailWith "filter-spaces.txt"

Spec.it "can filter by FULL test name" do
runTest ["--example", "gotham city is a dark"] >>= shouldFailWith "filter-spaces.txt"
runTest ["--example", "gotham city is a dark"] >>= shouldFailWith "filter-full-name.txt"

Spec.describe "--example-matches" do
Spec.it "can filter by test name by regex" do
Expand Down Expand Up @@ -74,10 +75,10 @@ main = runSpecAndExitProcess [consoleReporter] $

where
runTest args' = do
let opts = _ { cwd = Just "test-fixtures/project", stdin = Just pipe, stdout = Just pipe, stderr = Just pipe }
args = ["spago", "test", "--"] <> args'
execa "npx" ["spago", "build"] opts >>= _.getResult >>= shouldSucceed
execa "npx" args opts >>= _.getResult
let opts = _ { cwd = Just "test-fixtures/project", stdin = Just inherit, stdout = Just pipe, stderr = Just pipe }
args = ["test", "--"] <> args'
execa spagoCmd ["build"] opts >>= _.getResult >>= shouldSucceed
execa spagoCmd args opts >>= _.getResult

nukeLastResults =
FS.rm' "test-fixtures/project/.spec-results"
Expand Down Expand Up @@ -147,3 +148,7 @@ main = runSpecAndExitProcess [consoleReporter] $

stripColors = Regex.replace colorRegex ""
colorRegex = Regex.unsafeRegex "\x1B\\[([0-9]|;)+m" Regex.global

spagoCmd = case platform of
Just Win32 -> "spago.ps1"
_ -> "spago"

0 comments on commit 1e36ecd

Please sign in to comment.