Skip to content

Commit 32fa32c

Browse files
Add purescript-psa to the supported tools (#3)
1 parent e53c99c commit 32fa32c

18 files changed

+264
-203
lines changed

.github/workflows/integration.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,5 +21,5 @@ jobs:
2121
- name: Check tools are installed correctly
2222
run: |
2323
purty src/Main.purs
24-
spago build --purs-args '--codegen corefn,js'
24+
spago build --purs-args '--censor-lib --strict --codegen corefn,js'
2525
zephyr -f Main.main

README.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,14 @@ A GitHub Action which sets up a PureScript toolchain for CI. Contains the follow
66

77
- The [PureScript compiler](https://github.com/purescript/purescript)
88
- The [Spago package manager and build tool](https://github.com/purescript/spago)
9+
- The [`psa` error reporting frontend for the compiler](https://github.com/natefaubion/purescript-psa)
910

1011
You can also optionally include the following tools:
1112

1213
- The [Zephyr dead code elimination tool](https://github.com/coot/zephyr)
1314
- The [Purty source code formatter](https://gitlab.com/joneshf/purty)
1415

15-
This action is designed to support tools with static binaries. Your PureScript project may also depend on tooling and libraries provided by the NPM ecosystem, in which case you will also want to use the [setup-node](https://github.com/actions/setup-node) action.
16+
This action is designed to support PureScript tools. Your PureScript project may also depend on tooling and libraries provided by the NPM ecosystem, in which case you will also want to use the [setup-node](https://github.com/actions/setup-node) action.
1617

1718
## Usage
1819

@@ -41,6 +42,7 @@ steps:
4142
- uses: thomashoneyman/setup-purescript@main
4243
with:
4344
purescript: "0.13.8"
45+
psa: "0.7.2"
4446
spago: "0.15.3"
4547
purty: "latest"
4648
zephyr: "0.3.2"
@@ -61,7 +63,7 @@ jobs:
6163
runs-on: ubuntu-latest
6264
steps:
6365
- uses: actions/checkout@v2
64-
66+
6567
- uses: thomashoneyman/setup-purescript@main
6668
6769
- name: Cache PureScript dependencies
@@ -102,7 +104,7 @@ npm install
102104
GitHub Actions uses the `action.yml` file to define the action and the `dist/index.js` file to execute it. After making any changes to the source code, make sure those changes are visible by running:
103105

104106
```sh
105-
npm run package
107+
npm run build
106108
```
107109

108110
This will bundle and minify the source code so it is available to the end user.

action.yml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ inputs:
88
spago:
99
description: "The Spago version to install. Examples: latest, 0.15.3"
1010
default: "latest"
11+
psa:
12+
description: "The psa version to install. Examples: latest, 0.7.2"
13+
default: "latest"
1114
purty:
1215
description: "The Purty version to install. Examples: latest, 6.2.0"
1316
zephyr:
@@ -16,5 +19,5 @@ runs:
1619
using: "node12"
1720
main: "dist/index.js"
1821
branding:
19-
icon: 'download'
20-
color: 'gray-dark'
22+
icon: "download"
23+
color: "gray-dark"

dist/index.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/update.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/versions.json

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,7 @@
1-
{"purs":"0.13.8","spago":"0.15.3","purty":"6.2.0","zephyr":"0.3.2"}
1+
{
2+
"purs": "0.13.8",
3+
"spago": "0.15.3",
4+
"psa": "0.7.3",
5+
"purty": "6.2.0",
6+
"zephyr": "0.3.2"
7+
}

package-lock.json

Lines changed: 10 additions & 13 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,20 @@
33
"description": "Set up a PureScript toolchain in GitHub Actions",
44
"author": "Thomas Honeyman",
55
"license": "MIT",
6+
"repository": {
7+
"type": "git",
8+
"url": "https://github.com/thomashoneyman/setup-purescript.git"
9+
},
610
"scripts": {
7-
"package": "spago bundle-module --to output/index.js && ncc build --minify update.js && mv dist/index.js dist/update.js && ncc build --minify index.js"
11+
"build": "spago bundle-module --to output/index.js && ncc build --minify update.js && mv dist/index.js dist/update.js && ncc build --minify index.js"
812
},
913
"dependencies": {
1014
"@actions/core": "^1.2.4",
15+
"@actions/exec": "^1.0.4",
1116
"@actions/tool-cache": "^1.6.0",
1217
"xhr2": "^0.2.0"
1318
},
1419
"devDependencies": {
15-
"@zeit/ncc": "^0.22.3"
20+
"@vercel/ncc": "^0.23.0"
1621
}
1722
}

src/Actions/Exec.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
const exec = require("@actions/exec");
2+
3+
exports.execImpl = exec.exec;

src/Actions/Exec.purs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
-- | Exports functions from the @actions/exec module provided by GitHub
2+
-- | https://github.com/actions/toolkit/tree/main/packages/exec
3+
module Actions.Exec
4+
( exec
5+
) where
6+
7+
import Prelude
8+
9+
import Control.Promise (Promise, toAffE)
10+
import Effect.Aff (Aff)
11+
import Effect.Uncurried (EffectFn2, runEffectFn2)
12+
13+
foreign import execImpl :: EffectFn2 String (Array String) (Promise Number)
14+
15+
-- | Executes a command on the command line, with arguments
16+
exec :: String -> Array String -> Aff { succeeded :: Boolean }
17+
exec command args =
18+
map ((_ == 0.0) >>> { succeeded: _ })
19+
$ toAffE
20+
$ runEffectFn2 execImpl command args

src/Main.purs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,13 @@ import Data.Foldable (traverse_)
77
import Effect (Effect)
88
import Effect.Aff (launchAff_)
99
import Setup.BuildPlan (constructBuildPlan)
10-
import Setup.Download (download)
10+
import Setup.GetTool (getTool)
1111
import Setup.UpdateVersions (updateVersions)
1212

1313
main :: Json -> Effect Unit
14-
main json = do
15-
plan <- constructBuildPlan json
16-
launchAff_ $ traverse_ download plan
14+
main json = do
15+
tools <- constructBuildPlan json
16+
launchAff_ $ traverse_ getTool tools
1717

1818
update :: Effect Unit
19-
update = launchAff_ updateVersions
19+
update = launchAff_ updateVersions

src/Setup/BuildPlan.purs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49,24 +49,24 @@ resolve versionsContents tool = do
4949
Nothing | required tool -> throwError $ error "No input received for required key."
5050
Nothing -> pure Nothing
5151
Just field -> map Just $ getVersion field
52-
52+
5353
where
5454
getVersion :: Either String VersionField -> Effect { tool :: Tool, version :: Version }
5555
getVersion = case _ of
5656
Left err -> do
5757
Core.setFailed $ fold [ "Unable to parse version: ", err ]
5858
throwError $ error "Unable to complete fetching version."
59-
59+
6060
Right (Exact v) -> do
6161
Core.info "Found exact version"
6262
pure { tool, version: v }
6363

6464
Right Latest -> do
6565
Core.info $ fold [ "Fetching latest tag for ", Tool.name tool ]
6666

67-
let
67+
let
6868
version = lmap printJsonDecodeError $ (_ .: Tool.name tool) =<< decodeJson versionsContents
69-
parse = lmap parseErrorMessage <<< Version.parseVersion
69+
parse = lmap parseErrorMessage <<< Version.parseVersion
7070

7171
case parse =<< version of
7272
Left e -> do
@@ -75,4 +75,3 @@ resolve versionsContents tool = do
7575

7676
Right v ->
7777
pure { tool, version: v }
78-

src/Setup/Data/Key.purs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
module Setup.Data.Key
1+
module Setup.Data.Key
22
( Key
33
, fromTool
44
) where
@@ -13,6 +13,9 @@ purescriptKey = Key "purescript"
1313
spagoKey :: Key
1414
spagoKey = Key "spago"
1515

16+
psaKey :: Key
17+
psaKey = Key "psa"
18+
1619
purtyKey :: Key
1720
purtyKey = Key "purty"
1821

@@ -23,5 +26,6 @@ fromTool :: Tool -> Key
2326
fromTool = case _ of
2427
PureScript -> purescriptKey
2528
Spago -> spagoKey
29+
Psa -> psaKey
2630
Purty -> purtyKey
2731
Zephyr -> zephyrKey

0 commit comments

Comments
 (0)