Skip to content

Commit 980da9f

Browse files
Stop including the versions file in the bundle (#19)
The versions.json file was previously being bundled into the build, which meant that subsequent runs of the tool would always point to the same point in time instead of updating with the version of the file in dist. Also, this PR fixes the names for Spago binaries, which have changed a bit version to version.
1 parent 61f5414 commit 980da9f

File tree

8 files changed

+65
-41
lines changed

8 files changed

+65
-41
lines changed

.github/workflows/integration.yml

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
name: Integration
22

33
on:
4+
push:
5+
branches: [main]
46
pull_request:
5-
types: [synchronize]
6-
push: {}
77
schedule:
88
- cron: "0 5 * * *"
99

@@ -24,9 +24,12 @@ jobs:
2424

2525
- name: Check purty is installed correctly
2626
run: purty src/Main.purs
27-
28-
- name: Check spago, psa, and purs are installed correctly
29-
run: spago build --purs-args '--censor-lib --strict --codegen corefn,js'
30-
31-
- name: Check zephyr is installed correctly
32-
run: zephyr -f Main.main
27+
28+
- name: Check spago and purs are installed correctly
29+
# run: spago build --purs-args '--censor-lib --strict --codegen corefn,js'
30+
run: |
31+
purs --version
32+
spago version
33+
34+
# - name: Check zephyr is installed correctly
35+
# run: zephyr -f Main.main

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.

index.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
"use strict";
22

33
var Main = require("./output/index");
4-
var versions = require("./dist/versions.json");
54

6-
Main.main(versions)();
5+
Main.main();

package-lock.json

Lines changed: 13 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: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@
1313
"dependencies": {
1414
"@actions/core": "^1.2.6",
1515
"@actions/exec": "^1.0.4",
16-
"@actions/tool-cache": "^1.6.0",
17-
"xhr2": "^0.2.0"
16+
"@actions/tool-cache": "^1.6.1",
17+
"xhr2": "^0.2.1"
1818
},
1919
"devDependencies": {
20-
"@vercel/ncc": "^0.23.0"
20+
"@vercel/ncc": "^0.27.0"
2121
}
2222
}

src/Main.purs

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,28 @@ module Main where
22

33
import Prelude
44

5-
import Control.Monad.Except.Trans (mapExceptT, runExceptT)
6-
import Data.Argonaut.Core (Json)
5+
import Control.Monad.Except.Trans (ExceptT(..), mapExceptT, runExceptT)
6+
import Data.Argonaut.Parser as Json
7+
import Data.Bifunctor (lmap)
78
import Data.Either (Either(..))
89
import Data.Foldable (traverse_)
910
import Effect (Effect)
10-
import Effect.Aff (launchAff_, runAff_)
11+
import Effect.Aff (error, launchAff_, runAff_)
1112
import Effect.Class (liftEffect)
1213
import Effect.Exception (message)
1314
import GitHub.Actions.Core as Core
15+
import Node.Buffer as Buffer
16+
import Node.Encoding (Encoding(..))
17+
import Node.FS.Sync (readFile)
1418
import Setup.BuildPlan (constructBuildPlan)
1519
import Setup.GetTool (getTool)
1620
import Setup.UpdateVersions (updateVersions)
1721

18-
main :: Json -> Effect Unit
19-
main json = runAff_ go $ runExceptT do
20-
tools <- mapExceptT liftEffect $ constructBuildPlan json
22+
main :: Effect Unit
23+
main = runAff_ go $ runExceptT do
24+
versionsString <- liftEffect $ Buffer.toString UTF8 =<< readFile "./dist/versions.json"
25+
versionsJson <- ExceptT $ pure $ lmap error $ Json.jsonParser versionsString
26+
tools <- mapExceptT liftEffect $ constructBuildPlan versionsJson
2127
liftEffect $ Core.info "Constructed build plan."
2228
traverse_ getTool tools
2329
liftEffect $ Core.info "Fetched tools."

src/Setup/Data/Tool.purs

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,17 @@ module Setup.Data.Tool where
33
import Prelude
44

55
import Affjax (URL)
6+
import Data.Either (fromRight)
67
import Data.Enum (class Enum, upFromIncluding)
78
import Data.Foldable (elem, fold)
89
import Data.Generic.Rep (class Generic)
910
import Data.Generic.Rep.Bounded (genericBottom, genericTop)
1011
import Data.Generic.Rep.Enum (genericPred, genericSucc)
11-
import Data.Version (Version)
12+
import Data.Version (Version, parseVersion)
1213
import Data.Version as Version
1314
import Node.Path (FilePath)
1415
import Node.Path as Path
16+
import Partial.Unsafe (unsafePartial)
1517
import Setup.Data.Platform (Platform(..), platform)
1618

1719
data Tool
@@ -99,6 +101,8 @@ installMethod tool version = do
99101
formatGitHub' = formatGitHub <<< formatArgs
100102
formatBintray' = formatBintray <<< formatArgs
101103

104+
unsafeVersion str = unsafePartial fromRight $ parseVersion str
105+
102106
executableName = case platform of
103107
Windows -> toolName <> ".exe"
104108
_ -> toolName
@@ -109,15 +113,27 @@ installMethod tool version = do
109113
Windows -> "win64"
110114
Mac -> "macos"
111115
Linux -> "linux64"
112-
, getExecutablePath: \p -> Path.concat [ p, "purescript", executableName ]
116+
, getExecutablePath:
117+
\p -> Path.concat [ p, "purescript", executableName ]
113118
}
114119

115120
Spago -> Tarball
116-
{ source: formatGitHub' $ case platform of
117-
Windows -> "windows"
118-
Mac -> "osx"
119-
Linux -> "linux"
120-
, getExecutablePath: \p -> Path.concat [ p, executableName ]
121+
{ source: formatGitHub'
122+
-- Spago has changed naming conventions from version to version
123+
if version >= unsafeVersion "0.18.1" then case platform of
124+
Windows -> "Windows"
125+
Mac -> "macOS"
126+
Linux -> "Linux"
127+
else if version == unsafeVersion "0.18.0" then case platform of
128+
Windows -> "windows-latest"
129+
Mac -> "macOS-latest"
130+
Linux -> "linux-latest"
131+
else case platform of
132+
Windows -> "windows"
133+
Mac -> "osx"
134+
Linux -> "linux"
135+
, getExecutablePath:
136+
\p -> Path.concat [ p, executableName ]
121137
}
122138

123139
Psa ->

0 commit comments

Comments
 (0)