Skip to content

Commit 738cc6f

Browse files
author
BSKY
committed
Migrate to GitHub Actions
1 parent c5ab290 commit 738cc6f

File tree

4 files changed

+100
-58
lines changed

4 files changed

+100
-58
lines changed

.circleci/config.yml

Lines changed: 0 additions & 29 deletions
This file was deleted.

.github/workflows/workflow.yml

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
name: Main workflow
2+
3+
on: [push, pull_request]
4+
5+
jobs:
6+
test:
7+
strategy:
8+
matrix:
9+
os: [macos-latest, ubuntu-latest]
10+
node-version: [8.x, 10.x, 12.x]
11+
12+
runs-on: ${{ matrix.os }}
13+
14+
env:
15+
BS_CI: true
16+
OCAMLRUNPARAM: b
17+
18+
steps:
19+
- name: Checkout code
20+
uses: actions/checkout@v2
21+
22+
- name: Checkout submodules
23+
run: |
24+
auth_header="$(git config --local --get http.https://github.com/.extraheader)"
25+
git submodule sync --recursive
26+
git -c "http.extraheader=$auth_header" -c protocol.version=2 submodule update --init --force --recursive --depth=1
27+
28+
- name: Use Node.js ${{ matrix.node-version }}
29+
uses: actions/setup-node@v1
30+
with:
31+
node-version: ${{ matrix.node-version }}
32+
33+
- name: Install packages
34+
run: npm ci
35+
36+
- name: Run tests
37+
run: npm test

.travis.yml

Lines changed: 0 additions & 21 deletions
This file was deleted.

scripts/install.js

Lines changed: 63 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,6 @@ if (supported_os.indexOf(process.platform) < 0) {
2424
}
2525
var is_windows = process.platform === "win32";
2626

27-
28-
2927
var ninja_bin_output = path.join(root_dir, process.platform, "ninja.exe");
3028

3129
/**
@@ -99,13 +97,70 @@ function ensureExists(dir) {
9997
}
10098
}
10199

100+
/**
101+
* @param {string} stdlib
102+
*/
103+
function install(stdlib) {
104+
installDirBy(runtime_dir, ocaml_dir, function(file) {
105+
var y = path.parse(file);
106+
return y.name === "js" || y.ext.includes("cm");
107+
});
108+
installDirBy(others_dir, ocaml_dir, function(file) {
109+
var y = path.parse(file);
110+
return y.ext === ".ml" || y.ext === ".mli" || y.ext.includes("cm");
111+
});
112+
var stdlib_dir = path.join(jscomp_dir, stdlib);
113+
installDirBy(stdlib_dir, ocaml_dir, function(file) {
114+
var y = path.parse(file);
115+
return y.ext === ".ml" || y.ext === ".mli" || y.ext.includes("cm");
116+
});
117+
}
118+
119+
/**
120+
*
121+
* @param {string} sys_extension
122+
*
123+
*/
124+
function copyPrebuiltCompilersForUnix(sys_extension) {
125+
var output = `
126+
rule cp
127+
command = cp $in $out
128+
`;
129+
output += preBuiltCompilerArtifacts
130+
.map(function(x) {
131+
return `build ${x}.exe: cp ${x}${sys_extension}`;
132+
})
133+
.join("\n");
134+
output += "\n";
135+
136+
var filePath = path.join(lib_dir, "copy.ninja");
137+
fs.writeFileSync(filePath, output, "ascii");
138+
cp.execFileSync(ninja_bin_output, ["-f", "copy.ninja"], {
139+
cwd: lib_dir,
140+
stdio: [0, 1, 2]
141+
});
142+
fs.unlinkSync(filePath);
143+
}
102144

145+
/**
146+
*
147+
* @param {string} sys_extension
148+
*
149+
*/
150+
function copyPrebuiltCompilersForWindows(sys_extension) {
151+
preBuiltCompilerArtifacts.forEach(function(x) {
152+
fs.copyFileSync(
153+
path.join(lib_dir, `${x}${sys_extension}`),
154+
path.join(lib_dir, `${x}.exe`)
155+
);
156+
});
157+
}
103158

104159
/**
105160
* @returns {string|undefined}
106161
*/
107162
function checkPrebuiltBscCompiler() {
108-
if (process.env.BS_TRAVIS_CI) {
163+
if (process.env.BS_CI) {
109164
return;
110165
}
111166
try {
@@ -144,7 +199,7 @@ stdlib = ${stdlib}
144199
subninja runtime/release.ninja
145200
subninja others/release.ninja
146201
subninja $stdlib/release.ninja
147-
${process.env.BS_TRAVIS_CI ? "subninja test/build.ninja\n" : "\n"}
202+
${process.env.BS_CI ? "subninja test/build.ninja\n" : "\n"}
148203
build all: phony runtime others $stdlib
149204
`;
150205
var filePath = path.join(jscomp_dir, "release.ninja");
@@ -156,7 +211,7 @@ build all: phony runtime others $stdlib
156211
shell: false
157212
});
158213
var buildArgs = ["-f", "release.ninja"];
159-
if (process.env.BS_TRAVIS_CI) {
214+
if (process.env.BS_CI) {
160215
buildArgs.push("--verbose");
161216
}
162217
cp.execFileSync(ninja_bin_output, buildArgs, {
@@ -203,11 +258,11 @@ function provideCompiler() {
203258

204259
var filePath = path.join(lib_dir, "release.ninja");
205260
fs.writeFileSync(filePath, releaseNinja, "ascii");
206-
cp.execFileSync(ninja_bin_output, ["-f", "release.ninja","-t", "clean"], {
261+
cp.execFileSync(ninja_bin_output, ["-f", "release.ninja", "-t", "clean"], {
207262
cwd: lib_dir,
208263
stdio: [0, 1, 2]
209264
});
210-
cp.execFileSync(ninja_bin_output, ["-f", "release.ninja","-v"], {
265+
cp.execFileSync(ninja_bin_output, ["-f", "release.ninja", "-v"], {
211266
cwd: lib_dir,
212267
stdio: [0, 1, 2]
213268
});
@@ -224,5 +279,5 @@ var stdlib = ocamlVersion.includes("4.02") ? "stdlib-402" : "stdlib-406";
224279

225280
if (process.env.BS_TRAVIS_CI) {
226281
buildLibs(stdlib);
227-
require('./installUtils.js').install()
282+
require("./installUtils.js").install();
228283
}

0 commit comments

Comments
 (0)