Skip to content

Commit

Permalink
Fix CI
Browse files Browse the repository at this point in the history
  • Loading branch information
alfonsogarciacaro committed Feb 11, 2019
1 parent 5d9ceff commit b067567
Show file tree
Hide file tree
Showing 15 changed files with 136 additions and 50 deletions.
23 changes: 9 additions & 14 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,23 +1,18 @@
language: csharp
sudo: false # use the new container-based Travis infrastructure
os: linux
dist: trusty
sudo: false
dotnet: 2.1.403
mono: none

addons:
apt:
packages:
- libunwind8

before_install:
- curl -o- -L https://yarnpkg.com/install.sh | bash -s -- --version 1.2.1
- export PATH=$HOME/.yarn/bin:$PATH
cache:
yarn: true
# cache:
# yarn: true

before_script:
- nvm install 10.10.0
- nvm use 10.10.0
- nvm install 10.15.0
- nvm use 10.15.0
# # Update npm
# - npm install -g npm

script:
- ./build.sh All
- npm install && npm test
26 changes: 13 additions & 13 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ build:
verbosity: detailed

environment:
nodejs_version: "10.10.0"
nodejs_version: "10.15.0"

cache:
- "%LOCALAPPDATA%\\Yarn"
# cache:
# - "%LOCALAPPDATA%\\Yarn"

# Install scripts. (runs after repo cloning)
install:
Expand All @@ -23,15 +23,15 @@ os: Visual Studio 2015
# before_build:
# - cmd: set PATH=C:\Program Files (x86)\MSBuild\14.0\Bin;%PATH%
build_script:
- cmd: build.cmd
- cmd: npm install && npm test
test: off
# version: 0.0.1.{build}
artifacts:
# https://ci.appveyor.com/api/projects/fable-compiler/Fable/artifacts/src/dotnet/Fable.Repl/repl.zip
- path: src\Fable.Repl\out
name: repl
type: zip
# https://ci.appveyor.com/api/projects/fable-compiler/Fable/artifacts/src/dotnet/Fable.Repl/repl-bundle.zip
- path: src\Fable.Repl\bundle
name: repl-bundle
type: zip
# artifacts:
# # https://ci.appveyor.com/api/projects/fable-compiler/Fable/artifacts/src/dotnet/Fable.Repl/repl.zip
# - path: src\Fable.Repl\out
# name: repl
# type: zip
# # https://ci.appveyor.com/api/projects/fable-compiler/Fable/artifacts/src/dotnet/Fable.Repl/repl-bundle.zip
# - path: src\Fable.Repl\bundle
# name: repl-bundle
# type: zip
24 changes: 20 additions & 4 deletions build.fsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,15 @@ let buildTypescript projectDir =
let buildLibrary() =
cleanDirs ["build/fable-library"]
buildTypescript "src/fable-library"
run "npx fable-splitter --fable-library force:${outDir} -c src/fable-library/splitter.config.js"
run "npx fable-splitter -c src/fable-library/splitter.config.js"

let test() =
if pathExists "build/fable-library" |> not then
buildLibrary()

cleanDirs ["build/tests"]
run "npx fable-splitter -c tests/splitter.config.js"
run "npx mocha build/tests --reporter dot -t 10000"

let buildCompiler() =
let projectDir = "src/fable-compiler"
Expand All @@ -37,15 +45,23 @@ let buildCompiler() =
copyDirRecursive "build/fable-library" (projectDir </> "bin/fable-library")

match args with
| IgnoreCase "test"::_ ->
test()

| IgnoreCase "library"::_ ->
buildLibrary()

| IgnoreCase "compiler"::_ ->
buildCompiler()

| IgnoreCase "publish-compiler"::_ ->
buildCompiler()
pushNpm "src/fable-compiler"
| IgnoreCase "publish"::project ->
match project with
| [] -> failwith "Pass the project to publish"
| IgnoreCase "compiler"::_
| IgnoreCase "fable-compiler"::_ ->
buildCompiler()
pushNpm "src/fable-compiler"
| _ -> failwithf "Cannot publish %A" project

| _ ->
printfn "Please pass a target name"
Expand Down
2 changes: 1 addition & 1 deletion global.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"sdk": {
"version": "2.2.103"
"version": "2.1.403"
}
}
6 changes: 3 additions & 3 deletions package-lock.json

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

13 changes: 3 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,8 @@
"private": true,
"scripts": {
"build": "fable build.fsx --run",
"build-library-typescript": "tsc --project src/fable-library",
"build-library-fsharp": "fable-splitter --fable-library force:${outDir} -c src/fable-library/splitter.config.js",
"build-library": "concurrently \"npm:build-library-*\"",
"build-compiler-typescript": "",
"build-compiler-fsharp": "",
"build-compiler": "",
"clean-compiler": "cd src/fable-compiler && rm -rf dist/ bin/",
"clean-build-folder": "rm -rf build",
"clean": "concurrently \"npm:clean-*\""
"publish": "fable build.fsx --run publish",
"test": "fable build.fsx --run test"
},
"dependencies": {
"@babel/cli": "^7.2.3",
Expand All @@ -26,7 +19,7 @@
"concurrently": "^4.1.0",
"fable-babel-plugins": "^2.1.0",
"fable-compiler": "^2.1.10",
"fable-compiler-js": "^1.0.0-alpha-012",
"fable-compiler-js": "^1.0.0-alpha-014",
"fable-loader": "^2.1.2",
"fable-splitter": "^2.1.2",
"mocha": "^5.2.0",
Expand Down
3 changes: 3 additions & 0 deletions src/Fable.Cli/Util.fs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ module Literals =
set [| "System"
"System.Collections"
"System.Collections.Concurrent"
"System.ComponentModel"
"System.ComponentModel.Primitives"
"System.ComponentModel.TypeConverter"
"System.Console"
"System.Core"
"System.Diagnostics.Debug"
Expand Down
3 changes: 3 additions & 0 deletions src/Fable.Repl/Metadata.fs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ let references_core = [|
"netstandard"
"System.Collections"
"System.Collections.Concurrent"
"System.ComponentModel"
"System.ComponentModel.Primitives"
"System.ComponentModel.TypeConverter"
"System.Console"
"System.Core"
"System.Diagnostics.Debug"
Expand Down
17 changes: 16 additions & 1 deletion src/fable-library/String.ts
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ export function format(str: string, ...args: any[]) {
(match: any, idx: any, pad: any, pattern: any) => {
let rep = args[idx];
let padSymbol = " ";
if (typeof rep === "number") { // TODO: Long & Decimal || rep instanceof Long || rep instanceof Decimal) {
if (typeof rep === "number") {
switch ((pattern || "").substring(0, 1)) {
case "f": case "F":
rep = pattern.length > 1 ? rep.toFixed(pattern.substring(1)) : rep.toFixed(2);
Expand Down Expand Up @@ -226,6 +226,21 @@ export function format(str: string, ...args: any[]) {
rep = pattern;
}
}
} else if (rep instanceof Long) { // TODO: Other numeric types? Decimal, BigInt
switch ((pattern || "").substring(0, 1)) {
case "x":
rep = toHex(rep); break;
case "X":
rep = toHex(rep).toUpperCase(); break;
default:
const m = /^(0+)(\.0+)?$/.exec(pattern);
if (m != null) {
pad = "," + m[1].length.toString();
padSymbol = "0";
} else if (pattern) {
rep = pattern;
}
}
} else if (rep instanceof Date) {
rep = dateToString(rep, pattern);
}
Expand Down
12 changes: 10 additions & 2 deletions src/fable-library/splitter.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,18 @@ const outDir = useCommonjs
: "../../build/fable-library";

module.exports = {
entry: path.join(__dirname, "Fable.Library.fsproj"),
outDir: path.join(__dirname, outDir),
cli: {
path: resolve("../Fable.Cli"),
fableLibrary: "force:${outDir}"
},
entry: resolve("Fable.Library.fsproj"),
outDir: resolve(outDir),
allFiles: true,
// port: 61225,
babel: babelOptions,
fable: fableOptions,
};

function resolve(p) {
return path.join(__dirname, p);
}
Binary file not shown.
Binary file not shown.
Binary file added src/fable-metadata/System.ComponentModel.dll
Binary file not shown.
48 changes: 48 additions & 0 deletions src/fable-publish-utils/PublishUtils.fs
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,12 @@ let args: string list =
|> Seq.skip 2
|> Seq.toList

let isWindows =
nodeProcess?platform = "win32"

let isLinux =
nodeProcess?platform = "linux"

let fullPath (p: string): string =
path?resolve(p)

Expand Down Expand Up @@ -166,13 +172,22 @@ let runInDir cwd cmd: unit =
"cwd" ==> cwd
])

let tryRunForOutput (cmd: string): string option =
try
childProcess?execSync.Invoke(cmd).ToString().Trim() |> Some
with _ -> None

let runList cmdParts =
String.concat " " cmdParts |> run

let environVarOrNone (varName: string): string option =
nodeProcess?env?(varName)
|> Option.ofObj

let addToEnvPath (p: string): unit =
let SEPARATOR = if isWindows then ";" else ":"
nodeProcess?env?PATH <- p + SEPARATOR + nodeProcess?env?PATH

let (|IgnoreCase|_|) (pattern: string) (input: string) =
if String.Equals(input, pattern, StringComparison.OrdinalIgnoreCase) then
Some IgnoreCase
Expand Down Expand Up @@ -296,3 +311,36 @@ let pushNuget projFile =

let pushNpm projDir =
Publish.pushNpm projDir

let getDotNetSDKVersionFromGlobalJson(): string =
let json = readFile "global.json" |> Fable.Import.JS.JSON.parse
json?sdk?version

let installDotnetSdk() =
let sdkVersion = getDotNetSDKVersionFromGlobalJson()
let mustInstall =
match tryRunForOutput "dotnet --version" with
| None -> true
| Some v -> v <> sdkVersion
if mustInstall then
let archiveFileName =
if isWindows then
sprintf "dotnet-sdk-%s-win-x64.zip" sdkVersion
elif isLinux then
sprintf "dotnet-sdk-%s-linux-x64.tar.gz" sdkVersion
else
sprintf "dotnet-sdk-%s-osx-x64.tar.gz" sdkVersion
let downloadPath = sprintf "https://dotnetcli.blob.core.windows.net/dotnet/Sdk/%s/%s" sdkVersion archiveFileName
failwith "TODO: download and unzip"
// downloadSDK downloadPath archiveFileName
// addToEnvPath dotnetExe
(*
function DownloadAndUnzip(URL, outDir){
var zlib = require('zlib');
var https = require('https');
var out = fs.createWriteStream(outDir);
var request = https.get(URL, function(response) {
response.pipe(zlib.createGunzip()).pipe(out)
});
}
*)
9 changes: 7 additions & 2 deletions tests/splitter.config.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
const path = require("path");

module.exports = {
entry: path.join(__dirname, "Main/Fable.Tests.fsproj"),
outDir: path.join(__dirname, "../build/tests"),
cli: { path: resolve("../src/Fable.Cli") },
entry: resolve("Main/Fable.Tests.fsproj"),
outDir: resolve("../build/tests"),
fable: { define: defineConstants() },
babel: {
plugins: ["@babel/plugin-transform-modules-commonjs"],
Expand All @@ -25,3 +26,7 @@ function defineConstants() {
}
return ar;
}

function resolve(p) {
return path.join(__dirname, p);
}

0 comments on commit b067567

Please sign in to comment.