From ec41b7565b045e84db02a4a53d46813dd516c069 Mon Sep 17 00:00:00 2001 From: Anant Thazhemadam <47104651+thazhemadam@users.noreply.github.com> Date: Fri, 6 Sep 2024 23:13:03 +0530 Subject: [PATCH] ci: update tests workflow to use centralised reusable workflow and auto-suggest format changes (#159) * ci: update tests workflow to use centralised reusable workflow * ci: remove `FormatCheck` workflow Remove the `FormatCheck` workflow, since code in the repository should always be compliant with the SciML style, thus eliminating the need for automated formatting PRs. * ci(format-check): automatically comment formatting suggestions on PRs * chore: rename to BACKEND_GROUP * revert: rename to BACKEND_GROUP * fix: fallback to GROUP * fix: fallback to GROUP * fix: typo --------- Co-authored-by: Avik Pal --- .github/workflows/CI.yml | 52 ------------------------------- .github/workflows/FormatCheck.yml | 2 +- .github/workflows/FormatPR.yml | 29 ----------------- .github/workflows/Tests.yml | 25 +++++++++++++++ test/runtests.jl | 2 +- test/shared_testsetup.jl | 2 +- 6 files changed, 28 insertions(+), 84 deletions(-) delete mode 100644 .github/workflows/CI.yml delete mode 100644 .github/workflows/FormatPR.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 ec04c117..00000000 --- a/.github/workflows/CI.yml +++ /dev/null @@ -1,52 +0,0 @@ -name: CI -on: - pull_request: - branches: - - main - paths-ignore: - - "docs/**" - push: - branches: - - main - paths-ignore: - - "docs/**" -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: - runs-on: ubuntu-latest - strategy: - fail-fast: false - matrix: - version: - - "1" - steps: - - uses: actions/checkout@v4 - - uses: julia-actions/setup-julia@v2 - with: - version: ${{ matrix.version }} - - 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@v1 - - uses: julia-actions/julia-runtest@v1 - env: - BACKEND_GROUP: "CPU" - - uses: julia-actions/julia-processcoverage@v1 - with: - directories: src,ext - - uses: codecov/codecov-action@v4 - with: - files: lcov.info - token: ${{ secrets.CODECOV_TOKEN }} - fail_ci_if_error: true diff --git a/.github/workflows/FormatCheck.yml b/.github/workflows/FormatCheck.yml index 7e46c8db..fe9c1280 100644 --- a/.github/workflows/FormatCheck.yml +++ b/.github/workflows/FormatCheck.yml @@ -10,4 +10,4 @@ on: jobs: format-check: name: "Format Check" - uses: "SciML/.github/.github/workflows/format-check.yml@v1" + uses: "SciML/.github/.github/workflows/format-suggestions-on-pr.yml@v1" diff --git a/.github/workflows/FormatPR.yml b/.github/workflows/FormatPR.yml deleted file mode 100644 index a09c193e..00000000 --- a/.github/workflows/FormatPR.yml +++ /dev/null @@ -1,29 +0,0 @@ -name: format-pr -on: - schedule: - - cron: '0 0 * * *' -jobs: - build: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - name: Install JuliaFormatter and format - run: | - julia -e 'using Pkg; Pkg.add(PackageSpec(name="JuliaFormatter"))' - julia -e 'using JuliaFormatter; format(".")' - # https://github.com/marketplace/actions/create-pull-request - # https://github.com/peter-evans/create-pull-request#reference-example - - name: Create Pull Request - id: cpr - uses: peter-evans/create-pull-request@v6 - with: - token: ${{ secrets.GITHUB_TOKEN }} - commit-message: Format .jl files - title: 'Automatic JuliaFormatter.jl run' - branch: auto-juliaformatter-pr - delete-branch: true - labels: formatting, automated pr, no changelog - - name: Check outputs - run: | - echo "Pull Request Number - ${{ steps.cpr.outputs.pull-request-number }}" - echo "Pull Request URL - ${{ steps.cpr.outputs.pull-request-url }}" diff --git a/.github/workflows/Tests.yml b/.github/workflows/Tests.yml new file mode 100644 index 00000000..80e81163 --- /dev/null +++ b/.github/workflows/Tests.yml @@ -0,0 +1,25 @@ +name: "Tests" + +on: + pull_request: + branches: + - main + paths-ignore: + - 'docs/**' + push: + branches: + - main + paths-ignore: + - 'docs/**' + +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" + uses: "SciML/.github/.github/workflows/tests.yml@v1" + with: + group: "CPU" + secrets: "inherit" diff --git a/test/runtests.jl b/test/runtests.jl index 6ac0ba52..33e1f2c1 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -2,7 +2,7 @@ using ReTestItems, Pkg, InteractiveUtils, Hwloc @info sprint(versioninfo) -const BACKEND_GROUP = lowercase(get(ENV, "BACKEND_GROUP", "all")) +const BACKEND_GROUP = lowercase(get(ENV, "BACKEND_GROUP", get(ENV, "GROUP", "all"))) const EXTRA_PKGS = String[] (BACKEND_GROUP == "all" || BACKEND_GROUP == "cuda") && push!(EXTRA_PKGS, "LuxCUDA") diff --git a/test/shared_testsetup.jl b/test/shared_testsetup.jl index 0ad266d2..18425967 100644 --- a/test/shared_testsetup.jl +++ b/test/shared_testsetup.jl @@ -6,7 +6,7 @@ using MLDataDevices, GPUArraysCore LuxTestUtils.jet_target_modules!(["DeepEquilibriumNetworks", "Lux", "LuxLib"]) -const BACKEND_GROUP = lowercase(get(ENV, "BACKEND_GROUP", "all")) +const BACKEND_GROUP = lowercase(get(ENV, "BACKEND_GROUP", get(ENV, "GROUP", "all"))) if BACKEND_GROUP == "all" || BACKEND_GROUP == "cuda" using LuxCUDA