feat: Update action to deliminate the deprecation warnings (#20)

* feat: Update to deliminate deprecation warnings

* update dependencies

* change to the new API

* update env

* update dist js
This commit is contained in:
Frost Ming 2022-10-17 16:28:14 +08:00 committed by GitHub
parent f668fde1b0
commit 21f59457b4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 68469 additions and 7026 deletions

1
.gitignore vendored
View File

@ -2,3 +2,4 @@ node_modules/
yarn.lock
__pypackages__/
.pdm.toml
pnpm-lock.yaml

View File

@ -29,7 +29,7 @@ inputs:
default: "true"
required: false
runs:
using: "node12"
using: "node16"
main: "dist/setup-pdm.js"
branding:
icon: "code"

75421
dist/setup-pdm.js vendored

File diff suppressed because one or more lines are too long

View File

@ -11,15 +11,15 @@
"url": "git+https://github.com/pdm-project/setup-pdm.git"
},
"dependencies": {
"@actions/core": "^1.2.6",
"@actions/exec": "^1.0.4",
"semver": "^7.3.7",
"@actions/core": "^1.10.0",
"@actions/exec": "^1.1.1",
"semver": "^7.3.8",
"setup-python": "actions/setup-python"
},
"devDependencies": {
"@types/node": "^14.14.31",
"@types/semver": "^7.3.4",
"esbuild": "^0.9.0",
"typescript": "^4.2.2"
"@types/node": "^18.11.0",
"@types/semver": "^7.3.12",
"esbuild": "^0.15.11",
"typescript": "^4.8.4"
}
}

View File

@ -1,15 +1,14 @@
import * as core from '@actions/core'
import * as exec from '@actions/exec'
import * as setupPython from 'setup-python/src/find-python'
import { IS_WINDOWS } from 'setup-python/src/utils'
import * as os from 'os'
import { promises as fs } from 'fs'
import path from 'path'
import * as core from '@actions/core'
import * as exec from '@actions/exec'
import { IS_WINDOWS } from 'setup-python/src/utils'
import semParse from 'semver/functions/parse'
import semIntersect from 'semver/ranges/intersects'
import { findPythonVersion } from './utils'
const PDM_PYTHON_REQUIRES = '>=3.7'
const FALLBACK_INSTALL_VERSION = '3.10'
const GITHUB_REPO = 'https://github.com/pdm-project/pdm.git'
function getPep582Path(version: string): string {
@ -34,13 +33,13 @@ async function run(): Promise<void> {
cmdArgs.push('--pre')
}
try {
let installedPython = await setupPython.findPythonVersion(versionCompatible ? pythonVersion : FALLBACK_INSTALL_VERSION, arch)
let installedPython = await findPythonVersion(versionCompatible ? pythonVersion : PDM_PYTHON_REQUIRES, arch)
await exec.exec('python', cmdArgs)
if (core.getInput('enable-pep582') === 'true') {
core.exportVariable('PYTHONPATH', getPep582Path(installedPython.version))
core.exportVariable('PYTHONPATH', getPep582Path(installedPython))
}
if (!versionCompatible) {
installedPython = await setupPython.findPythonVersion(pythonVersion, arch)
installedPython = await findPythonVersion(pythonVersion, arch)
}
const pythonBin = path.join(process.env.pythonLocation as string, IS_WINDOWS ? 'python.exe' : 'bin/python').replace(/\\/g, '/')
await fs.writeFile('.pdm.toml', `[python]\npath="${pythonBin}"\n`)
@ -49,7 +48,7 @@ async function run(): Promise<void> {
// See https://github.com/actions/virtual-environments/issues/2803
core.exportVariable('LD_PRELOAD', '/lib/x86_64-linux-gnu/libgcc_s.so.1')
}
core.info(`Successfully setup ${pdmVersionOutput} with Python ${installedPython.version}`)
core.info(`Successfully setup ${pdmVersionOutput} with Python ${installedPython}`)
const matchersPath = path.join(__dirname, '..', '.github')
core.info(`##[add-matcher]${path.join(matchersPath, 'python.json')}`)
} catch (error: any) {

36
src/utils.ts Normal file
View File

@ -0,0 +1,36 @@
import * as core from '@actions/core';
import { useCpythonVersion } from 'setup-python/src/find-python';
import { findPyPyVersion } from 'setup-python/src/find-pypy';
function isPyPyVersion(versionSpec: string) {
return versionSpec.startsWith('pypy');
}
export async function findPythonVersion(version: string, architecture: string): Promise<string> {
let pythonVersion = '';
if (isPyPyVersion(version)) {
const installed = await findPyPyVersion(
version,
architecture,
true,
false
);
pythonVersion = `${installed.resolvedPyPyVersion}-${installed.resolvedPythonVersion}`;
core.info(
`Successfully set up PyPy ${installed.resolvedPyPyVersion} with Python (${installed.resolvedPythonVersion})`
);
return installed.resolvedPythonVersion;
} else {
const installed = await useCpythonVersion(
version,
architecture,
true,
false
);
pythonVersion = installed.version;
core.info(`Successfully set up ${installed.impl} (${pythonVersion})`);
return installed.version;
}
}

View File

@ -4,14 +4,14 @@
// "incremental": true, /* Enable incremental compilation */
"target": "es6" /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019' or 'ESNEXT'. */,
"module": "commonjs" /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */,
"allowJs": true /* Allow javascript files to be compiled. */,
// "allowJs": true /* Allow javascript files to be compiled. */,
// "checkJs": true, /* Report errors in .js files. */
// "jsx": "preserve", /* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */
// "declaration": true, /* Generates corresponding '.d.ts' file. */
// "declarationMap": true, /* Generates a sourcemap for each corresponding '.d.ts' file. */
// "sourceMap": true, /* Generates corresponding '.map' file. */
// "outFile": "./", /* Concatenate and emit output to single file. */
"outDir": "./dist" /* Redirect output structure to the directory. */,
"outDir": "./lib" /* Redirect output structure to the directory. */,
"rootDir": "./src" /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */,
// "composite": true, /* Enable project compilation */
// "tsBuildInfoFile": "./", /* Specify file to store incremental compilation information */