Skip to content

Commit

Permalink
Add JET and ExplicitImports tests, update CI (#105)
Browse files Browse the repository at this point in the history
* Add more linting tests using JET, JuliaFormatter and ExplicitImports.jl

* Fix JET warning

* Fix explicit imports

* Skip tests on 1.6

* Run CI on `pre` and `lts`

* Update actions
  • Loading branch information
adrhill authored Sep 14, 2024
1 parent 35068f3 commit 332e6b6
Show file tree
Hide file tree
Showing 7 changed files with 63 additions and 17 deletions.
13 changes: 5 additions & 8 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,20 +17,17 @@ jobs:
fail-fast: false
matrix:
version:
- '1.6'
- 'lts'
- '1'
- 'nightly'
- 'pre'
os:
- ubuntu-latest
arch:
- x64
steps:
- uses: actions/checkout@v2
- uses: julia-actions/setup-julia@v1
- uses: actions/checkout@v4
- uses: julia-actions/setup-julia@v2
with:
version: ${{ matrix.version }}
arch: ${{ matrix.arch }}
- uses: actions/cache@v1
- uses: actions/cache@v2
env:
cache-name: cache-artifacts
with:
Expand Down
6 changes: 4 additions & 2 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,18 @@ version = "4.0.0-DEV"
[deps]
ColorQuantization = "652893fb-f6a0-4a00-a44a-7fb8fac69e01"
ColorSchemes = "35d6a980-a343-548e-a6ea-1d62b119f2f4"
ColorTypes = "3da002f7-5984-5a60-b8a6-cbb66c0b333f"
Colors = "5ae59095-9a9b-59fe-a467-6f913c188581"
ImageCore = "a09fc81d-aa75-5fe9-8630-4744c3626534"
IndirectArrays = "9b13fd28-a010-5f03-acff-a1bbcff69959"
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
UnicodeGraphics = "ebadf6b4-db70-5817-83da-4a19ad584e34"

[compat]
ColorQuantization = "0.1"
ColorSchemes = "3"
ColorTypes = "0.11"
Colors = "0.12"
ImageCore = "0.10"
IndirectArrays = "1"
Random = "1"
UnicodeGraphics = "0.2"
julia = "1.6"
5 changes: 2 additions & 3 deletions src/DitherPunk.jl
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
module DitherPunk

using Base: require_one_based_indexing
using Random: rand
using ImageCore.ColorTypes
using ImageCore.Colors: DifferenceMetric, colordiff, DE_2000, invert_srgb_compand
using ColorTypes: ColorTypes, AbstractGray, Color, Colorant, Gray, HSV, Lab, XYZ, gray
using Colors: DifferenceMetric, colordiff, DE_2000, invert_srgb_compand
using ImageCore: channelview, floattype, clamp01
using IndirectArrays: IndirectArray

Expand Down
2 changes: 1 addition & 1 deletion src/error_diffusion.jl
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ end
function ErrorDiffusion(inds, vals, ranges)
length(inds) != length(vals) &&
throw(ArgumentError("Lengths of filter indices and values don't match."))
return ErrorDiffusion{typeof(vals)}(inds, vals, ranges)
return ErrorDiffusion{typeof(vals),typeof(ranges)}(inds, vals, ranges)
end

function ErrorDiffusion(filter::AbstractMatrix, offset::Integer)
Expand Down
3 changes: 3 additions & 0 deletions test/Project.toml
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
[deps]
Aqua = "4c88cf16-eb10-579e-8560-4a9242c79595"
ColorSchemes = "35d6a980-a343-548e-a6ea-1d62b119f2f4"
ExplicitImports = "7d51a73a-1435-4ff3-83d9-f097790105c7"
ImageBase = "c817782e-172a-44cc-b673-b171935fbb9e"
ImageIO = "82e4d734-157c-48bb-816b-45c225c6df19"
ImageMagick = "6218d12a-5da1-5696-b52f-db25d2ecc6d1"
IndirectArrays = "9b13fd28-a010-5f03-acff-a1bbcff69959"
JET = "c3a54625-cd67-489e-a8e7-0a5a0ff4e31b"
JuliaFormatter = "98e50ef6-434e-11e9-1051-2b60c6c9e899"
OffsetArrays = "6fe1bfb0-de20-5000-8ca7-80f57d26f881"
ReferenceTests = "324d217c-45ce-50fc-942e-d289b448e8cf"
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
Expand Down
8 changes: 5 additions & 3 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@ using Test
using Aqua

@testset "DitherPunk.jl" begin
@testset "Aqua.jl" begin
@info "Running Aqua.jl's auto quality assurance tests. These might print warnings from dependencies."
Aqua.test_all(DitherPunk; ambiguities=false)
if VERSION >= v"1.10"
@testset verbose = true "Linting" begin
@info "Testing linting..."
include("test_linting.jl")
end
end
@testset "Utilities" begin
@info "Testing utilities..."
Expand Down
43 changes: 43 additions & 0 deletions test/test_linting.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
using DitherPunk
using Test

using JuliaFormatter: JuliaFormatter
using Aqua: Aqua
using JET: JET
using ExplicitImports: ExplicitImports

@testset "Code formatting" begin
@info "...with JuliaFormatter.jl"
@test JuliaFormatter.format(DitherPunk; verbose=false, overwrite=false)
end

@testset "Aqua tests" begin
@info "...with Aqua.jl – this might print warnings from dependencies."
Aqua.test_all(DitherPunk; ambiguities=false)
end

@testset "JET tests" begin
@info "...with JET.jl"
JET.test_package(DitherPunk; target_defined_modules=true)
end

@testset "ExplicitImports tests" begin
@info "...with ExplicitImports.jl"
@testset "Improper implicit imports" begin
@test ExplicitImports.check_no_implicit_imports(DitherPunk) === nothing
end
@testset "Improper explicit imports" begin
@test ExplicitImports.check_no_stale_explicit_imports(DitherPunk;) === nothing
@test ExplicitImports.check_all_explicit_imports_via_owners(DitherPunk) === nothing
# TODO: test in the future when `public` is more common
# @test ExplicitImports.check_all_explicit_imports_are_public(DitherPunk) === nothing
end
@testset "Improper qualified accesses" begin
@test ExplicitImports.check_all_qualified_accesses_via_owners(DitherPunk) ===
nothing
@test ExplicitImports.check_no_self_qualified_accesses(DitherPunk) === nothing
# TODO: test in the future when `public` is more common
@test ExplicitImports.check_all_qualified_accesses_are_public(DitherPunk) ===
nothing
end
end

0 comments on commit 332e6b6

Please sign in to comment.