Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: update to spago@next #57

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,12 @@ jobs:
steps:
- uses: actions/checkout@v2

- uses: purescript-contrib/setup-purescript@main
# - uses: purescript-contrib/setup-purescript@main
- uses: srghma/setup-purescript@main
with:
purescript: "0.15.8"
spago: "0.20.9"
psa: "0.8.2"
purescript: "latest"
spago: "latest"
psa: "latest"
purs-tidy: "latest"

- name: Cache PureScript dependencies
Expand All @@ -31,7 +32,7 @@ jobs:
run: spago build --purs-args '--censor-lib --strict'

- name: Run tests
run: spago test
run: spago test --pedantic-packages

- name: Check formatting
run: npm run check
Expand Down
42 changes: 0 additions & 42 deletions bench/bench.dhall

This file was deleted.

16 changes: 16 additions & 0 deletions bench/spago.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package:
name: bench
dependencies:
- aff
- arrays
- console
- effect
- either
- foldable-traversable
- language-cst-parser
- maybe
- minibench
- node-buffer
- node-fs
- node-process
- prelude
File renamed without changes.
File renamed without changes.
35 changes: 35 additions & 0 deletions lib/spago.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package:
name: language-cst-parser
dependencies:
- arrays
- const
- control
- either
- enums
- foldable-traversable
- free
- functions
- functors
- identity
- integers
- lazy
- lists
- maybe
- newtype
- numbers
- ordered-collections
- partial
- prelude
- st
- strings
- transformers
- tuples
- typelevel-prelude
- unfoldable
- unsafe-coerce
test:
main: Test.Main
dependencies:
- console
- effect
- node-process
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion test/Main.purs → lib/test/Main.purs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ assertParse name src k = do
let res = parseFor (trim src)
unless (k res) do
Console.error $ "Assertion failed: " <> name
Process.exit 1
Process.exit' 1
where
trim =
String.split (Pattern "\n")
Expand Down
16 changes: 8 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
{
"private": true,
"scripts": {
"parse-package-set": "spago -x parse-package-set/parse-package-set.dhall run",
"bench-file": "spago -x bench/bench.dhall build && node --expose-gc --input-type=\"module\" -e \"import { main } from './output/BenchFile/index.js';main()\"",
"parse-file": "spago -x bench/bench.dhall build && node --input-type=\"module\" -e \"import { main } from './output/ParseFile/index.js';main()\" --",
"format": "purs-tidy format-in-place src test bench parse-package-set",
"check": "purs-tidy check src test bench parse-package-set"
"parse-package-set": "spago run --package parse-package-set",
"bench-file": "spago build --package bench && node --expose-gc --input-type=\"module\" -e \"import { main } from './output/BenchFile/index.js';main()\"",
"parse-file": "spago build --package bench && node --input-type=\"module\" -e \"import { main } from './output/ParseFile/index.js';main()\"",
"format": "purs-tidy format-in-place lib bench parse-package-set",
"check": "purs-tidy check lib bench parse-package-set"
},
"devDependencies": {
"purescript": "^0.15.0",
"purs-tidy": "^0.10.0",
"spago": "^0.21.0"
"purescript": "^0.15.15",
"purs-tidy": "^0.11.0",
"spago": "next"
}
}
5 changes: 0 additions & 5 deletions packages.dhall

This file was deleted.

47 changes: 0 additions & 47 deletions parse-package-set/parse-package-set.dhall

This file was deleted.

27 changes: 27 additions & 0 deletions parse-package-set/spago.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package:
name: parse-package-set
dependencies:
- aff
- argonaut-codecs
- argonaut-core
- arrays
- avar
- console
- datetime
- effect
- either
- exceptions
- filterable
- foldable-traversable
- foreign-object
- language-cst-parser
- maybe
- newtype
- node-buffer
- node-child-process
- node-fs
- node-path
- numbers
- parallel
- prelude
- strings
File renamed without changes.
38 changes: 24 additions & 14 deletions parse-package-set/Main.purs → parse-package-set/src/Main.purs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import Data.String.Regex.Unsafe (unsafeRegex)
import Data.Time.Duration (Milliseconds(..))
import Effect (Effect)
import Effect.AVar as EffectAVar
import Effect.Aff (Aff, runAff_)
import Effect.Aff (Aff, runAff_, throwError, error)
import Effect.Aff.AVar as AVar
import Effect.Class (liftEffect)
import Effect.Console as Console
Expand All @@ -38,6 +38,11 @@ import PureScript.CST.Errors (printParseError)
import PureScript.CST.Parser.Monad (PositionedError)
import PureScript.CST.Types (Module(..), ModuleHeader)
import PureScript.CST.ModuleGraph (sortModules, ModuleSort(..))
import Data.Argonaut.Core (Json)
import Data.Argonaut.Decode as Data.Argonaut.Decode
import Data.Argonaut.Decode (JsonDecodeError)
import Foreign.Object (Object)
import Foreign.Object as Foreign.Object

foreign import tmpdir :: String -> Effect String

Expand All @@ -49,13 +54,16 @@ main :: Effect Unit
main = runAff_ (either throwException mempty) do
tmpPath <- liftEffect $ tmpdir "cst-integration-"

writeTextFile UTF8 (tmpPath <> "/spago.dhall") defaultSpagoDhall
liftEffect $ Console.log $ "Making new project in " <> tmpPath

let execOpts = Exec.defaultExecSyncOptions { cwd = Just tmpPath }
s <- liftEffect $ Buffer.toString UTF8 =<< Exec.execSync "spago ls packages" execOpts
let lines = Str.split (Str.Pattern "\n") s
let packages = Str.joinWith " " (String.takeWhile (_ /= ' ') <$> lines)
_ <- liftEffect $ Exec.execSync ("spago install " <> packages) execOpts
writeTextFile UTF8 (tmpPath <> "/spago.yaml") defaultSpagoYaml

let execOptsFn = _ { cwd = Just tmpPath }
srghma marked this conversation as resolved.
Show resolved Hide resolved
s <- liftEffect $ Buffer.toString UTF8 =<< Exec.execSync' "spago ls packages --json" execOptsFn
let (objectOrError :: Either JsonDecodeError (Object Json)) = Data.Argonaut.Decode.decodeJson =<< Data.Argonaut.Decode.parseJson s
(object :: Object Json) <- either (throwError <<< error <<< Data.Argonaut.Decode.printJsonDecodeError) pure objectOrError
let (packages :: Array String) = Foreign.Object.keys object
srghma marked this conversation as resolved.
Show resolved Hide resolved
_ <- liftEffect $ Exec.execSync' ("spago install " <> Str.joinWith " " packages) execOptsFn

pursFiles <- getPursFiles 0 (tmpPath <> "/.spago")

Expand Down Expand Up @@ -154,13 +162,15 @@ main = runAff_ (either throwException mempty) do
[ "Error: cycle detected in module graph"
]

defaultSpagoDhall :: String
defaultSpagoDhall = Array.intercalate "\n"
[ "{ name = \"test-parser\""
, ", dependencies = [] : List Text"
, ", packages = https://github.com/purescript/package-sets/releases/download/psc-0.15.7-20230401/packages.dhall sha256:d385eeee6ca160c32d7389a1f4f4ee6a05aff95e81373cdc50670b436efa1060"
, ", sources = [] : List Text"
, "}"
defaultSpagoYaml :: String
defaultSpagoYaml = Array.intercalate "\n"
[ "package:"
, " name: test-parser"
, " dependencies: []"
, "workspace:"
, " package_set:"
, " registry: 50.4.0"
, " extra_packages: {}"
]

getPursFiles :: Int -> FilePath -> Aff (Array FilePath)
Expand Down
37 changes: 0 additions & 37 deletions spago.dhall

This file was deleted.

4 changes: 4 additions & 0 deletions spago.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
workspace:
package_set:
registry: 50.4.0
extra_packages: {}