tools: make ./v symlink work platform independent in CI (part 1) (#21453)

This commit is contained in:
Turiiya 2024-05-07 18:24:47 +02:00 committed by GitHub
parent 02d123a667
commit 6cda618ead
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 22 additions and 6 deletions

View file

@ -16,18 +16,20 @@ concurrency:
cancel-in-progress: true
jobs:
test-sudo:
test:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-20.04, macos-13]
os: [ubuntu-20.04, macos-13, windows-2019]
fail-fast: false
steps:
- uses: actions/checkout@v4
- name: Build V
run: make -j4
- name: Symlink
run: sudo ./v symlink
- name: Build and symlink (Windows)
if: runner.os == 'Windows'
run: ./make.bat && ./v symlink
- name: Build and symlink
if: runner.os != 'Windows'
run: make -j4 && sudo ./v symlink
- name: Check if V is usable
run: |
pwd

View file

@ -83,6 +83,20 @@ fn setup_symlink() {
warn_and_exit('You might need to run this again to have the `v` command in your %PATH%')
}
C.RegCloseKey(reg_sys_env_handle)
if os.getenv('GITHUB_JOB') != '' {
// Append V's install location to GITHUBs PATH environment variable.
// Resources:
// 1. https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions#environment-files
// 2. https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions#setting-an-environment-variable
mut content := os.read_file(os.getenv('GITHUB_PATH')) or {
eprintln('The `GITHUB_PATH` env variable is not defined.')
exit(1)
}
content += '\n${new_sys_env_path}\n'
os.write_file(os.getenv('GITHUB_PATH'), content) or {
panic('Failed to write to GITHUB_PATH.')
}
}
println('Done.')
println('Note: Restart your shell/IDE to load the new %PATH%.')
println('After restarting your shell/IDE, give `v version` a try in another directory!')