Merge pull request #56 from aminya/setup-python [skip ci]

This commit is contained in:
Amin Yahyaabadi 2022-04-24 17:26:02 -07:00 committed by GitHub
commit 9b3e93e13e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
14 changed files with 119 additions and 93 deletions

View File

@ -15,4 +15,8 @@ const compress =
module.exports = { module.exports = {
...terserConfig, ...terserConfig,
compress, compress,
format: {
...terserConfig.format,
comments: false,
},
} }

View File

@ -8,60 +8,61 @@ ignorePaths:
- .git/ - .git/
- dist/ - dist/
words: words:
- "buildtools" - aarch
- "ccache" - aminya
- "cmake"
- "CPATH"
- "Cppcheck"
- "CPPFLAGS"
- "cpprc"
- "dyld"
- "eabi"
- "execa"
- "gcovr"
- "Graphviz"
- "isci"
- "LDFLAGS"
- "msbuild"
- "msvc"
- "msys"
- "multilib"
- "nothrow"
- "Opencppcoverage"
- "OSSDK"
- "setx"
- "untildify"
- "vcpkg"
- "visualc"
- "visualcpp"
- pnpm
- Yahyaabadi
- vcvarsall
- kcov
- choco
- vsversion
- pwsh
- pypy
- ghes
- applellvm - applellvm
- xcrun - buildtools
- caxa
- ccache
- choco
- cmake
- CPATH
- Cppcheck
- CPPFLAGS
- cpprc
- Cpython
- deps
- devel
- dyld
- eabi
- execa
- gcovr
- ghes
- Graphviz
- isci
- kcov
- LDFLAGS
- libbinutils
- libdw
- libstdc - libstdc
- libtinfo - libtinfo
- libdw - msbuild
- npmrc - msvc
- setupcpp - msys
- aarch - multilib
- devel
- aminya
- caxa
- libbinutils
- tsbuildinfo
- deps
- mxschmitt - mxschmitt
- nothrow
- npmrc
- Opencppcoverage
- OSSDK
- pnpm
- pwsh
- pypy
- setupcpp
- setx
- terserrc - terserrc
- tsbuildinfo
- untildify
- vcpkg
- vcvarsall
- visualc
- visualcpp
- vsversion
- xcrun
- Yahyaabadi
ignoreWords: [] ignoreWords: []
import: [] import: []
dictionaryDefinitions: [] dictionaryDefinitions: []
dictionaries: [] dictionaries: []
language: "en, en-GB" language: en, en-GB
allowCompoundWords: true allowCompoundWords: true

2
dist/actions_python.a1cdadc4.js vendored Normal file

File diff suppressed because one or more lines are too long

1
dist/actions_python.a1cdadc4.js.map vendored Normal file

File diff suppressed because one or more lines are too long

2
dist/setup_cpp.js vendored

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

1
ignored-error-codes.json Normal file
View File

@ -0,0 +1 @@
["TS6133", "TS7010"]

View File

@ -0,0 +1 @@
["node_modules/setup-python/src/cache-distributions/poetry-cache.ts", "node_modules/time-delta/types/index.d.ts"]

View File

@ -14,10 +14,10 @@
"scripts": { "scripts": {
"build": "run-p test.tsc build.parcel copy.matchers", "build": "run-p test.tsc build.parcel copy.matchers",
"build.docker": "pnpm build && docker build -f ./building/docker/ubuntu_node.dockerfile -t setup_cpp .", "build.docker": "pnpm build && docker build -f ./building/docker/ubuntu_node.dockerfile -t setup_cpp .",
"build.parcel": "cross-env NODE_ENV=production parcel build --detailed-report", "build.parcel": "shx rm -rf ./dist/*.js ./dist/*.js.map && cross-env NODE_ENV=production parcel build --detailed-report",
"bump": "ncu -u -x execa && pnpm update", "bump": "ncu -u -x execa && pnpm update",
"clean": "shx rm -rf .parcel-cache dist exe", "clean": "shx rm -rf .parcel-cache dist exe",
"copy.matchers": "shx cp ./src/gcc/gcc_matcher.json ./dist/ && shx cp ./src/msvc/msvc_matcher.json ./dist && shx cp ./src/python/python_matcher.json ./dist/ && shx cp ./src/llvm/llvm_matcher.json ./dist/ ", "copy.matchers": "shx rm -rf ./dist/*.json && shx cp ./src/gcc/gcc_matcher.json ./dist/ && shx cp ./src/msvc/msvc_matcher.json ./dist && shx cp ./src/python/python_matcher.json ./dist/ && shx cp ./src/llvm/llvm_matcher.json ./dist/ ",
"dev": "cross-env NODE_ENV=development parcel watch", "dev": "cross-env NODE_ENV=development parcel watch",
"format": "prettier --write .", "format": "prettier --write .",
"lint": "eslint . --fix", "lint": "eslint . --fix",
@ -28,7 +28,7 @@
"test.cspell": "cspell lint --no-progress --show-suggestions", "test.cspell": "cspell lint --no-progress --show-suggestions",
"test.format": "prettier . --check", "test.format": "prettier . --check",
"test.lint": "eslint .", "test.lint": "eslint .",
"test.tsc": "tsc --noEmit", "test.tsc": "tsc --noEmit | loose-ts-check",
"test.unit": "jest --runInBand" "test.unit": "jest --runInBand"
}, },
"prettier": "prettier-config-atomic", "prettier": "prettier-config-atomic",
@ -42,7 +42,7 @@
"msvc-dev-cmd": "github:aminya/msvc-dev-cmd#9f672c1", "msvc-dev-cmd": "github:aminya/msvc-dev-cmd#9f672c1",
"numerous": "1.0.3", "numerous": "1.0.3",
"semver": "7.3.7", "semver": "7.3.7",
"setup-python": "github:actions/setup-python#7f80679172b057fc5e90d70d197929d454754a5a", "setup-python": "github:actions/setup-python#v3.1.2",
"time-delta": "github:aminya/time-delta#69d91a41cef28e569be9a2991129f5f7d1f0d00e", "time-delta": "github:aminya/time-delta#69d91a41cef28e569be9a2991129f5f7d1f0d00e",
"untildify": "^4.0.0", "untildify": "^4.0.0",
"which": "^2.0.2" "which": "^2.0.2"
@ -61,6 +61,7 @@
"eslint": "^8.13.0", "eslint": "^8.13.0",
"eslint-config-atomic": "^1.17.1", "eslint-config-atomic": "^1.17.1",
"jest": "^27.5.1", "jest": "^27.5.1",
"loose-ts-check": "^1.2.0",
"npm-check-updates": "^12.5.9", "npm-check-updates": "^12.5.9",
"npm-run-all2": "^5.0.2", "npm-run-all2": "^5.0.2",
"parcel": "^2.4.1", "parcel": "^2.4.1",

View File

@ -27,6 +27,7 @@ specifiers:
eslint-config-atomic: ^1.17.1 eslint-config-atomic: ^1.17.1
execa: ^5.1.1 execa: ^5.1.1
jest: ^27.5.1 jest: ^27.5.1
loose-ts-check: ^1.2.0
mri: ^1.2.0 mri: ^1.2.0
msvc-dev-cmd: github:aminya/msvc-dev-cmd#9f672c1 msvc-dev-cmd: github:aminya/msvc-dev-cmd#9f672c1
npm-check-updates: ^12.5.9 npm-check-updates: ^12.5.9
@ -36,7 +37,7 @@ specifiers:
prettier: 2.6.2 prettier: 2.6.2
prettier-config-atomic: ^3.0.9 prettier-config-atomic: ^3.0.9
semver: 7.3.7 semver: 7.3.7
setup-python: github:actions/setup-python#7f80679172b057fc5e90d70d197929d454754a5a setup-python: github:actions/setup-python#v3.1.2
shx: 0.3.4 shx: 0.3.4
terser-config-atomic: ^0.1.1 terser-config-atomic: ^0.1.1
time-delta: github:aminya/time-delta#69d91a41cef28e569be9a2991129f5f7d1f0d00e time-delta: github:aminya/time-delta#69d91a41cef28e569be9a2991129f5f7d1f0d00e
@ -55,7 +56,7 @@ dependencies:
msvc-dev-cmd: github.com/aminya/msvc-dev-cmd/9f672c1 msvc-dev-cmd: github.com/aminya/msvc-dev-cmd/9f672c1
numerous: 1.0.3 numerous: 1.0.3
semver: 7.3.7 semver: 7.3.7
setup-python: github.com/actions/setup-python/7f80679172b057fc5e90d70d197929d454754a5a setup-python: github.com/actions/setup-python/98f2ad02fd48d057ee3b4d4f66525b231c3e52b6
time-delta: github.com/aminya/time-delta/69d91a41cef28e569be9a2991129f5f7d1f0d00e time-delta: github.com/aminya/time-delta/69d91a41cef28e569be9a2991129f5f7d1f0d00e
untildify: 4.0.0 untildify: 4.0.0
which: 2.0.2 which: 2.0.2
@ -74,6 +75,7 @@ devDependencies:
eslint: 8.13.0 eslint: 8.13.0
eslint-config-atomic: 1.17.1 eslint-config-atomic: 1.17.1
jest: 27.5.1 jest: 27.5.1
loose-ts-check: 1.2.0
npm-check-updates: 12.5.9 npm-check-updates: 12.5.9
npm-run-all2: 5.0.2 npm-run-all2: 5.0.2
parcel: 2.4.1 parcel: 2.4.1
@ -86,8 +88,8 @@ devDependencies:
packages: packages:
/@actions/cache/1.0.11: /@actions/cache/2.0.2:
resolution: {integrity: sha512-L+VCF1JpFePAzxkYtpwYDWnd0WzSU1DoNPE2cuINKpEie27ONH0Cpqt40cG8NiJW4zbZLN+kNkEDo3F2MkUuRw==} resolution: {integrity: sha512-K1DCaW/OtHj5mV7hI7HEXiceX3rM4Nc0iG2hfYsrkEy6GiOeqlCC/LyICrBZIRDM6+vSrS12tg1ORl4hghomBA==}
dependencies: dependencies:
'@actions/core': 1.6.0 '@actions/core': 1.6.0
'@actions/exec': 1.1.1 '@actions/exec': 1.1.1
@ -5778,6 +5780,14 @@ packages:
js-tokens: 4.0.0 js-tokens: 4.0.0
dev: true dev: true
/loose-ts-check/1.2.0:
resolution: {integrity: sha512-RnVczoE60wOWBkgjjPVieeUknHftgeiyTnjxbwRBF1RRqdUGB42f4yUjJ0KNlBRLRQNnGZwEl+aM/YijcWJtTA==}
hasBin: true
dependencies:
chalk: 4.1.2
yargs: 16.2.0
dev: true
/lowercase-keys/1.0.1: /lowercase-keys/1.0.1:
resolution: {integrity: sha512-G2Lj61tXDnVFFOi8VZds+SoQjtQC3dgokKdDG2mTm1tx4m50NUHBOZSBwQQHyy0V12A0JTG4icfZQH+xPyh8VA==} resolution: {integrity: sha512-G2Lj61tXDnVFFOi8VZds+SoQjtQC3dgokKdDG2mTm1tx4m50NUHBOZSBwQQHyy0V12A0JTG4icfZQH+xPyh8VA==}
engines: {node: '>=0.10.0'} engines: {node: '>=0.10.0'}
@ -8219,12 +8229,12 @@ packages:
readable-stream: 3.6.0 readable-stream: 3.6.0
dev: true dev: true
github.com/actions/setup-python/7f80679172b057fc5e90d70d197929d454754a5a: github.com/actions/setup-python/98f2ad02fd48d057ee3b4d4f66525b231c3e52b6:
resolution: {tarball: https://codeload.github.com/actions/setup-python/tar.gz/7f80679172b057fc5e90d70d197929d454754a5a} resolution: {tarball: https://codeload.github.com/actions/setup-python/tar.gz/98f2ad02fd48d057ee3b4d4f66525b231c3e52b6}
name: setup-python name: setup-python
version: 2.2.2 version: 3.1.1
dependencies: dependencies:
'@actions/cache': 1.0.11 '@actions/cache': 2.0.2
'@actions/core': 1.6.0 '@actions/core': 1.6.0
'@actions/exec': 1.1.1 '@actions/exec': 1.1.1
'@actions/glob': 0.2.1 '@actions/glob': 0.2.1

View File

@ -0,0 +1,10 @@
import { isCacheFeatureAvailable } from "setup-python/src/utils"
import { getCacheDistributor } from "setup-python/src/cache-distributions/cache-factory"
export async function cacheDependencies(cache: string, pythonVersion: string) {
if (isCacheFeatureAvailable()) {
const cacheDependencyPath = undefined // core.getInput("cache-dependency-path") || undefined
const cacheDistributor = getCacheDistributor(cache, pythonVersion, cacheDependencyPath)
await cacheDistributor.restoreCache()
}
}

View File

@ -1,43 +1,39 @@
import * as finder from "setup-python/src/find-python" import { useCpythonVersion } from "setup-python/src/find-python"
import * as finderPyPy from "setup-python/src/find-pypy" import { findPyPyVersion } from "setup-python/src/find-pypy"
import { existsSync } from "fs" import { existsSync } from "fs"
import { warning } from "../utils/io/io" import { info, warning } from "../utils/io/io"
import { info } from "@actions/core" import { debug } from "@actions/core"
import path from "path" import path from "path"
import { isGitHubCI } from "../utils/env/isci" import { isGitHubCI } from "../utils/env/isci"
// import { getCacheDistributor } from "setup-python/src/cache-distributions/cache-factory" import { cacheDependencies } from "./actions_cache"
// import { isGhes } from "setup-python/src/utils"
function isPyPyVersion(versionSpec: string) { function isPyPyVersion(versionSpec: string) {
return versionSpec.startsWith("pypy-") return versionSpec.startsWith("pypy-")
} }
// // @ts-ignore
// async function cacheDependencies(cache: string, pythonVersion: string) {
// if (isGhes()) {
// throw new Error("Caching is not supported on GHES")
// }
// const cacheDependencyPath = core.getInput("cache-dependency-path") || undefined
// const cacheDistributor = getCacheDistributor(cache, pythonVersion, cacheDependencyPath)
// await cacheDistributor.restoreCache()
// }
export async function setupActionsPython(version: string, _setupDir: string, arch: string) { export async function setupActionsPython(version: string, _setupDir: string, arch: string) {
if (process.env.AGENT_TOOLSDIRECTORY?.trim()) {
debug(`Python is expected to be installed into AGENT_TOOLSDIRECTORY=${process.env.AGENT_TOOLSDIRECTORY}`)
process.env.RUNNER_TOOL_CACHE = process.env.AGENT_TOOLSDIRECTORY
} else {
debug(`Python is expected to be installed into RUNNER_TOOL_CACHE==${process.env.RUNNER_TOOL_CACHE}`)
}
if (version) {
let pythonVersion: string let pythonVersion: string
if (isPyPyVersion(version)) { if (isPyPyVersion(version)) {
const installed = await finderPyPy.findPyPyVersion(version, arch) const installed = await findPyPyVersion(version, arch)
pythonVersion = `${installed.resolvedPyPyVersion}-${installed.resolvedPythonVersion}` pythonVersion = `${installed.resolvedPyPyVersion}-${installed.resolvedPythonVersion}`
info(`Successfully setup PyPy ${installed.resolvedPyPyVersion} with Python (${installed.resolvedPythonVersion})`) info(`Successfully setup PyPy ${installed.resolvedPyPyVersion} with Python (${installed.resolvedPythonVersion})`)
} else { } else {
const installed = await finder.findPythonVersion(version, arch) const installed = await useCpythonVersion(version, arch)
pythonVersion = installed.version pythonVersion = installed.version
info(`Successfully setup ${installed.impl} (${pythonVersion})`) info(`Successfully setup ${installed.impl} (${pythonVersion})`)
} }
// const cache = core.getInput("cache") const cache = "pip" // core.getInput("cache") // package manager used for caching
// if (cache) {
// await cacheDependencies(cache, pythonVersion) await cacheDependencies(cache, pythonVersion)
// } }
if (isGitHubCI()) { if (isGitHubCI()) {
addPythonLoggingMatcher() addPythonLoggingMatcher()

View File

@ -6,14 +6,13 @@ import { setupChocoPack } from "../utils/setup/setupChocoPack"
import { isGitHubCI } from "../utils/env/isci" import { isGitHubCI } from "../utils/env/isci"
import { warning } from "@actions/core" import { warning } from "@actions/core"
export function setupPython(version: string, setupDir: string, arch: string) { export async function setupPython(version: string, setupDir: string, arch: string) {
if (!isGitHubCI()) { if (!isGitHubCI()) {
// TODO parse version // TODO parse version
return setupPythonViaSystem(version, setupDir, arch) return setupPythonViaSystem(version, setupDir, arch)
} }
try { try {
// eslint-disable-next-line @typescript-eslint/no-var-requires const { setupActionsPython } = await import("./actions_python")
const { setupActionsPython } = require("./actions_python") as typeof import("./actions_python")
return setupActionsPython(version, setupDir, arch) return setupActionsPython(version, setupDir, arch)
} catch (err) { } catch (err) {
warning(err as Error) warning(err as Error)

View File

@ -16,7 +16,7 @@
"inlineSources": true, "inlineSources": true,
"preserveSymlinks": true, "preserveSymlinks": true,
"removeComments": false, "removeComments": false,
"skipLibCheck": true, // TODO: time-delta has issues "skipLibCheck": false,
"lib": ["ES2018", "dom"], "lib": ["ES2018", "dom"],
"target": "ES2018", "target": "ES2018",
"allowJs": true, "allowJs": true,