Merge branch 'master' into pr/135

This commit is contained in:
Amin Yahyaabadi 2022-10-28 23:48:23 -07:00
commit f7e3122b1e
38 changed files with 1480 additions and 1180 deletions

View File

@ -6,6 +6,8 @@ on:
- master
- main
- dev
tags:
- "*"
jobs:
Test:
@ -23,7 +25,7 @@ jobs:
- macos-12
- macos-11
node:
- 14 # installed on the images
- 16
pnpm:
- 7
cache_reset_counter:
@ -57,21 +59,6 @@ jobs:
run: |
pnpm install
# Create self-contained executable that bundles Nodejs
- name: Create Executable
if: "contains(matrix.os, 'windows-2022') || contains(matrix.os, 'ubuntu-20.04') || contains(matrix.os, 'macos-11')"
run: |
pnpm run pack.exe
- name: Upload Executable
if: "contains(matrix.os, 'windows-2022') || contains(matrix.os, 'ubuntu-20.04') || contains(matrix.os, 'macos-11')"
uses: actions/upload-artifact@v3
with:
path: |
./exe
./dist
retention-days: 1
# - name: Setup SSH debugging session
# uses: mxschmitt/action-tmate@v3
@ -81,6 +68,49 @@ jobs:
pnpm run test
continue-on-error: ${{ contains(matrix.os, 'ubuntu-18.04') }}
# Create self-contained executable that bundles Nodejs
- name: Create Executable
if: "contains(matrix.os, 'windows-2022') || contains(matrix.os, 'ubuntu-22.04') || contains(matrix.os, 'macos-12')"
run: |
pnpm run pack.exe
- name: Upload Artifacts
if: ${{ (startsWith(github.ref, 'refs/tags/')) && contains(matrix.os, 'windows-2022') || contains(matrix.os, 'ubuntu-22.04') || contains(matrix.os, 'macos-12') }}
uses: actions/upload-artifact@v3
with:
path: |
./exe
./dist
retention-days: 1
Release:
needs: Test
if: startsWith(github.ref, 'refs/tags/')
runs-on: ubuntu-22.04
steps:
- name: Download Artifacts
uses: actions/download-artifact@v3
- name: Place Artifacts
run: |
mv -v artifact/* ./
chmod +x -R ./exe/
- name: Draft the release
uses: meeDamian/github-release@2.0
with:
token: ${{ secrets.GITHUB_TOKEN }}
gzip: folders
draft: true
files: >
./exe/setup_cpp_windows.exe
./exe/setup_cpp_linux
./exe/setup_cpp_mac
./dist/node12/setup_cpp.js
./dist/node12/setup_cpp.js.map
./dist/node12/
./dist/node16/
Docker:
if: ${{ !contains(github.event.head_commit.message, '[skip ci]') && !contains(github.event.head_commit.message, '[skip docker]') }}
runs-on: ${{ matrix.os }}

View File

@ -36,13 +36,13 @@ Tip: You can automate downloading using `wget`, `curl`, or other similar tools.
#### Executable
Download the executable for your platform from [here](https://github.com/aminya/setup-cpp/releases/tag/v0.20.1), and run it with the available options.
Download the executable for your platform from [here](https://github.com/aminya/setup-cpp/releases/tag/v0.21.0), and run it with the available options.
An example that installs llvm, cmake, ninja, ccache, and vcpkg:
```ps1
# windows example (open shell as admin)
curl.exe -LJO "https://github.com/aminya/setup-cpp/releases/download/v0.20.1/setup_cpp_windows.exe"
curl.exe -LJO "https://github.com/aminya/setup-cpp/releases/download/v0.21.0/setup_cpp_windows.exe"
.\setup_cpp_windows --compiler llvm --cmake true --ninja true --ccache true --vcpkg true
RefreshEnv.cmd # activate cpp environment variables
@ -50,7 +50,7 @@ RefreshEnv.cmd # activate cpp environment variables
```ps1
# linux example
wget "https://github.com/aminya/setup-cpp/releases/download/v0.20.1/setup_cpp_linux"
wget "https://github.com/aminya/setup-cpp/releases/download/v0.21.0/setup_cpp_linux"
chmod +x setup_cpp_linux
sudo ./setup_cpp_linux --compiler llvm --cmake true --ninja true --ccache true --vcpkg true
@ -59,7 +59,7 @@ source ~/.cpprc # activate cpp environment variables
```ps1
# mac example
wget "https://github.com/aminya/setup-cpp/releases/download/v0.20.1/setup_cpp_mac"
wget "https://github.com/aminya/setup-cpp/releases/download/v0.21.0/setup_cpp_mac"
chmod +x setup_cpp_mac
sudo ./setup_cpp_mac --compiler llvm --cmake true --ninja true --ccache true --vcpkg true
@ -74,7 +74,7 @@ NOTE: On Unix systems, you will not need `sudo` if you are already a root user (
#### With Nodejs
Download the `setup_cpp.js` file form [here](https://github.com/aminya/setup-cpp/releases/download/v0.20.1/setup_cpp.js), and run it with the available options.
Download the `setup_cpp.js` file form [here](https://github.com/aminya/setup-cpp/releases/download/v0.21.0/setup_cpp.js), and run it with the available options.
On Windows:
@ -82,7 +82,7 @@ Open the shell as admin, download via `curl`, then install
```ps1
# open shell as admin
curl.exe -LJO "https://github.com/aminya/setup-cpp/releases/download/v0.20.1/setup_cpp.js"
curl.exe -LJO "https://github.com/aminya/setup-cpp/releases/download/v0.21.0/setup_cpp.js"
node ./setup_cpp.js --compiler llvm --cmake true --ninja true --ccache true --vcpkg true
RefreshEnv.cmd # activate cpp environment variables
@ -91,7 +91,7 @@ RefreshEnv.cmd # activate cpp environment variables
On Linux or Mac:
```ps1
wget "https://github.com/aminya/setup-cpp/releases/download/v0.20.1/setup_cpp.js"
wget "https://github.com/aminya/setup-cpp/releases/download/v0.21.0/setup_cpp.js"
sudo node ./setup_cpp.js --compiler llvm --cmake true --ninja true --ccache true --vcpkg true
source ~/.cpprc # activate cpp environment variables
@ -170,7 +170,7 @@ FROM ubuntu:22.04 AS base
WORKDIR "/"
RUN apt-get update -qq
RUN apt-get install -y --no-install-recommends wget
RUN wget --no-verbose "https://github.com/aminya/setup-cpp/releases/download/v0.20.1/setup_cpp_linux"
RUN wget --no-verbose "https://github.com/aminya/setup-cpp/releases/download/v0.21.0/setup_cpp_linux"
RUN chmod +x ./setup_cpp_linux
# install llvm, cmake, ninja, and ccache
@ -262,7 +262,7 @@ stages:
apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 1E9377A2BA9EF27F
.setup_cpp: &setup_cpp |
curl -LJO "https://github.com/aminya/setup-cpp/releases/download/v0.20.1/setup_cpp_linux"
curl -LJO "https://github.com/aminya/setup-cpp/releases/download/v0.21.0/setup_cpp_linux"
chmod +x setup_cpp_linux
./setup_cpp_linux --compiler $compiler --cmake true --ninja true --ccache true --vcpkg true
source ~/.cpprc
@ -297,7 +297,7 @@ test_linux_gcc:
## Usage Examples
- [cpp_vcpkg_project project](https://github.com/aminya/cpp_vcpkg_project)
- [project_optins](https://github.com/aminya/project_options)
- [project_options](https://github.com/aminya/project_options)
- [cpp-best-practices starter project](https://github.com/cpp-best-practices/cpp_starter_project)
- [ftxui](https://github.com/ArthurSonzogni/FTXUI)
- [inja](https://github.com/pantor/inja)

View File

@ -80,8 +80,8 @@ inputs:
required: false
runs:
using: "node12"
main: "dist/setup_cpp.js"
using: "node16"
main: "dist/node16/setup_cpp.js"
branding:
icon: "award"

View File

@ -11,7 +11,7 @@ RUN pacman -S --noconfirm --needed nodejs
RUN pacman -S --noconfirm --needed curl
# add setup_cpp.js
COPY "./dist/" "/"
COPY "./dist/node12" "/"
WORKDIR "/"
# run installation

View File

@ -8,7 +8,7 @@ RUN dnf -y install nodejs
RUN dnf -y install curl
# add setup_cpp.js
COPY "./dist/" "/"
COPY "./dist/node12" "/"
WORKDIR "/"
# run installation

View File

@ -5,7 +5,7 @@ FROM ubuntu:22.04 AS base
WORKDIR "/"
RUN apt-get update -qq
RUN apt-get install -y --no-install-recommends wget
RUN wget --no-verbose "https://github.com/aminya/setup-cpp/releases/download/v0.20.1/setup_cpp_linux"
RUN wget --no-verbose "https://github.com/aminya/setup-cpp/releases/download/v0.21.0/setup_cpp_linux"
RUN chmod +x ./setup_cpp_linux
# install llvm, cmake, ninja, and ccache

View File

@ -12,7 +12,7 @@ RUN curl -fsSL https://deb.nodesource.com/setup_lts.x | bash -
RUN apt-get install -y --no-install-recommends nodejs
# add setup_cpp.js
ADD "./dist/" "/"
COPY "./dist/node12" "/"
WORKDIR "/"
# run installation

View File

@ -4,7 +4,7 @@ RUN apt-get update -qq
RUN apt-get install -y --no-install-recommends nodejs
# add setup_cpp.js
COPY "./dist/" "/"
COPY "./dist/node12" "/"
WORKDIR "/"
# run installation

View File

@ -1,4 +1,4 @@
const { exec } = require("@actions/exec")
import { node } from "execa"
function getPlatformName() {
switch (process.platform) {
@ -26,13 +26,19 @@ function main() {
return Promise.all(
exes.map((exe) =>
exec(
`./node_modules/.bin/caxa --input ./dist --output ./exe/setup_cpp_${getPlatformName()}${exe} -- "{{caxa}}/node_modules/.bin/node${exe}" "{{caxa}}/setup_cpp.js"`
)
node("./node_modules/caxa/build/index.mjs", [
"--input",
"./dist/node16",
"--output",
`./exe/setup_cpp_${getPlatformName()}${exe}`,
"--",
`{{caxa}}/node_modules/.bin/node${exe}`,
`{{caxa}}/setup_cpp.js`,
])
)
)
}
main().then((exit) => {
process.exit(exit)
main().catch((err) => {
throw err
})

3
dev/scripts/package.json Normal file
View File

@ -0,0 +1,3 @@
{
"type": "module"
}

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

2
dist/node12/setup_cpp.js vendored Normal file

File diff suppressed because one or more lines are too long

1
dist/node12/setup_cpp.js.map vendored Normal file

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

17
dist/node16/gcc_matcher.json vendored Normal file
View File

@ -0,0 +1,17 @@
{
"problemMatcher": [
{
"owner": "gcc",
"pattern": [
{
"regexp": "^(.*?):(\\d+):(\\d*):?\\s+(?:fatal\\s+)?(warning|error):\\s+(.*)$",
"file": 1,
"line": 2,
"column": 3,
"severity": 4,
"message": 5
}
]
}
]
}

17
dist/node16/llvm_matcher.json vendored Normal file
View File

@ -0,0 +1,17 @@
{
"problemMatcher": [
{
"owner": "llvm",
"pattern": [
{
"regexp": "^(.*?):(\\d+):(\\d*):?\\s+(?:fatal\\s+)?(warning|error):\\s+(.*)$",
"file": 1,
"line": 2,
"column": 3,
"severity": 4,
"message": 5
}
]
}
]
}

18
dist/node16/msvc_matcher.json vendored Normal file
View File

@ -0,0 +1,18 @@
{
"problemMatcher": [
{
"owner": "msvc",
"pattern": [
{
"regexp": "^(?:\\s+\\d+>)?(\\S.*)\\((\\d+),?(\\d+)?(?:,\\d+,\\d+)?\\)\\s*:\\s+(error|warning|info)\\s+(\\w{1,2}\\d+)\\s*:\\s*(.*)$",
"file": 1,
"line": 2,
"column": 3,
"severity": 4,
"code": 5,
"message": 6
}
]
}
]
}

18
dist/node16/python_matcher.json vendored Normal file
View File

@ -0,0 +1,18 @@
{
"problemMatcher": [
{
"owner": "python",
"pattern": [
{
"regexp": "^\\s*File\\s\\\"(.*)\\\",\\sline\\s(\\d+),\\sin\\s(.*)$",
"file": 1,
"line": 2
},
{
"regexp": "^\\s*raise\\s(.*)\\(\\'(.*)\\'\\)$",
"message": 2
}
]
}
]
}

2
dist/node16/setup_cpp.js vendored Normal file

File diff suppressed because one or more lines are too long

1
dist/node16/setup_cpp.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

View File

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

View File

@ -1 +0,0 @@
["node_modules/setup-python/src/cache-distributions/poetry-cache.ts"]

View File

@ -1,22 +1,22 @@
{
"name": "setup-cpp",
"version": "0.20.1",
"version": "0.21.0",
"description": "Install all the tools required for building and testing C++/C projects.",
"repository": "https://github.com/aminya/setup-cpp",
"license": "Apache-2.0",
"author": "Amin Yahyaabadi",
"exports": {
"import": "./dist/setup-cpp.mjs",
"require": "./dist/setup-cpp.js"
"import": "./dist/node12/setup-cpp.mjs",
"require": "./dist/node12/setup-cpp.js"
},
"main": "./dist/setup_cpp.js",
"main": "./dist/node12/setup_cpp.js",
"source": "./src/main.ts",
"bin": {
"setup-cpp": "./dist/setup_cpp.js",
"setup_cpp": "./dist/setup_cpp.js"
"setup-cpp": "./dist/node12/setup_cpp.js",
"setup_cpp": "./dist/node12/setup_cpp.js"
},
"scripts": {
"build": "shx rm -rf dist/ && shx mkdir ./dist && run-p lint.tsc build.parcel copy.matchers",
"build": "shx rm -rf dist/ && shx mkdir -p ./dist/node12 ./dist/node16 && run-p lint.tsc build.parcel copy.matchers",
"build.docker": "pnpm build && docker build -f ./dev/docker/ubuntu_node.dockerfile -t setup_cpp .",
"build.docker.arch": "pnpm build && docker build -f ./dev/docker/arch_node.dockerfile -t setup_cpp:arch .",
"build.docker.fedora": "pnpm build && docker build -f ./dev/docker/fedora_node.dockerfile -t setup_cpp:fedora .",
@ -24,7 +24,7 @@
"build.parcel": "cross-env NODE_ENV=production parcel build --detailed-report",
"bump": "ncu -u -x execa,numerous && pnpm update",
"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 cp ./src/gcc/gcc_matcher.json ./dist/node12/ && shx cp ./src/msvc/msvc_matcher.json ./dist/node12/ && shx cp ./src/python/python_matcher.json ./dist/node12/ && shx cp ./src/llvm/llvm_matcher.json ./dist/node12/ && shx cp ./dist/node12/*.json ./dist/node16/",
"dev": "cross-env NODE_ENV=development parcel watch",
"docs": "shx rm -rf packages/*/README.md && pnpm -r exec readme --path ../../dev/readme/template.md -y && pnpm -r exec ts-readme",
"format": "run-s lint.prettier",
@ -32,8 +32,8 @@
"lint.cspell": "cspell lint --no-progress --show-suggestions",
"lint.eslint": "eslint **/*.{ts,tsx,js,jsx,cjs,mjs,json,yaml} --no-error-on-unmatched-pattern --cache --cache-location ./.cache/eslint/ --fix",
"lint.prettier": "prettier --write .",
"lint.tsc": "tsc --noEmit | loose-ts-check",
"pack.exe": "shx rm -rf ./dist/tsconfig.tsbuildinfo && node ./dev/scripts/pack-exe.js",
"lint.tsc": "tsc --noEmit",
"pack.exe": "shx rm -rf ./dist/tsconfig.tsbuildinfo && ts-node --esm ./dev/scripts/pack-exe.ts",
"prepare": "pnpm run -r build && pnpm run -w build",
"start.docker": "docker run -t setup_cpp .",
"start.docker.arch": "docker run -t setup_cpp:arch .",
@ -50,7 +50,7 @@
},
"prettier": "prettier-config-atomic",
"dependencies": {
"@actions/core": "^1.9.1",
"@actions/core": "^1.10.0",
"@actions/exec": "^1.1.1",
"@actions/io": "^1.1.2",
"@actions/tool-cache": "^2.0.1",
@ -65,8 +65,8 @@
"msvc-dev-cmd": "github:aminya/msvc-dev-cmd#9f672c1",
"numerous": "1.0.3",
"patha": "^0.4.1",
"semver": "7.3.7",
"setup-python": "github:actions/setup-python#c474c82340438924daab9282d07300bfe7e3692d",
"semver": "7.3.8",
"setup-python": "github:actions/setup-python#v4.3.0",
"time-delta": "github:aminya/time-delta#69d91a41cef28e569be9a2991129f5f7d1f0d00e",
"ubuntu-version": "^2.0.0",
"untildify-user": "workspace:1.0.0",
@ -75,21 +75,20 @@
},
"devDependencies": {
"@types/cross-spawn": "^6.0.2",
"@types/jest": "^29.0.3",
"@types/jest": "^29.2.0",
"@types/mri": "^1.1.1",
"@types/node": "^18.7.18",
"@types/node": "^18.11.2",
"@types/semver": "^7.3.12",
"@types/which": "^2.0.1",
"caxa": "^2.1.0",
"caxa": "^3.0.1",
"cross-env": "7.0.3",
"cross-spawn": "^7.0.3",
"cspell": "^6.9.1",
"eslint": "^8.23.1",
"cspell": "^6.12.0",
"eslint": "^8.25.0",
"eslint-config-atomic": "^1.18.1",
"gen-readme": "^1.6.0",
"jest": "^29.0.3",
"loose-ts-check": "^1.2.0",
"npm-check-updates": "^16.1.3",
"jest": "^29.2.1",
"npm-check-updates": "^16.3.14",
"npm-run-all2": "^6.0.2",
"parcel": "2.7.0",
"prettier": "2.7.1",
@ -97,9 +96,10 @@
"readme-md-generator": "^1.0.0",
"shx": "0.3.4",
"terser-config-atomic": "^0.1.1",
"ts-jest": "^29.0.1",
"ts-jest": "^29.0.3",
"ts-node": "^10.9.1",
"ts-readme": "^1.1.3",
"typescript": "^4.8.3"
"typescript": "^4.8.4"
},
"engines": {
"node": ">=12.x"
@ -127,10 +127,11 @@
"electron": false,
"patha": "patha/dist/index.node.mjs"
},
"main.actions": "./dist/node16/setup_cpp.js",
"pnpm": {
"overrides": {
"semver": "7.3.7",
"eslint": "^8.23.1",
"semver": "7.3.8",
"eslint": "^8.25.0",
"prettier": "2.7.1",
"lru-cache": "7.8.1",
"core-js": "*",
@ -151,6 +152,15 @@
"includeNodeModules": true,
"optimize": true,
"outputFormat": "commonjs"
},
"main.actions": {
"context": "node",
"engines": {
"node": ">=16.x"
},
"includeNodeModules": true,
"optimize": true,
"outputFormat": "commonjs"
}
}
}

File diff suppressed because it is too large Load Diff

View File

@ -1,13 +1,14 @@
import { setupLLVM, VERSIONS, getUrl, setupClangTools, getLinuxUrl } from "../llvm"
import { getSpecificVersionAndUrl } from "../../utils/setup/version"
import { isUrlOnline } from "is-url-online"
import { setupTmpDir, cleanupTmpDir, testBin } from "../../utils/tests/test-helpers"
import { setupTmpDir, testBin } from "../../utils/tests/test-helpers"
import ciDetect from "@npmcli/ci-detect"
import execa from "execa"
import path, { addExeExt } from "patha"
import { chmodSync } from "fs"
import { getVersion } from "../../default_versions"
import { ubuntuVersion } from "../../utils/env/ubuntu_version"
import * as io from "@actions/io"
jest.setTimeout(400000)
async function testUrl(version: string) {
@ -54,6 +55,7 @@ describe("setup-llvm", () => {
it("Finds valid LLVM URLs", async () => {
await Promise.all(
[
"15.0.2",
// "14.0.1",
"14.0.0",
"13.0.0",
@ -121,7 +123,27 @@ describe("setup-llvm", () => {
await testBin("clang-format", ["--version"], binDir)
})
it("should setup LLVM 15.0.2", async () => {
await io.rmRF(directory)
await io.rmRF("/Users/runner/hostedtoolcache/llvm")
const { binDir } = await setupLLVM("15.0.2", directory, process.arch)
await testBin("clang++", ["--version"], binDir)
expect(process.env.CC?.includes("clang")).toBeTruthy()
expect(process.env.CXX?.includes("clang++")).toBeTruthy()
// test compilation
const file = path.join(__dirname, "main.cpp")
const main_exe = path.join(__dirname, addExeExt("main"))
execa.sync("clang++", [file, "-o", main_exe], { cwd: __dirname })
if (process.platform !== "win32") {
chmodSync(main_exe, "755")
}
execa.sync(main_exe, { cwd: __dirname, stdio: "inherit" })
})
afterAll(async () => {
await cleanupTmpDir("llvm")
await io.rmRF(directory)
}, 100000)
})

View File

@ -71,6 +71,9 @@ export const VERSIONS: Set<string> = getVersions([
"14.0.4",
"14.0.5",
"14.0.6",
"15.0.0",
"15.0.1",
"15.0.2",
])
//================================================
@ -174,10 +177,11 @@ const UBUNTU_SUFFIX_MAP: { [key: string]: string } = {
"13.0.1-ubuntu-18.04": "-ubuntu-18.04",
"14.0.0": "-ubuntu-18.04",
// "14.0.1": "-ubuntu-18.04", // only available for powerpc64le
"15.0.2": "-rhel86",
}
/** The latest supported LLVM version for the Linux (Ubuntu) platform. */
const MAX_UBUNTU: string = "14.0.0"
const MAX_UBUNTU: string = "15.0.2"
/** Gets an LLVM download URL for the Linux (Ubuntu) platform. */
export function getLinuxUrl(versionGiven: string): string {
@ -188,25 +192,34 @@ export function getLinuxUrl(versionGiven: string): string {
version = rc
}
let ubuntu: string
let linuxVersion: string
// ubuntu-version is specified
if (version.includes("ubuntu")) {
const givenUbuntuVersion = version.replace(/-ubuntu-.*/, "")
if (!VERSIONS.has(givenUbuntuVersion)) {
throw new Error(`Unsupported Ubuntu version: ${givenUbuntuVersion}`)
}
ubuntu = version.replace(givenUbuntuVersion, "")
linuxVersion = version.replace(givenUbuntuVersion, "")
version = getSpecificVersions(VERSIONS, givenUbuntuVersion)[0]
} else if (version !== "" && version in UBUNTU_SUFFIX_MAP) {
ubuntu = UBUNTU_SUFFIX_MAP[version]
linuxVersion = UBUNTU_SUFFIX_MAP[version]
} else {
// default to the maximum version
ubuntu = UBUNTU_SUFFIX_MAP[MAX_UBUNTU]
warning(`Falling back to LLVM version ${MAX_UBUNTU} ${ubuntu} for the Ubuntu.`)
linuxVersion = UBUNTU_SUFFIX_MAP[MAX_UBUNTU]
warning(`Falling back to LLVM version ${MAX_UBUNTU} ${linuxVersion} for the Ubuntu.`)
}
const prefix = "clang+llvm-"
const suffix = version === "5.0.0" ? `-linux-x86_64${ubuntu}.tar.xz` : `-x86_64-linux-gnu${ubuntu}.tar.xz`
let suffix: string
if (version === "5.0.0") {
suffix = `-linux-x86_64${linuxVersion}.tar.xz`
} else if (linuxVersion.includes("-rhel86")) {
suffix = `-x86_64-unknown-linux-gnu${linuxVersion}.tar.xz`
} else {
suffix = `-x86_64-linux-gnu${linuxVersion}.tar.xz`
}
if (semverLte(version, "9.0.1")) {
return getReleaseUrl(version, prefix, suffix)
} else {

View File

@ -5,69 +5,47 @@ import { info, warning } from "ci-log"
import { debug } from "@actions/core"
import { join } from "patha"
import ciDetect from "@npmcli/ci-detect"
import { isCacheFeatureAvailable, IS_LINUX, IS_WINDOWS } from "setup-python/src/utils"
import { isCacheFeatureAvailable, IS_MAC } from "setup-python/src/utils"
import { getCacheDistributor } from "setup-python/src/cache-distributions/cache-factory"
function isPyPyVersion(versionSpec: string) {
return versionSpec.startsWith("pypy")
}
/*
function resolveVersionInput(version: string): string {
let versionFile = getInput("python-version-file")
if (version && versionFile) {
warning("Both python-version and python-version-file inputs are specified, only python-version will be used")
}
if (version) {
return version
}
versionFile = versionFile || ".python-version"
if (!existsSync(versionFile)) {
throw new Error(`The specified python version file at: ${versionFile} does not exist`)
}
version = readFileSync(versionFile, "utf8")
info(`Resolved ${versionFile} as ${version}`)
return version
}
*/
export async function cacheDependencies(cache: string, pythonVersion: string) {
const cacheDependencyPath = undefined // core.getInput("cache-dependency-path") || undefined
const cacheDependencyPath = undefined
const cacheDistributor = getCacheDistributor(cache, pythonVersion, cacheDependencyPath)
await cacheDistributor.restoreCache()
}
const checkLatest = false
export async function setupActionsPython(version: string, _setupDir: string, arch: string) {
// According to the README windows binaries do not require to be installed
// in the specific location, but Mac and Linux do
if (!IS_WINDOWS && !process.env.AGENT_TOOLSDIRECTORY?.trim()) {
if (IS_LINUX) {
process.env.AGENT_TOOLSDIRECTORY = "/opt/hostedtoolcache"
} else {
if (IS_MAC) {
process.env.AGENT_TOOLSDIRECTORY = "/Users/runner/hostedtoolcache"
}
const agent_toolsdirectory = process.env.AGENT_TOOLSDIRECTORY?.trim()
if (typeof agent_toolsdirectory === "string" && agent_toolsdirectory !== "") {
process.env.RUNNER_TOOL_CACHE = process.env.AGENT_TOOLSDIRECTORY
}
debug(`Python is expected to be installed into RUNNER_TOOL_CACHE=${process.env.RUNNER_TOOL_CACHE}`)
// const version = resolveVersionInput(versionGiven)
debug(`Python is expected to be installed into ${process.env.RUNNER_TOOL_CACHE}`)
if (version) {
let pythonVersion: string
if (isPyPyVersion(version)) {
const installed = await findPyPyVersion(version, arch, true)
const installed = await findPyPyVersion(version, arch, true, checkLatest)
pythonVersion = `${installed.resolvedPyPyVersion}-${installed.resolvedPythonVersion}`
info(`Successfully set up PyPy ${installed.resolvedPyPyVersion} with Python (${installed.resolvedPythonVersion})`)
} else {
const installed = await useCpythonVersion(version, arch, true)
const installed = await useCpythonVersion(version, arch, true, checkLatest)
pythonVersion = installed.version
info(`Successfully set up ${installed.impl} (${pythonVersion})`)
}
if (isCacheFeatureAvailable()) {
const cache = "pip" // core.getInput("cache") // package manager used for caching
const cache = "pip" // package manager used for caching
await cacheDependencies(cache, pythonVersion)
}
}

View File

@ -47,20 +47,31 @@ export async function getSpecificVersionAndUrl(
}
}
// if the given set doesn't include the version, throw an error
if (!versions.has(version)) {
throw new Error(`Unsupported target! (platform='${platform}', version='${version}')`)
}
const offlineUrls: string[] = []
for (const specificVersion of getSpecificVersions(versions, version)) {
// eslint-disable-next-line no-await-in-loop
const url = await getUrl(platform, specificVersion)
// eslint-disable-next-line no-await-in-loop
if (url !== null && (await isUrlOnline(url))) {
if (url !== null) {
if (await isUrlOnline(url)) {
return [specificVersion, url]
} else {
offlineUrls.push(url)
}
}
}
throw new Error(`Unsupported target! (platform='${platform}', version='${version}')`)
throw new Error(
`Unsupported target! (platform='${platform}', version='${version}'). The offline urls tested:\n${offlineUrls.join(
"\n"
)}`
)
}
export const defaultVersionRegex = /v?(\d\S*)/

View File

@ -2,7 +2,7 @@
"compilerOptions": {
"strict": true,
"strictNullChecks": true,
"noUnusedLocals": true,
"noUnusedLocals": false,
"noUnusedParameters": true,
"noImplicitReturns": true,
"noImplicitAny": true,
@ -28,5 +28,5 @@
"outDir": "./dist"
},
"compileOnSave": false,
"include": ["./src", "packages/untildify-user/untildify.ts"]
"include": ["./src", "dev/scripts", "packages/untildify-user/untildify.ts"]
}