diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 03b99f97..cc000fe9 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -34,16 +34,10 @@ jobs: - '1.12-nightly' - '1.11' - '1.10' - - '1.9' - - '1.8' - - '1.7' - - '1.6' - 'nightly' include: - os: windows-latest julia-version: '1' - - os: windows-latest - julia-version: '1.6' - os: windows-latest julia-version: '1.12-nightly' - os: windows-latest diff --git a/CHANGELOG.md b/CHANGELOG.md index a9d083e4..445d5837 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Changed - The minimum supported julia version is increased to 1.6. ([#328]) +- Explicit imports are tested using ExplicitImports.jl ([#369]) ## Version [v0.8.14] - 2025-08-04 @@ -76,7 +77,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Use [Changelog.jl](https://github.com/JuliaDocs/Changelog.jl) to generate the changelog, and add it to the documentation. ([#277], [#279]) - `test_project_extras` prints failures the same on all julia versions. In particular, 1.11 and nightly are no outliers. ([#275]) - ## Version [v0.8.4] - 2023-12-01 ### Added diff --git a/Project.toml b/Project.toml index 03808671..9f5a9b6e 100644 --- a/Project.toml +++ b/Project.toml @@ -4,13 +4,17 @@ authors = ["Takafumi Arakaki and contributors"] version = "1.0.0-DEV" [deps] +ExplicitImports = "7d51a73a-1435-4ff3-83d9-f097790105c7" Pkg = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f" +TOML = "fa267f1f-6049-4f14-aa54-33bafae1ed76" Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" [compat] +ExplicitImports = "1.15.0" Pkg = "1.6" +TOML = "1.0.3" Test = "<0.0.1, 1" -julia = "1.6" +julia = "1.10" [extras] Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" diff --git a/docs/Project.toml b/docs/Project.toml index 842889d9..0167afda 100644 --- a/docs/Project.toml +++ b/docs/Project.toml @@ -1,7 +1,9 @@ [deps] Changelog = "5217a498-cd5d-4ec6-b8c2-9b85a09b6e3e" Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4" +DocumenterInterLinks = "d12716ef-a0f6-4df4-a9f1-a5a34e75c656" [compat] Changelog = "1" Documenter = "1" +DocumenterInterLinks = "1.1.0" diff --git a/docs/make.jl b/docs/make.jl index d681a5d0..ed6671bb 100644 --- a/docs/make.jl +++ b/docs/make.jl @@ -1,4 +1,5 @@ using Documenter, Aqua, Changelog +using DocumenterInterLinks: InterLinks # Generate a Documenter-friendly changelog from CHANGELOG.md Changelog.generate( @@ -8,6 +9,10 @@ Changelog.generate( repo = "JuliaTesting/Aqua.jl", ) +links = InterLinks( + "ExplicitImports" => "https://juliatesting.github.io/ExplicitImports.jl/stable/", +) + makedocs(; sitename = "Aqua.jl", format = Documenter.HTML(; @@ -30,9 +35,11 @@ makedocs(; "piracies.md", "persistent_tasks.md", "undocumented_names.md", + "explicit_imports.md", ], "release-notes.md", ], + plugins = [links], ) deploydocs(; repo = "github.com/JuliaTesting/Aqua.jl", push_preview = true) diff --git a/docs/src/explicit_imports.md b/docs/src/explicit_imports.md new file mode 100644 index 00000000..776dc6c8 --- /dev/null +++ b/docs/src/explicit_imports.md @@ -0,0 +1,7 @@ +# Explicit imports + +## [Test function](@id test_explicit_imports) + +```@docs +Aqua.test_explicit_imports +``` diff --git a/src/Aqua.jl b/src/Aqua.jl index acc33a39..1bdea6b6 100644 --- a/src/Aqua.jl +++ b/src/Aqua.jl @@ -1,10 +1,13 @@ module Aqua using Base: Docs, PkgId, UUID -using Pkg: Pkg, TOML, PackageSpec -using Pkg.Types: VersionSpec, semver_spec -using Test +using Pkg: Pkg, PackageSpec +using Pkg.Types: VersionSpec +using Pkg.Versions: semver_spec +using Test: Test, @test, @test_broken, @testset, detect_ambiguities +using TOML: TOML +using ExplicitImports: ExplicitImports include("utils.jl") include("ambiguities.jl") @@ -16,6 +19,7 @@ include("deps_compat.jl") include("piracies.jl") include("persistent_tasks.jl") include("undocumented_names.jl") +include("explicit_imports.jl") """ test_all(testtarget::Module) @@ -31,6 +35,7 @@ Run the following tests on the module `testtarget`: * [`test_piracies(testtarget)`](@ref test_piracies) * [`test_persistent_tasks(testtarget)`](@ref test_persistent_tasks) * [`test_undocumented_names(testtarget)`](@ref test_undocumented_names) +* [`test_explicit_imports(testtarget)`](@ref test_explicit_imports) The keyword argument `\$x` (e.g., `ambiguities`) can be used to control whether or not to run `test_\$x` (e.g., `test_ambiguities`). @@ -47,6 +52,7 @@ passed to `\$x` to specify the keyword arguments for `test_\$x`. - `piracies = true` - `persistent_tasks = true` - `undocumented_names = false` +- `explicit_imports = true` """ function test_all( testtarget::Module; @@ -59,6 +65,7 @@ function test_all( piracies = true, persistent_tasks = true, undocumented_names = false, + explicit_imports = false, ) if ambiguities !== false @testset "Method ambiguity" begin @@ -108,6 +115,11 @@ function test_all( test_undocumented_names(testtarget; askwargs(undocumented_names)...) end end + if explicit_imports !== false + @testset "Explicit imports" begin + test_explicit_imports(testtarget; askwargs(explicit_imports)...) + end + end end end # module diff --git a/src/explicit_imports.jl b/src/explicit_imports.jl new file mode 100644 index 00000000..f1884fa4 --- /dev/null +++ b/src/explicit_imports.jl @@ -0,0 +1,13 @@ +""" + test_explicit_imports(m::Module; kwargs...) + +Run the various tests provided by the package [ExplicitImports.jl](https://github.com/ericphanson/ExplicitImports.jl). + +# Keyword Arguments + +Same as those of the function [`ExplicitImports.test_explicit_imports`](@extref). +""" +function test_explicit_imports(m::Module; kwargs...) + # TODO: explicitly list kwargs here? + ExplicitImports.test_explicit_imports(m; kwargs...) +end diff --git a/test/test_smoke.jl b/test/test_smoke.jl index 481cfe7e..bb379390 100644 --- a/test/test_smoke.jl +++ b/test/test_smoke.jl @@ -3,7 +3,57 @@ module TestSmoke using Aqua # test defaults -Aqua.test_all(Aqua) + +# TODO: fix instead of ignoring +private_explicit_imports_aqua = (:PkgId,) # Base +private_explicit_imports_aquapiracy = (:is_in_mods,) # Test +private_qualified_accesses_aqua = ( + :JLOptions, # Base + :PkgId, # Base + :SIGKILL, # Base + :error_color, # Base + :eval, # Base + :isbindingresolved, # Base + :isdeprecated, # Base + :julia_cmd, # Base + :kwcall, # Core + :kwftype, # Core + :load_path_setup_code, # Base + :morespecific, # Base + :require, # Base + :respect_sysimage_versions, # Pkg + :show_tuple_as_call, # Base + :unwrap_unionall, # Base, +) +private_qualified_accesses_aquapiracy = ( + :MethodTable, # Core + :TypeofVararg, # Core + :loaded_modules_array, # Base + :methodtable, # Core + :uniontypes, # Base + :visit, # Base +) + +explicit_imports_param_for_aqua = @static if VERSION < v"1.12" + false # some symbols were only made public in more recent versions of Julia, the list above is for 1.12 +else + (; + all_explicit_imports_are_public = (; + ignore = ( + private_explicit_imports_aqua..., + private_explicit_imports_aquapiracy..., + ) + ), + all_qualified_accesses_are_public = (; + ignore = ( + private_qualified_accesses_aqua..., + private_qualified_accesses_aquapiracy..., + ) + ), + ) +end + +Aqua.test_all(Aqua; explicit_imports = explicit_imports_param_for_aqua) # test everything else Aqua.test_all( @@ -16,6 +66,8 @@ Aqua.test_all( deps_compat = false, piracies = false, persistent_tasks = false, + undocumented_names = false, + explicit_imports = false, ) end # module