diff --git a/.buildkite/Project.toml b/.buildkite/Project.toml index 3155fbad..3eb52567 100644 --- a/.buildkite/Project.toml +++ b/.buildkite/Project.toml @@ -9,6 +9,7 @@ ClimaDiagnostics = "1ecacbb8-0713-4841-9a07-eb5aa8a2d53f" ClimaTimeSteppers = "595c0a79-7f3d-439a-bc5a-b232dc3bde79" Dates = "ade2ca70-3891-5945-98fb-dc099432e06a" Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4" +ExplicitImports = "7d51a73a-1435-4ff3-83d9-f097790105c7" JuliaFormatter = "98e50ef6-434e-11e9-1051-2b60c6c9e899" MPI = "da04e1cc-30fd-572f-bb4f-1f8673147195" NCDatasets = "85f8d34a-cbdd-5861-8df4-14fed0d494ab" diff --git a/Project.toml b/Project.toml index 6e32954e..ac962abf 100644 --- a/Project.toml +++ b/Project.toml @@ -20,6 +20,7 @@ ClimaCore = "0.13.4, 0.14" ClimaTimeSteppers = "0.7.10" Dates = "1" Documenter = "1" +ExplicitImports = "1.6" JuliaFormatter = "1" NCDatasets = "0.13.1, 0.14" Profile = "1" @@ -34,6 +35,7 @@ Aqua = "4c88cf16-eb10-579e-8560-4a9242c79595" BenchmarkTools = "6e4b80f9-dd63-53aa-95a3-0cdb28fa8baf" ClimaTimeSteppers = "595c0a79-7f3d-439a-bc5a-b232dc3bde79" Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4" +ExplicitImports = "7d51a73a-1435-4ff3-83d9-f097790105c7" JuliaFormatter = "98e50ef6-434e-11e9-1051-2b60c6c9e899" Profile = "9abbd945-dff8-562f-b5e8-e1ebf5ef1b79" ProfileCanvas = "efd6af41-a80b-495e-886c-e51b0c7d77a3" @@ -41,4 +43,4 @@ SafeTestsets = "1bc83da4-3b8d-516f-aca4-4fe02f6d838f" Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" [targets] -test = ["Aqua", "BenchmarkTools", "ClimaTimeSteppers", "Documenter", "JuliaFormatter", "Profile", "ProfileCanvas", "SafeTestsets", "Test"] +test = ["Aqua", "BenchmarkTools", "ClimaTimeSteppers", "Documenter", "ExplicitImports", "JuliaFormatter", "Profile", "ProfileCanvas", "SafeTestsets", "Test"] diff --git a/test/aqua.jl b/test/aqua.jl index dbca8fef..1337ec77 100644 --- a/test/aqua.jl +++ b/test/aqua.jl @@ -1,6 +1,7 @@ using Test using ClimaDiagnostics using Aqua +import ExplicitImports @testset "Aqua tests" begin Aqua.test_undefined_exports(ClimaDiagnostics) @@ -9,3 +10,36 @@ using Aqua Aqua.detect_ambiguities(ClimaDiagnostics; recursive = true) Aqua.test_piracies(ClimaDiagnostics) end + +@testset "Explicit Imports" begin + @test isnothing(ExplicitImports.check_no_implicit_imports(ClimaDiagnostics)) + + # We import some variables to bring them to the top level, so that they are + # easier to use in user packages. These are technically stale imports, so we + # have to ignore them + + ignore = ( + :DiagnosticVariable, + :DivisorSchedule, + :ScheduledDiagnostic, + :average_pre_output_hook!, + ) + @test isnothing( + ExplicitImports.check_no_stale_explicit_imports( + ClimaDiagnostics; + ignore, + ), + ) + + # ClimaCore idiosyncrasies + ignore = (:HDF5, :topology, :vertical_topology) + @test isnothing( + ExplicitImports.check_all_qualified_accesses_via_owners( + ClimaDiagnostics; + ignore, + ), + ) + @test isnothing( + ExplicitImports.check_no_self_qualified_accesses(ClimaDiagnostics), + ) +end