Skip to content

[tooling] Simplify avalanchego build script #3861

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 2 commits into from
Apr 10, 2025
Merged

Conversation

maru-ava
Copy link
Contributor

@maru-ava maru-ava commented Apr 6, 2025

Why this should be merged

Previously the scripts/build.sh script delegated responsibility for actually building avalanchego to
scripts/build_avalanche.sh. This change incorporates build_avalanchego.sh into build.sh to simplify maintenance.

How this was tested

CI

Need to be documented in RELEASES.md?

N/A

@maru-ava maru-ava added the tooling Build, test and development tooling label Apr 6, 2025
@maru-ava maru-ava self-assigned this Apr 6, 2025
@github-project-automation github-project-automation bot moved this to Backlog 🗄️ in avalanchego Apr 6, 2025
@maru-ava maru-ava moved this from Backlog 🗄️ to In Review 👀 in avalanchego Apr 6, 2025
"$AVALANCHE_PATH"/scripts/build_avalanche.sh $build_args

# Exit build successfully if the AvalancheGo binary is created successfully
if [[ -f "$avalanchego_path" ]]; then
Copy link
Contributor Author

@maru-ava maru-ava Apr 6, 2025

Choose a reason for hiding this comment

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

This conditional block was not working as intended - the path could have been populated from a previous invocation, and set -e ensures that an error would result in an exit before this conditional would be evaluated.

Previously the `scripts/build.sh` script delegated responsibility for
actually building avalanchego to
`scripts/build_avalanche.sh`. This change incorporates
build_avalanchego.sh into build.sh to simplify maintenance.
@maru-ava maru-ava force-pushed the tooling-simplify-build.sh branch from a1c91ff to dc5f943 Compare April 6, 2025 16:16
Copy link
Contributor

@tsachiherman tsachiherman left a comment

Choose a reason for hiding this comment

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

Given that it's a no-op change, I shouldn't be critic here, so I'll approve it as is.
However, I'd like to provide few notes I've taken while reviewing this. There notes might be controversial, so please take these as a "open ended remarks":

  1. could we add the ability for the script to work from non-avalanche-path ? i.e. change directory to where we want to be, and then pop directory when we're done.
  2. When building the “*.go” isn’t needed, since a package is being built anyway.
  3. Why does the “go mod download” is even needed ? Wouldn’t the go build automatically do that ?
  4. When building, we’re writing out the go version with which we’ve built the binary. That’s perfectly fine. However, if it’s meaningful enough for us to print this out, shouldn’t we also embed that into the binary itself ( same as with the git commit hash ). I also think that we might want to embed the platform and build date & time into the binary ( for telemetry )

@maru-ava
Copy link
Contributor Author

maru-ava commented Apr 7, 2025

Given that it's a no-op change, I shouldn't be critic here, so I'll approve it as is. However, I'd like to provide few notes I've taken while reviewing this. There notes might be controversial, so please take these as a "open ended remarks":

  1. could we add the ability for the script to work from non-avalanche-path ? i.e. change directory to where we want to be, and then pop directory when we're done.

afaict this script can be invoked from any path. Is there an issue I'm missing with discovering the repo root from the script path?

Note that task will enable building (via scripts/run_task.sh build or task build if task is installed manually or provided via the nix shell) from anywhere in the tree without having to specify the script path (e.g. having to execute with ../../scripts/build.sh if in the tests/fixtures path).

  1. When building the “*.go” isn’t needed, since a package is being built anyway.

Fair point, I'll fix.

  1. Why does the “go mod download” is even needed ? Wouldn’t the go build automatically do that ?

For sure, go build will download automatically. Maybe someone cared about having a separation between module download and compilation? I'm just maintaining the existing behavior, I don't have a strong opinion either way since there is no functional difference created by this separation.

  1. When building, we’re writing out the go version with which we’ve built the binary. That’s perfectly fine. However, if it’s meaningful enough for us to print this out, shouldn’t we also embed that into the binary itself ( same as with the git commit hash ). I also think that we might want to embed the platform and build date & time into the binary ( for telemetry )

My intention in writing out the go version was mainly to give developers an indication of what version they are using since it is common to install different golang versions (i.e. to kick the tires on features of newer versions). It probably does make sense to embed the golang version used to compile for similar reasons.

Edit:

The go version is already included in the version string:

avalanchego/1.13.0 [database=v1.4.5, rpcchainvm=39, go=1.23.6]

For our release binaries and images we can always find out when they were built and with what version since we only build in CI for release with the version in go.mod and CI provides traceability for when a job ran. So while potentially useful, I'm not sure there's a non-devel need for more traceability.

As far as embedding the platform, do you mean the host or target arch/os? I'm not entirely sure of the value of providing the host details, and I'm even less sure of the value of the target given that it wouldn't be possible to run a binary on an os/arch that it wasn't built for.

@maru-ava maru-ava added this pull request to the merge queue Apr 10, 2025
Merged via the queue into master with commit 001ff19 Apr 10, 2025
24 checks passed
@maru-ava maru-ava deleted the tooling-simplify-build.sh branch April 10, 2025 22:08
@github-project-automation github-project-automation bot moved this from In Review 👀 to Done ✅ in avalanchego Apr 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
tooling Build, test and development tooling
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

3 participants