Skip to content

Commit

Permalink
add tests and ci (#2)
Browse files Browse the repository at this point in the history
* add tests and ci

* julia 1.0 compat

* add badges to readme

---------

Co-authored-by: Christopher Doris <github.com/cjdoris>
  • Loading branch information
cjdoris authored Feb 17, 2024
1 parent eb15419 commit 8936f3e
Show file tree
Hide file tree
Showing 3 changed files with 130 additions and 0 deletions.
24 changes: 24 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: Run tests

on:
push:
branches:
- main
pull_request:

jobs:
test:
name: Test (julia ${{ matrix.julia-version }})
runs-on: ${{ matrix.os }}
strategy:
matrix:
julia-version: ['1.0', '1.6', '1']
julia-arch: [x64]
os: [ubuntu-latest]
steps:
- uses: actions/checkout@v4
- uses: julia-actions/setup-julia@v1
with:
version: ${{ matrix.julia-version }}
arch: ${{ matrix.julia-arch }}
- run: julia test/runtests.jl
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# julia-downgrade-compat

[![Project Status: Active – The project has reached a stable, usable state and is being actively developed.](https://www.repostatus.org/badges/latest/active.svg)](https://www.repostatus.org/#active)
[![Tests](https://github.com/julia-actions/julia-downgrade-compat/actions/workflows/tests.yml/badge.svg)](https://github.com/julia-actions/julia-downgrade-compat/actions/workflows/tests.yml)

**Easy-peasy checking of compat lower bounds in your Julia package.**

Did you set your compat entries a long time ago? Are you sure they are still accurate?
Expand Down
103 changes: 103 additions & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
using Test

downgrade_jl = joinpath(dirname(@__DIR__), "downgrade.jl")

specs = [
(
strict = "v0",
ignore = "Pkg0",
compats = [
("julia", "1.6", "1.6"),
("Pkg0", "1.2", "1.2"),
("Pkg1", "1", "~1.0.0"),
("Pkg2", "1.2", "~1.2.0"),
("Pkg3", "1.2.3", "~1.2.3"),
("Pkg4", "0", "=0.0.0"),
("Pkg5", "0.2", "=0.2.0"),
("Pkg6", "0.2.3", "=0.2.3"),
("Pkg7", "0.0.3", "=0.0.3"),
("Pkg8", "0.0.0", "=0.0.0"),
("Pkg9", "^1.2.3", "~1.2.3"),
("Pkg10", "~1.2.3", "~1.2.3"),
("Pkg11", "=1.2.3", "=1.2.3"),
("Pkg12", "^1, ~2, =3", "~1.0.0"),
("Pkg13_jll", "1.2.3", "~1.2.3"),
]
)
(
strict = "true",
ignore = "Pkg0",
compats = [
("julia", "1.6", "1.6"),
("Pkg0", "1.2", "1.2"),
("Pkg1", "1", "=1.0.0"),
("Pkg2", "1.2", "=1.2.0"),
("Pkg3", "1.2.3", "=1.2.3"),
("Pkg4", "0", "=0.0.0"),
("Pkg5", "0.2", "=0.2.0"),
("Pkg6", "0.2.3", "=0.2.3"),
("Pkg7", "0.0.3", "=0.0.3"),
("Pkg8", "0.0.0", "=0.0.0"),
("Pkg9", "^1.2.3", "=1.2.3"),
("Pkg10", "~1.2.3", "=1.2.3"),
("Pkg11", "=1.2.3", "=1.2.3"),
("Pkg12", "^1, ~2, =3", "=1.0.0"),
("Pkg13_jll", "1.2.3", "=1.2.3"),
]
)
(
strict = "false",
ignore = "Pkg0",
compats = [
("julia", "1.6", "1.6"),
("Pkg0", "1.2", "1.2"),
("Pkg1", "1", "~1.0.0"),
("Pkg2", "1.2", "~1.2.0"),
("Pkg3", "1.2.3", "~1.2.3"),
("Pkg4", "0", "~0.0.0"),
("Pkg5", "0.2", "~0.2.0"),
("Pkg6", "0.2.3", "~0.2.3"),
("Pkg7", "0.0.3", "~0.0.3"),
("Pkg8", "0.0.0", "~0.0.0"),
("Pkg9", "^1.2.3", "~1.2.3"),
("Pkg10", "~1.2.3", "~1.2.3"),
("Pkg11", "=1.2.3", "=1.2.3"),
("Pkg12", "^1, ~2, =3", "~1.0.0"),
("Pkg13_jll", "1.2.3", "~1.2.3"),
]
)
]

function make_toml(compats)
io = IOBuffer()
println(io, "name = \"MyProject\"")
println(io)
println(io, "[compat]")
for (pkg, compat) in compats
println(io, pkg, " = \"", compat, "\"")
end
println(io)
println(io, "# some comment")
String(take!(io))
end

function test_downgrade(; strict, ignore, compats, file)
@info "testing $strict $ignore $file"
mktempdir() do dir
cd(dir) do
toml1 = make_toml([(pkg, compat) for (pkg, compat, _) in compats])
toml2 = make_toml([(pkg, compat) for (pkg, _, compat) in compats])
write("Project.toml", toml1)
run(`$(Base.julia_cmd()) $downgrade_jl $ignore $strict`)
toml3 = read("Project.toml", String)
@test toml3 != toml1
@test toml3 == toml2
end
end
end

@testset "julia-downgrade-compat" begin
@testset "basic $(spec.strict) $(spec.ignore) $file" for spec in specs, file in ["Project.toml", "JuliaProject.toml"]
test_downgrade(; spec..., file=file)
end
end

0 comments on commit 8936f3e

Please sign in to comment.