Skip to content

Commit

Permalink
Merge pull request #3 from calcit-lang/debug
Browse files Browse the repository at this point in the history
debug cache
  • Loading branch information
NoEgAm committed Mar 15, 2024
2 parents 0940221 + 74f3795 commit 86432fe
Show file tree
Hide file tree
Showing 6 changed files with 189 additions and 62 deletions.
1 change: 1 addition & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ inputs:
description: Version of Calcit install
required: true
default: 0.8.38

runs:
using: node20
main: dist/index.js
Expand Down
45 changes: 16 additions & 29 deletions dist/index.js

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

2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

41 changes: 12 additions & 29 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,41 +3,23 @@ const fs = require("fs");
const core = require("@actions/core");
const tc = require("@actions/tool-cache");

let getCrDownloadUrl = (version) => {
return `https://github.com/calcit-lang/calcit/releases/download/${version}/cr`;
};

let getCapsDownloadUrl = (version) => {
return `https://github.com/calcit-lang/calcit/releases/download/${version}/caps`;
};

const version = core.getInput("version");

async function setup() {
const binFolder = `/home/runner/bin/`;

async function setup(bin) {
try {
// Get version of tool to be installed

const pathToCr = await tc.downloadTool(
getCrDownloadUrl(version),
"/home/runner/bin/cr"
);
const pathToCaps = await tc.downloadTool(
getCapsDownloadUrl(version),
"/home/runner/bin/caps"
);

// TODO cache
// https://github.com/actions/toolkit/tree/main/packages/tool-cache#cache

// Expose the tool by adding it to the PATH
fs.chmodSync(pathToCr, 0o755);
core.addPath(path.dirname(pathToCr));
let url = `https://github.com/calcit-lang/calcit/releases/download/${version}/${bin}`;
let binPath = `${binFolder}${bin}`;

console.log(`add to path: ${pathToCr}`);
const pathToCr = await tc.downloadTool(url, binPath);
console.log(`downloaded to: ${pathToCr}`);

fs.chmodSync(pathToCaps, 0o755);
core.addPath(path.dirname(pathToCaps));
console.log(`add to path: ${pathToCaps}`);
fs.chmodSync(binPath, 0o755);
core.addPath(binFolder);
console.log(`add binary to path: ${binPath}`);
} catch (e) {
core.setFailed(e);
}
Expand All @@ -47,5 +29,6 @@ module.exports = setup;

if (require.main === module) {
console.log(`Setting up Calcit ${version}`);
setup();
setup("cr");
setup("caps");
}
12 changes: 9 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,19 +1,25 @@
{
"name": "setup-cr",
"version": "0.0.2",
"version": "0.0.3",
"description": "Setup Calcit runtime",
"main": "./index.js",
"repository": "git@github.com:calcit-lang/setup-cr.git",
"author": "tiye <jiyinyiyong@gmail.com>",
"license": "MIT",
"scripts": {
"dist": "ncc build index.js -o dist --source-map"
"dist": "ncc build index.js -o dist --source-map",
"stage-dist": "git add -v dist"
},
"pre-commit": [
"dist",
"stage-dist"
],
"dependencies": {
"@actions/core": "^1.10.1",
"@actions/tool-cache": "^2.0.1"
},
"devDependencies": {
"@vercel/ncc": "^0.38.1"
"@vercel/ncc": "^0.38.1",
"pre-commit": "^1.2.2"
}
}
150 changes: 150 additions & 0 deletions yarn.lock

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

0 comments on commit 86432fe

Please sign in to comment.