ci: remove 3rd party js from windows dll gha job - #32513
Conversation
|
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. Code Coverage & BenchmarksFor details see: https://corecheck.dev/bitcoin/bitcoin/pulls/32513. ReviewsSee the guideline for information on the review process.
If your review is incorrectly listed, please react with 👎 to this comment and the bot will ignore it on the next update. ConflictsReviewers, this pull request conflicts with the following ones:
If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first. |
|
Concept ACK. Thank you for taking this! |
2549a10 to
449cb9e
Compare
|
It might be better to use a more general solution for setting up VS prompts, this would also work once #32396 is merged. - name: Set up VS Developer Prompt
shell: pwsh
run: |
$vswherePath = "${env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer\vswhere.exe"
$installationPath = & 'C:\Program Files (x86)\Microsoft Visual Studio\Installer\vswhere.exe' -latest -property installationPath
if ($installationPath -and (test-path "$installationPath\Common7\Tools\vsdevcmd.bat")) {
& "${env:COMSPEC}" /s /c "`"$installationPath\Common7\Tools\vsdevcmd.bat`" -no_logo && set" | foreach-object {
$name, $value = $_ -split '=', 2
echo "$name=$value" >> $env:GITHUB_ENV
}
}This snippet was mostly taken from this |
449cb9e to
dc403f0
Compare
|
Rebased and taken @davidgumberg's great suggestion. |
| $name, $value = $_ -split '=', 2 | ||
| echo "$name=$value" >> $env:GITHUB_ENV |
There was a problem hiding this comment.
This part seems too invasive to me. Please compare the list of environment variables in the "Get tool information" step on the master branch with those in this PR.
There was a problem hiding this comment.
The only tool we need is msbuild.exe which is what my original version did? Shall I just put it back?
There was a problem hiding this comment.
The only tool we need is msbuild.exe...
We also use now mt.exe:
bitcoin/.github/workflows/ci.yml
Lines 246 to 253 in dc403f0
There was a problem hiding this comment.
Shall I just put it back?
Perhaps updating only the Path variable will be sufficient?
There was a problem hiding this comment.
The only tool we need is msbuild.exe which is what my original version did?
And we do use it—along with the VCToolsVersion environment variable—but only to determine whether the vcpkg binary cache needs to be invalidated. CMake is smart enough to inspect the build environment and locate the required tools on its own.
We might be able to use other indicators to invalidate the cache at the right time. Perhaps the top commit hash of vcpkg?
There was a problem hiding this comment.
I will look at using the top commit hash for cache invalidation. If I've understood you correct the current cache key is:
hashFiles('cmake_version', 'msbuild_version', 'toolset_version', 'vcpkg.json')we think this will be sufficient:
hashFiles('vcpkg_commit_hash', 'vcpkg.json')
Yes, I think so.
Which then means we can drop the vswhere tool finding.
Right. However, we still need to locate mt.exe.
UPD. Only a path can be added though:
"${sdk_dir}bin\${sdk_latest}\x64" | Out-File -FilePath "$env:GITHUB_PATH" -AppendThere was a problem hiding this comment.
I think this approach is no less invasive then what is done currently using an external script, setting up an environment that behaves the same as the VS Powershell utility. The advantage of this approach is that it makes use of Visual Studio utilities and commands zero maintenance cost, manually setting variables voids that, and we are subject to being broken by MS upstream, or wrestling with strange misconfigurations when some command that works on a local VS powershell environment is broken on CI because some environment variable is not set.
There was a problem hiding this comment.
The advantage of this approach is that it makes use of Visual Studio utilities and commands zero maintenance cost, manually setting variables voids that, and we are subject to being broken by MS upstream, or wrestling with strange misconfigurations when some command that works on a local VS powershell environment is broken on CI because some environment variable is not set.
That sounds compelling.
There was a problem hiding this comment.
@hebasto compelling enough to ACK as is?
There was a problem hiding this comment.
I think this approach is no less invasive then what is done currently using an external script...
I disagree. I've checked c44fb4f. The env: sections in the CI logs are indeed more bloated compared to the master branch. I'd prefer to avoid this.
|
This approach here should also be applied to replace the |
5bd3a34 to
ff2e35f
Compare
|
@hebasto @davidgumberg I believe all comments have been addressed? |
hebasto
left a comment
There was a problem hiding this comment.
ACK ff2e35f.
While touching this code, it seems reasonable to also address the other @davidgumberg's comment:
Might be nice to have a CI check like davidgumberg@1b98160 to prevent future regressions, but OK for a separate PR if out of scope.
I don't mind adding that. |
|
I suspect checking for manifests will currently fail for bench_bitcoin.exe as it doesn't yet have a manifest. Not sure about other binaries. Wouldn't be against adding missing manifests unless it slows down the builds noticeably. |
| "MT_EXE=${sdk_dir}bin\${sdk_latest}\x64\mt.exe" >> $env:GITHUB_ENV | ||
| $vswherePath = "${env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer\vswhere.exe" | ||
| $installationPath = & $vswherePath -latest -property installationPath | ||
| if ($installationPath -and (test-path "$installationPath\Common7\Tools\vsdevcmd.bat")) { |
There was a problem hiding this comment.
(Sorry for the churn here)
I think we actually want to drop this if guard here and above, the CI job should fail right here if the path to vsdevcmd.bat breaks, so that the cause/fix is obvious.
There was a problem hiding this comment.
Don't worry, I'm reworking it to do more manifest checks anyway so changes at this point are fine.
Will look at this.
There was a problem hiding this comment.
Should be addressed
ff2e35f to
a453e66
Compare
Added |
|
|
||
| Write-Host "Checking $exeName" | ||
| & mt.exe -nologo -inputresource:$_.FullName -validate_manifest | ||
| if ($LASTEXITCODE -ne 0) { |
There was a problem hiding this comment.
If I'm not mistaken, this if branch will never be reached since the CI script will exit if the line above has a non-zero exit code.
There was a problem hiding this comment.
Default behaviour in powershell is to continue on error (unless it's a terminating error like throw). When calling a powershell cmdlet you can set $ErrorActionPreference = 'Stop' but being as this is a call to an external process I don't believe that approach works here, hence why checking the exit code.
There was a problem hiding this comment.
Which now worries me about elsewhere we have used powershell, if it will exit like we think it should.
There was a problem hiding this comment.
Default behaviour in powershell is to continue on error
Do we have that turned off for all of our CIs?
There was a problem hiding this comment.
Doesn't appear to be turned off on our CI and I think it should be.
In Powershell 7.4 and up there is now a setting PSNativeCommandUseErrorActionPreference which should make calling native commands respect the ErrorActionPreference so we should set both of those, globally if possible. I will look into it.
There was a problem hiding this comment.
I'm wrong about powershell cmdlets: https://docs.github.com/en/actions/writing-workflows/workflow-syntax-for-github-actions#exit-codes-and-error-action-preference
Github sets ErrorActionPreference to stop but it doesn't appear that they set PSNativeCommandUseErrorActionPreference which is why calling native executables (like mt.exe) can still fail silently.
There was a problem hiding this comment.
Default behaviour in powershell is to continue on error
Do we have that turned off for all of our CIs?
We did:
bitcoin/.github/workflows/ci.yml
Lines 24 to 28 in e872a56
There was a problem hiding this comment.
@hebasto but there are a few places where we use pwsh, which will still fail fast if using exclusively cmdlets but doesn't appear to fail when calling native executables.
Here is a commit to demonstrate it won't always failfast: 4bf1031
and the job run that didn't fail: https://github.com/m3dwards/bitcoin/actions/runs/15415032095/job/43375709475
Suggest we set PSNativeCommandUseErrorActionPreference to true everywhere we use pwsh.
There was a problem hiding this comment.
This PR enables failing fast for executables in pwsh:
There was a problem hiding this comment.
@davidgumberg force pushed a change so that it behaves how you expected it to: https://github.com/bitcoin/bitcoin/compare/a453e66c827f260da597bf70273bcd0da2313774..7f8393ad745e6bc44dc9481428ea5979ed31a3c9
a453e66 to
7f8393a
Compare
|
Could you please rebase this PR to refresh the CI? |
7f8393a to
c44fb4f
Compare
We can use vswhere.exe directly to create a vs developer prompt and so can remove this third party dependency. Co-authored-by: David Gumberg <davidzgumberg@gmail.com> Github-Pull: bitcoin#32513 Rebased-From: 7ae0497
This sets up a vs developer command prompt and should hopefully should be more resilient to upstream changes Co-authored-by: David Gumberg <davidzgumberg@gmail.com> Github-Pull: bitcoin#32513 Rebased-From: e1a1b14
The other executables have manifests and these should be checked in addition to bitcoind. Skipping fuzz.exe, bench_bitcoin.exe and test_bitcoin-qt.exe as they do not have manifests. Github-Pull: bitcoin#32513 Rebased-From: 1569279
|
Backported to 30.x in #34283. |
We can use vswhere.exe directly to create a vs developer prompt and so can remove this third party dependency. Co-authored-by: David Gumberg <davidzgumberg@gmail.com> Github-Pull: bitcoin#32513 Rebased-From: 7ae0497
|
Backported to 29.x in #34446. |
624c745 doc: update release notes for v30.x (fanquake) 0f01a4c ci: Check windows manifests for all executables (Max Edwards) 4664621 ci: use a more generic way of finding mt.exe (Max Edwards) aa93758 ci: remove 3rd party js from windows dll gha job (Max Edwards) 290526b wallet: fix removeprunedfunds bug with conflicting transactions (Martin Zumsande) 4deda48 build: Remove outdated comment about -ffile-prefix-map (MarcoFalke) eda6c97 doc: Remove outdated -fdebug-prefix-map section in dev notes (MarcoFalke) c294b66 build: Temporarily remove confusing and brittle -fdebug-prefix-map (MarcoFalke) 33195bd test: allow overriding tar in get_previous_releases (fanquake) 810c75b chore: Update outdated GitHub Actions versions (Padraic Slattery) de79f7d qa: Fix Windows logging bug (Hennadii Stepanov) 311da7f test: check wallet rescan properly in feature_pruning (brunoerg) 4431a60 test: fix feature_pruning when built without wallet (brunoerg) 7e1090f psbt: Fix `PSBTInputSignedAndVerified` bounds `assert` (Lőrinc) 22bd006 doc: add 433 (Pay to Anchor) to bips.md (Sebastian Falbesoner) Pull request description: Backports: * #32513 * #34185 * #34272 * #34252 * #34281 * #34282 * #34344 * #34358 * #34390 * #34413 ACKs for top commit: willcl-ark: ACK 624c745 marcofleon: ACK 624c745 Tree-SHA512: 65f413419b50784d2661d89f2044acd5196eacd50841bb93d7437b83bd23ce535565168cd4c53f96ba485863a911f5a1ea5476b22955d6b931b65e87f78b9a17
3835e16 doc: update release notes for v29.x (fanquake) 6aec095 ci: remove 3rd party js from windows dll gha job (Max Edwards) c57009e chore: Update outdated GitHub Actions versions (Padraic Slattery) Pull request description: Backports: * #32513 (partial backport) * #34344 ACKs for top commit: willcl-ark: ACK 3835e16 sedited: ACK 3835e16 Tree-SHA512: e36b00e952fe6edbe931a131dbe66f14d97b2362453fe4a0e7be58697039945832075d486a6634228c4e1a0ab081e2919cf2c76ef2cfc8b2df6f321b6112c284
We can use vswhere.exe directly to create a vs developer prompt and so can remove this third party dependency. Co-authored-by: David Gumberg <davidzgumberg@gmail.com> Github-Pull: bitcoin#32513 Rebased-From: 7ae0497
f6e5ec5 doc: update release notes for v28.x (fanquake) 5879b5a chore: Update outdated GitHub Actions versions (Padraic Slattery) 4fca124 ci: remove 3rd party js from windows dll gha job (Max Edwards) 4d4e360 ci: use macos-14 image (fanquake) 6b5a536 doc: update copyright year (fanquake) Pull request description: Contains one change to switch the macOS runners to a version that still works (13 -> 14): * 4d4e360 Also backports: * #32513 (partial backport) * #34174 * #34344 ACKs for top commit: marcofleon: ACK f6e5ec5 Tree-SHA512: 63e4b08779852984c48aaf555f6ce9a7afd12bad65b8062dcc6351b39f6a3a355efd0e0277e8a62400588613db86c45f196efc1ac7b91317821d69301badebcf
|
Backported to 28.x in #34463. |
285cb78 ci: Replace `ilammy/msvc-dev-cmd` with manual MSVC setup (Hennadii Stepanov) Pull request description: The `ilammy/msvc-dev-cmd` repository seems [abandoned](ilammy/msvc-dev-cmd#103) and should be considered unsafe. This PR updates the workflow to load the MSVC environment variables directly via [`vcvars64.bat`](https://learn.microsoft.com/en-us/cpp/build/building-on-the-command-line). For reference, the Bitcoin Core project removed `ilammy/msvc-dev-cmd` in bitcoin/bitcoin#32513. **Note for Maintainers:** Once this PR is merged and other PRs are rebased on top of it, the `ilammy/msvc-dev-cmd` action should be removed from the "Action permission" settings in this repository. ACKs for top commit: real-or-random: utACK 285cb78 Tree-SHA512: 3faa9a316438ae3f4e7352890a77baaf0bf0adda4086111344d8279dc869a42ea837269527268fad1a2dd2e1893fd8fc51e5c3b205f394926b07988579a10ad9
We can use vswhere.exe directly to create a vs developer prompt and so can remove this third party dependency. Co-authored-by: David Gumberg <davidzgumberg@gmail.com> Github-Pull: bitcoin#32513 Rebased-From: 0e4705d
This sets up a vs developer command prompt and should hopefully should be more resilient to upstream changes Co-authored-by: David Gumberg <davidzgumberg@gmail.com> Github-Pull: bitcoin#32513 Rebased-From: e1f4194
The other executables have manifests and these should be checked in addition to bitcoind. Skipping fuzz.exe, bench_bitcoin.exe and test_bitcoin-qt.exe as they do not have manifests. Github-Pull: bitcoin#32513 Rebased-From: b5fdc90
5516cdf doc: update release notes for v30.x (fanquake) ed0f9d9 ci: Check windows manifests for all executables (Max Edwards) 1ea51a4 ci: use a more generic way of finding mt.exe (Max Edwards) 4ef0eb9 ci: remove 3rd party js from windows dll gha job (Max Edwards) 7d298bf wallet: fix removeprunedfunds bug with conflicting transactions (Martin Zumsande) f4957df build: Remove outdated comment about -ffile-prefix-map (MarcoFalke) 2d36935 doc: Remove outdated -fdebug-prefix-map section in dev notes (MarcoFalke) a9ff62b build: Temporarily remove confusing and brittle -fdebug-prefix-map (MarcoFalke) d529f01 test: allow overriding tar in get_previous_releases (fanquake) 72272fe chore: Update outdated GitHub Actions versions (Padraic Slattery) 500618b qa: Fix Windows logging bug (Hennadii Stepanov) 397a371 test: check wallet rescan properly in feature_pruning (brunoerg) c2fbc8c test: fix feature_pruning when built without wallet (brunoerg) 74f9b2c psbt: Fix `PSBTInputSignedAndVerified` bounds `assert` (Lőrinc) 7995038 doc: add 433 (Pay to Anchor) to bips.md (Sebastian Falbesoner) Pull request description: Backports: * bitcoin#32513 * bitcoin#34185 * bitcoin#34272 * bitcoin#34252 * bitcoin#34281 * bitcoin#34282 * bitcoin#34344 * bitcoin#34358 * bitcoin#34390 * bitcoin#34413 ACKs for top commit: willcl-ark: ACK 5516cdf marcofleon: ACK 5516cdf Tree-SHA512: 65f413419b50784d2661d89f2044acd5196eacd50841bb93d7437b83bd23ce535565168cd4c53f96ba485863a911f5a1ea5476b22955d6b931b65e87f78b9a17
We can use vswhere.exe directly to create a vs developer prompt and so can remove this third party dependency. Co-authored-by: David Gumberg <davidzgumberg@gmail.com> Github-Pull: bitcoin#32513 Rebased-From: 0e4705d
4aed72f doc: update release notes for v28.x (fanquake) 6e8b742 chore: Update outdated GitHub Actions versions (Padraic Slattery) 4c88401 ci: remove 3rd party js from windows dll gha job (Max Edwards) d5735e8 ci: use macos-14 image (fanquake) c601d30 doc: update copyright year (fanquake) Pull request description: Contains one change to switch the macOS runners to a version that still works (13 -> 14): * bitcoin@d5735e8 Also backports: * bitcoin#32513 (partial backport) * bitcoin#34174 * bitcoin#34344 ACKs for top commit: marcofleon: ACK 4aed72f Tree-SHA512: 63e4b08779852984c48aaf555f6ce9a7afd12bad65b8062dcc6351b39f6a3a355efd0e0277e8a62400588613db86c45f196efc1ac7b91317821d69301badebcf
We can use vswhere.exe directly to create a vs developer prompt and so can remove this third party dependency. Co-authored-by: David Gumberg <davidzgumberg@gmail.com> Github-Pull: bitcoin#32513 Rebased-From: 0e4705d
d6be234 doc: update release notes for v29.x (fanquake) 12a72a0 ci: remove 3rd party js from windows dll gha job (Max Edwards) c4d608d chore: Update outdated GitHub Actions versions (Padraic Slattery) Pull request description: Backports: * bitcoin#32513 (partial backport) * bitcoin#34344 ACKs for top commit: willcl-ark: ACK d6be234 sedited: ACK d6be234 Tree-SHA512: e36b00e952fe6edbe931a131dbe66f14d97b2362453fe4a0e7be58697039945832075d486a6634228c4e1a0ab081e2919cf2c76ef2cfc8b2df6f321b6112c284
… gha job 73e6006 ci: Check windows manifests for all executables (Max Edwards) f7d330f ci: use a more generic way of finding mt.exe (Max Edwards) 1477ca4 ci: remove 3rd party js from windows dll gha job (Max Edwards) Pull request description: The windows job uses the external dependency `ilammy/msvc-dev-cmd` which runs javascript. We use this to put various tools on the path such as `MSBuild.exe` and `mt.exe`. We can remove this dependency and use `vswhere.exe` directly to find these tools and create a "[Developer command prompt](https://github.com/microsoft/vswhere/wiki/Start-Developer-Command-Prompt#using-powershell)" as someone would on their dev machine. While in this area of the code, this PR also runs some additional manifest checks on the windows binaries. Fixes: #32508 ACKs for top commit: davidgumberg: crACK 73e6006 hebasto: ACK 73e6006. Tree-SHA512: df640dff27579a1c95daddc5a5ba8fd655bbd0a6f2aff74d0f63439c7185c0b18a90abfee3f1f032fe833cd19b822ef71812f44b24c4c044222e46d01c271864
… gha job b5fdc90 ci: Check windows manifests for all executables (Max Edwards) e1f4194 ci: use a more generic way of finding mt.exe (Max Edwards) 0e4705d ci: remove 3rd party js from windows dll gha job (Max Edwards) Pull request description: The windows job uses the external dependency `ilammy/msvc-dev-cmd` which runs javascript. We use this to put various tools on the path such as `MSBuild.exe` and `mt.exe`. We can remove this dependency and use `vswhere.exe` directly to find these tools and create a "[Developer command prompt](https://github.com/microsoft/vswhere/wiki/Start-Developer-Command-Prompt#using-powershell)" as someone would on their dev machine. While in this area of the code, this PR also runs some additional manifest checks on the windows binaries. Fixes: #32508 ACKs for top commit: davidgumberg: crACK b5fdc90 hebasto: ACK b5fdc90. Tree-SHA512: df640dff27579a1c95daddc5a5ba8fd655bbd0a6f2aff74d0f63439c7185c0b18a90abfee3f1f032fe833cd19b822ef71812f44b24c4c044222e46d01c271864
… gha job 156927903d64297500dd73380908c654b07bfb1a ci: Check windows manifests for all executables (Max Edwards) e1a1b14c9359751a4d0117a27a303d1f1d3ed30f ci: use a more generic way of finding mt.exe (Max Edwards) 7ae0497eef8f5b37fc1184897a5bbc9f023dfa67 ci: remove 3rd party js from windows dll gha job (Max Edwards) Pull request description: The windows job uses the external dependency `ilammy/msvc-dev-cmd` which runs javascript. We use this to put various tools on the path such as `MSBuild.exe` and `mt.exe`. We can remove this dependency and use `vswhere.exe` directly to find these tools and create a "[Developer command prompt](https://github.com/microsoft/vswhere/wiki/Start-Developer-Command-Prompt#using-powershell)" as someone would on their dev machine. While in this area of the code, this PR also runs some additional manifest checks on the windows binaries. Fixes: #32508 ACKs for top commit: davidgumberg: crACK 156927903d64297 hebasto: ACK 156927903d64297500dd73380908c654b07bfb1a. Tree-SHA512: df640dff27579a1c95daddc5a5ba8fd655bbd0a6f2aff74d0f63439c7185c0b18a90abfee3f1f032fe833cd19b822ef71812f44b24c4c044222e46d01c271864
The windows job uses the external dependency
ilammy/msvc-dev-cmdwhich runs javascript. We use this to put various tools on the path such asMSBuild.exeandmt.exe. We can remove this dependency and usevswhere.exedirectly to find these tools and create a "Developer command prompt" as someone would on their dev machine.While in this area of the code, this PR also runs some additional manifest checks on the windows binaries.
Fixes: #32508