Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add version test
Browse files Browse the repository at this point in the history
ttytm committed Mar 25, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
1 parent af45c3b commit 306466d
Showing 2 changed files with 32 additions and 0 deletions.
13 changes: 13 additions & 0 deletions .github/workflows/analyzer_tests.yml
Original file line number Diff line number Diff line change
@@ -45,3 +45,16 @@ jobs:

- name: Run tests
run: v test .

- name: Install v-analyzer
if: runner.os != 'Windows'
run: |
# Build and install v-analyzer at the head ref of the submitted changes.
v run build.vsh
sudo mv ./bin/v-analyzer /usr/local/bin/v-analyzer
v-analyzer --version
- name: Verify version
# TODO: include Windows
if: runner.os != 'Windows'
run: v .github/workflows/version_test.vv
19 changes: 19 additions & 0 deletions .github/workflows/version_test.vv
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import os
import v.vmod

fn test_version() {
if os.getenv('CI') != 'true' {
eprintln('Warning: Expecting usage in combination with CI workflow.')
}

git_ref := os.getenv('GITHUB_WORKFLOW_SHA').trim_space()[..7]
manifest := vmod.decode(@VMOD_FILE)!
assert manifest.name == 'v-analyzer'

// Move out of the project directory to ensure that we exclude the possiblity of
// deriving the commit reference from v-analyzer's directory at program startup.
os.chdir('/tmp/')!
analyzer_version := os.execute_opt('v-analyzer --version')!.output.all_after_last(' ').trim_space()

assert '${manifest.version}.${git_ref}' == analyzer_version
}

0 comments on commit 306466d

Please sign in to comment.