Skip to content
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

build(agd): use timestamps again; hashes weren't necessary #9179

Merged
merged 7 commits into from
Apr 10, 2024

Conversation

michaelfig
Copy link
Member

@michaelfig michaelfig commented Apr 1, 2024

refs: #8715
(ostensibly) closes: #8996

Description

Recommendation: Best viewed with hide whitespace changes.

The build hashes introduced in #8715 didn't actually solve the # endo-branch: XXX problem that it was designed to, the more careful handling of the Endo-based packages and caches in #8715 did instead.

The complexity introduced by trying to use build hashes is not worth the cost, so this PR both simplifies and makes the original timestamp-based builds more robust.

Security Considerations

n/a

Scaling Considerations

Simpler to understand and more efficient to execute agoric-sdk/bin/agd.

As a drive-by, reuse longer yarn install timeouts, so that the QEMU arm64 Docker builds succeed consistently again. This is a temporary fix until Agoric-SDK uses a solution for faster multiplatform builds (like #9043).

Documentation Considerations

n/a

Testing Considerations

Build process and CI tests should be adequate for this PR.

Upgrade Considerations

n/a

@michaelfig michaelfig added tooling repo-wide infrastructure agd Agoric (Golang) Daemon labels Apr 1, 2024
@michaelfig michaelfig self-assigned this Apr 1, 2024
@michaelfig michaelfig added automerge:no-update (expert!) Automatically merge without updates force:integration Force integration tests to run on PR and removed automerge:no-update (expert!) Automatically merge without updates labels Apr 1, 2024
@michaelfig michaelfig requested review from mhofman, turadg and kriskowal and removed request for turadg April 1, 2024 20:05
@michaelfig michaelfig marked this pull request as ready for review April 1, 2024 20:06
bin/agd Outdated
fi
diff -u "$stamp" "$stamp.new" || return 1
return 0
echo ${1+"$@"} 1>&2
Copy link
Member

Choose a reason for hiding this comment

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

the indentation changed here. time for .editorconfig?

Copy link
Member Author

Choose a reason for hiding this comment

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

I thought shfmt -w could do no wrong!

Copy link
Member

Choose a reason for hiding this comment

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

I discovered recently it needs --indent 4 in our codebase. I just checked and it ignores .editorconfig.

I can add a .sh format check to CI if you think it's worthwhile.

Copy link
Member Author

Choose a reason for hiding this comment

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

A format check would be welcome, but of lower priority. I don't mind doing manual shfmt for a little while.

Copy link
Member

Choose a reason for hiding this comment

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

please use the formatting of .sh scripts. CI isn't checking it because the script doesn't end in .sh. Consider renaming the file go agd-with-build.sh or something like that and having bin/agd symlink to it.

For the reformatting, please have the base reformat in a separate commit before your changes. I did that in https://github.com/Agoric/agoric-sdk/tree/ta-agd-build-fix if you want to use those

Copy link
Member

Choose a reason for hiding this comment

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

a symlink might not be compatible with tooling in the cosmovisor ecosystem

Copy link
Member Author

Choose a reason for hiding this comment

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

A symlink is not compatible, but a tiny redirecting shell script is, so I did that.

Copy link
Member

@kriskowal kriskowal left a comment

Choose a reason for hiding this comment

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

I appreciate the simplification and trust CI exercises this. From this review, my knowledge of bash grew from “more than I would like” to “even more than I would like”.

golang/cosmos/Makefile Show resolved Hide resolved
bin/agd Outdated
fi
diff -u "$stamp" "$stamp.new" || return 1
return 0
echo ${1+"$@"} 1>&2
Copy link
Member

Choose a reason for hiding this comment

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

What does this do?

Copy link
Member Author

Choose a reason for hiding this comment

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

It echoes the fatal arguments to stderr with proper escaping.

bin/agd Show resolved Hide resolved
Comment on lines 138 to 139
STAMPS=node_modules/.cache/agoric
mkdir -p "$STAMPS"
Copy link
Member

Choose a reason for hiding this comment

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

glad to see CI less coupled to the agd script implementation.

can't we remove this too? The script already defines STAMPS so it just needs mkdir. Did you avoid that due to cross-platform concerns? We only support Mac and Linux and I think mkdir -p works in both. Then you can just have the script mkdir idempotently.

Copy link
Member Author

Choose a reason for hiding this comment

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

Just some detritus... I've removed it.

bin/agd Outdated
set -x
case "${2-''}" in
--force | -f)
rm -rf "$thisdir/../$STAMPS"
Copy link
Member

Choose a reason for hiding this comment

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

this will remove all agoric cache. shouldn't it remove just the files in its purview?

Copy link
Member Author

Choose a reason for hiding this comment

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

Now I've isolated the stamps in a subdirectory so that the whole cache isn't deleted.

bin/agd Outdated
yarn "$@"
}

# Check if any package.json is newer than the installation stamp.
Copy link
Member

Choose a reason for hiding this comment

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

This is a really broad scope for agd. I don't expect a tool that I run to do yarn install or yarn scripts. This also unnecessarily couples agd to a particular package manager.

Not a blocker but a discussion I'd like to start. Can we leave package management to the package manager? I just started #9209 to track

Suggested change
# Check if any package.json is newer than the installation stamp.
# Check if any package.json is newer than the installation stamp.
# If some package.json is newer than the last yarn install, run yarn install
# UNTIL https://github.com/Agoric/agoric-sdk/issues/9209

package.json Outdated
Comment on lines 63 to 64
"build": "yarn workspaces run build && mkdir -p node_modules/.cache/agoric && date >node_modules/.cache/agoric/yarn-built",
"postinstall": "patch-package && mkdir -p node_modules/.cache/agoric && date >node_modules/.cache/agoric/yarn-installed",
Copy link
Member

Choose a reason for hiding this comment

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

this is quite a bit of boilerplate for package.json. please have a helper script.

Suggested change
"build": "yarn workspaces run build && mkdir -p node_modules/.cache/agoric && date >node_modules/.cache/agoric/yarn-built",
"postinstall": "patch-package && mkdir -p node_modules/.cache/agoric && date >node_modules/.cache/agoric/yarn-installed",
"build": "yarn workspaces run build && scripts/timestamp.sh yarn-built",
"postinstall": "patch-package && scripts/timestamp.sh yarn-installed",

I wonder if there's a little npm package for reading and writing cached values or comparing timestamps with a cached value on disk.

Copy link
Member Author

Choose a reason for hiding this comment

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

I adopted this in scripts/agd-builder.sh.

Copy link
Member

@turadg turadg left a comment

Choose a reason for hiding this comment

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

👍

Comment on lines 242 to 245
# Run the built Cosmos daemon.
# shellcheck disable=SC2031
export PATH="$thisdir/../packages/cosmic-swingset/bin:$PATH"
exec "$thisdir/../$GOLANG_DAEMON" ${1+"$@"}
Copy link
Member

Choose a reason for hiding this comment

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

consider moving this to bin/agd so this builder script's only job is to build

Copy link
Member Author

Choose a reason for hiding this comment

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

Oh, good idea!

@michaelfig michaelfig added the automerge:no-update (expert!) Automatically merge without updates label Apr 10, 2024
@mergify mergify bot merged commit 00cccfc into master Apr 10, 2024
74 checks passed
@mergify mergify bot deleted the mfig-agd-build-fix branch April 10, 2024 20:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
agd Agoric (Golang) Daemon automerge:no-update (expert!) Automatically merge without updates force:integration Force integration tests to run on PR tooling repo-wide infrastructure
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Flake in deployment-test CI job
4 participants