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

Generate Project.toml with Pkg's custom key order, and update reference tests to v1.7 #335

Merged
merged 8 commits into from
Jan 8, 2022

Conversation

tkf
Copy link
Contributor

@tkf tkf commented Jan 6, 2022

In Julia 1.7, Project.toml generated by PkgTemplates is not compatible with Pkg's sort order.

(@v1.7) pkg> activate --temp
  Activating new project at `/tmp/jl_ZsryYH`

julia> using PkgTemplates
 │ Package PkgTemplates not found, but a package named PkgTemplates is available from a registry.
 │ Install package?
 │   (jl_ZsryYH) pkg> add PkgTemplates
 └ (y/n) [y]:
...

(jl_ZsryYH) pkg> st
      Status `/tmp/jl_ZsryYH/Project.toml`
  [14b8a8f1] PkgTemplates v0.7.25

julia> Template(user = "tkf")("ExamplePackage")
[ Info: Running prehooks
...
[ Info: New package is at /home/arakaki/.julia/dev/ExamplePackage

shell> cd ~/.julia/dev/ExamplePackage
/home/arakaki/.julia/dev/ExamplePackage

shell> cat Project.toml
name = "ExamplePackage"
uuid = "db43d3c3-1afb-45d2-b722-e2cdd05cc17f"
authors = ["Takafumi Arakaki <[email protected]> and contributors"]
version = "0.1.0"

[extras]
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"

[compat]
julia = "1"

[targets]
test = ["Test"]

The order of the tables is different from how Pkg sorts them. If I update it with Pkg:

(jl_ZsryYH) pkg> activate .
  Activating project at `~/.julia/dev/ExamplePackage`

(ExamplePackage) pkg> add UUIDs
...

Then git diff shows me

diff --git a/Project.toml b/Project.toml
index 3d3b37e..922c5e8 100644
--- a/Project.toml
+++ b/Project.toml
@@ -3,11 +3,14 @@ uuid = "db43d3c3-1afb-45d2-b722-e2cdd05cc17f"
 authors = ["Takafumi Arakaki <[email protected]> and contributors"]
 version = "0.1.0"

-[extras]
-Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
+[deps]
+UUIDs = "cf7118a7-6976-5b1a-9a39-7adc72f591a4"

 [compat]
 julia = "1"

+[extras]
+Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
+
 [targets]
 test = ["Test"]

This PR solves this issue with a custom write_project with the sort key taken form Pkg.

It also bumps the Julia version used for the reference test to check the bug this PR fixes. To make it work, I added a mocking for uuid4.

close #298

@codecov
Copy link

codecov bot commented Jan 6, 2022

Codecov Report

Merging #335 (01a45bd) into master (cb02b34) will increase coverage by 0.07%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #335      +/-   ##
==========================================
+ Coverage   94.68%   94.76%   +0.07%     
==========================================
  Files          20       20              
  Lines         621      630       +9     
==========================================
+ Hits          588      597       +9     
  Misses         33       33              
Impacted Files Coverage Δ
src/plugins/project_file.jl 94.11% <100.00%> (+4.11%) ⬆️
src/plugins/tests.jl 100.00% <100.00%> (ø)
src/plugins/ci.jl 97.46% <0.00%> (-1.27%) ⬇️
src/template.jl 98.42% <0.00%> (-0.02%) ⬇️
src/PkgTemplates.jl 100.00% <0.00%> (ø)
src/plugins/badges.jl 100.00% <0.00%> (ø)
src/plugins/git.jl 95.08% <0.00%> (+1.53%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update cb02b34...01a45bd. Read the comment docs.

Since Manifest.toml format v2 includes Julia version, reference tests need
exactly equivalent VERSION.
Copy link
Collaborator

@nickrobinson251 nickrobinson251 left a comment

Choose a reason for hiding this comment

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

Thanks a lot!

A couple small suggestions that i'd appreciate.

It also bumps the Julia version used for the reference test to check the bug this PR fixes.

This will close #298, which has been on the wish-list a long while, so i'm very grateful for you doing it!

To make it work, I added a mocking for uuid4.

Just to check my understanding: this mocking is needed as the output of uuid4() is different in v1.6+ (post JuliaLang/julia#35872)?

.github/workflows/CI.yml Show resolved Hide resolved
src/plugins/project_file.jl Outdated Show resolved Hide resolved
src/plugins/project_file.jl Outdated Show resolved Hide resolved
@tkf
Copy link
Contributor Author

tkf commented Jan 8, 2022

Thanks for the review!

This will close #298

FYI I added close #298 to the OP to auto-close it. But feel free to remove it if you manage it differently.

Just to check my understanding: this mocking is needed as the output of uuid4() is different in v1.6+ (post JuliaLang/julia#35872)?

Oooh, this explains why. I was a bit puzzled why, but I agree that it explains it. (I initially speculated that the test may actually not be running because that 1.5 was not in the CI matrix before realizing the explicit include)

@nickrobinson251
Copy link
Collaborator

nickrobinson251 commented Jan 8, 2022

hmm, it seems deeleting the 1.5 job from the GHA workflow file might not be sufficient, as it seems the repo is somehow still expecting a 1.5 job to run and pass... I wonder if this is something that needs changing in the repo settings (to which i don't have access)

Screenshot 2022-01-08 at 12 43 32

Perhaps @christopher-dG knows? And/or perhaps @oxinabox might be able to bump my permissions to allow me to access repo settiing to investigate?

@nickrobinson251 nickrobinson251 changed the title Generate Project.toml with Pkg's custom key order Generate Project.toml with Pkg's custom key order, and update reference tests to v1.7 Jan 8, 2022
@christopher-dG
Copy link
Member

I've replaced the 1.5 required check in the repo settings with a 1.7 one :)

@nickrobinson251 nickrobinson251 merged commit 015dfc4 into JuliaCI:master Jan 8, 2022
@nickrobinson251
Copy link
Collaborator

Thanks!

@tkf tkf deleted the project_key_order branch January 8, 2022 18:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Update reference tests for Julia 1.6
3 participants