Skip to content

Commit

Permalink
tools: improve v symlink -githubci diagnostic message, when used ou…
Browse files Browse the repository at this point in the history
…tside CIs or with sudo (#21340)
  • Loading branch information
spytheman committed Apr 24, 2024
1 parent be90cf3 commit 59013f1
Show file tree
Hide file tree
Showing 2 changed files with 94 additions and 1 deletion.
88 changes: 88 additions & 0 deletions .github/workflows/check_symlink_works.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
name: V Symlink Works

on:
workflow_dispatch:
push:
paths:
- 'cmd/tools/vsymlink.v'
- '.github/workflows/check_symlink_works.yml'
pull_request:
paths:
- 'cmd/tools/vsymlink.v'
- '.github/workflows/check_symlink_works.yml'

jobs:
check-ubuntu-with-sudo:
runs-on: ubuntu-20.04
steps:
- name: Checkout V
uses: actions/checkout@v4
- name: Build V
run: make && sudo ./v symlink
- name: Check if V is usable
run: |
pwd
v version
cd ~
pwd
v version
echo 'println(123)' > hi.v
v run hi.v
echo 'Using `sudo ./v symlink` :rocket: !!!' >> $GITHUB_STEP_SUMMARY
check-ubuntu:
runs-on: ubuntu-20.04
steps:
- name: Checkout V
uses: actions/checkout@v4
- name: Build V
run: make && ./v symlink -githubci
- name: Check if V is usable
run: |
pwd
v version
cd ~
pwd
v version
echo 'println(123)' > hi.v
v run hi.v
echo "Everything was fine :rocket:" >> $GITHUB_STEP_SUMMARY
check-macos:
runs-on: macos-13
steps:
- name: Checkout V
uses: actions/checkout@v4
- name: Build V
run: make && ./v symlink -githubci
- name: Check if V is usable
run: |
pwd
v version
cd ~
pwd
v version
echo 'println(123)' > hi.v
v run hi.v
echo "Everything fine on macos too :rocket:" >> $GITHUB_STEP_SUMMARY
check-windows:
runs-on: windows-2019
steps:
- name: Checkout V
uses: actions/checkout@v4
- name: Build V
run: |
.\make.bat
.\v.exe symlink -githubci
- name: Check if V is usable
shell: bash
run: |
pwd
v version
cd ~
pwd
v version
echo 'println(123)' > hi.v
v run hi.v
echo "All fine on Windows as well :rocket:" >> $GITHUB_STEP_SUMMARY
7 changes: 6 additions & 1 deletion cmd/tools/vsymlink.v
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,12 @@ fn setup_symlink_github() {
// 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 {
panic('Failed to read GITHUB_PATH.')
eprintln('The `GITHUB_PATH` env variable is not defined.')
eprintln(' This command: `v symlink -githubci` is intended to be used within GithubActions .yml files.')
eprintln(' It also needs to be run *as is*, *** without `sudo` ***, otherwise it will not work.')
eprintln(' For local usage, outside CIs, on !windows, prefer `sudo ./v symlink` .')
eprintln(' On windows, use `.\\v.exe symlink` instead.')
exit(1)
}
content += '\n${os.getwd()}\n'
os.write_file(os.getenv('GITHUB_PATH'), content) or { panic('Failed to write to GITHUB_PATH.') }
Expand Down

0 comments on commit 59013f1

Please sign in to comment.