diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 769a917bdf..3e31eb5856 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -1,11 +1,12 @@ -name: Test JuliaAstro +name: CI on: - push: - branches: [main] - pull_request: - schedule: - - cron: '15 2 * * *' # 2:15 AM UTC every day + workflow_call: + inputs: + test_args: + required: true + type: string + jobs: test: name: Julia ${{ matrix.version }} - ${{ matrix.os }} - ${{ matrix.arch }} - ${{ github.event_name }} @@ -32,4 +33,5 @@ jobs: - uses: julia-actions/julia-buildpkg@v1 - uses: julia-actions/julia-runtest@v1 with: - coverage: false + test_args: ${{ inputs.test_args }} + coverage: false diff --git a/.github/workflows/CI_dev.yml b/.github/workflows/CI_dev.yml new file mode 100644 index 0000000000..c2f2766df3 --- /dev/null +++ b/.github/workflows/CI_dev.yml @@ -0,0 +1,14 @@ +name: Test JuliaAstro (dev) + +on: + push: + branches: [main] + pull_request: + schedule: + - cron: '15 2 * * *' # 2:15 AM UTC every day + +jobs: + test-dev: + uses: ./.github/workflows/CI.yml + with: + test_args: "--verbose packages_dev" diff --git a/.github/workflows/CI_release.yml b/.github/workflows/CI_release.yml new file mode 100644 index 0000000000..8f61f2879b --- /dev/null +++ b/.github/workflows/CI_release.yml @@ -0,0 +1,14 @@ +name: Test JuliaAstro (release) + +on: + push: + branches: [main] + pull_request: + schedule: + - cron: '15 2 * * 1' # 2:15 AM UTC every Monday + +jobs: + test-release: + uses: ./.github/workflows/CI.yml + with: + test_args: "--verbose packages_release" diff --git a/Project.toml b/Project.toml index 40532d451f..648b4a7921 100644 --- a/Project.toml +++ b/Project.toml @@ -1,6 +1,9 @@ name = "JuliaAstroDocs" uuid = "5ba9df79-bc07-467f-bade-66a1d49082bd" +[workspace] +projects = ["test", "docs"] + [deps] TypedTables = "9d95f2ec-7b3d-5a63-8d20-e2491e220bb9" diff --git a/README.md b/README.md index f482920113..86435c6865 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,9 @@ JuliaAstro.github.io [![docs](https://img.shields.io/badge/docs-stable-blue.svg)](https://juliaastro.org/) [![Build](https://github.com/JuliaAstro/JuliaAstro.github.io/actions/workflows/Documentation.yml/badge.svg)](https://github.com/JuliaAstro/JuliaAstro.github.io/actions/workflows/Documentation.yml) [![Deploy](https://github.com/JuliaAstro/JuliaAstro.github.io/actions/workflows/pages/pages-build-deployment/badge.svg?branch=gh-pages)](https://github.com/JuliaAstro/JuliaAstro.github.io/actions/workflows/pages/pages-build-deployment) -[![Test JuliaAstro](https://github.com/JuliaAstro/JuliaAstro.github.io/actions/workflows/CI.yml/badge.svg)](https://github.com/JuliaAstro/JuliaAstro.github.io/actions/workflows/CI.yml) + +[![Test JuliaAstro (release)](https://github.com/JuliaAstro/JuliaAstro.github.io/actions/workflows/CI_release.yml/badge.svg)](https://github.com/JuliaAstro/JuliaAstro.github.io/actions/workflows/CI_release.yml) +[![Test JuliaAstro (dev)](https://github.com/JuliaAstro/JuliaAstro.github.io/actions/workflows/CI_dev.yml/badge.svg)](https://github.com/JuliaAstro/JuliaAstro.github.io/actions/workflows/CI_dev.yml) ## Description @@ -98,12 +100,14 @@ All in all, to add a new case study: 1. Update the content in the new file with your case study text. 1. Add an entry to `JuliaAstro.github.io/docs/case_studies//config.json` with your new case study filename. Note that trailing commas are not supported in the JSON spec. -## Testing locally / developer docs +## Developer docs + +### Documentation Add [LiveServer.jl](https://github.com/JuliaDocs/LiveServer.jl) to your global env and then run the following in the `JuliaAstro.github.io/` folder: ```julia-repl -> julia --proj=docs/ +julia --proj=docs/ julia> using LiveServer @@ -117,3 +121,24 @@ The `include_dirs` arg allows our internal Revise worklow to pick up changes in See our [Contributing page](https://juliaastro.org/home/#Contributing) for more. +### Testing + +Run all tests: + +```julia-repl +julia --proj + +julia> ] + +pkg> test +``` + +Run specific tests (currently `packages_release` and `packages_dev`): + +```julia-repl +julia --proj + +julia> import Pkg + +julia> Pkg.test("JuliaAstroDocs"; test_args=`--verbose packages_release`) # or packages_dev +``` diff --git a/docs/Project.toml b/docs/Project.toml index a6fddfbbd4..347ea9d614 100644 --- a/docs/Project.toml +++ b/docs/Project.toml @@ -8,7 +8,6 @@ MultiDocumenter = "87ed4bf0-c935-4a67-83c3-2a03bee4197c" Revise = "295af30f-e4ad-537b-8983-00126c2a3abe" [sources] -JuliaAstroDocs = {path = ".."} MultiDocumenter = {url = "https://github.com/JuliaComputing/MultiDocumenter.jl"} [compat] diff --git a/test/Project.toml b/test/Project.toml index f22fc7d1e1..c9bb6b454f 100644 --- a/test/Project.toml +++ b/test/Project.toml @@ -1,8 +1,6 @@ [deps] InteractiveUtils = "b77e0a4c-d291-57a0-90e8-8db25a27a240" JuliaAstroDocs = "5ba9df79-bc07-467f-bade-66a1d49082bd" +ParallelTestRunner = "d3525ed8-44d0-4b2c-a655-542cee43accc" Pkg = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f" Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" - -[sources] -JuliaAstroDocs = {path = ".."} diff --git a/test/_packages.jl b/test/_packages.jl new file mode 100644 index 0000000000..5cb761f182 --- /dev/null +++ b/test/_packages.jl @@ -0,0 +1,38 @@ +function test_packages(mode) + @testset "Compatibility - $(mode)" begin + for package in packages_juliaastro + p_name = package.name + @info string("Adding: ", p_name) + @testset "$(p_name)" begin + if mode == :release + if p_name == "Spectra.jl" + # TODO: Register + @test Pkg.add(url="https://github.com/JuliaAstro/Spectra.jl") == nothing + else + @test Pkg.add(chopsuffix(p_name, ".jl")) == nothing + end + elseif mode == :dev + @test Pkg.add(url=package.repo) == nothing + else + throw(ArgumentError("`mode` argument to `test_packages` must be either `:release` or `:dev`.")) + end + end + end + + @testset "Precompilation" begin + @test Pkg.precompile(; strict=true) == nothing + end + + @testset "Package loading" begin + for package in packages_juliaastro + p_name = package.name + @info string("Loading: ", p_name) + @testset "$(p_name)" begin + @test eval(quote + @time_imports using $(Symbol(chopsuffix(p_name, ".jl"))) + end) == nothing + end + end + end + end +end diff --git a/test/packages_dev.jl b/test/packages_dev.jl new file mode 100644 index 0000000000..798b11ee63 --- /dev/null +++ b/test/packages_dev.jl @@ -0,0 +1,3 @@ +include("_packages.jl") + +test_packages(:dev) diff --git a/test/packages_release.jl b/test/packages_release.jl new file mode 100644 index 0000000000..d1f52078b7 --- /dev/null +++ b/test/packages_release.jl @@ -0,0 +1,3 @@ +include("_packages.jl") + +test_packages(:release) diff --git a/test/runtests.jl b/test/runtests.jl index 2f55cba92e..7c6976a764 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -4,54 +4,27 @@ This file defines integration tests for the JuliaAstro package ecosystem. These are tests that confirm various packages can be installed and work together. =# -using Test, Pkg, InteractiveUtils - +using ParallelTestRunner: runtests, find_tests, parse_args import JuliaAstroDocs -ecosystem_t = JuliaAstroDocs.ecosystem_t() - -packages_juliaastro = filter(ecosystem_t) do package - occursin("juliaastro", lowercase(package.repo)) -end -unique!(p -> p.name, packages_juliaastro) -sort!(packages_juliaastro) - -@testset "JuliaAstro Package Evalauation" begin - @testset "Compatible versions exist" begin - ENV["JULIA_PKG_PRECOMPILE_AUTO"] = 0 - for package in packages_juliaastro - p_name = package.name - @testset "$(p_name)" begin - if p_name == "Spectra.jl" - @test Pkg.add(url="https://github.com/JuliaAstro/Spectra.jl") == nothing - else - @test Pkg.add(chopsuffix(p_name, ".jl")) == nothing - end - end - end - end +const init_code = quote + # Start by testing that we can install all packages + # Worry if they compile successfully after + ENV["JULIA_PKG_PRECOMPILE_AUTO"] = 0 - @testset "Development versions compatible" begin - # Start by testing that we can install all packages - # Worry if they compile successfully after - ENV["JULIA_PKG_PRECOMPILE_AUTO"] = 0 + import Pkg + using JuliaAstroDocs: ecosystem_t + using InteractiveUtils: @time_imports - for package in packages_juliaastro - @testset "$(package.name)" begin - @test Pkg.add(url=package.repo) == nothing - end - end + packages_juliaastro = filter(ecosystem_t()) do package + occursin("juliaastro", lowercase(package.repo)) end + unique!(p -> p.name, packages_juliaastro) + sort!(packages_juliaastro) +end - @testset "Precompilation" begin - @test Pkg.precompile(; strict=true) == nothing - end +args = parse_args(Base.ARGS) +testsuite = find_tests(@__DIR__) +delete!(testsuite, "_packages") - @testset "Package loading" begin - for package in packages_juliaastro - @test eval(quote - @time_imports using $(Symbol(chopsuffix(package.name, ".jl"))) - end) == nothing - end - end -end +runtests(JuliaAstroDocs, args; testsuite, init_code)