Skip to content
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

test github actions #8141

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/actions/setup-opam/.gitattributes
@@ -0,0 +1 @@
*.exe binary
Empty file.
5 changes: 5 additions & 0 deletions .github/actions/setup-opam/action.yml
@@ -0,0 +1,5 @@
name: Setup opam environment
description: Installs opam
runs:
using: 'node12'
main: 'index.js'
105 changes: 105 additions & 0 deletions .github/actions/setup-opam/index.js
@@ -0,0 +1,105 @@
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/

const core = require('@actions/core');
const exec = require('@actions/exec');
const io = require('@actions/io');
const tc = require('@actions/tool-cache');
const path = require('path');
const uuidV4 = require('uuid/v4');

const CYGWIN_PACKAGES = [
'rsync',
'patch',
'diffutils',
'curl',
'make',
'unzip',
'git',
'm4',
'perl',
'mingw64-x86_64-gcc-core',
];

async function installWindows() {
// Install cygwin and the packages that opam needs.
//
// TODO: see if this might be faster:
//
// const cygwinInstaller = await tc.downloadTool('https://cygwin.com/setup-x86_64.exe');
// await exec.exec(cygwinInstaller, [
// '--no-admin',
// '--no-shortcuts',
// '--packages',
// ...CYGWIN_PACKAGES,
// '--prune-install',
// '--quiet-mode',
// ]);
await exec.exec(`choco.exe install cygwin`);
await exec.exec(`choco.exe install ${CYGWIN_PACKAGES.join(' ')} --source=cygwin`);

// download opam installer
console.log(`Downloading opam`);
const opamInstaller = await tc.downloadTool('https://github.com/fdopen/opam-repository-mingw/releases/download/0.0.0.2/opam64.tar.xz');

// extract opam installer. tool-cache's extractTar almost works, except for
// actions/toolkit#165 and actions/toolkit#180, so we duplicate some of its
// functionality.
const tempDirectory = process.env['RUNNER_TEMP'] || path.join(process.env['USERPROFILE'] || 'C:\\', 'flow', 'temp');
const dest = path.join(tempDirectory, uuidV4());
await io.mkdirP(dest);
console.log(`Created temporary directory ${dest}`);
const tarPath = await io.which('tar', true);
await exec.exec(`"${tarPath}"`, ["-x", "--force-local", "-f", opamInstaller, "-C", dest.replace(/\\/g, '/')]);

// run opam installer
await exec.exec(
"c:\\tools\\cygwin\\bin\\bash.exe",
["opam64/install.sh"],
{
cwd: dest,
env: {
...process.env,
PATH: "c:\\tools\\cygwin\\bin",
},
}
);
}

async function installLinux() {
const url = 'https://github.com/ocaml/opam/releases/download/2.0.5/opam-2.0.5-x86_64-linux';
const exe = await tc.downloadTool(url);
// TODO: chmod +x, mv into PATH
}

async function installMac() {
const url = 'https://github.com/ocaml/opam/releases/download/2.0.5/opam-2.0.5-x86_64-macos';
const exe = await tc.downloadTool(url);
// TODO: chmod +x, mv into PATH
}

async function run() {
try {
switch (process.platform) {
case 'win32':
await installWindows();
break;
case 'linux':
await installLinux();
break;
case 'darwin':
await installMac();
break;
default:
core.setFailed(`Unsupported platform: ${process.platform}`);
}
} catch (error) {
core.setFailed(error.message);
}
}

run();
1 change: 1 addition & 0 deletions .github/actions/setup-opam/node_modules/.bin/semver

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

1 change: 1 addition & 0 deletions .github/actions/setup-opam/node_modules/.bin/uuid

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

28 changes: 28 additions & 0 deletions .github/actions/setup-opam/node_modules/.yarn-integrity

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

107 changes: 107 additions & 0 deletions .github/actions/setup-opam/node_modules/@actions/core/README.md

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

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

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

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