10000 Improve on "Add support for Windows builds" by paulo-ferraz-oliveira · Pull Request #52 · erlef/setup-beam · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Improve on "Add support for Windows builds" #52

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 16 commits into from
Jul 8, 2021
Merged

Improve on "Add support for Windows builds" #52

merged 16 commits into from
Jul 8, 2021

Conversation

paulo-ferraz-oliveira
Copy link
Collaborator
@paulo-ferraz-oliveira paulo-ferraz-oliveira commented Jun 24, 2021

Closes #51. Also closes #50. Also closes #53. Also closes #46.

  1. support more OTP+Windows versions; try to bridge the gap with gleam-lang/setup-erlang, that seems to support pre-21 versions
  2. merge ci.yml with test.yml (and tweak output text) - tweaking the titles is not particularly helpful (GitHub still adds the matrix variables to it, so it makes for a less readable output)
  3. add Elixir to Windows builds

@paulo-ferraz-oliveira
Copy link
Collaborator Author

Let me add some self-review comments, for clarity. FWIW, this pull request closes two outstanding issues: #50 and #51, but created recently.

@paulo-ferraz-oliveira
Copy link
Collaborator Author

I split the CI files into three different files. Rationale: easier to see where an error comes from, easier to have more inspectable job names.

@paulo-ferraz-oliveira paulo-ferraz-oliveira marked this pull request as ready for review June 25, 2021 02:27
@@ -9,12 +9,8 @@ FILE_INPUT="${VSN}.zip"
FILE_OUTPUT=elixir.zip
DIR_FOR_BIN=.setup-beam/elixir

rm -f "${FILE_OUTPUT}"
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed what was unnecessary, even if old code. It makes for easier maintenance.

$ProgressPreference="SilentlyContinue"
Invoke-WebRequest "https://github.com/erlang/otp/releases/download/OTP-$VSN/otp_win64_$VSN.exe" -OutFile "$FILE_OUTPUT"
$ProgressPreference="Continue"
New-Item "$DIR_FOR_BIN" -ItemType Directory | Out-Null
Move-Item "$FILE_OUTPUT" "$DIR_FOR_BIN"
Start-Process "./$DIR_FOR_BIN/$FILE_OUTPUT" /S -Wait
Write-Output "C:/Program Files/erl-$VSN/bin" | Out-File -FilePath $Env:GITHUB_PATH -Encoding utf8 -Append
$ErlExec = Get-ChildItem -Path "C:/Program Files/" -Recurse -Depth 2 -Filter 'erl.exe' -Name | ForEach-Object { Write-Output "C:/Program Files/$_" }
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, so the new approach is to find erl.exe and make the container folder part of the path. 🎉 , more Windows versions supported.

@@ -13,7 +13,7 @@ async function installOTP(osVersion, otpVersion) {
await exec(path.join(__dirname, 'install-otp.sh'), [osVersion, otpVersion])
} else if (OS === 'win32') {
const script = path.join(__dirname, 'install-otp.ps1')
await exec(`powershell.exe ${script} -VSN:${otpVersion}`)
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I got into trouble with powershell and paths. This removed my obstacles.

@@ -17,19 +18,15 @@ async function main() {
const otpVersion = await installOTP(otpSpec, osVersion)

const elixirSpec = core.getInput('elixir-version', { required: false })
const shouldMixHex = core.getInput('install-hex', {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is actually just moving code around, to revert a previous decision that created more confusion that expected.

@@ -342,14 +337,6 @@ async function get(url0, pageIdxs) {
return ret
}

function prependToPath(what) {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I learned, yesterday, that .addPath existed. It's a nice replacement for this.

@paulo-ferraz-oliveira
Copy link
Collaborator Author

@starbelly, I'm going to ask for your review here. There's nothing special in the pull request but some extra eyes are always nice. You could probably also run this over that project you have with multiple rebar3 versions and whatnot, even using Windows, maybe (?)

@paulo-ferraz-oliveira
Copy link
Collaborator Author

Tests are failing because 22.3 is getting converted to 22.3.0 (ranges, again!) which doesn't exist; we might want to tackle this with #52 soon (potentially even merge that into this pull request).

if (versions.includes(spec)) {
if (
versions.includes(spec) ||
core.getInput('version-type', { required: false }) === 'strict'
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm tentatively adding this here. I ran into version-related trouble while implementing Windows and feel since this has been reported as an issue before it might just be time to implement it. Adding it to this pull request since a bug, made evident, seems impossible to overcome with such a mechanism.

@paulo-ferraz-oliveira
Copy link
Collaborator Author

I believe there might be some more getVersionFromSpec -related changes on the way. It's working, sure, but that's because the input is dynamic. As-is, this is a time-bomb. Let me think on it further.

@paulo-ferraz-oliveira
Copy link
Collaborator Author
8000

Added "Also closes #53. Also closes #46." as a consequence of testing Windows version ranges.

@paulo-ferraz-oliveira
Copy link
Collaborator Author

I'm pushing an update to the way we find non-semver stuff in the versions we have. I've recently introduced the strict-version option which allows for a more repeatable use (the version is picked as-is - or otherwise errors out if it's not found).

@@ -16,6 +16,8 @@ async function all() {
await testOTPVersions()
await testElixirVersions()
await testRebar3Versions()

await testGetVersionFromSpec()
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mind you none of the other tests change, so this should give us some confidence in backward compatibility.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, some actually change, but the update only made the previous implementation issue (not getting the latest latest) into evidence, so I guess this is good.

@@ -278,11 +266,24 @@ async function getRebar3Versions() {
}

function getVersionFromSpec(spec, versions) {
if (versions.includes(spec)) {
return spec
if (core.getInput('version-type', { required: false }) === 'strict') {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new option (version-type)...

}

return semver.maxSatisfying(versions, semver.validRange(spec))
// We keep a map of semver => actualver in order to use semver ranges to find appropriate versions
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

... and the new way we keep references in a map for further handling. Tests should be the stuff giving us confidence over this, so we should improve/add to those if you feel it's warranted.

@paulo-ferraz-oliveira paulo-ferraz-oliveira marked this pull request as draft July 7, 2021 14:27
return version
}

function sortVersions(left, right) {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This one's a proper attempt at solving OTP-like versions, with 5 elements like 0.0.0.0.0

@@ -224,10 +219,7 @@ async function getOTPVersions(osVersion) {
.filter((x) => x.name.match(/^otp_win64_.*.exe$/))
.forEach((x) => {
const otpMatch = x.name.match(/^otp_win64_(.*).exe$/)
let otpVersion = otpMatch[1]
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was moved to getVersionFromSpec to centralise version management/handling.

@@ -209,11 +208,7 @@ async function getOTPVersions(osVersion) {
.split('\n')
.forEach((line) => {
const otpMatch = line.match(/^(OTP-)?([^ ]+)/)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was moved to getVersionFromSpec to centralise version management/handling.

@paulo-ferraz-oliveira
Copy link
Collaborator Author

This is ready for general review.

@paulo-ferraz-oliveira paulo-ferraz-oliveira marked this pull request as ready for review July 7, 2021 17:16
@@ -0,0 +1,87 @@
---
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like splitting these out into different workflows for easy digestion 👍

@@ -192,6 +196,149 @@ async function testRebar3Versions() {
assert.deepStrictEqual(got, expected)
}

async function testGetVersionFromSpec() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Definitely not something to do here, but an interesting idea might be to property test functions like these. There are indeed js libs for this. Might be overkill, but makes sense to me 🤷

@starbelly
Copy link
Member

Stellar work as usual @paulo-ferraz-oliveira ❤️💛💚💙💜

seal-of-approval

@paulo-ferraz-oliveira
Copy link
Collaborator Author

I'm going to test this in some repo.s that use Windows and then, based on those results, will either merge or perform smaller fixes.

@paulo-ferraz-oliveira
Copy link
Collaborator Author

This is working here:

@paulo-ferraz-oliveira
Copy link
Collaborator Author
paulo-ferraz-oliveira commented Jul 8, 2021

@starbelly, based on the previous message and your approval, could you unblock the merge so I can squash + merge?

Edit - maybe this'll help: https://github.community/t/expected-waiting-for-status-to-be-reported/18001.

@paulo-ferraz-oliveira
Copy link
Collaborator Author
paulo-ferraz-oliveira commented Jul 8, 2021

I'm going to try to close and reopen this to see if the workflow issue goes away.

Edit: it doesn't 😢.

@paulo-ferraz-oliveira
Copy link
Collaborator Author

It's merged. Thanks for all the help, Bryan.

@paulo-ferraz-oliveira paulo-ferraz-oliveira deleted the feature/erlang-windows-builds-improved branch July 8, 2021 14:41
@paulo-ferraz-oliveira paulo-ferraz-oliveira changed the title Improve on "Add Windows to the mix" Improve on "Add support for Windows builds" Jul 8, 2021
default: true
rebar3-version:
description: Version range or exact version of rebar3 to use
version-type:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just wanted to say a big thank you for this option in particular (and the whole project in general.) :D

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants
0