From 32b3bbe2eb1074d945fc5ebd725db4ebd28cb395 Mon Sep 17 00:00:00 2001 From: Yi-Te Huang Date: Mon, 8 Apr 2024 20:53:18 +0800 Subject: [PATCH 1/3] modify runtests and CI --- .github/workflows/CI-Code-Quality.yml | 54 ------------------- .../workflows/{CI-Core.yml => Runtests.yml} | 11 +++- Project.toml | 4 +- test/code-quality/Project.toml | 1 + test/code-quality/aqua.jl | 2 + test/code-quality/jet.jl | 2 + test/code-quality/runtests.jl | 15 ------ test/runtests.jl | 9 ++++ 8 files changed, 26 insertions(+), 72 deletions(-) delete mode 100644 .github/workflows/CI-Code-Quality.yml rename .github/workflows/{CI-Core.yml => Runtests.yml} (87%) delete mode 100644 test/code-quality/runtests.jl diff --git a/.github/workflows/CI-Code-Quality.yml b/.github/workflows/CI-Code-Quality.yml deleted file mode 100644 index 108d869d..00000000 --- a/.github/workflows/CI-Code-Quality.yml +++ /dev/null @@ -1,54 +0,0 @@ -name: Code Quality Tests - -on: - push: - branches: - - 'main' - paths-ignore: - - 'docs/**' - pull_request: - branches: - - 'main' - paths-ignore: - - 'docs/**' - types: - - opened - - reopened - - synchronize - - ready_for_review - -jobs: - test: - name: Julia ${{ matrix.version }} - ${{ matrix.os }} - ${{ matrix.arch }} ( ${{ matrix.group }} ) - runs-on: ${{ matrix.os }} - permissions: # needed to allow julia-actions/cache to delete old caches that it has created - actions: write - contents: read - if: ${{ !github.event.pull_request.draft }} - strategy: - fail-fast: false - matrix: - version: [1] - os: [ubuntu-latest] - arch: [x64] - group: ['Code Quality'] - - steps: - - uses: actions/checkout@v4 - - uses: julia-actions/setup-julia@v2 - with: - version: ${{ matrix.version }} - arch: ${{ matrix.arch }} - - uses: julia-actions/cache@v1 - # - uses: julia-actions/julia-buildpkg@v1 - - name: Create and set up the code-quality environment - run: | - julia --color=yes --project=test/code-quality -e ' - import Pkg - Pkg.develop(path=".") # Develop the QuantumToolbox package - Pkg.instantiate() - Pkg.precompile() - ' - - name: Run the code-quality tests - run: julia --color=yes --project=test/code-quality test/code-quality/runtests.jl - diff --git a/.github/workflows/CI-Core.yml b/.github/workflows/Runtests.yml similarity index 87% rename from .github/workflows/CI-Core.yml rename to .github/workflows/Runtests.yml index 566a94b7..4918a4db 100644 --- a/.github/workflows/CI-Core.yml +++ b/.github/workflows/Runtests.yml @@ -18,7 +18,7 @@ on: - ready_for_review jobs: - test: + tests: name: Julia ${{ matrix.version }} - ${{ matrix.os }} - ${{ matrix.arch }} ( ${{ matrix.group }} ) runs-on: ${{ matrix.os }} permissions: # needed to allow julia-actions/cache to delete old caches that it has created @@ -42,6 +42,13 @@ jobs: group: - Core + # for code quality tests + include: + - version: '1' + os: 'ubuntu-latest' + arch: 'x64' + group: 'Code-Quality' + steps: - uses: actions/checkout@v4 - uses: julia-actions/setup-julia@v2 @@ -60,4 +67,4 @@ jobs: with: files: lcov.info token: ${{ secrets.CODECOV_TOKEN }} - fail_ci_if_error: true + fail_ci_if_error: true \ No newline at end of file diff --git a/Project.toml b/Project.toml index def21200..08cf4043 100644 --- a/Project.toml +++ b/Project.toml @@ -28,6 +28,7 @@ LinearAlgebra = "<0.0.1, 1" LinearMaps = "3" LinearSolve = "2" OrdinaryDiffEq = "6" +Pkg = "<0.0.1, 1" Random = "<0.0.1, 1" Reexport = "1" SparseArrays = "<0.0.1, 1" @@ -36,7 +37,8 @@ Test = "<0.0.1, 1" julia = "1.7" [extras] +Pkg = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f" Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" [targets] -test = ["Test"] +test = ["Pkg", "Test"] diff --git a/test/code-quality/Project.toml b/test/code-quality/Project.toml index 94275ae3..26b4f8f1 100644 --- a/test/code-quality/Project.toml +++ b/test/code-quality/Project.toml @@ -1,3 +1,4 @@ [deps] Aqua = "4c88cf16-eb10-579e-8560-4a9242c79595" JET = "c3a54625-cd67-489e-a8e7-0a5a0ff4e31b" +QuantumToolbox = "6c2fb7c5-b903-41d2-bc5e-5a7c320b9fab" diff --git a/test/code-quality/aqua.jl b/test/code-quality/aqua.jl index b158c897..99637669 100644 --- a/test/code-quality/aqua.jl +++ b/test/code-quality/aqua.jl @@ -1,3 +1,5 @@ +using Aqua + @testset "Code quality (Aqua.jl)" begin Aqua.test_all(QuantumToolbox; ambiguities = false,) end \ No newline at end of file diff --git a/test/code-quality/jet.jl b/test/code-quality/jet.jl index 968f1533..b9c482c4 100644 --- a/test/code-quality/jet.jl +++ b/test/code-quality/jet.jl @@ -1,3 +1,5 @@ +using JET + @testset "Code quality (JET.jl)" begin JET.test_package(QuantumToolbox; target_defined_modules=true, ignore_missing_comparison=true) end \ No newline at end of file diff --git a/test/code-quality/runtests.jl b/test/code-quality/runtests.jl deleted file mode 100644 index fd4cfeb4..00000000 --- a/test/code-quality/runtests.jl +++ /dev/null @@ -1,15 +0,0 @@ -using Test -using QuantumToolbox -using Aqua -using JET - -const GROUP = get(ENV, "GROUP", "All") - -const testdir = dirname(@__FILE__) - -if (GROUP == "All") || (GROUP == "Code Quality") - using Aqua - using JET - include(joinpath(testdir, "aqua.jl")) - include(joinpath(testdir, "jet.jl")) -end \ No newline at end of file diff --git a/test/runtests.jl b/test/runtests.jl index c9f04673..01a1810f 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -1,4 +1,5 @@ using Test +using Pkg using QuantumToolbox const GROUP = get(ENV, "GROUP", "All") @@ -28,3 +29,11 @@ if (GROUP == "All") || (GROUP == "Core") include(joinpath(testdir, test)) end end + +if (GROUP == "All") || (GROUP == "Code-Quality") + Pkg.activate("code-quality") + Pkg.develop(PackageSpec(path = dirname(@__DIR__))) + Pkg.instantiate() + include(joinpath(testdir, "code-quality/aqua.jl")) + include(joinpath(testdir, "code-quality/jet.jl")) +end \ No newline at end of file From 4f26fd2df340facbb75482726211fc0462262ca5 Mon Sep 17 00:00:00 2001 From: Yi-Te Huang Date: Mon, 8 Apr 2024 21:05:03 +0800 Subject: [PATCH 2/3] fix typo --- .github/workflows/Runtests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/Runtests.yml b/.github/workflows/Runtests.yml index 4918a4db..147ef774 100644 --- a/.github/workflows/Runtests.yml +++ b/.github/workflows/Runtests.yml @@ -18,7 +18,7 @@ on: - ready_for_review jobs: - tests: + test: name: Julia ${{ matrix.version }} - ${{ matrix.os }} - ${{ matrix.arch }} ( ${{ matrix.group }} ) runs-on: ${{ matrix.os }} permissions: # needed to allow julia-actions/cache to delete old caches that it has created From 70dcdb7a4fa5572ddc0a7166d904a9e0f69db7cf Mon Sep 17 00:00:00 2001 From: Yi-Te Huang Date: Mon, 8 Apr 2024 23:27:13 +0800 Subject: [PATCH 3/3] use to add and --- test/{code-quality => }/aqua.jl | 0 test/code-quality/Project.toml | 4 ---- test/{code-quality => }/jet.jl | 0 test/runtests.jl | 8 +++----- 4 files changed, 3 insertions(+), 9 deletions(-) rename test/{code-quality => }/aqua.jl (100%) delete mode 100644 test/code-quality/Project.toml rename test/{code-quality => }/jet.jl (100%) diff --git a/test/code-quality/aqua.jl b/test/aqua.jl similarity index 100% rename from test/code-quality/aqua.jl rename to test/aqua.jl diff --git a/test/code-quality/Project.toml b/test/code-quality/Project.toml deleted file mode 100644 index 26b4f8f1..00000000 --- a/test/code-quality/Project.toml +++ /dev/null @@ -1,4 +0,0 @@ -[deps] -Aqua = "4c88cf16-eb10-579e-8560-4a9242c79595" -JET = "c3a54625-cd67-489e-a8e7-0a5a0ff4e31b" -QuantumToolbox = "6c2fb7c5-b903-41d2-bc5e-5a7c320b9fab" diff --git a/test/code-quality/jet.jl b/test/jet.jl similarity index 100% rename from test/code-quality/jet.jl rename to test/jet.jl diff --git a/test/runtests.jl b/test/runtests.jl index 01a1810f..f1637392 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -31,9 +31,7 @@ if (GROUP == "All") || (GROUP == "Core") end if (GROUP == "All") || (GROUP == "Code-Quality") - Pkg.activate("code-quality") - Pkg.develop(PackageSpec(path = dirname(@__DIR__))) - Pkg.instantiate() - include(joinpath(testdir, "code-quality/aqua.jl")) - include(joinpath(testdir, "code-quality/jet.jl")) + Pkg.add(["Aqua", "JET"]) + include(joinpath(testdir, "aqua.jl")) + include(joinpath(testdir, "jet.jl")) end \ No newline at end of file