Skip to content
name: Upstream pretest
on:
push:
schedule:
- cron: '0 0 * * *'
workflow_dispatch:
permissions:
contents: write
jobs:
enmr-PRs:
runs-on: windows-latest
outputs:
exec_list: ${{ steps.make_exec_list.outputs.exec_list }}
remove_list: ${{ steps.make_exec_list.outputs.remove_list }}
steps:
- name: git config
run: |
git config --global core.autocrlf false
git config --global user.name "sun pack bot"
git config --global user.email "[email protected]"
git config --global --add url.https://github.com/.insteadOf "[email protected]:"
- name: checkout
uses: actions/checkout@main
with:
sparse-checkout-cone-mode: false
sparse-checkout: |
.gitmodules
- name: make exec list
id: make_exec_list
run: |
$exec_list = @()
$remove_list = @()
foreach ($subm_key in git config --file .gitmodules --name-only --get-regexp '^submodule\..+\.url$') {
$subm_url = git config --file .gitmodules --get $subm_key
Write-Host "URL: $subm_url"
if ($subm_url -notmatch '^git@github\.com:([\w\-]+)/([\w\-]+)\.git$') {
throw "Unexpected subm_url format: $subm_url"
}
$subm_owner = $Matches[1]
$subm_name = $Matches[2]
$subm_merge_pr_nums = @()
foreach ($ref_l in git ls-remote $subm_url 'refs/pull/*/merge') {
if ($ref_l -notmatch '^[0-9a-f]+\s+refs/pull/(\d+)/merge$') {
throw "Unexpected merge ref format: $ref_l"
}
$pr_num = $Matches[1]
Write-Host "- Found PR $pr_num"
$subm_merge_pr_nums += $pr_num
$exec_list += @{
'subm_name' = $subm_name;
'org_repo' = "$subm_owner/$subm_name";
'fork_repo' = "SunSerega/$subm_name";
'pr_num' = $pr_num;
}
}
if ($subm_owner -ne 'KhronosGroup') {
throw 'Unexpected original owner of submodule: $subm_owner'
}
$subm_fork_url = "[email protected]:SunSerega/${subm_name}.git"
if ($subm_fork_url -eq $subm_url) {
throw "Fork url [$subm_fork_url] = subm_url [$subm_url]"
}
$subm_pretest_pr_nums = @()
foreach ($ref_l in git ls-remote $subm_fork_url 'refs/heads/pretest/*') {
if ($ref_l -notmatch '^[0-9a-f]+\s+refs/heads/pretest/(.+)$') {
throw "Unexpected subm pretest ref format: $ref_l"
}
$pr_num = $Matches[1]
Write-Host "- Found subm pretest branch for PR $pr_num"
if ($subm_merge_pr_nums -contains $pr_num) { continue }
$subm_pretest_pr_nums += $pr_num
}
$core_pretest_pr_nums = @()
foreach ($ref_l in git ls-remote origin "refs/heads/subm-pretest/$subm_owner/$subm_name/*") {
if ($ref_l -notmatch "^[0-9a-f]+\s+refs/heads/subm-pretest/$subm_owner/$subm_name/(.+)$") {
throw "Unexpected core pretest ref format: $ref_l"
}
$pr_num = $Matches[1]
Write-Host "- Found core pretest branch for PR $pr_num"
if ($subm_merge_pr_nums -contains $pr_num) { continue }
$core_pretest_pr_nums += $pr_num
}
if ($subm_pretest_pr_nums -or $core_pretest_pr_nums) {
$remove_list += @{
'org_repo' = "$subm_owner/$subm_name";
'fork_repo' = "SunSerega/$subm_name";
'subm_pretest_pr_nums' = $subm_pretest_pr_nums -join ',';
'core_pretest_pr_nums' = $core_pretest_pr_nums -join ',';
}
}
}
$json = ConvertTo-Json -Compress $exec_list
Write-Host $json
echo "exec_list=$json" >> $env:GITHUB_OUTPUT
$json = ConvertTo-Json -Compress $remove_list
Write-Host $json
echo "remove_list=$json" >> $env:GITHUB_OUTPUT
pretest-each:
runs-on: windows-latest
needs: enmr-PRs
if: ${{ needs.enmr-PRs.outputs.exec_list != '[]' }}
strategy:
fail-fast: false
matrix:
exec-data: ${{ fromJson(needs.enmr-PRs.outputs.exec_list) }}
steps:
- name: git config
run: |
git config --global core.autocrlf false
git config --global user.name "sun pack bot"
git config --global user.email "[email protected]"
git config --global --add url.https://github.com/.insteadOf "[email protected]:"
- name: checkout main repo
uses: actions/checkout@main
with:
path: './core'
fetch-depth: 0
- name: checkout subm fork
uses: actions/checkout@main
with:
repository: ${{ matrix.exec-data.fork_repo }}
ref: 'custom'
path: './fork'
fetch-depth: 0
token: ${{ secrets.POCGL_pretest_upstream_PAT }}
- name: Install OpenCL driver for Intel CPU
run: |
# https://www.intel.com/content/www/us/en/developer/articles/technical/intel-cpu-runtime-for-opencl-applications-with-sycl-support.html
Invoke-WebRequest -Uri 'https://registrationcenter-download.intel.com/akdlm/IRC_NAS/0e6849e6-2c56-480b-afcf-be8331d5c4f6-opencl/w_opencl_runtime_p_2024.1.0.968.exe' -OutFile 'D:\igfx.exe'
7z x "D:\igfx.exe" -o"D:\igfx" -y
D:\igfx\w_opencl_runtime_p_2024.1.0.968.msi /quiet
- name: Download and unpack Pascal compiler
run: |
Invoke-WebRequest -Uri 'https://github.com/SunSerega/pascalabcnet/releases/download/custom-build-tag/PABCNETC.zip' -OutFile 'D:\PABCNETC.zip'
Expand-Archive -Path 'D:\PABCNETC.zip' -DestinationPath 'D:\PABCNETC' -Force
- name: pretest
run: |
$subm_name = '${{ matrix.exec-data.subm_name }}'
$org_repo = '${{ matrix.exec-data.org_repo }}'
$fork_repo = '${{ matrix.exec-data.fork_repo }}'
$pr_num = "${{ matrix.exec-data.pr_num }}"
Write-Host "Updating subm fork..."
Push-Location './fork'
git fetch
$fork_main_branch_name = 'custom'
$fork_branch_name = "pretest/$pr_num"
if (&{ git show-ref --verify -q 'refs/remotes/origin/$fork_branch_name'; $? }) {
Write-Host "Branch for PR $pr_num exists. Merging with ${fork_main_branch_name}:"
git checkout $fork_branch_name
git merge $fork_main_branch_name
git push
} else {
Write-Host "Branch for PR $pr_num doesn't exist. Creating:"
git branch $fork_branch_name
git push --set-upstream origin $fork_branch_name
}
Write-Host "Merging latest commits from PR $pr_num"
git merge "refs/pull/$pr_num/merge"
git push
Pop-Location
Write-Host "Updating main repo..."
Push-Location './core'
git fetch --all
Write-Host '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~'
git show-ref
Write-Host '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~'
git branch -r
Write-Host '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~'
# $core_main_branch_name = '${{ github.head_ref || github.ref_name }}'
$core_main_branch_name = git symbolic-ref refs/remotes/origin/HEAD --short
if (-not $?) { throw "git symbolic-ref failed" }
$core_branch_name = "subm-pretest/$org_repo/$pr_num"
if (&{ git show-ref --verify -q 'refs/remotes/origin/$core_branch_name'; $? }) {
Write-Host "Branch for PR $pr_num exists. Merging with ${core_main_branch_name}:"
git checkout $core_branch_name
git merge $core_main_branch_name -m "[auto pretest] Merge $core_branch_name into subm-pretest/... branch"
git push
} else {
Write-Host "Branch for PR $pr_num doesn't exist. Creating:"
git branch $core_branch_name
git push --set-upstream origin $core_branch_name
}
& .\DeleteAllTemp.bat NoPause | Out-Null
Write-Host "Compile: " -NoNewline
Start-Process -FilePath 'D:\PABCNETC\pabcnetcclear.exe' -ArgumentList '"PackAll.pas"' -Wait -NoNewWindow
& .\PackAll.exe "Stages= PullUpstream + Reference + Dummy + OpenCL+OpenCLABC + OpenGL+OpenGLABC + Compile + Test + Release" "PullUpstreamBranch=${subm_name}:${fork_branch_name}"
if (-not $?) { throw "PackAll failed" }
git add -A
git commit -m "[auto pretest] test changes"
git push
Pop-Location
remove-old-pretest:
runs-on: windows-latest
needs: enmr-PRs
if: ${{ needs.enmr-PRs.outputs.remove_list != '[]' }}
strategy:
fail-fast: false
matrix:
remove-data: ${{ fromJson(needs.enmr-PRs.outputs.remove_list) }}
steps:
- name: git config
run: |
git config --global core.autocrlf false
git config --global user.name "sun pack bot"
git config --global user.email "[email protected]"
git config --global --add url.https://github.com/.insteadOf "[email protected]:"
- name: checkout subm fork
uses: actions/checkout@main
with:
repository: ${{ matrix.remove-data.fork_repo }}
token: ${{ secrets.POCGL_pretest_upstream_PAT }}
sparse-checkout-cone-mode: false
sparse-checkout: '<NOTHING>'
- name: remove old pretest branches
run: |
function Split-OrEmpty {
param ( $s )
if (-not $s) { return @() }
return $s -split ','
}
$org_repo = '${{ matrix.remove-data.org_repo }}'
$fork_repo = '${{ matrix.remove-data.fork_repo }}'
$subm_pretest_pr_nums = Split-OrEmpty '${{ matrix.remove-data.subm_pretest_pr_nums }}'
$core_pretest_pr_nums = Split-OrEmpty '${{ matrix.remove-data.core_pretest_pr_nums }}'
$main_repo_dir = './core'
New-Item -ItemType Directory -Path $main_repo_dir | Out-Null
Push-Location $main_repo_dir
$main_repo_url = '${{ github.server_url }}/${{ github.repository }}'
# $main_repo_branch = '${{ github.head_ref || github.ref_name }}'
$main_repo_branch = git symbolic-ref refs/remotes/origin/HEAD --short
if (-not $?) { throw "git symbolic-ref failed" }
Write-Host "Cloning main repo [$main_repo_url]: branch [$main_repo_branch]"
git clone -b $main_repo_branch --filter=tree:0 --no-progress --no-checkout $main_repo_url .
if (-not $?) { throw "git clone failed" }
# git branch -r
$core_removed_pr_nums = @()
foreach ($pr_num in $core_pretest_pr_nums) {
Write-Host "Checking if subm-pretest branch for PR $pr_num is trivial"
$branch_name = "subm-pretest/$org_repo/$pr_num"
Write-Host $branch_name
$is_trivial = $true
foreach ($commit_name in git show --pretty=format:"%s" -s "HEAD..origin/$branch_name") {
Write-Host "- $commit_name"
if ($commit_name.StartsWith('[auto pretest]')) { continue }
Write-Host "--- NOT TRIVIAL"
$is_trivial = $false
# break
}
if (-not $?) { throw "git show failed" }
if ($is_trivial) {
Write-Host "Is trivial, removing..."
git push origin --delete $branch_name # BRANCH DELETE
$core_removed_pr_nums += $pr_num
}
Write-Host '~~~~~'
}
Pop-Location
$core_pretest_pr_nums = $core_pretest_pr_nums |
Where-Object { $_ -notin $core_removed_pr_nums }
foreach ($pr_num in $subm_pretest_pr_nums) {
Write-Host "PR $pr_num was closed"
if ($core_pretest_pr_nums -contains $pr_num) {
Write-Host "But main repo is still referencing it"
} else {
Write-Host "Removing..."
git push origin --delete "pretest/$pr_num" # BRANCH DELETE
}
Write-Host '~~~~~'
}
if ($core_pretest_pr_nums) {
Write-Host "pretest branches for these PRs are dangling:"
foreach ($pr_num in $core_pretest_pr_nums) {
Write-Host "- $pr_num"
}
throw "Some pretest branches in main repo are dangling"
}