From f4b85ae24e3deb0b31366c598a66e08bb4d4bc32 Mon Sep 17 00:00:00 2001 From: Sven Serlier <85389871+wrt54g@users.noreply.github.com> Date: Sun, 3 Jul 2022 20:10:08 +0200 Subject: [PATCH 1/9] Update actions --- .github/workflows/check-dist.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/check-dist.yml b/.github/workflows/check-dist.yml index 4c3d69e2..6274fd28 100644 --- a/.github/workflows/check-dist.yml +++ b/.github/workflows/check-dist.yml @@ -21,7 +21,7 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - name: Set Node.js 16.x uses: actions/setup-node@v3 @@ -45,7 +45,7 @@ jobs: id: diff # If index.js was different than expected, upload the expected version as an artifact - - uses: actions/upload-artifact@v2 + - uses: actions/upload-artifact@v3 if: ${{ failure() && steps.diff.conclusion == 'failure' }} with: name: dist From 5a1dd6b34d3ec33151c395cf8fc433629fdcc47c Mon Sep 17 00:00:00 2001 From: Sven Serlier <85389871+wrt54g@users.noreply.github.com> Date: Sun, 3 Jul 2022 20:11:27 +0200 Subject: [PATCH 2/9] Update actions --- .github/workflows/codeql-analysis.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index c30fab46..3ea240d8 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -18,11 +18,11 @@ jobs: steps: - name: Checkout repository - uses: actions/checkout@v2 + uses: actions/checkout@v3 # Initializes the CodeQL tools for scanning. - name: Initialize CodeQL - uses: github/codeql-action/init@v1 + uses: github/codeql-action/init@v2 # Override language selection by uncommenting this and choosing your languages # with: # languages: go, javascript, csharp, python, cpp, java @@ -30,7 +30,7 @@ jobs: # Autobuild attempts to build any compiled languages (C/C++, C#, or Java). # If this step fails, then you should remove it and run the build manually (see below) - name: Autobuild - uses: github/codeql-action/autobuild@v1 + uses: github/codeql-action/autobuild@v2 # â„šī¸ Command-line programs to run using the OS shell. # 📚 https://git.io/JvXDl @@ -44,4 +44,4 @@ jobs: # make release - name: Perform CodeQL Analysis - uses: github/codeql-action/analyze@v1 + uses: github/codeql-action/analyze@v2 From 7d9c63da1be5117e942432dfba15cb5583b6f811 Mon Sep 17 00:00:00 2001 From: Sven Serlier <85389871+wrt54g@users.noreply.github.com> Date: Sun, 3 Jul 2022 20:13:21 +0200 Subject: [PATCH 3/9] Update actions/checkout to v3 --- .github/workflows/licensed.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/licensed.yml b/.github/workflows/licensed.yml index a78560b8..6f4cd922 100644 --- a/.github/workflows/licensed.yml +++ b/.github/workflows/licensed.yml @@ -13,7 +13,7 @@ jobs: runs-on: ubuntu-latest name: Check licenses steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - name: Set Node.js 16.x uses: actions/setup-node@v3 with: From d08a9d79f10546626afc655b2a5376f88e0126ff Mon Sep 17 00:00:00 2001 From: Sven Serlier <85389871+wrt54g@users.noreply.github.com> Date: Sun, 3 Jul 2022 20:13:56 +0200 Subject: [PATCH 4/9] Update actions --- .github/workflows/release-new-action-version.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/release-new-action-version.yml b/.github/workflows/release-new-action-version.yml index 955ced7e..968c77fb 100644 --- a/.github/workflows/release-new-action-version.yml +++ b/.github/workflows/release-new-action-version.yml @@ -21,7 +21,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Update the ${{ env.TAG_NAME }} tag - uses: actions/publish-action@v0.1.0 + uses: actions/publish-action@v0.2.0 with: source-tag: ${{ env.TAG_NAME }} - slack-webhook: ${{ secrets.SLACK_WEBHOOK }} \ No newline at end of file + slack-webhook: ${{ secrets.SLACK_WEBHOOK }} From 4a7ca55b4090b249d2dbdb572c6bf83ca085ae44 Mon Sep 17 00:00:00 2001 From: Sven Serlier <85389871+wrt54g@users.noreply.github.com> Date: Sun, 3 Jul 2022 20:14:29 +0200 Subject: [PATCH 5/9] Update actions --- .github/workflows/test-pypy.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test-pypy.yml b/.github/workflows/test-pypy.yml index e4a53bb2..4800662e 100644 --- a/.github/workflows/test-pypy.yml +++ b/.github/workflows/test-pypy.yml @@ -34,7 +34,7 @@ jobs: steps: - name: Checkout - uses: actions/checkout@v2 + uses: actions/checkout@v3 - name: setup-python ${{ matrix.pypy }} id: setup-python From b318cecd93bd700ebeebeba61bcae2f0231111ce Mon Sep 17 00:00:00 2001 From: Sven Serlier <85389871+wrt54g@users.noreply.github.com> Date: Sun, 3 Jul 2022 20:15:21 +0200 Subject: [PATCH 6/9] Update actions/checkout to v3 --- .github/workflows/workflow.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/workflow.yml b/.github/workflows/workflow.yml index 171e2055..5c8cc77f 100644 --- a/.github/workflows/workflow.yml +++ b/.github/workflows/workflow.yml @@ -17,7 +17,7 @@ jobs: operating-system: [ubuntu-latest, windows-latest] steps: - name: Checkout - uses: actions/checkout@v2 + uses: actions/checkout@v3 - name: Set Node.js 16.x uses: actions/setup-node@v3 From b88a682917db311eac9aab40569d7ee9db572924 Mon Sep 17 00:00:00 2001 From: IvanZosimov Date: Fri, 15 Jul 2022 16:52:20 +0200 Subject: [PATCH 7/9] Fix resolveVersionInput() logic --- dist/setup/index.js | 15 +++++++++------ src/setup-python.ts | 22 ++++++++++++---------- 2 files changed, 21 insertions(+), 16 deletions(-) diff --git a/dist/setup/index.js b/dist/setup/index.js index 9ac89a4f..57bd35fe 100644 --- a/dist/setup/index.js +++ b/dist/setup/index.js @@ -65262,17 +65262,20 @@ function resolveVersionInput() { } if (versionFile) { if (!fs_1.default.existsSync(versionFile)) { - logWarning(`The specified python version file at: ${versionFile} doesn't exist. Attempting to find .python-version file.`); - versionFile = '.python-version'; - if (!fs_1.default.existsSync(versionFile)) { - throw new Error(`The ${versionFile} doesn't exist.`); - } + throw new Error(`The specified python version file at: ${versionFile} doesn't exist.`); } version = fs_1.default.readFileSync(versionFile, 'utf8'); core.info(`Resolved ${versionFile} as ${version}`); return version; } - core.warning("Neither 'python-version' nor 'python-version-file' inputs were supplied."); + logWarning("Neither 'python-version' nor 'python-version-file' inputs were supplied. Attempting to find '.python-version' file."); + versionFile = '.python-version'; + if (fs_1.default.existsSync(versionFile)) { + version = fs_1.default.readFileSync(versionFile, 'utf8'); + core.info(`Resolved ${versionFile} as ${version}`); + return version; + } + logWarning(`${versionFile} doesn't exist.`); return version; } function run() { diff --git a/src/setup-python.ts b/src/setup-python.ts index db17735b..23356889 100644 --- a/src/setup-python.ts +++ b/src/setup-python.ts @@ -38,24 +38,26 @@ function resolveVersionInput(): string { if (versionFile) { if (!fs.existsSync(versionFile)) { - logWarning( - `The specified python version file at: ${versionFile} doesn't exist. Attempting to find .python-version file.` + throw new Error( + `The specified python version file at: ${versionFile} doesn't exist.` ); - versionFile = '.python-version'; - if (!fs.existsSync(versionFile)) { - throw new Error(`The ${versionFile} doesn't exist.`); - } } - version = fs.readFileSync(versionFile, 'utf8'); core.info(`Resolved ${versionFile} as ${version}`); - return version; } - core.warning( - "Neither 'python-version' nor 'python-version-file' inputs were supplied." + logWarning( + "Neither 'python-version' nor 'python-version-file' inputs were supplied. Attempting to find '.python-version' file." ); + versionFile = '.python-version'; + if (fs.existsSync(versionFile)) { + version = fs.readFileSync(versionFile, 'utf8'); + core.info(`Resolved ${versionFile} as ${version}`); + return version; + } + + logWarning(`${versionFile} doesn't exist.`); return version; } From 592a7a7a45a48972db5452787b01b1f407e38948 Mon Sep 17 00:00:00 2001 From: Milos Pantic <101411245+panticmilos@users.noreply.github.com> Date: Tue, 19 Jul 2022 14:20:19 +0200 Subject: [PATCH 8/9] Add linux os release info to primary key (#467) --- __tests__/cache-restore.test.ts | 23 +++++++++++++++--- dist/setup/index.js | 36 +++++++++++++++++++++++++--- src/cache-distributions/pip-cache.ts | 15 +++++++++--- src/utils.ts | 17 +++++++++++++ 4 files changed, 82 insertions(+), 9 deletions(-) diff --git a/__tests__/cache-restore.test.ts b/__tests__/cache-restore.test.ts index 573f36a9..b0d44b8f 100644 --- a/__tests__/cache-restore.test.ts +++ b/__tests__/cache-restore.test.ts @@ -2,6 +2,7 @@ import * as core from '@actions/core'; import * as cache from '@actions/cache'; import * as exec from '@actions/exec'; import {getCacheDistributor} from '../src/cache-distributions/cache-factory'; +import * as utils from './../src/utils'; describe('restore-cache', () => { const pipFileLockHash = @@ -28,6 +29,7 @@ virtualenvs.path = "{cache-dir}/virtualenvs" # /Users/patrick/Library/Caches/py let saveSatetSpy: jest.SpyInstance; let getStateSpy: jest.SpyInstance; let setOutputSpy: jest.SpyInstance; + let getLinuxOSReleaseInfoSpy: jest.SpyInstance; // cache spy let restoreCacheSpy: jest.SpyInstance; @@ -74,6 +76,8 @@ virtualenvs.path = "{cache-dir}/virtualenvs" # /Users/patrick/Library/Caches/py return primaryKey; } ); + + getLinuxOSReleaseInfoSpy = jest.spyOn(utils, 'getLinuxOSReleaseInfo'); }); describe('Validate provided package manager', () => { @@ -109,11 +113,24 @@ virtualenvs.path = "{cache-dir}/virtualenvs" # /Users/patrick/Library/Caches/py pythonVersion, dependencyFile ); + + if (process.platform === 'linux') { + getLinuxOSReleaseInfoSpy.mockImplementation(() => + Promise.resolve('Ubuntu-20.4') + ); + } + await cacheDistributor.restoreCache(); - expect(infoSpy).toHaveBeenCalledWith( - `Cache restored from key: setup-python-${process.env['RUNNER_OS']}-python-${pythonVersion}-${packageManager}-${fileHash}` - ); + if (process.platform === 'linux' && packageManager === 'pip') { + expect(infoSpy).toHaveBeenCalledWith( + `Cache restored from key: setup-python-${process.env['RUNNER_OS']}-Ubuntu-20.4-python-${pythonVersion}-${packageManager}-${fileHash}` + ); + } else { + expect(infoSpy).toHaveBeenCalledWith( + `Cache restored from key: setup-python-${process.env['RUNNER_OS']}-python-${pythonVersion}-${packageManager}-${fileHash}` + ); + } }, 30000 ); diff --git a/dist/setup/index.js b/dist/setup/index.js index 57bd35fe..dec74449 100644 --- a/dist/setup/index.js +++ b/dist/setup/index.js @@ -64430,8 +64430,17 @@ class PipCache extends cache_distributor_1.default { computeKeys() { return __awaiter(this, void 0, void 0, function* () { const hash = yield glob.hashFiles(this.cacheDependencyPath); - const primaryKey = `${this.CACHE_KEY_PREFIX}-${process.env['RUNNER_OS']}-python-${this.pythonVersion}-${this.packageManager}-${hash}`; - const restoreKey = `${this.CACHE_KEY_PREFIX}-${process.env['RUNNER_OS']}-python-${this.pythonVersion}-${this.packageManager}`; + let primaryKey = ''; + let restoreKey = ''; + if (utils_1.IS_LINUX) { + const osRelease = yield utils_1.getLinuxOSReleaseInfo(); + primaryKey = `${this.CACHE_KEY_PREFIX}-${process.env['RUNNER_OS']}-${osRelease}-python-${this.pythonVersion}-${this.packageManager}-${hash}`; + restoreKey = `${this.CACHE_KEY_PREFIX}-${process.env['RUNNER_OS']}-${osRelease}-python-${this.pythonVersion}-${this.packageManager}`; + } + else { + primaryKey = `${this.CACHE_KEY_PREFIX}-${process.env['RUNNER_OS']}-python-${this.pythonVersion}-${this.packageManager}-${hash}`; + restoreKey = `${this.CACHE_KEY_PREFIX}-${process.env['RUNNER_OS']}-python-${this.pythonVersion}-${this.packageManager}`; + } return { primaryKey, restoreKey: [restoreKey] @@ -65357,16 +65366,26 @@ var __importStar = (this && this.__importStar) || function (mod) { __setModuleDefault(result, mod); return result; }; +var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { + function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } + return new (P || (P = Promise))(function (resolve, reject) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } + step((generator = generator.apply(thisArg, _arguments || [])).next()); + }); +}; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", ({ value: true })); -exports.isCacheFeatureAvailable = exports.isGhes = exports.validatePythonVersionFormatForPyPy = exports.writeExactPyPyVersionFile = exports.readExactPyPyVersionFile = exports.getPyPyVersionFromPath = exports.isNightlyKeyword = exports.validateVersion = exports.createSymlinkInFolder = exports.WINDOWS_PLATFORMS = exports.WINDOWS_ARCHS = exports.IS_LINUX = exports.IS_WINDOWS = void 0; +exports.getLinuxOSReleaseInfo = exports.isCacheFeatureAvailable = exports.isGhes = exports.validatePythonVersionFormatForPyPy = exports.writeExactPyPyVersionFile = exports.readExactPyPyVersionFile = exports.getPyPyVersionFromPath = exports.isNightlyKeyword = exports.validateVersion = exports.createSymlinkInFolder = exports.WINDOWS_PLATFORMS = exports.WINDOWS_ARCHS = exports.IS_LINUX = exports.IS_WINDOWS = void 0; const cache = __importStar(__nccwpck_require__(7799)); const core = __importStar(__nccwpck_require__(2186)); const fs_1 = __importDefault(__nccwpck_require__(7147)); const path = __importStar(__nccwpck_require__(1017)); const semver = __importStar(__nccwpck_require__(1383)); +const exec = __importStar(__nccwpck_require__(1514)); exports.IS_WINDOWS = process.platform === 'win32'; exports.IS_LINUX = process.platform === 'linux'; exports.WINDOWS_ARCHS = ['x86', 'x64']; @@ -65450,6 +65469,17 @@ function isCacheFeatureAvailable() { return true; } exports.isCacheFeatureAvailable = isCacheFeatureAvailable; +function getLinuxOSReleaseInfo() { + return __awaiter(this, void 0, void 0, function* () { + const { stdout, stderr, exitCode } = yield exec.getExecOutput('lsb_release', ['-i', '-r', '-s'], { + silent: true + }); + const [osRelease, osVersion] = stdout.trim().split('\n'); + core.debug(`OS Release: ${osRelease}, Version: ${osVersion}`); + return `${osVersion}-${osRelease}`; + }); +} +exports.getLinuxOSReleaseInfo = getLinuxOSReleaseInfo; /***/ }), diff --git a/src/cache-distributions/pip-cache.ts b/src/cache-distributions/pip-cache.ts index 17055ea5..460b097c 100644 --- a/src/cache-distributions/pip-cache.ts +++ b/src/cache-distributions/pip-cache.ts @@ -7,7 +7,7 @@ import * as path from 'path'; import os from 'os'; import CacheDistributor from './cache-distributor'; -import {IS_WINDOWS} from '../utils'; +import {getLinuxOSReleaseInfo, IS_LINUX, IS_WINDOWS} from '../utils'; class PipCache extends CacheDistributor { constructor( @@ -57,8 +57,17 @@ class PipCache extends CacheDistributor { protected async computeKeys() { const hash = await glob.hashFiles(this.cacheDependencyPath); - const primaryKey = `${this.CACHE_KEY_PREFIX}-${process.env['RUNNER_OS']}-python-${this.pythonVersion}-${this.packageManager}-${hash}`; - const restoreKey = `${this.CACHE_KEY_PREFIX}-${process.env['RUNNER_OS']}-python-${this.pythonVersion}-${this.packageManager}`; + let primaryKey = ''; + let restoreKey = ''; + + if (IS_LINUX) { + const osRelease = await getLinuxOSReleaseInfo(); + primaryKey = `${this.CACHE_KEY_PREFIX}-${process.env['RUNNER_OS']}-${osRelease}-python-${this.pythonVersion}-${this.packageManager}-${hash}`; + restoreKey = `${this.CACHE_KEY_PREFIX}-${process.env['RUNNER_OS']}-${osRelease}-python-${this.pythonVersion}-${this.packageManager}`; + } else { + primaryKey = `${this.CACHE_KEY_PREFIX}-${process.env['RUNNER_OS']}-python-${this.pythonVersion}-${this.packageManager}-${hash}`; + restoreKey = `${this.CACHE_KEY_PREFIX}-${process.env['RUNNER_OS']}-python-${this.pythonVersion}-${this.packageManager}`; + } return { primaryKey, diff --git a/src/utils.ts b/src/utils.ts index eb3a1ba6..6eb1388f 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -3,6 +3,7 @@ import * as core from '@actions/core'; import fs from 'fs'; import * as path from 'path'; import * as semver from 'semver'; +import * as exec from '@actions/exec'; export const IS_WINDOWS = process.platform === 'win32'; export const IS_LINUX = process.platform === 'linux'; @@ -119,3 +120,19 @@ export function isCacheFeatureAvailable(): boolean { return true; } + +export async function getLinuxOSReleaseInfo() { + const {stdout, stderr, exitCode} = await exec.getExecOutput( + 'lsb_release', + ['-i', '-r', '-s'], + { + silent: true + } + ); + + const [osRelease, osVersion] = stdout.trim().split('\n'); + + core.debug(`OS Release: ${osRelease}, Version: ${osVersion}`); + + return `${osVersion}-${osRelease}`; +} From 49a521fa062d323a7f2391290b18cf928ddfe90a Mon Sep 17 00:00:00 2001 From: Dmitry Shibanov Date: Mon, 25 Jul 2022 15:02:06 +0200 Subject: [PATCH 9/9] Fix poetry version (#445) --- .github/workflows/e2e-cache.yml | 6 ++--- __tests__/cache-restore.test.ts | 6 +++++ __tests__/data/pyproject.toml | 15 ++++++++++++ dist/setup/index.js | 31 ++++++++++++++++++------- src/cache-distributions/poetry-cache.ts | 24 ++++++++++++++++++- src/setup-python.ts | 12 +++++----- src/utils.ts | 5 ++++ 7 files changed, 80 insertions(+), 19 deletions(-) create mode 100644 __tests__/data/pyproject.toml diff --git a/.github/workflows/e2e-cache.yml b/.github/workflows/e2e-cache.yml index 0aea4b77..2e903a48 100644 --- a/.github/workflows/e2e-cache.yml +++ b/.github/workflows/e2e-cache.yml @@ -72,15 +72,15 @@ jobs: - uses: actions/checkout@v3 - name: Install poetry run: pipx install poetry + - name: Init pyproject.toml + run: mv ./__tests__/data/pyproject.toml . - name: Setup Python uses: ./ with: python-version: ${{ matrix.python-version }} cache: 'poetry' - - name: Init pyproject.toml - run: poetry init -n - name: Install dependencies - run: poetry add flake8 + run: poetry install python-pip-dependencies-caching-path: name: Test pip (Python ${{ matrix.python-version}}, ${{ matrix.os }}) diff --git a/__tests__/cache-restore.test.ts b/__tests__/cache-restore.test.ts index b0d44b8f..8331b812 100644 --- a/__tests__/cache-restore.test.ts +++ b/__tests__/cache-restore.test.ts @@ -1,6 +1,7 @@ import * as core from '@actions/core'; import * as cache from '@actions/cache'; import * as exec from '@actions/exec'; +import * as io from '@actions/io'; import {getCacheDistributor} from '../src/cache-distributions/cache-factory'; import * as utils from './../src/utils'; @@ -37,6 +38,9 @@ virtualenvs.path = "{cache-dir}/virtualenvs" # /Users/patrick/Library/Caches/py // exec spy let getExecOutputSpy: jest.SpyInstance; + // io spy + let whichSpy: jest.SpyInstance; + beforeEach(() => { process.env['RUNNER_OS'] = process.env['RUNNER_OS'] ?? 'linux'; @@ -77,6 +81,8 @@ virtualenvs.path = "{cache-dir}/virtualenvs" # /Users/patrick/Library/Caches/py } ); + whichSpy = jest.spyOn(io, 'which'); + whichSpy.mockImplementation(() => '/path/to/python'); getLinuxOSReleaseInfoSpy = jest.spyOn(utils, 'getLinuxOSReleaseInfo'); }); diff --git a/__tests__/data/pyproject.toml b/__tests__/data/pyproject.toml new file mode 100644 index 00000000..ff4d8bd0 --- /dev/null +++ b/__tests__/data/pyproject.toml @@ -0,0 +1,15 @@ +[tool.poetry] +name = "testactiontasks" +version = "0.1.0" +description = "" +authors = ["Your Name "] + +[tool.poetry.dependencies] +python = "^3.8" +flake8 = "^4.0.1" + +[tool.poetry.dev-dependencies] + +[build-system] +requires = ["poetry-core>=1.0.0"] +build-backend = "poetry.core.masonry.api" diff --git a/dist/setup/index.js b/dist/setup/index.js index dec74449..3d373467 100644 --- a/dist/setup/index.js +++ b/dist/setup/index.js @@ -64573,9 +64573,12 @@ var __importDefault = (this && this.__importDefault) || function (mod) { }; Object.defineProperty(exports, "__esModule", ({ value: true })); const glob = __importStar(__nccwpck_require__(8090)); +const io = __importStar(__nccwpck_require__(7436)); const path = __importStar(__nccwpck_require__(1017)); const exec = __importStar(__nccwpck_require__(1514)); +const core = __importStar(__nccwpck_require__(2186)); const cache_distributor_1 = __importDefault(__nccwpck_require__(8953)); +const utils_1 = __nccwpck_require__(1314); class PoetryCache extends cache_distributor_1.default { constructor(pythonVersion, patterns = '**/poetry.lock') { super('poetry', patterns); @@ -64591,6 +64594,17 @@ class PoetryCache extends cache_distributor_1.default { if (poetryConfig['virtualenvs.in-project'] === true) { paths.push(path.join(process.cwd(), '.venv')); } + const pythonLocation = yield io.which('python'); + if (pythonLocation) { + core.debug(`pythonLocation is ${pythonLocation}`); + const { exitCode, stderr } = yield exec.getExecOutput(`poetry env use ${pythonLocation}`, undefined, { ignoreReturnCode: true }); + if (exitCode) { + utils_1.logWarning(stderr); + } + } + else { + utils_1.logWarning('python binaries were not found in PATH'); + } return paths; }); } @@ -65241,7 +65255,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", ({ value: true })); -exports.logWarning = void 0; const core = __importStar(__nccwpck_require__(2186)); const finder = __importStar(__nccwpck_require__(9996)); const finderPyPy = __importStar(__nccwpck_require__(4003)); @@ -65277,14 +65290,14 @@ function resolveVersionInput() { core.info(`Resolved ${versionFile} as ${version}`); return version; } - logWarning("Neither 'python-version' nor 'python-version-file' inputs were supplied. Attempting to find '.python-version' file."); + utils_1.logWarning("Neither 'python-version' nor 'python-version-file' inputs were supplied. Attempting to find '.python-version' file."); versionFile = '.python-version'; if (fs_1.default.existsSync(versionFile)) { version = fs_1.default.readFileSync(versionFile, 'utf8'); core.info(`Resolved ${versionFile} as ${version}`); return version; } - logWarning(`${versionFile} doesn't exist.`); + utils_1.logWarning(`${versionFile} doesn't exist.`); return version; } function run() { @@ -65332,11 +65345,6 @@ function run() { } }); } -function logWarning(message) { - const warningPrefix = '[warning]'; - core.info(`${warningPrefix}${message}`); -} -exports.logWarning = logWarning; run(); @@ -65379,7 +65387,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", ({ value: true })); -exports.getLinuxOSReleaseInfo = exports.isCacheFeatureAvailable = exports.isGhes = exports.validatePythonVersionFormatForPyPy = exports.writeExactPyPyVersionFile = exports.readExactPyPyVersionFile = exports.getPyPyVersionFromPath = exports.isNightlyKeyword = exports.validateVersion = exports.createSymlinkInFolder = exports.WINDOWS_PLATFORMS = exports.WINDOWS_ARCHS = exports.IS_LINUX = exports.IS_WINDOWS = void 0; +exports.logWarning = exports.getLinuxOSReleaseInfo = exports.isCacheFeatureAvailable = exports.isGhes = exports.validatePythonVersionFormatForPyPy = exports.writeExactPyPyVersionFile = exports.readExactPyPyVersionFile = exports.getPyPyVersionFromPath = exports.isNightlyKeyword = exports.validateVersion = exports.createSymlinkInFolder = exports.WINDOWS_PLATFORMS = exports.WINDOWS_ARCHS = exports.IS_LINUX = exports.IS_WINDOWS = void 0; const cache = __importStar(__nccwpck_require__(7799)); const core = __importStar(__nccwpck_require__(2186)); const fs_1 = __importDefault(__nccwpck_require__(7147)); @@ -65480,6 +65488,11 @@ function getLinuxOSReleaseInfo() { }); } exports.getLinuxOSReleaseInfo = getLinuxOSReleaseInfo; +function logWarning(message) { + const warningPrefix = '[warning]'; + core.info(`${warningPrefix}${message}`); +} +exports.logWarning = logWarning; /***/ }), diff --git a/src/cache-distributions/poetry-cache.ts b/src/cache-distributions/poetry-cache.ts index 5e22b5dd..60ecea2b 100644 --- a/src/cache-distributions/poetry-cache.ts +++ b/src/cache-distributions/poetry-cache.ts @@ -1,9 +1,11 @@ import * as glob from '@actions/glob'; -import * as os from 'os'; +import * as io from '@actions/io'; import * as path from 'path'; import * as exec from '@actions/exec'; +import * as core from '@actions/core'; import CacheDistributor from './cache-distributor'; +import {logWarning} from '../utils'; class PoetryCache extends CacheDistributor { constructor( @@ -28,6 +30,26 @@ class PoetryCache extends CacheDistributor { paths.push(path.join(process.cwd(), '.venv')); } + const pythonLocation = await io.which('python'); + + if (pythonLocation) { + core.debug(`pythonLocation is ${pythonLocation}`); + const { + exitCode, + stderr + } = await exec.getExecOutput( + `poetry env use ${pythonLocation}`, + undefined, + {ignoreReturnCode: true} + ); + + if (exitCode) { + logWarning(stderr); + } + } else { + logWarning('python binaries were not found in PATH'); + } + return paths; } diff --git a/src/setup-python.ts b/src/setup-python.ts index 23356889..1ebcbac3 100644 --- a/src/setup-python.ts +++ b/src/setup-python.ts @@ -5,7 +5,12 @@ import * as path from 'path'; import * as os from 'os'; import fs from 'fs'; import {getCacheDistributor} from './cache-distributions/cache-factory'; -import {isCacheFeatureAvailable, IS_LINUX, IS_WINDOWS} from './utils'; +import { + isCacheFeatureAvailable, + logWarning, + IS_LINUX, + IS_WINDOWS +} from './utils'; function isPyPyVersion(versionSpec: string) { return versionSpec.startsWith('pypy'); @@ -115,9 +120,4 @@ async function run() { } } -export function logWarning(message: string): void { - const warningPrefix = '[warning]'; - core.info(`${warningPrefix}${message}`); -} - run(); diff --git a/src/utils.ts b/src/utils.ts index 6eb1388f..7d4fa02e 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -136,3 +136,8 @@ export async function getLinuxOSReleaseInfo() { return `${osVersion}-${osRelease}`; } + +export function logWarning(message: string): void { + const warningPrefix = '[warning]'; + core.info(`${warningPrefix}${message}`); +}