-
-
Notifications
You must be signed in to change notification settings - Fork 829
Verify on CI that gleam binary architectures match target architectures #3897
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
Verify on CI that gleam binary architectures match target architectures #3897
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you!
Why is it that there are new workflows for this? There is a very large amount of extra work being performed and CI complexity to maintain here. I would have expected 1 extra step in each workflow to run the check command.
Let me quote some bits from above:
I just added them for testing purposes – wanted to make sure this works in the exact environment it is supposed to be run: GitHub runners. This way:
I wanted to keep the changes to the existing workflows as minimal as possible. |
425e8fb
to
7fb022f
Compare
Ah, thank you! I understand now. Sorry for my poor reading. I still find the shell script rather complex and hard to read. I do think we should move the substring to match for to the top level of the workflow, to the same place we keep all the other variables. That way there's no conditional logic in the script and you can read one of them very easily in a list. |
No worries, I can imagine you having plenty of other things on your mind taking care of Gleam. And thank you very much for that btw! :)
Hmm – I am not sure where else it might make more sense to put it? From what I see, all the variables are defined as part of the individual workflows. Or did I miss something? Currently, the only context where this mapping is useful, is within this verification script. The script is being called from and reused by three workflows ( A subset of the following target architectures is defined for each workflow: target:
- x86_64-unknown-linux-gnu
- aarch64-unknown-linux-gnu
- x86_64-unknown-linux-musl
- aarch64-unknown-linux-musl
- x86_64-apple-darwin
- aarch64-apple-darwin
- x86_64-pc-windows-msvc
- aarch64-pc-windows-msvc And these are exactly the strings that are being used as inputs to the build steps in order to compile the binary. To me it makes sense to use the exact same strings as the inputs to the verification steps, for any mapping that needs to happen in the context of the verification.
Apart from the mapping, what is it that makes it so hard to read? Did you have a look at the file with proper syntax highlighting? Not saying the script is a piece of art but the "Files changed" view makes it definitely harder to read. For shell scripts I also find an indentation 4 spaces instead of 2 spaces easier on the eyes. I tried to make it easier to read by:
Options that I can think of:
I've just created a rough draft of “Option 3” but would like to test it on a GitHub runner first. I'll catch some sleep now and push it for you to review sometime later today. ✌️ |
0f7569f
to
c595abc
Compare
Thanks for insisting, that's better. How do you feel about it now? TestingAll iterations are tested for all 3 workflows and all 8 target architectures respectively. MatchingRefactored it so that both,
Undecided whether we want to stay strict or be more forgiving, but we could make the matching case insensitive. DebuggingMade sure for the workflow step output to include all the necessary debug information for fixing issues, should it ever fail: Run set -xeuo pipefail
+ BINARY_PATH=target/x86_64-unknown-linux-gnu/release/gleam
+ [[ x86_64-unknown-linux-gnu == *\w\i\n\d\o\w\s* ]]
+ ./bin/verify-binary-architecture.sh x86_64-unknown-linux-gnu target/x86_64-unknown-linux-gnu/release/gleam
+ '[' 2 -ne 2 ']'
+ TARGET_TRIPLE=x86_64-unknown-linux-gnu
+ BINARY_PATH=target/x86_64-unknown-linux-gnu/release/gleam
++ file -b target/x86_64-unknown-linux-gnu/release/gleam
+ BINARY_FILE_TYPE='ELF 64-bit LSB pie executable, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, BuildID[sha1]=601c49edc1890db724f4a1fbfc450fa08b40df4d, for GNU/Linux 3.2.0, not stripped'
+ ARCHITECTURE_PATTERNS_FOR_AARCH64='aarch64|Aarch64|arm64'
+ ARCHITECTURE_PATTERNS_FOR_X86_64='x86-64|x86_64'
++ echo x86_64-unknown-linux-gnu
++ parse_architecture
++ normalize_architecture
++ sed -E -e 's/(aarch64|Aarch64|arm64)/AArch64/' -e 's/(x86-64|x86_64)/x86-64/'
++ head -n1
++ grep -Eo -e 'aarch64|Aarch64|arm64' -e 'x86-64|x86_64'
+ TARGET_ARCHITECTURE=x86-64
++ echo 'ELF 64-bit LSB pie executable, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, BuildID[sha1]=601c49edc1890db724f4a1fbfc450fa08b40df4d, for GNU/Linux 3.2.0, not stripped'
++ parse_architecture
++ normalize_architecture
++ sed -E -e 's/(aarch64|Aarch64|arm64)/AArch64/' -e 's/(x86-64|x86_64)/x86-64/'
++ grep -Eo -e 'aarch64|Aarch64|arm64' -e 'x86-64|x86_64'
++ head -n1
Architecture match for 'x86_64-unknown-linux-gnu'!
+ BINARY_ARCHITECTURE=x86-64
+ '[' x86-64 '!=' x86-64 ']'
+ echo 'Architecture match for '\''x86_64-unknown-linux-gnu'\''!'
+ exit 0 Failing workflow steps are annoying enough, so lets make it easy to debug and fix. DocumentationI was afraid that it might not be self documenting enough, but it's actually quite good. But it might still make sense to document which platforms use which architecture patterns: # `darwin`: `arm64` and `x86_64`
# `linux`: `aarch64` and `x86-64`
# `windows`: `Aarch64` and `x86-64`
# `rust build target`: `aarch64` and `x86_64` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you, but there's still logic in the script for mapping between strings.
bin/verify-binary-architecture.sh
Outdated
sed -E \ | ||
-e "s/($ARCHITECTURE_PATTERNS_FOR_AARCH64)/AArch64/" \ | ||
-e "s/($ARCHITECTURE_PATTERNS_FOR_X86_64)/x86-64/" | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please remove all the logic from this script relating to converting strings to other strings. I want this script to accept an exactly string and check that the output of file matches it. There should be zero mapping logic in here at all, it is too hard to understand.
…atches target architecture
…target architecture
…ture normalization logic
… patterns for better understanding
…s for better understanding
…d binary architectures in verification script
494b06f
to
7d371da
Compare
91c8ecb
to
242cd82
Compare
There we go – spread expected binary architecture strings across all three GitHub workflows. |
391f01a
to
d2859b5
Compare
…ion script accross all three GitHub workflows as per Louis preference
d2859b5
to
b2f9c6e
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wonderful work! Thank you for working through that with me! I know I am very slow to reply!
This PR is regarding issue #1630:
./bin/verify-binary-architecture.sh
./.github/workflows/ci-verify-binary-architecture.yaml
./.github/workflows/release-nightly-verify-binary-architecture.yaml
./.github/workflows/release-verify-binary-architecture.yaml
./.github/workflows/ci.yaml
./.github/workflows/release-nightly.yaml
./.github/workflows/release.yaml
How it works:
target architecture
and thebinary path
as arguments and does it's thingbinary path
and pass them to the bash scriptWhen reviewing:
./.github/workflows/*-verify-binary-architecture.yaml
workflows in the first pass, as they are adding a lot of noise – and focus on the bash script and the changes to the existing workflows instead.Notes and Todos:
file
outputs for the various target architectures and OSes somewhere for future reference?