Skip to content

Commit f5f9d33

Browse files
Merge pull request #79 from swiftwasm/katei/add-to-path
Add `add-to-path` input to control whether the toolchain is added to the PATH
2 parents 4a6da4c + 960984e commit f5f9d33

File tree

8 files changed

+38
-5
lines changed

8 files changed

+38
-5
lines changed

.github/workflows/test.yml

+21
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,27 @@ jobs:
4242
- uses: actions/checkout@v3
4343
- uses: ./
4444
- run: swift --version
45+
test-skip-add-to-path:
46+
runs-on: ubuntu-22.04
47+
steps:
48+
- uses: actions/checkout@v3
49+
- uses: ./
50+
id: setup
51+
with:
52+
add-to-path: false
53+
- name: Ensure that the toolchain is not added to the PATH
54+
shell: node {0}
55+
run: |
56+
const path = require('path');
57+
const toolchainPath = path.join(process.env.TOOLCHAIN_PATH, 'usr', 'bin');
58+
const pathEnv = process.env.PATH;
59+
console.log(`Checking if ${toolchainPath} is in the PATH (${pathEnv})`);
60+
const pathCandidates = pathEnv.split(path.delimiter);
61+
if (pathCandidates.includes(toolchainPath)) {
62+
throw new Error(`Toolchain path ${toolchainPath} is in the PATH`);
63+
}
64+
env:
65+
TOOLCHAIN_PATH: ${{ steps.setup.outputs.toolchain-path }}
4566
test-nightly:
4667
runs-on: ubuntu-20.04
4768
steps:

action.yml

+3
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ branding:
66
inputs:
77
swift-version:
88
description: 'Swift version to configure. Reads from .swift-version if unset. Use default value if both are absent.'
9+
add-to-path:
10+
description: 'Add the toolchain to the PATH'
11+
default: 'true'
912
runs:
1013
using: 'node16'
1114
main: 'dist/index.js'

dist/index.js

+3-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/index.js.map

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/nightly/index.js

+3-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/nightly/index.js.map

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

index.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,9 @@ async function run(version) {
1313
core.debug(`Resolved toolchain download URL: ${url}`);
1414
const toolchainPath = await installToolchain(url, version, platform);
1515
core.info(`Toolchain installed at ${toolchainPath}`);
16-
core.addPath(`${toolchainPath}/usr/bin`);
16+
if (core.getBooleanInput("add-to-path")) {
17+
core.addPath(`${toolchainPath}/usr/bin`);
18+
}
1719
core.setOutput("toolchain-path", toolchainPath);
1820
}
1921

nightly/action.yml

+3
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ inputs:
77
token:
88
description: Personal access token (PAT) used to fetch releases.
99
default: ${{ github.token }}
10+
add-to-path:
11+
description: 'Add the toolchain to the PATH'
12+
default: 'true'
1013
runs:
1114
using: 'node16'
1215
main: '../dist/nightly/index.js'

0 commit comments

Comments
 (0)