-
Notifications
You must be signed in to change notification settings - Fork 10
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
Make buildkite env reproducible #2179
base: main
Are you sure you want to change the base?
Conversation
@@ -21,15 +21,18 @@ steps: | |||
rm -rf ${JULIA_DEPOT_PATH} | |||
fi | |||
|
|||
- echo "--- Check that ClimaCore is developed in Manifest" | |||
- julia --check-bounds=yes -e 'using Pkg; Pkg.add("TOML"); using TOML; using Test; @test TOML.parse(join(readlines(".buildkite/Manifest.toml")[7:end], "\n"))["deps"]["ClimaCore"][1]["path"] == ".."' |
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.
I wonder if we can avoid hardcoding the path to the Manifest and rely on julia itself. For example, pkgdir(ClimaCore)
would tell us. I don't know if Pkg has some functions to inpect a project without instantiating it
Also, we should avoid continuing the bulid if this check fails.
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.
Unfortunately, pkgdir(ClimaCore)
requires loading (and precompileing ClimaCore
), which is why I went with just using TOML
like this. It's ugly, but much more lightweight.
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.
Yes, I was wondering if Pkg
had some way to probe the environment programmatically without instanting it. I mean, it has to do it to instantiate up the env in the first place, but I don't know if this is somehow exposed to the user.
Alternatively, a slightly cleaner julia one liner would be:
using TOML; @assert TOML.parsefile(".buildkite/Manifest.toml")["deps"]["ClimaCore"][1]["path"] == ".."
This is to for N manifests:
using TOML; for f in filter(x->startswith("Manifest",x), readdir(".buildkite")); @assert TOML.parsefile(joinpath(".buildkite",f))["deps"]["ClimaCore"][1]["path"] == ".."; end
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.
Yes, I was wondering if Pkg had some way to probe the environment programmatically without instanting it.
I didn't see anything from a quick look through Pkg.<tab>
. Another option, just using Pkg would be to Pkg.develop(".")
and then check if the manifest has changed (via git).
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.
I like using TOML; @assert TOML.parsefile(".buildkite/Manifest.toml")["deps"]["ClimaCore"][1]["path"] == ".."
, want to move forward with that?
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.
A quick look seems to indicate that Pkg.dependencies()[UUID("d414da3d-4745-48bb-8d80-42e94e092884")].source
is ClimaCore's path in this environment.
We can probably clean this up to avoid hardcoding the uuid and use the name instead
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.
I kind of like that using TOML; @assert TOML.parsefile(".buildkite/Manifest.toml")["deps"]["ClimaCore"][1]["path"] == ".."
is explicitly looking at the manifest file. The Pkg.dependencies
business requires us to look into the implementation to see where it's getting that from. Also:
Pkg.dependencies()::Dict{UUID, PackageInfo}
This feature is considered experimental.
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.
I think the strength of using Pkg
is that we are guaranteed to access the same information that the julia is using in instantiating the environment.
Pkg.dependencies().source
is part of the documented API of this function, so I don't think that this is looking into the implementation.
Actually, looking at the documentation, I see that there's directly a field isdeveloped
to check what we want to check
Pkg.dependencies()::Dict{UUID, PackageInfo}
Query the dependecy graph.
The result is a `Dict` that maps a package UUID to a `PackageInfo` struct representing the dependency (a package).
PackageInfo fields:
| `field` | `Description` |
|:---------------|:-----------------------------------------------------------|
| `name` | The name of the package |
| `version` | The version of the package (this is `Nothing` for stdlibs) |
| `isdeveloped` | Whether a package is directly tracking a directory |
| `ispinned` | Whether a package is pinned |
| `source` | The directory containing the source code for that package |
| `dependencies` | The dependencies of that package as a vector of UUIDs |
So the test could be
using Pkg; @assert Pkg.dependencies()[Base.UUID("d414da3d-4745-48bb-8d80-42e94e092884")].isdeveloped
This feature is considered experimental.
This feature was introduced in julia 1.4 and has not changed at all since then. I opened an issue to Pkg to ask why they are still considered experimental.
All of this said, I don't feel strongly about this. I think that the benefits compared to manually parsing the file are more theoretical than practical, so I am happy to go with the other solution too. I'll leave it up to you.
e4ac391
to
6b91622
Compare
This is an attempt to close #2178. I don't know that this is the best way to do this, but it should work.