Skip to content

Commit 6cda618

Browse files
authored
tools: make ./v symlink work platform independent in CI (part 1) (#21453)
1 parent 02d123a commit 6cda618

File tree

2 files changed

+22
-6
lines changed

2 files changed

+22
-6
lines changed

.github/workflows/check_symlink_works.yml

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,18 +16,20 @@ concurrency:
1616
cancel-in-progress: true
1717

1818
jobs:
19-
test-sudo:
19+
test:
2020
runs-on: ${{ matrix.os }}
2121
strategy:
2222
matrix:
23-
os: [ubuntu-20.04, macos-13]
23+
os: [ubuntu-20.04, macos-13, windows-2019]
2424
fail-fast: false
2525
steps:
2626
- uses: actions/checkout@v4
27-
- name: Build V
28-
run: make -j4
29-
- name: Symlink
30-
run: sudo ./v symlink
27+
- name: Build and symlink (Windows)
28+
if: runner.os == 'Windows'
29+
run: ./make.bat && ./v symlink
30+
- name: Build and symlink
31+
if: runner.os != 'Windows'
32+
run: make -j4 && sudo ./v symlink
3133
- name: Check if V is usable
3234
run: |
3335
pwd

cmd/tools/vsymlink/vsymlink_windows.c.v

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,20 @@ fn setup_symlink() {
8383
warn_and_exit('You might need to run this again to have the `v` command in your %PATH%')
8484
}
8585
C.RegCloseKey(reg_sys_env_handle)
86+
if os.getenv('GITHUB_JOB') != '' {
87+
// Append V's install location to GITHUBs PATH environment variable.
88+
// Resources:
89+
// 1. https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions#environment-files
90+
// 2. https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions#setting-an-environment-variable
91+
mut content := os.read_file(os.getenv('GITHUB_PATH')) or {
92+
eprintln('The `GITHUB_PATH` env variable is not defined.')
93+
exit(1)
94+
}
95+
content += '\n${new_sys_env_path}\n'
96+
os.write_file(os.getenv('GITHUB_PATH'), content) or {
97+
panic('Failed to write to GITHUB_PATH.')
98+
}
99+
}
86100
println('Done.')
87101
println('Note: Restart your shell/IDE to load the new %PATH%.')
88102
println('After restarting your shell/IDE, give `v version` a try in another directory!')

0 commit comments

Comments
 (0)