Skip to content

Commit

Permalink
use for loop and test_args
Browse files Browse the repository at this point in the history
  • Loading branch information
sunxd3 committed Mar 25, 2024
1 parent f57d767 commit 2021e12
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 52 deletions.
63 changes: 22 additions & 41 deletions .github/workflows/Tests.yml
Original file line number Diff line number Diff line change
@@ -1,18 +1,16 @@
name: Tests
name: Run tests

on:
push:
branches: ["master"]
paths:
- 'src/**/*'
- 'test/**/*'
pull_request:
paths:
- 'src/**/*'
- 'test/**/*'

workflow_dispatch:

permissions:
contents: read
actions: write

jobs:
test:
name: Julia ${{ matrix.version }} on ${{ matrix.os }} (${{ matrix.arch }})
Expand All @@ -32,15 +30,15 @@ jobs:
env:
CACHE_NAME: julia-${{ matrix.version }}-${{ matrix.arch }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Julia
uses: julia-actions/setup-julia@v1
- uses: actions/checkout@v4
name: Checkout
- uses: julia-actions/setup-julia@v1
name: Set up Julia
with:
version: ${{ matrix.version }}
arch: ${{ matrix.arch }}
- name: Cache Julia packages and artifacts
uses: actions/cache@v4
- uses: actions/cache@v4
name: Cache Julia packages and artifacts
with:
path: |
~/.julia
Expand All @@ -49,46 +47,29 @@ jobs:
restore-keys: |
${{ runner.os }}-${{ env.CACHE_NAME }}-
${{ runner.os }}-julia-${{ matrix.version }}-
- name: Build package
uses: julia-actions/julia-buildpkg@v1
- name: Running `unit` tests
uses: julia-actions/julia-runtest@v1
env:
TEST_GROUP: unit
- name: Running `parser` tests
uses: julia-actions/julia-runtest@v1
env:
TEST_GROUP: parser
- name: Running `analysis_passes` tests
uses: julia-actions/julia-runtest@v1
env:
TEST_GROUP: analysis_passes
- name: Running `compile_BUGS_examples` tests
uses: julia-actions/julia-runtest@v1
env:
TEST_GROUP: compile_BUGS_examples
- name: Running `corner_cases` tests
uses: julia-actions/julia-runtest@v1
env:
TEST_GROUP: corner_cases
- name: Running `graph` tests
uses: julia-actions/julia-runtest@v1
env:
TEST_GROUP: graph
- uses: julia-actions/julia-buildpkg@v1
name: Build package
- name: Run tests
run: |
groups=(unit parser analysis_passes compile_BUGS_examples corner_cases graph)
for group in "${groups[@]}"; do
julia --color=yes --project=. -e "import Pkg; Pkg.instantiate(); Pkg.test(coverage=true, test_args=[\"$group\"]);" || break
done
shell: bash
- name: Running `gibbs` tests
uses: nick-fields/retry@v3
with:
timeout_minutes: 10
max_attempts: 3
command: julia --project -e 'using Pkg; Pkg.instantiate(); Pkg.test(coverage=true)'
command: julia --project=. -e "import Pkg; Pkg.test(;coverage=true, test_args=[\"gibbs\"])"
env:
TEST_GROUP: gibbs
- name: Running `mcmchains` tests
uses: nick-fields/retry@v3
with:
timeout_minutes: 10
max_attempts: 3
command: julia --project -e 'using Pkg; Pkg.instantiate(); Pkg.test(coverage=true)'
command: julia --project=. -e "import Pkg; Pkg.test(;coverage=true, test_args=[\"mcmchains\"])"
env:
TEST_GROUP: mcmchains
- uses: julia-actions/julia-processcoverage@v1
Expand Down
26 changes: 15 additions & 11 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -32,25 +32,27 @@ using Test

AbstractMCMC.setprogress!(false)

const test_group = get(ENV, "TEST_GROUP", "run_all")

if test_group == "profile"
if "profile" in ARGS
include("profile.jl")
elseif test_group == "unit"
elseif "unit" in ARGS
@info "Running unit tests"
@testset "doctests" begin
DocMeta.setdocmeta!(JuliaBUGS, :DocTestSetup, :(using JuliaBUGS); recursive=true)
Documenter.doctest(JuliaBUGS; manual=false)
end
include("utils.jl")
elseif test_group == "parser"
elseif "parser" in ARGS
@info "Running parser tests"
@testset "Parser" begin
include("parser/bugs_macro.jl")
include("parser/bugs_parser.jl")
include("parser/winbugs_examples.jl")
end
elseif test_group == "analysis_passes"
elseif "analysis_passes" in ARGS
@info "Running analysis passes tests"
include("passes.jl")
elseif test_group == "compile_BUGS_examples"
elseif "compile_BUGS_examples" in ARGS
@info "Running BUGS examples tests"
@testset "BUGS examples volume 1" begin
@testset "$m" for m in keys(JuliaBUGS.BUGSExamples.VOLUME_1)
model_def = JuliaBUGS.BUGSExamples.VOLUME_1[m].model_def
Expand All @@ -59,17 +61,19 @@ elseif test_group == "compile_BUGS_examples"
model = compile(model_def, data, inits)
end
end
elseif test_group == "corner_cases"
elseif "corner_cases" in ARGS
@info "Running corner cases tests"
@testset "Some corner cases" begin
include("bugs_primitives.jl")
include("compile.jl")
include("cumulative_density.jl")
end
elseif test_group == "graph"
elseif "graph" in ARGS
@info "Running graph tests"
include("graphs.jl")
elseif test_group == "gibbs"
elseif "gibbs" in ARGS
include("gibbs.jl")
elseif test_group == "mcmchains"
elseif "mcmchains" in ARGS
include("ext/mcmchains.jl")
else # run all
include("profile.jl")
Expand Down

0 comments on commit 2021e12

Please sign in to comment.