Skip to content

Commit

Permalink
Improve CI (#166)
Browse files Browse the repository at this point in the history
Only substantial changes to the code is renaming `VOLUME_I` and
`VOLUME_II` to `VOLUME_1\2`.

Some test code are moved around. 
Test CI is factored into multiple smaller ones:
- `mcmcchains` and `gibbs` tests will be retried if error for max 3
times

---------

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
  • Loading branch information
sunxd3 and github-actions[bot] authored Mar 26, 2024
1 parent 4f4772a commit 964c651
Show file tree
Hide file tree
Showing 54 changed files with 225 additions and 352 deletions.
59 changes: 0 additions & 59 deletions .github/workflows/Benchmark.yml

This file was deleted.

45 changes: 45 additions & 0 deletions .github/workflows/CompatHelper.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: CompatHelper
on:
schedule:
- cron: 0 0 * * *
workflow_dispatch:
permissions:
contents: write
pull-requests: write
jobs:
CompatHelper:
runs-on: ubuntu-latest
steps:
- name: Check if Julia is already available in the PATH
id: julia_in_path
run: which julia
continue-on-error: true
- name: Install Julia, but only if it is not already available in the PATH
uses: julia-actions/setup-julia@v1
with:
version: '1'
arch: ${{ runner.arch }}
if: steps.julia_in_path.outcome != 'success'
- name: "Add the General registry via Git"
run: |
import Pkg
ENV["JULIA_PKG_SERVER"] = ""
Pkg.Registry.add("General")
shell: julia --color=yes {0}
- name: "Install CompatHelper"
run: |
import Pkg
name = "CompatHelper"
uuid = "aa819f21-2bde-4658-8897-bab36330d9b7"
version = "3"
Pkg.add(; name, uuid, version)
shell: julia --color=yes {0}
- name: "Run CompatHelper"
run: |
import CompatHelper
CompatHelper.main()
shell: julia --color=yes {0}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
COMPATHELPER_PRIV: ${{ secrets.DOCUMENTER_KEY }}
# COMPATHELPER_PRIV: ${{ secrets.COMPATHELPER_PRIV }}
76 changes: 51 additions & 25 deletions .github/workflows/Tests.yml
Original file line number Diff line number Diff line change
@@ -1,55 +1,81 @@
name: CI
name: Tests

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

workflow_dispatch:

jobs:
test:
name: Julia ${{ matrix.version }} - ${{ matrix.os }} - ${{ matrix.arch }}
name: Julia ${{ matrix.version }} on ${{ matrix.os }} (${{ matrix.arch }})
runs-on: ${{ matrix.os }}
continue-on-error: ${{ matrix.version == 'nightly' }}
strategy:
fail-fast: false
matrix:
version:
- '1'
- '1.9'
- 'nightly'
os:
- ubuntu-latest
- macOS-latest
- windows-latest
arch:
- x64
version: ['1', '1.9', 'nightly']
os: [ubuntu-latest, macOS-latest, windows-latest]
arch: [x64]
include:
- version: '1'
os: ubuntu-latest
arch: x64
coverage: true
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- uses: julia-actions/setup-julia@v1
with:
version: ${{ matrix.version }}
arch: ${{ matrix.arch }}
- uses: actions/cache@v1
env:
cache-name: cache-artifacts
- uses: actions/cache@v4
with:
path: ~/.julia/artifacts
key: ${{ runner.os }}-test-${{ env.cache-name }}-${{ hashFiles('**/Project.toml') }}
path: |
~/.julia
~/.julia/artifacts
key: ${{ runner.os }}-julia-${{ matrix.version }}-${{ matrix.arch }}-${{ hashFiles('**/Project.toml', '**/Manifest.toml') }}
restore-keys: |
${{ runner.os }}-test-${{ env.cache-name }}-
${{ runner.os }}-test-
${{ runner.os }}-
${{ runner.os }}-julia-${{ matrix.version }}-${{ matrix.arch }}-
${{ runner.os }}-julia-${{ matrix.version }}-
- uses: julia-actions/julia-buildpkg@v1
- uses: julia-actions/julia-runtest@v1
- name: Running elementary tests
uses: julia-actions/julia-runtest@v1
env:
TEST_GROUP: "elementary"
- name: Running compilation tests
uses: julia-actions/julia-runtest@v1
env:
TEST_GROUP: "compilation"
- name: Profile compiler passes
run: julia --color=yes --project=. -e "import Pkg; Pkg.instantiate(); Pkg.test(;coverage=true);" >> $GITHUB_STEP_SUMMARY
env:
TEST_GROUP: "profile"
- name: Running `gibbs` tests
uses: nick-fields/retry@v3
with:
timeout_minutes: 10
max_attempts: 3
command: julia --color=yes --project=. -e "import Pkg; Pkg.instantiate(); Pkg.test(coverage=true);"
env:
TEST_GROUP: "gibbs"
- name: Running `mcmchains` tests
uses: nick-fields/retry@v3
with:
timeout_minutes: 10
max_attempts: 3
command: julia --color=yes --project=. -e "import Pkg; Pkg.instantiate(); Pkg.test(coverage=true);"
env:
TEST_GROUP: "mcmchains"
- uses: julia-actions/julia-processcoverage@v1
if: matrix.coverage
- uses: codecov/codecov-action@v1
- uses: codecov/codecov-action@v4
if: matrix.coverage
with:
file: lcov.info
Expand Down
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name = "JuliaBUGS"
uuid = "ba9fb4c0-828e-4473-b6a1-cd2560fee5bf"
version = "0.5.1"
version = "0.5.2"

[deps]
AbstractMCMC = "80f14c24-f653-4e6a-9b94-39d6b0f70001"
Expand Down
2 changes: 1 addition & 1 deletion docs/src/example.md
Original file line number Diff line number Diff line change
Expand Up @@ -276,4 +276,4 @@ Note that the `init_params` argument is now a vector of initial parameters for e
Sometimes the progress logger can cause problems in distributed setting, so we can disable it by setting `progress = false`.

## More Examples
We have transcribed all the examples from the first volume of the BUGS Examples ([original](https://www.multibugs.org/examples/latest/VolumeI.html) and [transcribed](https://github.com/TuringLang/JuliaBUGS.jl/tree/master/src/BUGSExamples/Volume_I)). All programs and data are included, and can be compiled using the steps described in the tutorial above.
We have transcribed all the examples from the first volume of the BUGS Examples ([original](https://www.multibugs.org/examples/latest/VolumeI.html) and [transcribed](https://github.com/TuringLang/JuliaBUGS.jl/tree/master/src/BUGSExamples/VOLUME_1)). All programs and data are included, and can be compiled using the steps described in the tutorial above.
52 changes: 26 additions & 26 deletions src/BUGSExamples/BUGSExamples.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,38 +2,38 @@ module BUGSExamples

using JuliaBUGS: @bugs

include("Volume_I/Blocker.jl")
include("Volume_I/Bones.jl")
include("Volume_I/Dogs.jl")
include("Volume_I/Dyes.jl")
include("Volume_I/Epil.jl")
include("Volume_I/Equiv.jl")
include("Volume_I/Inhalers.jl")
include("Volume_I/Kidney.jl")
include("Volume_I/Leuk.jl")
include("Volume_I/LeukFr.jl")
include("Volume_I/LSAT.jl")
include("Volume_I/Magnesium.jl")
include("Volume_I/Mice.jl")
include("Volume_I/Oxford.jl")
include("Volume_I/Pumps.jl")
include("Volume_I/Rats.jl")
include("Volume_I/Salm.jl")
include("Volume_I/Seeds.jl")
include("Volume_I/Stacks.jl")
include("Volume_I/Surgical.jl")
include("Volume_1/Blocker.jl")
include("Volume_1/Bones.jl")
include("Volume_1/Dogs.jl")
include("Volume_1/Dyes.jl")
include("Volume_1/Epil.jl")
include("Volume_1/Equiv.jl")
include("Volume_1/Inhalers.jl")
include("Volume_1/Kidney.jl")
include("Volume_1/Leuk.jl")
include("Volume_1/LeukFr.jl")
include("Volume_1/LSAT.jl")
include("Volume_1/Magnesium.jl")
include("Volume_1/Mice.jl")
include("Volume_1/Oxford.jl")
include("Volume_1/Pumps.jl")
include("Volume_1/Rats.jl")
include("Volume_1/Salm.jl")
include("Volume_1/Seeds.jl")
include("Volume_1/Stacks.jl")
include("Volume_1/Surgical.jl")

include("Volume_II/BiRats.jl")
include("Volume_II/Eyes.jl")
include("Volume_2/BiRats.jl")
include("Volume_2/Eyes.jl")

const VOLUME_I = (
const VOLUME_1 = (
blockers=blockers,
bones=bones,
dogs=dogs,
dyes=dyes,
epil=epil,
equiv=equiv,
inhalers=inhalers,
# inhalers=inhalers,
kidney=kidney,
leuk=leuk,
leukfr=leukfr,
Expand All @@ -50,10 +50,10 @@ const VOLUME_I = (
surgical_realistic=surgical_realistic,
)

const VOLUME_II = (birats=birats, eyes=eyes)
const VOLUME_2 = (birats=birats, eyes=eyes)

function has_ground_truth(m::Symbol)
if m in union(keys(VOLUME_I), keys(VOLUME_II))
if m in union(keys(VOLUME_1), keys(VOLUME_2))
return haskey(getfield(BUGSExamples, m), :reference_results)
else
return false
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion src/compiler_pass.jl
Original file line number Diff line number Diff line change
Expand Up @@ -486,7 +486,7 @@ The function returns three values:
Array elements and array variables are represented by tuples in the returned value. All `Colon` indexing is assumed to be concretized.
# Examples
```jldoctest
```jldoctest; setup = :(using JuliaBUGS: evaluate_and_track_dependencies)
julia> evaluate_and_track_dependencies(:(x[a]), (x=[missing, missing], a = missing))
(missing, (:a, (:x, 1:2)))
Expand Down
8 changes: 4 additions & 4 deletions src/utils.jl
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ end
Extract all the array variable names and number of dimensions from a given simple expression.
# Examples:
```jldoctest
```jldoctest; setup = :(using JuliaBUGS: extract_variable_names_and_numdims)
julia> extract_variable_names_and_numdims(:((a + b) * c), ())
(a = 0, b = 0, c = 0)
Expand Down Expand Up @@ -154,7 +154,7 @@ will raise an error.
# Example:
```jldoctest
extract_variable_names_and_numdims(
JuliaBUGS.extract_variable_names_and_numdims(
@bugs begin
for i in 1:N
for j in 1:T
Expand Down Expand Up @@ -434,7 +434,7 @@ Replace all `Colon()`s in `expr` with the corresponding array size.
# Examples
```jldoctest
julia> concretize_colon_indexing(:(f(x[1, :])), (x = [1 2 3 4; 5 6 7 8; 9 10 11 12],))
julia> JuliaBUGS.concretize_colon_indexing(:(f(x[1, :])), (x = [1 2 3 4; 5 6 7 8; 9 10 11 12],))
:(f(x[1, 1:4]))
```
"""
Expand All @@ -460,7 +460,7 @@ This function evaluates expressions that consist solely of arithmetic operations
is specifically designed for scenarios such as calculating array indices or determining loop boundaries.
# Example:
```jldoctest
```jldoctest; setup = :(using JuliaBUGS: simple_arithmetic_eval)
julia> simple_arithmetic_eval((a = 1, b = [1, 2]), 1)
1
Expand Down
7 changes: 6 additions & 1 deletion test/gibbs.jl
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
using JuliaBUGS: MHFromPrior, Gibbs
using DynamicPPL: DynamicPPL

@testset "Simple gibbs" begin
model_def = @bugs begin
# Likelihood
Expand Down Expand Up @@ -32,7 +35,9 @@
:varinfo,
begin
vi = model.varinfo
SimpleVarInfo(DynamicPPL.values_as(vi, NamedTuple), vi.logp, vi.transformation)
DynamicPPL.SimpleVarInfo(
DynamicPPL.values_as(vi, NamedTuple), vi.logp, vi.transformation
)
end,
)

Expand Down
Loading

4 comments on commit 964c651

@sunxd3
Copy link
Member Author

@sunxd3 sunxd3 commented on 964c651 Mar 26, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/103662

Tip: Release Notes

Did you know you can add release notes too? Just add markdown formatted text underneath the comment after the text
"Release notes:" and it will be added to the registry PR, and if TagBot is installed it will also be added to the
release that TagBot creates. i.e.

@JuliaRegistrator register

Release notes:

## Breaking changes

- blah

To add them here just re-invoke and the PR will be updated.

Tagging

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v0.5.2 -m "<description of version>" 964c651f07767ec0f9aacedf87d3e3ba3d6afddf
git push origin v0.5.2

Also, note the warning: Version 0.5.2 skips over 0.5.1
This can be safely ignored. However, if you want to fix this you can do so. Call register() again after making the fix. This will update the Pull request.

@sunxd3
Copy link
Member Author

@sunxd3 sunxd3 commented on 964c651 Mar 26, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request updated: JuliaRegistries/General/103662

Tip: Release Notes

Did you know you can add release notes too? Just add markdown formatted text underneath the comment after the text
"Release notes:" and it will be added to the registry PR, and if TagBot is installed it will also be added to the
release that TagBot creates. i.e.

@JuliaRegistrator register

Release notes:

## Breaking changes

- blah

To add them here just re-invoke and the PR will be updated.

Tagging

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v0.5.2 -m "<description of version>" 964c651f07767ec0f9aacedf87d3e3ba3d6afddf
git push origin v0.5.2

Also, note the warning: Version 0.5.2 skips over 0.5.1
This can be safely ignored. However, if you want to fix this you can do so. Call register() again after making the fix. This will update the Pull request.

Please sign in to comment.