Skip to content

Update for PureScript 0.14 and remove Purty #21

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

Merged
merged 4 commits into from
Aug 6, 2021
Merged
Show file tree
Hide file tree
Changes from all 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
5 changes: 0 additions & 5 deletions .github/workflows/integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,9 @@ jobs:

- uses: ./ # equivalent to purescript-contrib/setup-purescript@<branch>
with:
purty: "latest"
zephyr: "latest"

- name: Check purty is installed correctly
run: purty src/Main.purs

- name: Check spago and purs are installed correctly
# run: spago build --purs-args '--censor-lib --strict --codegen corefn,js'
run: |
purs --version
spago version
Expand Down
10 changes: 4 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ A GitHub Action which sets up a PureScript toolchain for CI. Contains the follow
You can also optionally include the following tools:

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

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.

Expand Down Expand Up @@ -43,10 +42,9 @@ steps:
- uses: actions/checkout@v2
- uses: purescript-contrib/setup-purescript@main
with:
purescript: "0.13.8"
psa: "0.7.2"
spago: "0.15.3"
purty: "latest"
purescript: "0.14.0"
psa: "0.8.2"
spago: "latest"
zephyr: "0.3.2"
- run: spago build
```
Expand Down Expand Up @@ -120,4 +118,4 @@ These libraries and applications are examples of `setup-purescript` in action:
- [halogen-formless](https://github.com/thomashoneyman/purescript-halogen-formless/blob/main/.github/workflows/ci.yml)
- [halogen-hooks](https://github.com/thomashoneyman/purescript-halogen-hooks/blob/main/.github/workflows/ci.yml)
- [slug](https://github.com/thomashoneyman/purescript-slug/blob/main/.github/workflows/ci.yml)
- Add your project here
- ...add your package here!
2 changes: 0 additions & 2 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ inputs:
psa:
description: "The psa version to install. Examples: latest, 0.7.2"
default: "latest"
purty:
description: "The Purty version to install. Examples: latest, 6.2.0"
zephyr:
description: "The Zephyr version to install. Examples: latest, 0.3.2"
runs:
Expand Down
2 changes: 1 addition & 1 deletion dist/index.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/update.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/versions.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"purs":"0.14.3","spago":"0.20.3","psa":"0.8.2","purty":"7.0.0","zephyr":"0.3.2"}
{ "purs": "0.14.3", "spago": "0.20.3", "psa": "0.8.2", "zephyr": "0.3.2" }
21 changes: 1 addition & 20 deletions packages.dhall
Original file line number Diff line number Diff line change
@@ -1,23 +1,4 @@
let upstream =
https://github.com/purescript/package-sets/releases/download/psc-0.13.8-20200922/packages.dhall sha256:5edc9af74593eab8834d7e324e5868a3d258bbab75c5531d2eb770d4324a2900
https://github.com/purescript/package-sets/releases/download/psc-0.14.3-20210722/packages.dhall sha256:1ceb43aa59436bf5601bac45f6f3781c4e1f0e4c2b8458105b018e5ed8c30f8c

in upstream
with versions =
{ dependencies =
[ "console"
, "control"
, "either"
, "exceptions"
, "foldable-traversable"
, "functions"
, "integers"
, "lists"
, "maybe"
, "orders"
, "parsing"
, "partial"
, "strings"
]
, repo = "https://github.com/hdgarrood/purescript-versions.git"
, version = "v5.0.1"
}
11 changes: 5 additions & 6 deletions shell.nix
Original file line number Diff line number Diff line change
@@ -1,22 +1,21 @@
let
pkgs = import (builtins.fetchTarball {
url = "https://github.com/NixOS/nixpkgs/archive/20.03.tar.gz";
url = "https://github.com/NixOS/nixpkgs/archive/21.05.tar.gz";
}) {};

# 2020-08-01 nix-prefetch-git https://github.com/justinwoo/easy-purescript-nix
# 2021-08-05 nix-prefetch-git https://github.com/justinwoo/easy-purescript-nix
pursPkgs = import (pkgs.fetchFromGitHub {
owner = "justinwoo";
repo = "easy-purescript-nix";
rev = "7ff5a12af5750f94d0480059dba0ba6b82c6c452";
sha256 = "0af25dqhs13ii4mx9jjkx2pww4ddbs741vb5gfc5ckxb084d69fq";
rev = "bbef4245cd6810ea84e97a47c801947bfec9fadc";
sha256 = "00764zbwhbn61jwb5px2syzi2f9djyl8fmbd2p8wma985af54iwx";
}) { inherit pkgs; };

in pkgs.stdenv.mkDerivation {
name = "setup-purescript";
buildInputs = with pursPkgs; [
pursPkgs.purs
pursPkgs.spago
pursPkgs.purty
pkgs.nodejs-12_x
pkgs.nodejs-14_x
];
}
26 changes: 19 additions & 7 deletions spago.dhall
Original file line number Diff line number Diff line change
@@ -1,22 +1,34 @@
{ name = "setup-purescript"
, dependencies =
[ "aff"
, "aff-promise"
, "aff-retry"
, "affjax"
, "argonaut-codecs"
, "argonaut-core"
, "console"
, "debug"
, "arrays"
, "bifunctors"
, "effect"
, "either"
, "enums"
, "exceptions"
, "foldable-traversable"
, "github-actions-toolkit"
, "monad-loops"
, "integers"
, "math"
, "maybe"
, "newtype"
, "node-buffer"
, "node-fs"
, "node-path"
, "node-process"
, "nullable"
, "psci-support"
, "record"
, "parsing"
, "partial"
, "prelude"
, "refs"
, "strings"
, "tailrec"
, "transformers"
, "tuples"
, "versions"
]
, packages = ./packages.dhall
Expand Down
2 changes: 1 addition & 1 deletion src/Main.purs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ main = runAff_ go $ runExceptT do

go res = case join res of
Left err -> Core.setFailed (message err)
Right a -> pure unit
Right _ -> pure unit

update :: Effect Unit
update = launchAff_ updateVersions
4 changes: 0 additions & 4 deletions src/Setup/Data/Key.purs
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,6 @@ spagoKey = Key "spago"
psaKey :: Key
psaKey = Key "psa"

purtyKey :: Key
purtyKey = Key "purty"

zephyrKey :: Key
zephyrKey = Key "zephyr"

Expand All @@ -30,5 +27,4 @@ fromTool = case _ of
PureScript -> purescriptKey
Spago -> spagoKey
Psa -> psaKey
Purty -> purtyKey
Zephyr -> zephyrKey
86 changes: 30 additions & 56 deletions src/Setup/Data/Tool.purs
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,23 @@ module Setup.Data.Tool where
import Prelude

import Affjax (URL)
import Data.Either (fromRight)
import Data.Either (fromRight')
import Data.Enum (class Enum, upFromIncluding)
import Data.Foldable (elem, fold)
import Data.Generic.Rep (class Generic)
import Data.Generic.Rep.Bounded (genericBottom, genericTop)
import Data.Generic.Rep.Enum (genericPred, genericSucc)
import Data.Bounded.Generic (genericBottom, genericTop)
import Data.Enum.Generic (genericPred, genericSucc)
import Data.Version (Version, parseVersion)
import Data.Version as Version
import Node.Path (FilePath)
import Node.Path as Path
import Partial.Unsafe (unsafePartial)
import Partial.Unsafe (unsafeCrashWith)
import Setup.Data.Platform (Platform(..), platform)

data Tool
= PureScript
| Spago
| Psa
| Purty
| Zephyr

derive instance eqTool :: Eq Tool
Expand Down Expand Up @@ -52,7 +51,6 @@ name = case _ of
PureScript -> "purs"
Spago -> "spago"
Psa -> "psa"
Purty -> "purty"
Zephyr -> "zephyr"

-- | The source repository for a tool (whether on GitHub or Gitlab)
Expand All @@ -69,9 +67,6 @@ repository = case _ of
Psa ->
{ owner: "natefaubion", name: "purescript-psa" }

Purty ->
{ owner: "joneshf", name: "purty" }

Zephyr ->
{ owner: "coot", name: "zephyr" }

Expand Down Expand Up @@ -99,59 +94,53 @@ installMethod tool version = do
formatArgs = { repo: toolRepo, tag: formatTag, tarball: _ }

formatGitHub' = formatGitHub <<< formatArgs
formatBintray' = formatBintray <<< formatArgs

unsafeVersion str = unsafePartial fromRight $ parseVersion str
unsafeVersion str = fromRight' (\_ -> unsafeCrashWith "Unexpected Left") $ parseVersion str

executableName = case platform of
Windows -> toolName <> ".exe"
_ -> toolName

case tool of
PureScript -> Tarball
{ source: formatGitHub' case platform of
Windows -> "win64"
Mac -> "macos"
Linux -> "linux64"
{ source:
formatGitHub' case platform of
Windows -> "win64"
Mac -> "macos"
Linux -> "linux64"
, getExecutablePath:
\p -> Path.concat [ p, "purescript", executableName ]
}

Spago -> Tarball
{ source: formatGitHub'
-- Spago has changed naming conventions from version to version
if version >= unsafeVersion "0.18.1" then case platform of
Windows -> "Windows"
Mac -> "macOS"
Linux -> "Linux"
else if version == unsafeVersion "0.18.0" then case platform of
Windows -> "windows-latest"
Mac -> "macOS-latest"
Linux -> "linux-latest"
else case platform of
Windows -> "windows"
Mac -> "osx"
Linux -> "linux"
{ source:
formatGitHub'
-- Spago has changed naming conventions from version to version
if version >= unsafeVersion "0.18.1" then case platform of
Windows -> "Windows"
Mac -> "macOS"
Linux -> "Linux"
else if version == unsafeVersion "0.18.0" then case platform of
Windows -> "windows-latest"
Mac -> "macOS-latest"
Linux -> "linux-latest"
else case platform of
Windows -> "windows"
Mac -> "osx"
Linux -> "linux"
, getExecutablePath:
\p -> Path.concat [ p, executableName ]
}

Psa ->
NPM (toolRepo.name <> "@" <> Version.showVersion version)

Purty -> Tarball
{ source: formatBintray' $ case platform of
Windows -> "win"
Mac -> "osx"
Linux -> "linux"
, getExecutablePath: \p -> Path.concat [ p, executableName ]
}

Zephyr -> Tarball
{ source: formatGitHub' $ case platform of
Windows -> "Windows"
Mac -> "macOS"
Linux -> "Linux"
{ source:
formatGitHub' $ case platform of
Windows -> "Windows"
Mac -> "macOS"
Linux -> "Linux"
, getExecutablePath: \p -> Path.concat [ p, "zephyr", executableName ]
}

Expand Down Expand Up @@ -182,18 +171,3 @@ installMethod tool version = do
, tarball
, ".tar.gz"
]

formatBintray :: { repo :: ToolRepository, tag :: String, tarball :: String } -> String
formatBintray { repo, tag, tarball } =
-- Example: https://dl.bintray.com/joneshf/generic/purty-6.2.0-linux.tar.gz
fold
[ "https://dl.bintray.com/"
, repo.owner
, "/generic/"
, repo.name
, "-"
, tag
, "-"
, tarball
, ".tar.gz"
]
12 changes: 4 additions & 8 deletions src/Setup/UpdateVersions.purs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import Prelude
import Affjax as AX
import Affjax.ResponseFormat as RF
import Control.Monad.Rec.Class (untilJust)
import Data.Argonaut.Core (Json, jsonEmptyObject, stringify, stringifyWithIndent)
import Data.Argonaut.Core (Json, jsonEmptyObject, stringifyWithIndent)
import Data.Argonaut.Decode (decodeJson, printJsonDecodeError, (.:))
import Data.Argonaut.Encode ((:=), (~>))
import Data.Array (foldl)
Expand Down Expand Up @@ -63,10 +63,6 @@ fetchLatestReleaseVersion tool = Tool.repository tool # case tool of
PureScript -> fetchFromGitHubReleases
Spago -> fetchFromGitHubReleases
Psa -> fetchFromGitHubTags
-- Technically, Purty is hosted on Gitlab. But without an accessible way to
-- fetch the latest release tag from Gitlab via an API, it seems better to fetch
-- from the GitHub mirror.
Purty -> fetchFromGitHubTags
Zephyr -> fetchFromGitHubReleases
where
-- TODO: These functions really ought to be in ExceptT to avoid all the
Expand Down Expand Up @@ -98,7 +94,7 @@ fetchLatestReleaseVersion tool = Tool.repository tool # case tool of
$ fold
[ "Failed to decode GitHub response. This is most likely due to a timeout.\n\n"
, printJsonDecodeError e
, stringify body
, stringifyWithIndent 2 body
]
Right [] -> pure Nothing
Right objects ->
Expand All @@ -113,7 +109,7 @@ fetchLatestReleaseVersion tool = Tool.repository tool # case tool of
]
Right tagName ->
case tagStrToVersion tagName of
Left e -> do
Left _ -> do
liftEffect $ warning $ fold
[ "Got invalid version"
, tagName
Expand Down Expand Up @@ -153,7 +149,7 @@ fetchLatestReleaseVersion tool = Tool.repository tool # case tool of
throwError $ error $ fold
[ "Failed to decode GitHub response. This is most likely due to a timeout.\n\n"
, printJsonDecodeError e
, stringify body
, stringifyWithIndent 2 body
]

Right arr -> do
Expand Down