Skip to content

Add add-to-path input to control whether the toolchain is added to the PATH #79

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,27 @@ jobs:
- uses: actions/checkout@v3
- uses: ./
- run: swift --version
test-skip-add-to-path:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3
- uses: ./
id: setup
with:
add-to-path: false
- name: Ensure that the toolchain is not added to the PATH
shell: node {0}
run: |
const path = require('path');
const toolchainPath = path.join(process.env.TOOLCHAIN_PATH, 'usr', 'bin');
const pathEnv = process.env.PATH;
console.log(`Checking if ${toolchainPath} is in the PATH (${pathEnv})`);
const pathCandidates = pathEnv.split(path.delimiter);
if (pathCandidates.includes(toolchainPath)) {
throw new Error(`Toolchain path ${toolchainPath} is in the PATH`);
}
env:
TOOLCHAIN_PATH: ${{ steps.setup.outputs.toolchain-path }}
test-nightly:
runs-on: ubuntu-20.04
steps:
Expand Down
3 changes: 3 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ branding:
inputs:
swift-version:
description: 'Swift version to configure. Reads from .swift-version if unset. Use default value if both are absent.'
add-to-path:
description: 'Add the toolchain to the PATH'
default: 'true'
runs:
using: 'node16'
main: 'dist/index.js'
4 changes: 3 additions & 1 deletion dist/index.js

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

2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

4 changes: 3 additions & 1 deletion dist/nightly/index.js

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

2 changes: 1 addition & 1 deletion dist/nightly/index.js.map

Large diffs are not rendered by default.

4 changes: 3 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@ async function run(version) {
core.debug(`Resolved toolchain download URL: ${url}`);
const toolchainPath = await installToolchain(url, version, platform);
core.info(`Toolchain installed at ${toolchainPath}`);
core.addPath(`${toolchainPath}/usr/bin`);
if (core.getBooleanInput("add-to-path")) {
core.addPath(`${toolchainPath}/usr/bin`);
}
core.setOutput("toolchain-path", toolchainPath);
}

Expand Down
3 changes: 3 additions & 0 deletions nightly/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ inputs:
token:
description: Personal access token (PAT) used to fetch releases.
default: ${{ github.token }}
add-to-path:
description: 'Add the toolchain to the PATH'
default: 'true'
runs:
using: 'node16'
main: '../dist/nightly/index.js'