From 65f056c1f2db29e9a372cdd66b3490b633c4f7e9 Mon Sep 17 00:00:00 2001 From: David Widmann Date: Sat, 29 Jun 2024 00:06:58 +0200 Subject: [PATCH] Update CI: No nightly tests, improve macOS CI setup + use julia-actions/cache (#1863) * Test prereleases if available * Fix name? * Fix matrix * Fixes * Fix syntax * Another round of fixes * Remove prerelease CI * Better mac fix? * Fix typo * Fix failing tests on 1.11-beta (#1862) * Increase sample size when testing empirical moments of DiscreteNonParametric * Use StableRNGs for semicircle.jl to avoid breakage on 1.11-beta * Run CI on all PRs. Also CI for workflow_dispatch and merge_group * Update semicircle.jl Co-authored-by: David Widmann * Update locationscale.jl Co-authored-by: David Widmann * Update locationscale.jl Co-authored-by: David Widmann --------- Co-authored-by: David Widmann --------- Co-authored-by: Andreas Noack --- .github/workflows/CI.yml | 30 +++++++----------------- test/univariate/continuous/semicircle.jl | 6 ++--- test/univariate/locationscale.jl | 14 +++++------ 3 files changed, 18 insertions(+), 32 deletions(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 9d791e2056..3039dbfc98 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -2,12 +2,12 @@ name: CI on: pull_request: - branches: - - master push: branches: - master tags: '*' + workflow_dispatch: + merge_group: concurrency: # Skip intermediate builds: always. @@ -17,42 +17,27 @@ concurrency: jobs: test: - name: Julia ${{ matrix.version }} - ${{ matrix.os }} - ${{ matrix.arch }} - ${{ github.event_name }} + name: Julia ${{ matrix.version }} - ${{ matrix.os }} - ${{ github.event_name }} runs-on: ${{ matrix.os }} - continue-on-error: ${{ matrix.version == 'nightly' }} strategy: fail-fast: false matrix: version: - '1.3' - '1' - - 'nightly' os: - ubuntu-latest - macos-latest - windows-latest - arch: - - x64 - include: - - os: macOS-14 - arch: aarch64 - version: '1' steps: - uses: actions/checkout@v4 - uses: julia-actions/setup-julia@v2 with: version: ${{ matrix.version }} - arch: ${{ matrix.arch }} - - uses: actions/cache@v4 - env: - cache-name: cache-artifacts - with: - path: ~/.julia/artifacts - key: ${{ runner.os }}-test-${{ env.cache-name }}-${{ hashFiles('**/Project.toml') }} - restore-keys: | - ${{ runner.os }}-test-${{ env.cache-name }}- - ${{ runner.os }}-test- - ${{ runner.os }}- + # ARM64 on macos-latest is neither supported by older Julia versions nor setup-julia + arch: ${{ matrix.os == 'macos-latest' && matrix.version != '1.3' && 'aarch64' || 'x64' }} + show-versioninfo: true + - uses: julia-actions/cache@v1 - uses: julia-actions/julia-buildpkg@v1 - uses: julia-actions/julia-runtest@v1 - run: | @@ -74,6 +59,7 @@ jobs: - uses: julia-actions/setup-julia@v2 with: version: '1' + show-versioninfo: true - run: | julia --project=docs -e ' using Pkg diff --git a/test/univariate/continuous/semicircle.jl b/test/univariate/continuous/semicircle.jl index 8dbf2ff2c4..7079aa9490 100644 --- a/test/univariate/continuous/semicircle.jl +++ b/test/univariate/continuous/semicircle.jl @@ -1,5 +1,5 @@ using Distributions -using Random: MersenneTwister +using StableRNGs using Test d = Semicircle(2.0) @@ -39,8 +39,8 @@ d = Semicircle(2.0) @test quantile(d, .5) == .0 @test quantile(d, 1.0) == +2.0 -rng = MersenneTwister(0) -for r in rand(rng, Uniform(0,10), 5) +rng = StableRNG(123) +@testset for r in rand(rng, Uniform(0,10), 5) N = 10^4 semi = Semicircle(r) sample = rand(rng, semi, N) diff --git a/test/univariate/locationscale.jl b/test/univariate/locationscale.jl index c4876e1970..5d5f9640b4 100644 --- a/test/univariate/locationscale.jl +++ b/test/univariate/locationscale.jl @@ -110,7 +110,7 @@ function test_location_scale( @test invlogccdf(dtest, log(0.5)) ≈ invlogccdf(dref, log(0.5)) @test invlogccdf(dtest, log(0.8)) ≈ invlogccdf(dref, log(0.8)) - r = Array{float(eltype(dtest))}(undef, 100000) + r = Array{float(eltype(dtest))}(undef, 200000) if ismissing(rng) rand!(dtest, r) else @@ -148,7 +148,7 @@ end rng = MersenneTwister(123) @testset "Normal" begin - for _rng in (missing, rng), sign in (1, -1) + @testset for _rng in (missing, rng), sign in (1, -1) test_location_scale_normal(_rng, 0.3, sign * 0.2, 0.1, 0.2) test_location_scale_normal(_rng, -0.3, sign * 0.1, -0.1, 0.3) test_location_scale_normal(_rng, 1.3, sign * 0.4, -0.1, 0.5) @@ -156,11 +156,11 @@ end test_location_scale_normal(rng, ForwardDiff.Dual(0.3), 0.2, 0.1, 0.2) end @testset "DiscreteNonParametric" begin - probs = normalize!(rand(10), 1) - for _rng in (missing, rng), sign in (1, -1) - test_location_scale_discretenonparametric(_rng, 1//3, sign * 1//2, 1:10, probs) - test_location_scale_discretenonparametric(_rng, -1//4, sign * 1//3, (-10):(-1), probs) - test_location_scale_discretenonparametric(_rng, 6//5, sign * 3//2, 15:24, probs) + _probs = normalize!(rand(10), 1) + @testset for _rng in (missing, rng), sign in (1, -1) + test_location_scale_discretenonparametric(_rng, 1//3, sign * 1//2, 1:10, _probs) + test_location_scale_discretenonparametric(_rng, -1//4, sign * 1//3, (-10):(-1), _probs) + test_location_scale_discretenonparametric(_rng, 6//5, sign * 3//2, 15:24, _probs) end end