-
Notifications
You must be signed in to change notification settings - Fork 0
130 lines (100 loc) · 5.07 KB
/
upstream pretest.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
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 }}
steps:
- name: git config
run: |
git config --global core.autocrlf false
# git config --global --add url.https://github.com/.insteadOf "[email protected]:"
# Get-Service ssh-agent
# Get-Service ssh-agent | Select StartType
Get-Service -Name ssh-agent | Set-Service -StartupType Manual
Start-Service -Name ssh-agent
$ssh_key = '${{ secrets.SSH_KEY }}'
$ssh_key | Set-Content 'ssh_key'
ssh-add 'ssh_key'
# - uses: webfactory/[email protected]
# with:
# ssh-private-key: ${{ secrets.SSH_KEY }}
- 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 = @()
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"
$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 format: $ref_l"
}
$pr_num = $Matches[1]
# Write-Host "- Found PR $pr_num"
$pr_nums += $pr_num
$exec_list += "$pr_num;$subm_url"
}
$subm_fork_url = $subm_url -replace 'KhronosGroup','SunSerega'
if ($subm_fork_url -eq $subm_url) {
throw "Cannot form fork URL from: $subm_url"
}
$fork_dir = './fork'
New-Item -ItemType Directory -Path $fork_dir | Out-Null
Push-Location $fork_dir
git init --bare
git remote add fork $subm_fork_url
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 format: $ref_l"
}
$pr_num = $Matches[1]
if ($pr_nums -contains $pr_num) { continue }
Write-Host "pretest branch for PR $pr_num is no longer needed"
git push fork --delete "pretest/$pr_num"
}
Pop-Location
Remove-Item -Recurse $fork_dir
}
$json = $exec_list | ConvertTo-Json -Compress
# Write-Host $json
echo "exec_list=$json" >> $env:GITHUB_OUTPUT
pretest-each:
runs-on: windows-latest
needs: enmr-PRs
strategy:
fail-fast: false
matrix:
exec_node: ${{ 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]:"
- uses: webfactory/[email protected]
with:
ssh-private-key: ${{ secrets.SSH_KEY }}
- name: checkout
uses: actions/checkout@main
- name: pretest
run: |
$exec_node = "${{ matrix.exec_node }}"
$pr_num, $subm_url = $exec_node -split ';', 2
# Write-Host "Testing PR $pr_num from: $subm_url"
# aaaaa