-
Notifications
You must be signed in to change notification settings - Fork 1
168 lines (151 loc) · 5.89 KB
/
rust.yml
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
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
name: "cargo"
on:
workflow_dispatch:
push:
branches:
- master
env:
CARGO_TERM_COLOR: always
jobs:
bindgen:
defaults:
run:
shell: powershell
strategy:
matrix:
os: [windows-11-preview_aarch64, windows-2025]
target: [aarch64-pc-windows-msvc, x86_64-pc-windows-msvc, i686-pc-windows-msvc]
exclude:
- os: windows-11-preview_aarch64
target: x86_64-pc-windows-msvc
- os: windows-11-preview_aarch64
target: i686-pc-windows-msvc
- os: windows-2025
target: aarch64-pc-windows-msvc
runs-on: ${{ matrix.os }}
steps:
- if: matrix.os != 'windows-11-preview_aarch64'
uses: hustcer/setup-nu@main
with:
version: '*'
- if: matrix.os == 'windows-11-preview_aarch64'
uses: robinraju/release-downloader@v1
with:
repository: 'git-for-windows/git'
tag: 'v2.48.0-rc1.windows.1'
filename: 'Git-2.48.0-rc1-arm64.exe'
- if: matrix.os == 'windows-11-preview_aarch64'
uses: robinraju/release-downloader@v1
with:
repository: 'llvm/llvm-project'
tag: 'llvmorg-19.1.5'
filename: 'LLVM-19.1.5-woa64.exe'
- if: matrix.os == 'windows-11-preview_aarch64'
uses: robinraju/release-downloader@v1
with:
repository: 'microsoft/winget-cli'
latest: true
filename: 'Microsoft.DesktopAppInstaller_8wekyb3d8bbwe.msixbundle'
out-file-path: 'deps'
- name: Use nushell
if: matrix.os == 'windows-11-preview_aarch64'
run: |
function Log {
param(
[Parameter(Mandatory=$true)] [string]$Message,
[string]$Level = "INFO"
)
Write-Host "$(Get-Date -Format 'yyyy-MM-dd HH:mm:ss') [$Level] - $Message"
}
$installs = @(
@{ Name = 'Chocolatey'; Action = {
Set-ExecutionPolicy Bypass -Scope Process -Force
[System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072
iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1')) | Out-Null
}},
@{ Name = 'Visual Studio 2022 Build Tools (aarch64)'; Action = {
choco install visualstudio2022buildtools -y --no-progress --silent --package-parameters '--add Microsoft.VisualStudio.Component.VC.Tools.ARM64 --add Microsoft.VisualStudio.Component.Windows11SDK.22621'
}},
@{ Name = 'Rust (nightly, aarch64)'; Action = {
Invoke-WebRequest -Uri 'https://win.rustup.rs/aarch64' -OutFile '${{github.workspace}}\rustup-init.exe';
& '${{github.workspace}}\rustup-init.exe' --default-host aarch64-pc-windows-msvc --default-toolchain nightly -y
}},
@{ Name = 'Git 2.48.0-rc1'; Action = {
& '${{github.workspace}}\Git-2.48.0-rc1-arm64.exe' /VERYSILENT
}},
@{ Name = 'LLVM 19.1.5'; Action = {
& '${{github.workspace}}\LLVM-19.1.5-woa64.exe' /S
}}
)
$installs | ForEach-Object {
Log -Message "Starting installation of $($_.Name)..."
& $_.Action
Log -Message "$($_.Name) installation completed."
}
$exports = @(
"$env:ProgramData\chocolatey\bin", # Chocolatey
"$env:USERPROFILE\.cargo\bin", # Rust
"$env:ProgramFiles\Git\cmd", # Git
"$env:ProgramFiles\Git\bin" # Bash
)
$exports | ForEach-Object {
$path = $_
Add-Content -Path $env:GITHUB_PATH -Value $path
Log -Message "Added $path to $env:GITHUB_PATH"
}
- name: Install Rust
if: matrix.os != 'windows-11-preview_aarch64'
uses: dtolnay/rust-toolchain@nightly
with:
targets: ${{ matrix.target }}
components: rustfmt
- name: Checkout repository
uses: actions/checkout@v4
- name: Run tests and generate bindings
env:
PHNT_VERSION: PHNT_WIN11_24H2
PHNT_MODE: PHNT_MODE_USER
run: |
cargo test --release -vv -F regenerate --target ${{ matrix.target }}
- name: Extract architecture from target triple and move bindings
run: |
$arch = '${{ matrix.target }}' -split '-' | Select-Object -First 1
$arch = if ($arch -eq 'i686') { 'x86' } else { $arch }
Add-Content -Path $env:GITHUB_ENV -Value "ARCH=$arch"
$output = Get-ChildItem -Path "target/${{ matrix.target }}/release/build/**/$($arch)_bindgen.rs" -Recurse | Select-Object -First 1
Copy-Item -Path $output.FullName -Destination "src/ffi/$($arch)_bindgen.rs"
Write-Host "Moved $output to src/ffi/$($arch)_bindgen.rs"
- name: Upload generated file as artifact
uses: actions/upload-artifact@v4
with:
name: ${{ env.ARCH }}_bindgen.rs
path: src/ffi/${{ env.ARCH }}_bindgen.rs
commit-and-push:
runs-on: ubuntu-latest
needs: bindgen
if: success() # Run only if the generate-bindgen job succeeds
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Download generated files
uses: actions/download-artifact@v4
with:
pattern: "*bindgen.rs"
path: src/ffi
merge-multiple: true
- name: Configure Git
run: |
git config user.name "GitHub Actions"
git config user.email "[email protected]"
- name: Commit and push changes
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
git add src/ffi
# Check if there are any changes to commit
if git diff --quiet --exit-code --cached; then
echo "No changes to commit."
else
git commit -m "chore: update vendored bindings"
git push --force
fi