Skip to content
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
247 changes: 238 additions & 9 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,22 @@ on:
paths:
- "**.v"
- "**.vsh"
- "**.c"
- "**.h"
- "**.m"
- "**.md"
- "**/ci.yml"
- ".github/workflows/*.yml"
pull_request:
paths:
- "**.v"
- "**.vsh"
- "**.c"
- "**.h"
- "**.m"
- "**.md"
- "**/ci.yml"
- ".github/workflows/*.yml"

concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.sha }}
Expand Down Expand Up @@ -42,11 +50,48 @@ jobs:
uses: actions/checkout@v6
with:
path: gui
fetch-depth: 0
- name: Verify formatting of changed V files
if: github.event_name == 'pull_request'
working-directory: gui
run: |
base_ref="${{ github.base_ref }}"
git fetch --no-tags origin "$base_ref:refs/remotes/origin/$base_ref"
git diff --name-only -z --diff-filter=ACMRT "origin/${base_ref}...HEAD" -- '*.v' '*.vsh' > /tmp/vfmt-files
if [ ! -s /tmp/vfmt-files ]; then
echo "No changed V/VSH files to format-check."
exit 0
fi
xargs -0 v fmt -verify -inprocess < /tmp/vfmt-files
- name: Verify formatting
if: github.event_name != 'pull_request'
run: v fmt -verify -inprocess gui/
- name: Check formatting of MD files
run: v check-md gui/
- name: Check syntax of changed examples
if: github.event_name == 'pull_request'
working-directory: gui
run: |
base_ref="${{ github.base_ref }}"
files_list="${RUNNER_TEMP}/gui-example-syntax-files"
git fetch --no-tags origin "$base_ref:refs/remotes/origin/$base_ref"
git diff --name-only -z --diff-filter=ACMRT "origin/${base_ref}...HEAD" -- 'examples/*.v' 'examples/*.vsh' > "$files_list"
if [ ! -s "$files_list" ]; then
echo "No changed example V/VSH files to syntax-check."
exit 0
fi
while IFS= read -r -d '' file; do
case "$file" in
*.v)
v -check -N -W "$file"
;;
*.vsh)
v -check -W "$file"
;;
esac
done < "$files_list"
- name: Check syntax of examples
if: github.event_name != 'pull_request'
run: v gui/examples/_check.vsh

compiling:
Expand All @@ -57,7 +102,7 @@ jobs:
runs-on: ${{ matrix.os }}
timeout-minutes: 25
env:
VFLAGS: -no-parallel -cc clang
VFLAGS: -no-parallel
steps:
- name: Install V
id: install-v
Expand All @@ -76,35 +121,219 @@ jobs:
uses: actions/checkout@v6
with:
path: gui
fetch-depth: 0
- name: Run tests
env:
VFLAGS: -no-parallel -cc clang
run: v test gui/
- name: Check compilation of examples
env:
VFLAGS: -no-parallel -cc clang
run: v should-compile-all gui/examples/
- name: Check compilation of changed examples with -W
if: github.event_name == 'pull_request'
env:
VFLAGS: -no-parallel -cc clang
working-directory: gui
run: |
base_ref="${{ github.base_ref }}"
files_list="${RUNNER_TEMP}/gui-example-compile-files"
git fetch --no-tags origin "$base_ref:refs/remotes/origin/$base_ref"
git diff --name-only -z --diff-filter=ACMRT "origin/${base_ref}...HEAD" -- 'examples/*.v' > "$files_list"
if [ ! -s "$files_list" ]; then
echo "No changed example .v files to compile with -W."
exit 0
fi
mkdir -p examples/bin
while IFS= read -r -d '' file; do
output_file="examples/bin/$(basename "${file%.v}")"
v -no-parallel -W -o "$output_file" "$file"
done < "$files_list"
- name: Check compilation of examples with -W
if: github.event_name != 'pull_request'
env:
VFLAGS: -no-parallel -cc clang
run: v gui/examples/_build.vsh

compiling-on-windows:
runs-on: windows-latest
timeout-minutes: 35
timeout-minutes: 60
env:
VFLAGS: -no-parallel -cc msvc
V_VERSION: 0.5.1
VFLAGS: -no-parallel
VCPKG_BINARY_CACHE: ${{ github.workspace }}\vcpkg-binary-cache
VCPKG_BINARY_SOURCES: clear;files,${{ github.workspace }}\vcpkg-binary-cache,readwrite
steps:
- name: Install V
id: install-v
uses: vlang/setup-v@v1.4
shell: pwsh
run: |
$ProgressPreference = 'SilentlyContinue'
$asset = 'v_windows.zip'
$url = "https://github.com/vlang/v/releases/download/$env:V_VERSION/$asset"
Invoke-WebRequest -Uri $url -OutFile $asset
Expand-Archive -Path $asset -DestinationPath . -Force
$vPath = (Resolve-Path .\v).Path
Add-Content -Path $env:GITHUB_PATH -Value $vPath
- name: Verify V version
shell: pwsh
run: |
$vVersion = v version
Write-Host $vVersion
if ($vVersion -notlike "*$env:V_VERSION*") {
throw "Expected V version $env:V_VERSION"
}
- name: Restore vcpkg binary cache
id: restore-vcpkg-cache
uses: actions/cache/restore@v4
with:
check-latest: true
path: ${{ env.VCPKG_BINARY_CACHE }}
key: windows-vcpkg-x64-windows-pango-freetype-${{ env.V_VERSION }}-v1
restore-keys: |
windows-vcpkg-x64-windows-pango-freetype-
- name: Restore V module cache
id: restore-vglyph-cache
uses: actions/cache/restore@v4
with:
path: ~/.vmodules/vglyph
key: windows-vmodules-vglyph-${{ env.V_VERSION }}-v1
restore-keys: |
windows-vmodules-vglyph-
- name: Install pango and freetype
run: vcpkg install pango freetype
shell: pwsh
run: |
New-Item -ItemType Directory -Force -Path "$env:VCPKG_BINARY_CACHE" | Out-Null
vcpkg install pango freetype
- name: Save vcpkg binary cache
if: ${{ steps.restore-vcpkg-cache.outputs.cache-hit != 'true' }}
uses: actions/cache/save@v4
with:
path: ${{ env.VCPKG_BINARY_CACHE }}
key: ${{ steps.restore-vcpkg-cache.outputs.cache-primary-key }}
- name: Expose vcpkg pkg-config paths
shell: pwsh
run: |
$ErrorActionPreference = 'Stop'
$triplet = 'x64-windows'
$vcpkgExe = (Get-Command vcpkg -ErrorAction Stop).Source
$roots = @()
if ($vcpkgExe) {
$roots += Split-Path -Parent $vcpkgExe
}
if ($env:VCPKG_ROOT) {
$roots += $env:VCPKG_ROOT
}
$vcpkgRoot = $null
foreach ($root in ($roots | Select-Object -Unique)) {
if (Test-Path (Join-Path $root "installed\$triplet")) {
$vcpkgRoot = $root
break
}
}
if (-not $vcpkgRoot) {
throw "Could not find vcpkg installed\$triplet from vcpkg.exe or VCPKG_ROOT"
}
$tripletRoot = Join-Path $vcpkgRoot "installed\$triplet"
$pkgConfigDirs = @(
(Join-Path $tripletRoot 'lib\pkgconfig'),
(Join-Path $tripletRoot 'share\pkgconfig')
) | Where-Object { Test-Path $_ }
if ($pkgConfigDirs.Count -eq 0) {
throw "No pkgconfig directories found under $tripletRoot"
}
$pkgConfigPath = $pkgConfigDirs -join ';'
"PKG_CONFIG_PATH=$pkgConfigPath" | Add-Content -Path $env:GITHUB_ENV
$env:PKG_CONFIG_PATH = $pkgConfigPath

$pathEntries = @()
$binDir = Join-Path $tripletRoot 'bin'
if (Test-Path $binDir) {
$pathEntries += $binDir
}
$pkgconfDir = Join-Path $tripletRoot 'tools\pkgconf'
if (Test-Path $pkgconfDir) {
$pathEntries += $pkgconfDir
}
foreach ($entry in $pathEntries) {
$entry | Add-Content -Path $env:GITHUB_PATH
}
if ($pathEntries.Count -gt 0) {
$env:PATH = ($pathEntries + $env:PATH) -join ';'
}

if (-not (Get-Command pkg-config -ErrorAction SilentlyContinue)) {
$pkgconf = Get-Command pkgconf -ErrorAction SilentlyContinue
if ($pkgconf) {
$shimDir = Join-Path $env:RUNNER_TEMP 'pkg-config-shim'
New-Item -ItemType Directory -Force -Path $shimDir | Out-Null
Set-Content -Path (Join-Path $shimDir 'pkg-config.cmd') -Encoding ascii -Value @(
'@echo off',
'"' + $pkgconf.Source + '" %*'
)
$shimDir | Add-Content -Path $env:GITHUB_PATH
$env:PATH = "$shimDir;$env:PATH"
}
}

$pkgConfig = Get-Command pkg-config -ErrorAction Stop
& $pkgConfig.Source --exists freetype2 pango pangoft2
if ($LASTEXITCODE -ne 0) {
throw "pkg-config could not resolve freetype2 pango pangoft2"
}
- name: Install vglyph
run: v install vglyph
- name: Save V module cache
if: ${{ steps.restore-vglyph-cache.outputs.cache-hit != 'true' }}
uses: actions/cache/save@v4
with:
path: ~/.vmodules/vglyph
key: ${{ steps.restore-vglyph-cache.outputs.cache-primary-key }}
- name: Checkout the gui module
uses: actions/checkout@v6
with:
path: gui
fetch-depth: 0
- name: Configure MSVC developer environment
uses: ilammy/msvc-dev-cmd@v1
- name: Run Windows setup preflight
env:
GUI_WINDOWS_PREFLIGHT_CC: msvc
run: v -cc msvc run gui/_windows_preflight.vsh
- name: Run tests
env:
VFLAGS: -no-parallel -cc msvc
VJOBS: 1
VTEST_ONLY_FN: test_*
run: v test gui/
- name: Check compilation of examples
run: v should-compile-all gui/examples/
env:
VFLAGS: -no-parallel -cc msvc
run: v gui/examples/_build.vsh --no-warnings --skip-missing-sqlite
- name: Check compilation of changed examples with -W
if: github.event_name == 'pull_request'
env:
VFLAGS: -no-parallel -cc msvc
shell: pwsh
working-directory: gui
run: |
$baseRef = '${{ github.base_ref }}'
git fetch --no-tags origin "${baseRef}:refs/remotes/origin/${baseRef}"
if ($LASTEXITCODE -ne 0) {
exit $LASTEXITCODE
}
$files = @(git diff --name-only --diff-filter=ACMRT "origin/${baseRef}...HEAD" -- 'examples/*.v')
if ($LASTEXITCODE -ne 0) {
exit $LASTEXITCODE
}
if ($files.Count -eq 0) {
Write-Host 'No changed example .v files to compile with -W.'
exit 0
}
v examples/_build.vsh --skip-missing-sqlite @files
if ($LASTEXITCODE -ne 0) {
exit $LASTEXITCODE
}
- name: Check compilation of examples with -W
run: v gui/examples/_build.vsh
if: github.event_name != 'pull_request'
env:
VFLAGS: -no-parallel -cc msvc
run: v gui/examples/_build.vsh --skip-missing-sqlite
Loading
Loading