fix: post action run even if cache is false (#24)

This commit is contained in:
Frost Ming 2022-10-21 22:17:30 +08:00 committed by GitHub
parent 5f2990033f
commit ed9b6c5626
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 144 additions and 85 deletions

86
dist/cache-save.js vendored
View File

@ -2068,7 +2068,7 @@ var require_core = __commonJS({
process.env["PATH"] = `${inputPath}${path.delimiter}${process.env["PATH"]}`; process.env["PATH"] = `${inputPath}${path.delimiter}${process.env["PATH"]}`;
} }
exports.addPath = addPath; exports.addPath = addPath;
function getInput2(name, options) { function getInput(name, options) {
const val = process.env[`INPUT_${name.replace(/ /g, "_").toUpperCase()}`] || ""; const val = process.env[`INPUT_${name.replace(/ /g, "_").toUpperCase()}`] || "";
if (options && options.required && !val) { if (options && options.required && !val) {
throw new Error(`Input required and not supplied: ${name}`); throw new Error(`Input required and not supplied: ${name}`);
@ -2078,19 +2078,19 @@ var require_core = __commonJS({
} }
return val.trim(); return val.trim();
} }
exports.getInput = getInput2; exports.getInput = getInput;
function getMultilineInput(name, options) { function getMultilineInput(name, options) {
const inputs = getInput2(name, options).split("\n").filter((x) => x !== ""); const inputs = getInput(name, options).split("\n").filter((x) => x !== "");
if (options && options.trimWhitespace === false) { if (options && options.trimWhitespace === false) {
return inputs; return inputs;
} }
return inputs.map((input) => input.trim()); return inputs.map((input) => input.trim());
} }
exports.getMultilineInput = getMultilineInput; exports.getMultilineInput = getMultilineInput;
function getBooleanInput(name, options) { function getBooleanInput2(name, options) {
const trueValue = ["true", "True", "TRUE"]; const trueValue = ["true", "True", "TRUE"];
const falseValue = ["false", "False", "FALSE"]; const falseValue = ["false", "False", "FALSE"];
const val = getInput2(name, options); const val = getInput(name, options);
if (trueValue.includes(val)) if (trueValue.includes(val))
return true; return true;
if (falseValue.includes(val)) if (falseValue.includes(val))
@ -2098,7 +2098,7 @@ var require_core = __commonJS({
throw new TypeError(`Input does not meet YAML 1.2 "Core Schema" specification: ${name} throw new TypeError(`Input does not meet YAML 1.2 "Core Schema" specification: ${name}
Support boolean input list: \`true | True | TRUE | false | False | FALSE\``); Support boolean input list: \`true | True | TRUE | false | False | FALSE\``);
} }
exports.getBooleanInput = getBooleanInput; exports.getBooleanInput = getBooleanInput2;
function setOutput(name, value) { function setOutput(name, value) {
const filePath = process.env["GITHUB_OUTPUT"] || ""; const filePath = process.env["GITHUB_OUTPUT"] || "";
if (filePath) { if (filePath) {
@ -43712,9 +43712,9 @@ var require_dist9 = __commonJS({
} }
}); });
// node_modules/.pnpm/@azure+storage-blob@12.11.0/node_modules/@azure/storage-blob/dist/index.js // node_modules/.pnpm/@azure+storage-blob@12.12.0/node_modules/@azure/storage-blob/dist/index.js
var require_dist10 = __commonJS({ var require_dist10 = __commonJS({
"node_modules/.pnpm/@azure+storage-blob@12.11.0/node_modules/@azure/storage-blob/dist/index.js"(exports) { "node_modules/.pnpm/@azure+storage-blob@12.12.0/node_modules/@azure/storage-blob/dist/index.js"(exports) {
"use strict"; "use strict";
Object.defineProperty(exports, "__esModule", { value: true }); Object.defineProperty(exports, "__esModule", { value: true });
var coreHttp = require_dist7(); var coreHttp = require_dist7();
@ -52196,7 +52196,7 @@ var require_dist10 = __commonJS({
var version = { var version = {
parameterPath: "version", parameterPath: "version",
mapper: { mapper: {
defaultValue: "2021-08-06", defaultValue: "2021-10-04",
isConstant: true, isConstant: true,
serializedName: "x-ms-version", serializedName: "x-ms-version",
type: { type: {
@ -56498,14 +56498,15 @@ var require_dist10 = __commonJS({
serializer: xmlSerializer serializer: xmlSerializer
}; };
var logger = logger$1.createClientLogger("storage-blob"); var logger = logger$1.createClientLogger("storage-blob");
var SDK_VERSION = "12.11.0"; var SDK_VERSION = "12.12.0";
var SERVICE_VERSION = "2021-08-06"; var SERVICE_VERSION = "2021-10-04";
var BLOCK_BLOB_MAX_UPLOAD_BLOB_BYTES = 256 * 1024 * 1024; var BLOCK_BLOB_MAX_UPLOAD_BLOB_BYTES = 256 * 1024 * 1024;
var BLOCK_BLOB_MAX_STAGE_BLOCK_BYTES = 4e3 * 1024 * 1024; var BLOCK_BLOB_MAX_STAGE_BLOCK_BYTES = 4e3 * 1024 * 1024;
var BLOCK_BLOB_MAX_BLOCKS = 5e4; var BLOCK_BLOB_MAX_BLOCKS = 5e4;
var DEFAULT_BLOCK_BUFFER_SIZE_BYTES = 8 * 1024 * 1024; var DEFAULT_BLOCK_BUFFER_SIZE_BYTES = 8 * 1024 * 1024;
var DEFAULT_BLOB_DOWNLOAD_BLOCK_BYTES = 4 * 1024 * 1024; var DEFAULT_BLOB_DOWNLOAD_BLOCK_BYTES = 4 * 1024 * 1024;
var DEFAULT_MAX_DOWNLOAD_RETRY_REQUESTS = 5; var DEFAULT_MAX_DOWNLOAD_RETRY_REQUESTS = 5;
var REQUEST_TIMEOUT = 100 * 1e3;
var StorageOAuthScopes = "https://storage.azure.com/.default"; var StorageOAuthScopes = "https://storage.azure.com/.default";
var URLConstants = { var URLConstants = {
Parameters: { Parameters: {
@ -56690,6 +56691,28 @@ var require_dist10 = __commonJS({
]; ];
var BlobUsesCustomerSpecifiedEncryptionMsg = "BlobUsesCustomerSpecifiedEncryption"; var BlobUsesCustomerSpecifiedEncryptionMsg = "BlobUsesCustomerSpecifiedEncryption";
var BlobDoesNotUseCustomerSpecifiedEncryption = "BlobDoesNotUseCustomerSpecifiedEncryption"; var BlobDoesNotUseCustomerSpecifiedEncryption = "BlobDoesNotUseCustomerSpecifiedEncryption";
var PathStylePorts = [
"10000",
"10001",
"10002",
"10003",
"10004",
"10100",
"10101",
"10102",
"10103",
"10104",
"11000",
"11001",
"11002",
"11003",
"11004",
"11100",
"11101",
"11102",
"11103",
"11104"
];
function escapeURLPath(url2) { function escapeURLPath(url2) {
const urlParsed = coreHttp.URLBuilder.parse(url2); const urlParsed = coreHttp.URLBuilder.parse(url2);
let path = urlParsed.getPath(); let path = urlParsed.getPath();
@ -56924,7 +56947,7 @@ var require_dist10 = __commonJS({
return false; return false;
} }
const host = parsedUrl.getHost() + (parsedUrl.getPort() === void 0 ? "" : ":" + parsedUrl.getPort()); const host = parsedUrl.getHost() + (parsedUrl.getPort() === void 0 ? "" : ":" + parsedUrl.getPort());
return /^.*:.*:.*$|^localhost(:[0-9]+)?$|^(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])(\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])){3}(:[0-9]+)?$/.test(host); return /^.*:.*:.*$|^localhost(:[0-9]+)?$|^(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])(\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])){3}(:[0-9]+)?$/.test(host) || parsedUrl.getPort() !== void 0 && PathStylePorts.includes(parsedUrl.getPort());
} }
function toBlobTagsString(tags2) { function toBlobTagsString(tags2) {
if (tags2 === void 0) { if (tags2 === void 0) {
@ -57404,6 +57427,13 @@ var require_dist10 = __commonJS({
}; };
} }
} }
function EscapePath(blobName) {
const split = blobName.split("/");
for (let i = 0; i < split.length; i++) {
split[i] = encodeURIComponent(split[i]);
}
return split.join("/");
}
var StorageBrowserPolicy = class extends coreHttp.BaseRequestPolicy { var StorageBrowserPolicy = class extends coreHttp.BaseRequestPolicy {
constructor(nextPolicy, options) { constructor(nextPolicy, options) {
super(nextPolicy, options); super(nextPolicy, options);
@ -57902,7 +57932,7 @@ ${key}:${decodeURIComponent(lowercaseQueries[key])}`;
} }
}; };
var packageName = "azure-storage-blob"; var packageName = "azure-storage-blob";
var packageVersion = "12.11.0"; var packageVersion = "12.12.0";
var StorageClientContext = class extends coreHttp__namespace.ServiceClient { var StorageClientContext = class extends coreHttp__namespace.ServiceClient {
constructor(url2, options) { constructor(url2, options) {
if (url2 === void 0) { if (url2 === void 0) {
@ -57919,7 +57949,7 @@ ${key}:${decodeURIComponent(lowercaseQueries[key])}`;
this.requestContentType = "application/json; charset=utf-8"; this.requestContentType = "application/json; charset=utf-8";
this.baseUri = options.endpoint || "{url}"; this.baseUri = options.endpoint || "{url}";
this.url = url2; this.url = url2;
this.version = options.version || "2021-08-06"; this.version = options.version || "2021-10-04";
} }
}; };
var StorageClient = class { var StorageClient = class {
@ -60268,8 +60298,10 @@ ${key}:${decodeURIComponent(lowercaseQueries[key])}`;
let pos = 0; let pos = 0;
const count = end - offset; const count = end - offset;
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
const timeout = setTimeout(() => reject(new Error(`The operation cannot be completed in timeout.`)), REQUEST_TIMEOUT);
stream2.on("readable", () => { stream2.on("readable", () => {
if (pos >= count) { if (pos >= count) {
clearTimeout(timeout);
resolve(); resolve();
return; return;
} }
@ -60285,12 +60317,16 @@ ${key}:${decodeURIComponent(lowercaseQueries[key])}`;
pos += chunkLength; pos += chunkLength;
}); });
stream2.on("end", () => { stream2.on("end", () => {
clearTimeout(timeout);
if (pos < count) { if (pos < count) {
reject(new Error(`Stream drains before getting enough data needed. Data read: ${pos}, data need: ${count}`)); reject(new Error(`Stream drains before getting enough data needed. Data read: ${pos}, data need: ${count}`));
} }
resolve(); resolve();
}); });
stream2.on("error", reject); stream2.on("error", (msg) => {
clearTimeout(timeout);
reject(msg);
});
}); });
} }
async function streamToBuffer2(stream2, buffer, encoding) { async function streamToBuffer2(stream2, buffer, encoding) {
@ -62349,16 +62385,16 @@ ${key}:${decodeURIComponent(lowercaseQueries[key])}`;
} }
} }
getBlobClient(blobName) { getBlobClient(blobName) {
return new BlobClient(appendToURLPath(this.url, encodeURIComponent(blobName)), this.pipeline); return new BlobClient(appendToURLPath(this.url, EscapePath(blobName)), this.pipeline);
} }
getAppendBlobClient(blobName) { getAppendBlobClient(blobName) {
return new AppendBlobClient(appendToURLPath(this.url, encodeURIComponent(blobName)), this.pipeline); return new AppendBlobClient(appendToURLPath(this.url, EscapePath(blobName)), this.pipeline);
} }
getBlockBlobClient(blobName) { getBlockBlobClient(blobName) {
return new BlockBlobClient(appendToURLPath(this.url, encodeURIComponent(blobName)), this.pipeline); return new BlockBlobClient(appendToURLPath(this.url, EscapePath(blobName)), this.pipeline);
} }
getPageBlobClient(blobName) { getPageBlobClient(blobName) {
return new PageBlobClient(appendToURLPath(this.url, encodeURIComponent(blobName)), this.pipeline); return new PageBlobClient(appendToURLPath(this.url, EscapePath(blobName)), this.pipeline);
} }
async getProperties(options = {}) { async getProperties(options = {}) {
if (!options.conditions) { if (!options.conditions) {
@ -64641,7 +64677,7 @@ var import_fs = __toESM(require("fs"));
function run() { function run() {
return __async(this, null, function* () { return __async(this, null, function* () {
try { try {
const cache2 = core.getInput("cache"); const cache2 = core.getBooleanInput("cache");
if (cache2) { if (cache2) {
yield saveCache2(); yield saveCache2();
} }
@ -64656,11 +64692,7 @@ function saveCache2() {
const cachePaths = JSON.parse(core.getState("cache-paths")); const cachePaths = JSON.parse(core.getState("cache-paths"));
core.debug(`paths for caching are ${cachePaths.join(", ")}`); core.debug(`paths for caching are ${cachePaths.join(", ")}`);
if (cachePaths.every((path) => !import_fs.default.existsSync(path))) { if (cachePaths.every((path) => !import_fs.default.existsSync(path))) {
throw new Error( throw new Error(`Cache folder path is retrieved for pdm but doesn't exist on disk: ${cachePaths.join(", ")}`);
`Cache folder path is retrieved for pdm but doesn't exist on disk: ${cachePaths.join(
", "
)}`
);
} }
const primaryKey = core.getState("cache-primary-key"); const primaryKey = core.getState("cache-primary-key");
const matchedKey = core.getState("cache-matched-key"); const matchedKey = core.getState("cache-matched-key");
@ -64668,9 +64700,7 @@ function saveCache2() {
core.warning("Error retrieving key from state."); core.warning("Error retrieving key from state.");
return; return;
} else if (matchedKey === primaryKey) { } else if (matchedKey === primaryKey) {
core.info( core.info(`Cache hit occurred on the primary key ${primaryKey}, not saving cache.`);
`Cache hit occurred on the primary key ${primaryKey}, not saving cache.`
);
return; return;
} }
const cacheId = yield cache.saveCache(cachePaths, primaryKey); const cacheId = yield cache.saveCache(cachePaths, primaryKey);

62
dist/setup-pdm.js vendored
View File

@ -43712,9 +43712,9 @@ var require_dist9 = __commonJS({
} }
}); });
// node_modules/.pnpm/@azure+storage-blob@12.11.0/node_modules/@azure/storage-blob/dist/index.js // node_modules/.pnpm/@azure+storage-blob@12.12.0/node_modules/@azure/storage-blob/dist/index.js
var require_dist10 = __commonJS({ var require_dist10 = __commonJS({
"node_modules/.pnpm/@azure+storage-blob@12.11.0/node_modules/@azure/storage-blob/dist/index.js"(exports) { "node_modules/.pnpm/@azure+storage-blob@12.12.0/node_modules/@azure/storage-blob/dist/index.js"(exports) {
"use strict"; "use strict";
Object.defineProperty(exports, "__esModule", { value: true }); Object.defineProperty(exports, "__esModule", { value: true });
var coreHttp = require_dist7(); var coreHttp = require_dist7();
@ -52196,7 +52196,7 @@ var require_dist10 = __commonJS({
var version = { var version = {
parameterPath: "version", parameterPath: "version",
mapper: { mapper: {
defaultValue: "2021-08-06", defaultValue: "2021-10-04",
isConstant: true, isConstant: true,
serializedName: "x-ms-version", serializedName: "x-ms-version",
type: { type: {
@ -56498,14 +56498,15 @@ var require_dist10 = __commonJS({
serializer: xmlSerializer serializer: xmlSerializer
}; };
var logger = logger$1.createClientLogger("storage-blob"); var logger = logger$1.createClientLogger("storage-blob");
var SDK_VERSION = "12.11.0"; var SDK_VERSION = "12.12.0";
var SERVICE_VERSION = "2021-08-06"; var SERVICE_VERSION = "2021-10-04";
var BLOCK_BLOB_MAX_UPLOAD_BLOB_BYTES = 256 * 1024 * 1024; var BLOCK_BLOB_MAX_UPLOAD_BLOB_BYTES = 256 * 1024 * 1024;
var BLOCK_BLOB_MAX_STAGE_BLOCK_BYTES = 4e3 * 1024 * 1024; var BLOCK_BLOB_MAX_STAGE_BLOCK_BYTES = 4e3 * 1024 * 1024;
var BLOCK_BLOB_MAX_BLOCKS = 5e4; var BLOCK_BLOB_MAX_BLOCKS = 5e4;
var DEFAULT_BLOCK_BUFFER_SIZE_BYTES = 8 * 1024 * 1024; var DEFAULT_BLOCK_BUFFER_SIZE_BYTES = 8 * 1024 * 1024;
var DEFAULT_BLOB_DOWNLOAD_BLOCK_BYTES = 4 * 1024 * 1024; var DEFAULT_BLOB_DOWNLOAD_BLOCK_BYTES = 4 * 1024 * 1024;
var DEFAULT_MAX_DOWNLOAD_RETRY_REQUESTS = 5; var DEFAULT_MAX_DOWNLOAD_RETRY_REQUESTS = 5;
var REQUEST_TIMEOUT = 100 * 1e3;
var StorageOAuthScopes = "https://storage.azure.com/.default"; var StorageOAuthScopes = "https://storage.azure.com/.default";
var URLConstants = { var URLConstants = {
Parameters: { Parameters: {
@ -56690,6 +56691,28 @@ var require_dist10 = __commonJS({
]; ];
var BlobUsesCustomerSpecifiedEncryptionMsg = "BlobUsesCustomerSpecifiedEncryption"; var BlobUsesCustomerSpecifiedEncryptionMsg = "BlobUsesCustomerSpecifiedEncryption";
var BlobDoesNotUseCustomerSpecifiedEncryption = "BlobDoesNotUseCustomerSpecifiedEncryption"; var BlobDoesNotUseCustomerSpecifiedEncryption = "BlobDoesNotUseCustomerSpecifiedEncryption";
var PathStylePorts = [
"10000",
"10001",
"10002",
"10003",
"10004",
"10100",
"10101",
"10102",
"10103",
"10104",
"11000",
"11001",
"11002",
"11003",
"11004",
"11100",
"11101",
"11102",
"11103",
"11104"
];
function escapeURLPath(url2) { function escapeURLPath(url2) {
const urlParsed = coreHttp.URLBuilder.parse(url2); const urlParsed = coreHttp.URLBuilder.parse(url2);
let path8 = urlParsed.getPath(); let path8 = urlParsed.getPath();
@ -56924,7 +56947,7 @@ var require_dist10 = __commonJS({
return false; return false;
} }
const host = parsedUrl.getHost() + (parsedUrl.getPort() === void 0 ? "" : ":" + parsedUrl.getPort()); const host = parsedUrl.getHost() + (parsedUrl.getPort() === void 0 ? "" : ":" + parsedUrl.getPort());
return /^.*:.*:.*$|^localhost(:[0-9]+)?$|^(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])(\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])){3}(:[0-9]+)?$/.test(host); return /^.*:.*:.*$|^localhost(:[0-9]+)?$|^(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])(\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])){3}(:[0-9]+)?$/.test(host) || parsedUrl.getPort() !== void 0 && PathStylePorts.includes(parsedUrl.getPort());
} }
function toBlobTagsString(tags2) { function toBlobTagsString(tags2) {
if (tags2 === void 0) { if (tags2 === void 0) {
@ -57404,6 +57427,13 @@ var require_dist10 = __commonJS({
}; };
} }
} }
function EscapePath(blobName) {
const split = blobName.split("/");
for (let i = 0; i < split.length; i++) {
split[i] = encodeURIComponent(split[i]);
}
return split.join("/");
}
var StorageBrowserPolicy = class extends coreHttp.BaseRequestPolicy { var StorageBrowserPolicy = class extends coreHttp.BaseRequestPolicy {
constructor(nextPolicy, options) { constructor(nextPolicy, options) {
super(nextPolicy, options); super(nextPolicy, options);
@ -57902,7 +57932,7 @@ ${key}:${decodeURIComponent(lowercaseQueries[key])}`;
} }
}; };
var packageName = "azure-storage-blob"; var packageName = "azure-storage-blob";
var packageVersion = "12.11.0"; var packageVersion = "12.12.0";
var StorageClientContext = class extends coreHttp__namespace.ServiceClient { var StorageClientContext = class extends coreHttp__namespace.ServiceClient {
constructor(url2, options) { constructor(url2, options) {
if (url2 === void 0) { if (url2 === void 0) {
@ -57919,7 +57949,7 @@ ${key}:${decodeURIComponent(lowercaseQueries[key])}`;
this.requestContentType = "application/json; charset=utf-8"; this.requestContentType = "application/json; charset=utf-8";
this.baseUri = options.endpoint || "{url}"; this.baseUri = options.endpoint || "{url}";
this.url = url2; this.url = url2;
this.version = options.version || "2021-08-06"; this.version = options.version || "2021-10-04";
} }
}; };
var StorageClient = class { var StorageClient = class {
@ -60268,8 +60298,10 @@ ${key}:${decodeURIComponent(lowercaseQueries[key])}`;
let pos = 0; let pos = 0;
const count = end - offset; const count = end - offset;
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
const timeout = setTimeout(() => reject(new Error(`The operation cannot be completed in timeout.`)), REQUEST_TIMEOUT);
stream3.on("readable", () => { stream3.on("readable", () => {
if (pos >= count) { if (pos >= count) {
clearTimeout(timeout);
resolve(); resolve();
return; return;
} }
@ -60285,12 +60317,16 @@ ${key}:${decodeURIComponent(lowercaseQueries[key])}`;
pos += chunkLength; pos += chunkLength;
}); });
stream3.on("end", () => { stream3.on("end", () => {
clearTimeout(timeout);
if (pos < count) { if (pos < count) {
reject(new Error(`Stream drains before getting enough data needed. Data read: ${pos}, data need: ${count}`)); reject(new Error(`Stream drains before getting enough data needed. Data read: ${pos}, data need: ${count}`));
} }
resolve(); resolve();
}); });
stream3.on("error", reject); stream3.on("error", (msg) => {
clearTimeout(timeout);
reject(msg);
});
}); });
} }
async function streamToBuffer2(stream3, buffer, encoding) { async function streamToBuffer2(stream3, buffer, encoding) {
@ -62349,16 +62385,16 @@ ${key}:${decodeURIComponent(lowercaseQueries[key])}`;
} }
} }
getBlobClient(blobName) { getBlobClient(blobName) {
return new BlobClient(appendToURLPath(this.url, encodeURIComponent(blobName)), this.pipeline); return new BlobClient(appendToURLPath(this.url, EscapePath(blobName)), this.pipeline);
} }
getAppendBlobClient(blobName) { getAppendBlobClient(blobName) {
return new AppendBlobClient(appendToURLPath(this.url, encodeURIComponent(blobName)), this.pipeline); return new AppendBlobClient(appendToURLPath(this.url, EscapePath(blobName)), this.pipeline);
} }
getBlockBlobClient(blobName) { getBlockBlobClient(blobName) {
return new BlockBlobClient(appendToURLPath(this.url, encodeURIComponent(blobName)), this.pipeline); return new BlockBlobClient(appendToURLPath(this.url, EscapePath(blobName)), this.pipeline);
} }
getPageBlobClient(blobName) { getPageBlobClient(blobName) {
return new PageBlobClient(appendToURLPath(this.url, encodeURIComponent(blobName)), this.pipeline); return new PageBlobClient(appendToURLPath(this.url, EscapePath(blobName)), this.pipeline);
} }
async getProperties(options = {}) { async getProperties(options = {}) {
if (!options.conditions) { if (!options.conditions) {

View File

@ -2,10 +2,9 @@ import * as core from '@actions/core';
import * as cache from '@actions/cache'; import * as cache from '@actions/cache';
import fs from 'fs'; import fs from 'fs';
async function run() { async function run() {
try { try {
const cache = core.getInput('cache'); const cache = core.getBooleanInput('cache');
if (cache) { if (cache) {
await saveCache(); await saveCache();
} }
@ -20,12 +19,8 @@ async function saveCache() {
core.debug(`paths for caching are ${cachePaths.join(', ')}`); core.debug(`paths for caching are ${cachePaths.join(', ')}`);
if (cachePaths.every(path => !fs.existsSync(path))) { if (cachePaths.every((path) => !fs.existsSync(path))) {
throw new Error( throw new Error(`Cache folder path is retrieved for pdm but doesn't exist on disk: ${cachePaths.join(', ')}`);
`Cache folder path is retrieved for pdm but doesn't exist on disk: ${cachePaths.join(
', '
)}`
);
} }
const primaryKey = core.getState('cache-primary-key'); const primaryKey = core.getState('cache-primary-key');
@ -36,9 +31,7 @@ async function saveCache() {
return; return;
} else if (matchedKey === primaryKey) { } else if (matchedKey === primaryKey) {
// no change in target directories // no change in target directories
core.info( core.info(`Cache hit occurred on the primary key ${primaryKey}, not saving cache.`);
`Cache hit occurred on the primary key ${primaryKey}, not saving cache.`
);
return; return;
} }

View File

@ -1,13 +1,13 @@
import * as os from 'os' import * as os from 'os';
import path from 'path' import path from 'path';
import * as core from '@actions/core' import * as core from '@actions/core';
import { exec } from '@actions/exec' import { exec } from '@actions/exec';
import { IS_WINDOWS } from 'setup-python/src/utils' import { IS_WINDOWS } from 'setup-python/src/utils';
import semParse from 'semver/functions/parse' import semParse from 'semver/functions/parse';
import * as utils from './utils' import * as utils from './utils';
import { cacheDependencies } from './caches' import { cacheDependencies } from './caches';
const INSTALL_SCRIPT_URL = 'https://raw.githubusercontent.com/pdm-project/pdm/main/install-pdm.py' const INSTALL_SCRIPT_URL = 'https://raw.githubusercontent.com/pdm-project/pdm/main/install-pdm.py';
interface InstallOutput { interface InstallOutput {
pdm_version: string; pdm_version: string;
pdm_bin: string; pdm_bin: string;
@ -16,53 +16,53 @@ interface InstallOutput {
} }
function getPep582Path(installDir: string, pythonVersion: string): string { function getPep582Path(installDir: string, pythonVersion: string): string {
const parsedVersion = semParse(pythonVersion)! const parsedVersion = semParse(pythonVersion)!;
if (IS_WINDOWS) { if (IS_WINDOWS) {
return path.resolve(installDir, 'Lib/site-packages/pdm/pep582') return path.resolve(installDir, 'Lib/site-packages/pdm/pep582');
} else { } else {
return path.resolve(installDir, 'lib', `python${parsedVersion.major}.${parsedVersion.minor}`, 'site-packages/pdm/pep582') return path.resolve(installDir, 'lib', `python${parsedVersion.major}.${parsedVersion.minor}`, 'site-packages/pdm/pep582');
} }
} }
async function run(): Promise<void> { async function run(): Promise<void> {
const arch = core.getInput('architecture') || os.arch() const arch = core.getInput('architecture') || os.arch();
const pdmVersion = core.getInput('version') const pdmVersion = core.getInput('version');
const pythonVersion = core.getInput('python-version') const pythonVersion = core.getInput('python-version');
const cmdArgs = ['-'] const cmdArgs = ['-'];
if (core.getBooleanInput('prerelease')) { if (core.getBooleanInput('prerelease')) {
cmdArgs.push('--prerelease') cmdArgs.push('--prerelease');
} }
if (pdmVersion) { if (pdmVersion) {
cmdArgs.push('--version', pdmVersion) cmdArgs.push('--version', pdmVersion);
} }
cmdArgs.push('-o', 'install-output.json') cmdArgs.push('-o', 'install-output.json');
// Use the default python version installed with the runner // Use the default python version installed with the runner
try { try {
await exec('python', cmdArgs, { input: await utils.fetchUrlAsBuffer(INSTALL_SCRIPT_URL) }) await exec('python', cmdArgs, { input: await utils.fetchUrlAsBuffer(INSTALL_SCRIPT_URL) });
const installOutput: InstallOutput = JSON.parse(await utils.readFile('install-output.json')) const installOutput: InstallOutput = JSON.parse(await utils.readFile('install-output.json'));
core.debug(`Install output: ${installOutput}`) core.debug(`Install output: ${installOutput}`);
core.setOutput('pdm-version', installOutput.pdm_version) core.setOutput('pdm-version', installOutput.pdm_version);
core.setOutput('pdm-bin', path.join(installOutput.install_location, installOutput.pdm_bin)) core.setOutput('pdm-bin', path.join(installOutput.install_location, installOutput.pdm_bin));
core.addPath(path.dirname(installOutput.pdm_bin)) core.addPath(path.dirname(installOutput.pdm_bin));
if (core.getBooleanInput('enable-pep582')) { if (core.getBooleanInput('enable-pep582')) {
core.exportVariable('PYTHONPATH', getPep582Path(installOutput.install_location, installOutput.install_python_version)) core.exportVariable('PYTHONPATH', getPep582Path(installOutput.install_location, installOutput.install_python_version));
} }
const installedPython = await utils.findPythonVersion(pythonVersion, arch) const installedPython = await utils.findPythonVersion(pythonVersion, arch);
if (process.platform === 'linux') { if (process.platform === 'linux') {
// See https://github.com/actions/virtual-environments/issues/2803 // See https://github.com/actions/virtual-environments/issues/2803
core.exportVariable('LD_PRELOAD', '/lib/x86_64-linux-gnu/libgcc_s.so.1') core.exportVariable('LD_PRELOAD', '/lib/x86_64-linux-gnu/libgcc_s.so.1');
} }
core.info(`Successfully setup ${installOutput.pdm_version} with Python ${installedPython}`) core.info(`Successfully setup ${installOutput.pdm_version} with Python ${installedPython}`);
const matchersPath = path.join(__dirname, '..', '.github') const matchersPath = path.join(__dirname, '..', '.github');
core.info(`##[add-matcher]${path.join(matchersPath, 'python.json')}`) core.info(`##[add-matcher]${path.join(matchersPath, 'python.json')}`);
if (utils.isCacheAvailable()) { if (utils.isCacheAvailable()) {
await cacheDependencies(installOutput.pdm_bin, installedPython); await cacheDependencies(installOutput.pdm_bin, installedPython);
} }
} catch (error: any) { } catch (error: any) {
core.setFailed(error.message) core.setFailed(error.message);
} }
} }
run() run();