From c78ec37dd225bd4cea86191fc356ba3bcbd19a3c Mon Sep 17 00:00:00 2001 From: Anant Thazhemadam <47104651+thazhemadam@users.noreply.github.com> Date: Wed, 24 Apr 2024 02:08:01 +0530 Subject: [PATCH] ci: standardise workflows using SciML's reusable workflows (#289) * ci: update invalidations workflow to use centralised reusable workflow * ci: update format check workflow to use centralised reusable workflow * ci: standardize the tests workflow, using the reusable workflow * Standardize the tests workflow, using the reusab SciML tests workflow. * Rename the tests workflow to `Tests.yml`, instead of `CI.yml`, since it's more semantically correct and CI encompasses all the workflows that are run. * ci(Tests): remove the `exclude` block for the test matrix Since we don't test with Julia 1.6 anyways, remove the exclude block. Note: this was initially left in while the workflow was standardised to maintain status quo (with the previous version of the workflow). * Fix deprecations * Fix more deprecations --------- Co-authored-by: David Widmann --- .github/workflows/CI.yml | 82 ----------------------------- .github/workflows/FormatCheck.yml | 36 ++----------- .github/workflows/Invalidations.yml | 37 ++----------- .github/workflows/Tests.yml | 39 ++++++++++++++ test/interface/parameters.jl | 4 +- test/interface/unconstrained.jl | 10 ++-- 6 files changed, 53 insertions(+), 155 deletions(-) delete mode 100644 .github/workflows/CI.yml create mode 100644 .github/workflows/Tests.yml diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml deleted file mode 100644 index daf389b..0000000 --- a/.github/workflows/CI.yml +++ /dev/null @@ -1,82 +0,0 @@ -name: CI - -on: - push: - branches: - - master - pull_request: - -concurrency: - # Skip intermediate builds: always. - # Cancel intermediate builds: only if it is a pull request build. - group: ${{ github.workflow }}-${{ github.ref }} - cancel-in-progress: ${{ startsWith(github.ref, 'refs/pull/') }} - -jobs: - test: - continue-on-error: ${{ matrix.version == 'nightly' }} - runs-on: ${{ matrix.os }} - strategy: - fail-fast: false - matrix: - version: - - '1' - os: - - ubuntu-latest - arch: - - x64 - - x86 - group: - - Interface - - Integrators - - Regression - exclude: # test 32bit only with Julia 1 but not LTS - - version: '1.6' - arch: x86 - 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 }}- - - uses: julia-actions/julia-buildpkg@latest - - uses: julia-actions/julia-runtest@latest - with: - coverage: ${{ matrix.version == '1' && matrix.arch == 'x64' }} - env: - GROUP: ${{ matrix.group }} - - uses: julia-actions/julia-processcoverage@v1 - if: matrix.version == '1' && matrix.arch == 'x64' - - uses: codecov/codecov-action@v4 - if: matrix.version == '1' && matrix.arch == 'x64' - with: - file: lcov.info - token: ${{ secrets.CODECOV_TOKEN }} # required - fail_ci_if_error: true - - uses: coverallsapp/github-action@master - if: matrix.version == '1' && matrix.arch == 'x64' - with: - github-token: ${{ secrets.GITHUB_TOKEN }} - path-to-lcov: lcov.info - flag-name: group-${{ matrix.group }} # unique name for coverage report of each group - parallel: true - # combine coveralls coverage reports - finish: - needs: test - runs-on: ubuntu-latest - steps: - - name: Coveralls Finished - uses: coverallsapp/github-action@master - with: - github-token: ${{ secrets.GITHUB_TOKEN }} - parallel-finished: true diff --git a/.github/workflows/FormatCheck.yml b/.github/workflows/FormatCheck.yml index 0da7ebb..ce3eadc 100644 --- a/.github/workflows/FormatCheck.yml +++ b/.github/workflows/FormatCheck.yml @@ -1,4 +1,4 @@ -name: format-check +name: "Format Check" on: push: @@ -9,34 +9,6 @@ on: pull_request: jobs: - build: - runs-on: ${{ matrix.os }} - strategy: - matrix: - julia-version: [1] - julia-arch: [x64] - os: [ubuntu-latest] - steps: - - uses: julia-actions/setup-julia@latest - with: - version: ${{ matrix.julia-version }} - - - uses: actions/checkout@v4 - - name: Install JuliaFormatter and format - # This will use the latest version by default but you can set the version like so: - # - # julia -e 'using Pkg; Pkg.add(PackageSpec(name="JuliaFormatter", version="0.13.0"))' - run: | - julia -e 'using Pkg; Pkg.add(PackageSpec(name="JuliaFormatter"))' - julia -e 'using JuliaFormatter; format(".", verbose=true)' - - name: Format check - run: | - julia -e ' - out = Cmd(`git diff --name-only`) |> read |> String - if out == "" - exit(0) - else - @error "Some files have not been formatted !!!" - write(stdout, out) - exit(1) - end' + format-check: + name: "Format Check" + uses: "SciML/.github/.github/workflows/format-check.yml@v1" diff --git a/.github/workflows/Invalidations.yml b/.github/workflows/Invalidations.yml index 66c86a3..45fcabd 100644 --- a/.github/workflows/Invalidations.yml +++ b/.github/workflows/Invalidations.yml @@ -3,38 +3,7 @@ name: Invalidations on: pull_request: -concurrency: - # Skip intermediate builds: always. - # Cancel intermediate builds: always. - group: ${{ github.workflow }}-${{ github.ref }} - cancel-in-progress: true - jobs: - evaluate: - # Only run on PRs to the default branch. - # In the PR trigger above branches can be specified only explicitly whereas this check should work for master, main, or any other default branch - if: github.base_ref == github.event.repository.default_branch - runs-on: ubuntu-latest - steps: - - uses: julia-actions/setup-julia@v2 - with: - version: '1' - - uses: actions/checkout@v4 - - uses: julia-actions/julia-buildpkg@v1 - - uses: julia-actions/julia-invalidations@v1 - id: invs_pr - - - uses: actions/checkout@v4 - with: - ref: ${{ github.event.repository.default_branch }} - - uses: julia-actions/julia-buildpkg@v1 - - uses: julia-actions/julia-invalidations@v1 - id: invs_default - - - name: Report invalidation counts - run: | - echo "Invalidations on default branch: ${{ steps.invs_default.outputs.total }} (${{ steps.invs_default.outputs.deps }} via deps)" >> $GITHUB_STEP_SUMMARY - echo "This branch: ${{ steps.invs_pr.outputs.total }} (${{ steps.invs_pr.outputs.deps }} via deps)" >> $GITHUB_STEP_SUMMARY - - name: Check if the PR does increase number of invalidations - if: steps.invs_pr.outputs.total > steps.invs_default.outputs.total - run: exit 1 + evaluate-invalidations: + name: "Evaluate Invalidations" + uses: "SciML/.github/.github/workflows/invalidations.yml@v1" diff --git a/.github/workflows/Tests.yml b/.github/workflows/Tests.yml new file mode 100644 index 0000000..b8744e0 --- /dev/null +++ b/.github/workflows/Tests.yml @@ -0,0 +1,39 @@ +name: "Run Tests" + +on: + push: + branches: + - master + pull_request: + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: ${{ github.ref_name != github.event.repository.default_branch || github.ref != 'refs/tags/v*' }} + +jobs: + tests: + name: "Tests" + strategy: + fail-fast: false + matrix: + version: + - '1' + arch: + - x64 + - x86 + group: + - Interface + - Integrators + - Regression + include: + - coverage: false + - version: '1' + arch: x64 + coverage: true + uses: "SciML/.github/.github/workflows/tests.yml@v1" + with: + group: ${{ matrix.group }} + julia-version: '1' + julia-arch: ${{ matrix.arch }} + coverage: ${{ matrix.coverage }} + secrets: "inherit" diff --git a/test/interface/parameters.jl b/test/interface/parameters.jl index 68fee38..e23b7e6 100644 --- a/test/interface/parameters.jl +++ b/test/interface/parameters.jl @@ -24,12 +24,12 @@ h(p, t; idxs = nothing) = 0.1 sol1 = solve(prob, MethodOfSteps(Tsit5())) @test length(sol1) == 21 @test first(sol1(12))≈0.884 atol=1e-4 - @test first(sol1[end])≈1 atol=1e-5 + @test first(sol1.u[end])≈1 atol=1e-5 # solve problem with updated parameter prob.p[1] = 1.4 sol2 = solve(prob, MethodOfSteps(Tsit5())) @test length(sol2) == 47 @test first(sol2(12))≈1.125 atol=5e-4 - @test first(sol2[end])≈0.994 atol=2e-5 + @test first(sol2.u[end])≈0.994 atol=2e-5 end diff --git a/test/interface/unconstrained.jl b/test/interface/unconstrained.jl index ad10f04..0e3dca3 100644 --- a/test/interface/unconstrained.jl +++ b/test/interface/unconstrained.jl @@ -46,9 +46,9 @@ using Test sol4 = solve(prob, alg4; abstol = 1e-12, reltol = 1e-12) # relaxed tests to prevent floating point issues - @test abs(sol1[end] - sol2[end]) < 2.5e-8 - @test abs(sol1[end] - sol3[end]) < 3.7e-8 - @test abs(sol1[end] - sol4[end]) < 9.0e-11 # 9.0e-13 + @test abs(sol1.u[end] - sol2.u[end]) < 2.5e-8 + @test abs(sol1.u[end] - sol3.u[end]) < 3.7e-8 + @test abs(sol1.u[end] - sol4.u[end]) < 9.0e-11 # 9.0e-13 end end @@ -82,8 +82,8 @@ using Test sol4 = solve(prob, alg4; abstol = 1e-12, reltol = 1e-12) # relaxed tests to prevent floating point issues - @test abs(sol1[end] - sol3[end]) < 1.2e-13 # 1.2e-15 - @test abs(sol1[end] - sol4[end]) < 3.1e-13 # 3.1e-15 + @test abs(sol1.u[end] - sol3.u[end]) < 1.2e-13 # 1.2e-15 + @test abs(sol1.u[end] - sol4.u[end]) < 3.1e-13 # 3.1e-15 end end end