Skip to content

Commit

Permalink
Merge pull request reasonml#2 from jchavarri/joo
Browse files Browse the repository at this point in the history
Bring in jchavarri's changes
  • Loading branch information
jaredly authored Nov 27, 2019
2 parents 1aca9a2 + 7b335f1 commit d667cb8
Show file tree
Hide file tree
Showing 332 changed files with 18,241 additions and 47,766 deletions.
82 changes: 82 additions & 0 deletions .ci/build-platform.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
parameters:
platform: "macOS"
vmImage: "macOS-10.13"

jobs:
- job: ${{ parameters.platform }}
pool:
vmImage: ${{ parameters.vmImage }}
demands: node.js
timeoutInMinutes: 120 # This is mostly for Windows
steps:
- powershell: $Env:Path
continueOnError: true
condition: and(eq(variables['AGENT.OS'], 'Windows_NT'), and(eq(variables['Build.Reason'], 'PullRequest'), and(succeeded(), ne(variables['Build.SourceBranch'], variables['System.PullRequest.TargetBranch']))))
displayName: "Print env in powershell"
# Needed so that the mingw tar doesn't shadow the system tar. See
# pipelines.yaml. We need windows bsdtar from system32, not the mingw
# one. Note powershell doesn't need escaping of backslashes.
- powershell: Write-Host "##vso[task.setvariable variable=PATH;]C:\Windows\system32;${env:PATH}"
continueOnError: true
condition: eq(variables['AGENT.OS'], 'Windows_NT')
displayName: "Make sure windows/system32 is at front of path if windows"
- powershell: $Env:Path
continueOnError: true
condition: and(eq(variables['AGENT.OS'], 'Windows_NT'), and(eq(variables['Build.Reason'], 'PullRequest'), and(succeeded(), ne(variables['Build.SourceBranch'], variables['System.PullRequest.TargetBranch']))))
displayName: "Print env in powershell"
- powershell: get-command tar
continueOnError: true
condition: and(eq(variables['AGENT.OS'], 'Windows_NT'), and(eq(variables['Build.Reason'], 'PullRequest'), and(succeeded(), ne(variables['Build.SourceBranch'], variables['System.PullRequest.TargetBranch']))))
displayName: "Print where tar is located"
- powershell: tar --help
continueOnError: true
condition: and(eq(variables['AGENT.OS'], 'Windows_NT'), and(eq(variables['Build.Reason'], 'PullRequest'), and(succeeded(), ne(variables['Build.SourceBranch'], variables['System.PullRequest.TargetBranch']))))
displayName: "Print tar help"
- bash: |
# COMPUTE THE ESY INSTALL CACHE LOCATION AHEAD OF TIME
DESIRED_LEN="86"
# Note: This will need to change when upgrading esy version
# that reenables long paths on windows.
if [ "$AGENT_OS" == "Windows_NT" ]; then
DESIRED_LEN="33"
fi
HOME_ESY3="$HOME/.esy/3"
HOME_ESY3_LEN=${#HOME_ESY3}
NUM_UNDERS=$(echo "$(($DESIRED_LEN-$HOME_ESY3_LEN))")
UNDERS=$(printf "%-${NUM_UNDERS}s" "_")
UNDERS="${UNDERS// /_}"
THE_ESY__CACHE_INSTALL_PATH=${HOME_ESY3}${UNDERS}/i
if [ "$AGENT_OS" == "Windows_NT" ]; then
THE_ESY__CACHE_INSTALL_PATH=$( cygpath --mixed --absolute "$THE_ESY__CACHE_INSTALL_PATH")
fi
echo "THE_ESY__CACHE_INSTALL_PATH: $THE_ESY__CACHE_INSTALL_PATH"
# This will be exposed as an env var ESY__CACHE_INSTALL_PATH, or an
# Azure var esy__cache_install_path
echo "##vso[task.setvariable variable=esy__cache_install_path]$THE_ESY__CACHE_INSTALL_PATH"
# - bash: |
# which esy
# echo "$( which esy )"
# echo "##vso[task.setvariable variable=esy_bin_location]$(which esy)"
# displayName: "Find esy binary"
# - bash: echo ${ESY_BIN_LOCATION}
# displayName: "Print esy bin location"
- bash: env
displayName: "Print environment"
- template: utils/use-node.yml
- template: utils/use-esy.yml
- script: "esy install"
displayName: "esy install"
- template: utils/restore-build-cache.yml
- script: "esy build"
displayName: "esy build"
- template: utils/create-docs.yml
- script: "esy test"
displayName: "Test command"
- script: "esy release"
displayName: "esy release"
- template: utils/publish-build-cache.yml
- task: PublishBuildArtifacts@1
displayName: "Publish Artifact: ${{ parameters.platform }}"
inputs:
PathtoPublish: "_release"
ArtifactName: ${{ parameters.platform }}
34 changes: 34 additions & 0 deletions .ci/cross-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
steps:
- template: utils/use-node.yml

- script: "mkdir _release"
displayName: "Create _release dir"

- template: release-platform-setup.yml
parameters:
platform: "Linux"
folder: "platform-linux"

- template: release-platform-setup.yml
parameters:
platform: "macOS"
folder: "platform-darwin"

- template: release-platform-setup.yml
parameters:
platform: "Windows"
folder: "platform-windows-x64"

- script: "node .ci/pipelines-release.js"
displayName: "node .ci/pipelines-release.js"
continueOnError: true

- script: "npm pack ."
displayName: "npm pack"
workingDirectory: "_release"

- task: PublishBuildArtifacts@1
displayName: "Publish Artifact: Release"
inputs:
PathtoPublish: "_release"
ArtifactName: Release
15 changes: 15 additions & 0 deletions .ci/esy-build-steps.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Cross-platform set of build steps for building esy projects

steps:
- template: utils/use-node.yml
- template: utils/use-esy.yml
- template: utils/restore-build-cache.yml
- script: esy install
displayName: 'esy install'
- script: esy build
displayName: 'esy build'
- template: utils/publish-build-cache.yml
- script: esy x refmt --version
displayName: 'esy x refmt --version'
# Run tests or any additional steps here
# - script: esy b dune runtest
38 changes: 38 additions & 0 deletions .ci/opam-build-steps.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# Shared steps for building OPAM projects

steps:
- task: NodeTool@0
inputs:
versionSpec: '8.9'
- script: brew install gpatch
displayName: 'brew install gpatch'
- script: brew install opam
displayName: 'brew install opam'
- script: opam --version
displayName: 'Check opam version'
- script: opam init --auto-setup --dot-profile=~/.bash_profile
displayName: 'opam init'
- script: opam remote add ocamlorg https://opam.ocaml.org || true
displayName: 'opam remote add ocamlorg'
- script: opam remove default || true
displayName: 'opam remove default'
- script: opam update
displayName: 'opam update'
- script: opam switch create $(OCAML_VERSION)
displayName: 'Use OCaml version: $(OCAML_VERSION)'
- script: opam install -y dune
displayName: 'opam install -y dune'
- script: opam install -y menhir
displayName: 'opam install -y menhir'
- script: opam install -y utop
displayName: 'opam install -y utop'
- script: make clean-for-ci
displayName: 'make clean-for-ci'
- script: opam pin add -y reason .
displayName: "opam pin add -y reason ."
- script: opam pin add -y rtop .
displayName: "opam pin add -y rtop ."
- script: eval $(opam env); make test-ci
displayName: "make test-ci"
- script: git diff --exit-code
displayName: "Check git is clean"
114 changes: 114 additions & 0 deletions .ci/pipelines-release.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
const fs = require("fs");
const path = require("path");

console.log("Creating package.json");

// From the project root pwd
const mainPackageJsonPath =
fs.existsSync('esy.json') ?
'esy.json' : 'package.json';

const exists = fs.existsSync(mainPackageJsonPath);
if (!exists) {
console.error("No package.json or esy.json at " + mainPackageJsonPath);
process.exit(1);
}
// Now require from this script's location.
const mainPackageJson = require(path.join('..', mainPackageJsonPath));
const bins =
Array.isArray(mainPackageJson.esy.release.bin) ?
mainPackageJson.esy.release.bin.reduce(
(acc, curr) => Object.assign({ [curr]: "bin/" + curr }, acc),
{}
) :
Object.keys(mainPackageJson.esy.release.bin).reduce(
(acc, currKey) => Object.assign({ [currKey]: "bin/" + mainPackageJson.esy.release.bin[currKey] }, acc),
{}
);

const rewritePrefix =
mainPackageJson.esy &&
mainPackageJson.esy.release &&
mainPackageJson.esy.release.rewritePrefix;

const packageJson = JSON.stringify(
{
name: mainPackageJson.name,
version: mainPackageJson.version,
license: mainPackageJson.license,
description: mainPackageJson.description,
repository: mainPackageJson.repository,
scripts: {
postinstall:
rewritePrefix ?
"ESY_RELEASE_REWRITE_PREFIX=true node ./postinstall.js" :
"node ./postinstall.js"
},
bin: bins,
files: [
"_export/",
"bin/",
"postinstall.js",
"esyInstallRelease.js",
"platform-linux/",
"platform-darwin/",
"platform-windows-x64/"
]
},
null,
2
);

fs.writeFileSync(
path.join(__dirname, "..", "_release", "package.json"),
packageJson,
{
encoding: "utf8"
}
);

try {
console.log("Copying LICENSE");
fs.copyFileSync(
path.join(__dirname, "..", "LICENSE"),
path.join(__dirname, "..", "_release", "LICENSE")
);
} catch (e) {
console.warn("No LICENSE found");
}

console.log("Copying README.md");
fs.copyFileSync(
path.join(__dirname, "..", "README.md"),
path.join(__dirname, "..", "_release", "README.md")
);

console.log("Copying postinstall.js");
fs.copyFileSync(
path.join(__dirname, "release-postinstall.js"),
path.join(__dirname, "..", "_release", "postinstall.js")
);

console.log("Creating placeholder files");
const placeholderFile = `:; echo "You need to have postinstall enabled"; exit $?
@ECHO OFF
ECHO You need to have postinstall enabled`;
fs.mkdirSync(path.join(__dirname, "..", "_release", "bin"));

Object.keys(bins).forEach(
name => {
if(bins[name]) {
const binPath = path.join(
__dirname,
"..",
"_release",
bins[name]
);
fs.writeFileSync(binPath, placeholderFile);
fs.chmodSync(binPath, 0777);
} else {
console.log("bins[name] name=" + name + " was empty. Weird.");
console.log(bins);
}
}
);
16 changes: 16 additions & 0 deletions .ci/release-platform-setup.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
parameters:
platform: "macOS"
folder: "platform-darwin"

steps:
- task: DownloadBuildArtifacts@0
displayName: "Download ${{ parameters.platform }} Artifacts"
inputs:
artifactName: ${{ parameters.platform }}
downloadPath: $(Build.StagingDirectory)

- script: "mkdir _release/${{ parameters.folder }}"
displayName: "Create _release/${{ parameters.folder }}"

- script: "cp -r $(Build.StagingDirectory)/${{ parameters.platform }}/ _release/${{ parameters.folder }}"
displayName: "cp ${{ parameters.platform }}"
Loading

0 comments on commit d667cb8

Please # to comment.