Skip to content

Stop including the versions file in the bundle #19

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 10 commits into from
Feb 25, 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
19 changes: 11 additions & 8 deletions .github/workflows/integration.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
name: Integration

on:
push:
branches: [main]
pull_request:
types: [synchronize]
push: {}
schedule:
- cron: "0 5 * * *"

Expand All @@ -24,9 +24,12 @@ jobs:

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

- name: Check spago, psa, and purs are installed correctly
run: spago build --purs-args '--censor-lib --strict --codegen corefn,js'

- name: Check zephyr is installed correctly
run: zephyr -f Main.main

- name: Check spago and purs are installed correctly
# run: spago build --purs-args '--censor-lib --strict --codegen corefn,js'
run: |
purs --version
spago version

# - name: Check zephyr is installed correctly
# run: zephyr -f Main.main
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.

3 changes: 1 addition & 2 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
"use strict";

var Main = require("./output/index");
var versions = require("./dist/versions.json");

Main.main(versions)();
Main.main();
26 changes: 13 additions & 13 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@
"dependencies": {
"@actions/core": "^1.2.6",
"@actions/exec": "^1.0.4",
"@actions/tool-cache": "^1.6.0",
"xhr2": "^0.2.0"
"@actions/tool-cache": "^1.6.1",
"xhr2": "^0.2.1"
},
"devDependencies": {
"@vercel/ncc": "^0.23.0"
"@vercel/ncc": "^0.27.0"
}
}
18 changes: 12 additions & 6 deletions src/Main.purs
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,28 @@ module Main where

import Prelude

import Control.Monad.Except.Trans (mapExceptT, runExceptT)
import Data.Argonaut.Core (Json)
import Control.Monad.Except.Trans (ExceptT(..), mapExceptT, runExceptT)
import Data.Argonaut.Parser as Json
import Data.Bifunctor (lmap)
import Data.Either (Either(..))
import Data.Foldable (traverse_)
import Effect (Effect)
import Effect.Aff (launchAff_, runAff_)
import Effect.Aff (error, launchAff_, runAff_)
import Effect.Class (liftEffect)
import Effect.Exception (message)
import GitHub.Actions.Core as Core
import Node.Buffer as Buffer
import Node.Encoding (Encoding(..))
import Node.FS.Sync (readFile)
import Setup.BuildPlan (constructBuildPlan)
import Setup.GetTool (getTool)
import Setup.UpdateVersions (updateVersions)

main :: Json -> Effect Unit
main json = runAff_ go $ runExceptT do
tools <- mapExceptT liftEffect $ constructBuildPlan json
main :: Effect Unit
main = runAff_ go $ runExceptT do
versionsString <- liftEffect $ Buffer.toString UTF8 =<< readFile "./dist/versions.json"
versionsJson <- ExceptT $ pure $ lmap error $ Json.jsonParser versionsString
tools <- mapExceptT liftEffect $ constructBuildPlan versionsJson
liftEffect $ Core.info "Constructed build plan."
traverse_ getTool tools
liftEffect $ Core.info "Fetched tools."
Expand Down
30 changes: 23 additions & 7 deletions src/Setup/Data/Tool.purs
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,17 @@ module Setup.Data.Tool where
import Prelude

import Affjax (URL)
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.Version (Version)
import Data.Version (Version, parseVersion)
import Data.Version as Version
import Node.Path (FilePath)
import Node.Path as Path
import Partial.Unsafe (unsafePartial)
import Setup.Data.Platform (Platform(..), platform)

data Tool
Expand Down Expand Up @@ -99,6 +101,8 @@ installMethod tool version = do
formatGitHub' = formatGitHub <<< formatArgs
formatBintray' = formatBintray <<< formatArgs

unsafeVersion str = unsafePartial fromRight $ parseVersion str

executableName = case platform of
Windows -> toolName <> ".exe"
_ -> toolName
Expand All @@ -109,15 +113,27 @@ installMethod tool version = do
Windows -> "win64"
Mac -> "macos"
Linux -> "linux64"
, getExecutablePath: \p -> Path.concat [ p, "purescript", executableName ]
, getExecutablePath:
\p -> Path.concat [ p, "purescript", executableName ]
}

Spago -> Tarball
{ source: formatGitHub' $ case platform of
Windows -> "windows"
Mac -> "osx"
Linux -> "linux"
, getExecutablePath: \p -> Path.concat [ p, executableName ]
{ 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 ->
Expand Down