mirror of
https://github.com/actions/runner.git
synced 2025-12-18 08:17:02 +00:00
test out different workspaces
This commit is contained in:
@@ -1,5 +1,9 @@
|
|||||||
//const glob = require('@actions/glob')
|
import * as crypto from 'crypto'
|
||||||
|
import * as fs from 'fs'
|
||||||
import * as glob from '@actions/glob'
|
import * as glob from '@actions/glob'
|
||||||
|
import * as path from 'path'
|
||||||
|
import * as stream from 'stream'
|
||||||
|
import * as util from 'util'
|
||||||
|
|
||||||
async function run(): Promise<void> {
|
async function run(): Promise<void> {
|
||||||
// arg0 -> node
|
// arg0 -> node
|
||||||
@@ -14,18 +18,48 @@ async function run(): Promise<void> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
console.log(`Match Pattern: ${matchPatterns}`)
|
console.log(`Match Pattern: ${matchPatterns}`)
|
||||||
try {
|
let hasMatch = false
|
||||||
const result = await glob.hashFiles(
|
console.log('runner cwd: ', process.cwd())
|
||||||
matchPatterns,
|
const githubWorkspace = process.env['GITHUB_WORKSPACE'] ?? process.cwd()
|
||||||
{followSymbolicLinks},
|
console.log('current workspace: ', process.env['GITHUB_WORKSPACE'])
|
||||||
true
|
const result = crypto.createHash('sha256')
|
||||||
)
|
let count = 0
|
||||||
console.error(`__OUTPUT__${result}__OUTPUT__`)
|
const globber = await glob.create(matchPatterns, {followSymbolicLinks})
|
||||||
process.exit(0)
|
for await (const file of globber.globGenerator()) {
|
||||||
} catch (error) {
|
console.log(file)
|
||||||
console.log(error)
|
if (!file.startsWith(`${githubWorkspace}${path.sep}`)) {
|
||||||
process.exit(1)
|
console.log(`Ignore '${file}' since it is not under GITHUB_WORKSPACE.`)
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
if (fs.statSync(file).isDirectory()) {
|
||||||
|
console.log(`Skip directory '${file}'.`)
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
const hash = crypto.createHash('sha256')
|
||||||
|
const pipeline = util.promisify(stream.pipeline)
|
||||||
|
await pipeline(fs.createReadStream(file), hash)
|
||||||
|
result.write(hash.digest())
|
||||||
|
count++
|
||||||
|
if (!hasMatch) {
|
||||||
|
hasMatch = true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
result.end()
|
||||||
|
|
||||||
|
if (hasMatch) {
|
||||||
|
console.log(`Found ${count} files to hash.`)
|
||||||
|
console.error(`__OUTPUT__${result.digest('hex')}__OUTPUT__`)
|
||||||
|
} else {
|
||||||
|
console.error(`__OUTPUT____OUTPUT__`)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
run()
|
run()
|
||||||
|
.then(out => {
|
||||||
|
console.log(out)
|
||||||
|
process.exit(0)
|
||||||
|
})
|
||||||
|
.catch(err => {
|
||||||
|
console.error(err)
|
||||||
|
process.exit(1)
|
||||||
|
})
|
||||||
|
|||||||
@@ -15,6 +15,13 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|||||||
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
var __asyncValues = (this && this.__asyncValues) || function (o) {
|
||||||
|
if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
|
||||||
|
var m = o[Symbol.asyncIterator], i;
|
||||||
|
return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i);
|
||||||
|
function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }
|
||||||
|
function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }
|
||||||
|
};
|
||||||
var __importStar = (this && this.__importStar) || function (mod) {
|
var __importStar = (this && this.__importStar) || function (mod) {
|
||||||
if (mod && mod.__esModule) return mod;
|
if (mod && mod.__esModule) return mod;
|
||||||
var result = {};
|
var result = {};
|
||||||
@@ -23,9 +30,15 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|||||||
return result;
|
return result;
|
||||||
};
|
};
|
||||||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||||
//const glob = require('@actions/glob')
|
const crypto = __importStar(__nccwpck_require__(6113));
|
||||||
|
const fs = __importStar(__nccwpck_require__(7147));
|
||||||
const glob = __importStar(__nccwpck_require__(8090));
|
const glob = __importStar(__nccwpck_require__(8090));
|
||||||
|
const path = __importStar(__nccwpck_require__(1017));
|
||||||
|
const stream = __importStar(__nccwpck_require__(2781));
|
||||||
|
const util = __importStar(__nccwpck_require__(3837));
|
||||||
function run() {
|
function run() {
|
||||||
|
var e_1, _a;
|
||||||
|
var _b;
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
// arg0 -> node
|
// arg0 -> node
|
||||||
// arg1 -> hashFiles.js
|
// arg1 -> hashFiles.js
|
||||||
@@ -38,18 +51,61 @@ function run() {
|
|||||||
followSymbolicLinks = true;
|
followSymbolicLinks = true;
|
||||||
}
|
}
|
||||||
console.log(`Match Pattern: ${matchPatterns}`);
|
console.log(`Match Pattern: ${matchPatterns}`);
|
||||||
|
let hasMatch = false;
|
||||||
|
console.log('runner cwd: ', process.cwd());
|
||||||
|
const githubWorkspace = (_b = process.env['GITHUB_WORKSPACE'], (_b !== null && _b !== void 0 ? _b : process.cwd()));
|
||||||
|
console.log('current workspace: ', process.env['GITHUB_WORKSPACE']);
|
||||||
|
const result = crypto.createHash('sha256');
|
||||||
|
let count = 0;
|
||||||
|
const globber = yield glob.create(matchPatterns, { followSymbolicLinks });
|
||||||
try {
|
try {
|
||||||
const result = yield glob.hashFiles(matchPatterns, { followSymbolicLinks }, true);
|
for (var _c = __asyncValues(globber.globGenerator()), _d; _d = yield _c.next(), !_d.done;) {
|
||||||
console.error(`__OUTPUT__${result}__OUTPUT__`);
|
const file = _d.value;
|
||||||
process.exit(0);
|
console.log(file);
|
||||||
|
if (!file.startsWith(`${githubWorkspace}${path.sep}`)) {
|
||||||
|
console.log(`Ignore '${file}' since it is not under GITHUB_WORKSPACE.`);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (fs.statSync(file).isDirectory()) {
|
||||||
|
console.log(`Skip directory '${file}'.`);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
const hash = crypto.createHash('sha256');
|
||||||
|
const pipeline = util.promisify(stream.pipeline);
|
||||||
|
yield pipeline(fs.createReadStream(file), hash);
|
||||||
|
result.write(hash.digest());
|
||||||
|
count++;
|
||||||
|
if (!hasMatch) {
|
||||||
|
hasMatch = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
catch (error) {
|
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
||||||
console.log(error);
|
finally {
|
||||||
process.exit(1);
|
try {
|
||||||
|
if (_d && !_d.done && (_a = _c.return)) yield _a.call(_c);
|
||||||
|
}
|
||||||
|
finally { if (e_1) throw e_1.error; }
|
||||||
|
}
|
||||||
|
result.end();
|
||||||
|
if (hasMatch) {
|
||||||
|
console.log(`Found ${count} files to hash.`);
|
||||||
|
console.error(`__OUTPUT__${result.digest('hex')}__OUTPUT__`);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
console.error(`__OUTPUT____OUTPUT__`);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
run();
|
run()
|
||||||
|
.then(out => {
|
||||||
|
console.log(out);
|
||||||
|
process.exit(0);
|
||||||
|
})
|
||||||
|
.catch(err => {
|
||||||
|
console.error(err);
|
||||||
|
process.exit(1);
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
/***/ }),
|
/***/ }),
|
||||||
@@ -1441,7 +1497,9 @@ function hashFiles(globber, verbose = false) {
|
|||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
const writeDelegate = verbose ? core.info : core.debug;
|
const writeDelegate = verbose ? core.info : core.debug;
|
||||||
let hasMatch = false;
|
let hasMatch = false;
|
||||||
|
console.log('globber cwd: ',process.cwd())
|
||||||
const githubWorkspace = (_b = process.env['GITHUB_WORKSPACE']) !== null && _b !== void 0 ? _b : process.cwd();
|
const githubWorkspace = (_b = process.env['GITHUB_WORKSPACE']) !== null && _b !== void 0 ? _b : process.cwd();
|
||||||
|
console.log('workspace: ', githubWorkspace);
|
||||||
const result = crypto.createHash('sha256');
|
const result = crypto.createHash('sha256');
|
||||||
let count = 0;
|
let count = 0;
|
||||||
try {
|
try {
|
||||||
|
|||||||
Reference in New Issue
Block a user