Skip to content

Commit

Permalink
Merge pull request #198 from aminya/fixes [skip ci]
Browse files Browse the repository at this point in the history
  • Loading branch information
aminya authored Sep 7, 2023
2 parents afcae25 + 99191e7 commit 771f77f
Show file tree
Hide file tree
Showing 28 changed files with 112 additions and 22,414 deletions.
2 changes: 2 additions & 0 deletions .terserrc.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
const { buildTerserOptions } = require("terser-config-atomic/dist/builder")
module.exports = buildTerserOptions(process.env.NODE_ENV, undefined, true)
7 changes: 7 additions & 0 deletions dist/actions/actions_python.24bdf8c6.js

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions dist/actions/actions_python.24bdf8c6.js.map

Large diffs are not rendered by default.

5,991 changes: 0 additions & 5,991 deletions dist/actions/actions_python.4dcd5257.js

This file was deleted.

1 change: 0 additions & 1 deletion dist/actions/actions_python.4dcd5257.js.map

This file was deleted.

1,477 changes: 20 additions & 1,457 deletions dist/actions/setup-cpp.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/actions/setup-cpp.js.map

Large diffs are not rendered by default.

7 changes: 7 additions & 0 deletions dist/legacy/actions_python.5006cbf4.js

Large diffs are not rendered by default.

Large diffs are not rendered by default.

5,991 changes: 0 additions & 5,991 deletions dist/legacy/actions_python.c2017515.js

This file was deleted.

1 change: 0 additions & 1 deletion dist/legacy/actions_python.c2017515.js.map

This file was deleted.

1,477 changes: 20 additions & 1,457 deletions dist/legacy/setup-cpp.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/legacy/setup-cpp.js.map

Large diffs are not rendered by default.

7 changes: 7 additions & 0 deletions dist/modern/actions_python.1fa67834.js

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions dist/modern/actions_python.1fa67834.js.map

Large diffs are not rendered by default.

5,991 changes: 0 additions & 5,991 deletions dist/modern/actions_python.945fba47.js

This file was deleted.

1,477 changes: 20 additions & 1,457 deletions dist/modern/setup-cpp.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/modern/setup-cpp.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,8 @@
"setup-python": "github:actions/setup-python#v4.7.0",
"shx": "0.3.4",
"simple-update-notifier": "^2.0.0",
"terser-config-atomic": "^1.0.0",
"time-delta": "github:aminya/time-delta#69d91a41cef28e569be9a2991129f5f7d1f0d00e",
"ts-jest": "^29.1.1",
"ts-node": "^10.9.1",
"ts-readme": "^1.1.3",
"typescript": "^5.1.6",
Expand Down
4 changes: 2 additions & 2 deletions packages/user-access/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ npm install --save user-access

<!-- INSERT GENERATED DOCS START -->

### `giveUserAccess` (function)
### `grantUserWriteAccess` (function)

Give the user access to the given path and its sub-directories. It changes the owner to the SUDO_USER. This allows
the user to use the folder without sudo
Expand All @@ -27,7 +27,7 @@ the user to use the folder without sudo

- path (`string`) - The path to give the user access to

**returns:** void
**returns:** Promise<void>

<!-- INSERT GENERATED DOCS END -->

Expand Down
6 changes: 3 additions & 3 deletions packages/user-access/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { isSudo, execRootSync } from "admina"
import { isSudo, execRoot } from "admina"
import { statSync } from "fs"

/**
Expand All @@ -7,14 +7,14 @@ import { statSync } from "fs"
*
* @param path The path to give the user access to
*/
export function giveUserAccess(path: string) {
export async function grantUserWriteAccess(path: string) {
if (
(process.platform === "linux" || process.platform === "darwin") &&
isSudo() &&
process.env.SUDO_USER !== undefined
) {
const isDirectory = statSync(path).isDirectory()
execRootSync("chown", [...(isDirectory ? ["-R"] : []), process.env.SUDO_USER, path], {
await execRoot("chown", [...(isDirectory ? ["-R"] : []), process.env.SUDO_USER, path], {
cwd: path,
stdio: "inherit",
shell: true,
Expand Down
55 changes: 7 additions & 48 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/python/python.ts
Original file line number Diff line number Diff line change
Expand Up @@ -276,4 +276,4 @@ async function addPythonBaseExecPrefix_raw(python: string) {
*
* The answer is cached for subsequent calls
*/
export const addPythonBaseExecPrefix = memoize(addPythonBaseExecPrefix_raw)
export const addPythonBaseExecPrefix = memoize(addPythonBaseExecPrefix_raw, { isPromise: true })
4 changes: 2 additions & 2 deletions src/utils/env/addEnv.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { error, warning } from "ci-log"
import { execPowershell } from "exec-powershell"
import { delimiter } from "path"
import escapeSpace from "escape-path-with-spaces"
import { giveUserAccess } from "user-access"
import { grantUserWriteAccess } from "user-access"
import escapeQuote from "escape-quotes"
import { pathExists } from "path-exists"

Expand Down Expand Up @@ -212,7 +212,7 @@ export async function finalizeCpprc() {
writeFileSync(cpprc_path, unique_entries.join("\n"))

try {
giveUserAccess(cpprc_path)
grantUserWriteAccess(cpprc_path)
} catch {
// ignore
}
Expand Down
2 changes: 1 addition & 1 deletion src/utils/env/ubuntu_version.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ async function ubuntuVersion_raw(): Promise<number[] | null> {
}

/** Detect Ubuntu version */
export const ubuntuVersion = memoize(ubuntuVersion_raw)
export const ubuntuVersion = memoize(ubuntuVersion_raw, { isPromise: true })

/** Detect Ubuntu version using os.version() for Ubuntu based distros */
function detectUsingOsVersion() {
Expand Down
6 changes: 3 additions & 3 deletions src/utils/setup/extract.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@ import { mkdirP } from "@actions/io"
import which from "which"
import { setupSevenZip } from "../../sevenzip/sevenzip"
import { warning } from "ci-log"
import { giveUserAccess } from "user-access"
import { grantUserWriteAccess } from "user-access"
export { extractTar, extractXar } from "@actions/tool-cache"

let sevenZip: string | undefined

/// Extract 7z using 7z
export async function extract7Zip(file: string, dest: string) {
await execa(await getSevenZip(), ["x", file, `-o${dest}`, "-y"], { stdio: "inherit" })
giveUserAccess(dest)
grantUserWriteAccess(dest)
return dest
}

Expand Down Expand Up @@ -55,6 +55,6 @@ export async function extractTarByExe(file: string, dest: string, flags = ["--st
}
}

giveUserAccess(dest)
grantUserWriteAccess(dest)
return dest
}
2 changes: 1 addition & 1 deletion src/utils/setup/setupPipPack.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ async function getPython_raw(): Promise<string> {
}
return pythonBin
}
const getPython = memoize(getPython_raw)
const getPython = memoize(getPython_raw, { isPromise: true })

async function pipHasPackage(python: string, name: string) {
const result = await execa(python, ["-m", "pip", "-qq", "index", "versions", name], {
Expand Down
4 changes: 2 additions & 2 deletions src/vcpkg/vcpkg.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { execaSync } from "execa"
import { notice } from "ci-log"
import { pathExists } from "path-exists"
import { addShExt, addShRelativePrefix, dirname, join } from "patha"
import { giveUserAccess } from "user-access"
import { grantUserWriteAccess } from "user-access"
import which from "which"
import { addPath } from "../utils/env/addEnv"
import { hasDnf } from "../utils/env/hasDnf"
Expand Down Expand Up @@ -62,7 +62,7 @@ export async function setupVcpkg(_version: string, setupDir: string, _arch: stri
stdio: "inherit",
})

giveUserAccess(setupDir)
grantUserWriteAccess(setupDir)

await addPath(setupDir)
// eslint-disable-next-line require-atomic-updates
Expand Down

0 comments on commit 771f77f

Please sign in to comment.