diff --git a/.coverage/.gitignore b/.coverage/.gitignore deleted file mode 100644 index 498a960..0000000 --- a/.coverage/.gitignore +++ /dev/null @@ -1,5 +0,0 @@ -# SPDX-FileCopyrightText: © 2022 Michael Goerz -# -# SPDX-License-Identifier: MIT OR CC0-1.0 - -*.info diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index c125176..02038ea 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -14,68 +14,125 @@ on: pull_request: branches: - master + # Keep a warm `julia-actions/cache` entry on the default branch + schedule: + - cron: '0 4 * * 1,4' + workflow_dispatch: +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/') }} +permissions: + contents: read env: GKSwstype: 100 - JULIA_PKG_PRECOMPILE_AUTO: false + ENVCHECK_URL: https://raw.githubusercontent.com/JuliaQuantumControl/JuliaQuantumControl/refs/heads/master/scripts/envcheck.jl jobs: test: - name: Test ${{ matrix.title }} - runs-on: ${{ matrix.os }} + name: Test (Julia ${{ matrix.version }}) + runs-on: ubuntu-latest + timeout-minutes: 60 + permissions: + actions: write # for julia-actions/cache to delete the caches it created + contents: read strategy: fail-fast: false matrix: - include: - - title: 'Linux - Latest' - os: ubuntu-latest - version: '1' + version: + - '1' steps: - uses: actions/checkout@v7 - uses: julia-actions/setup-julia@v3 with: version: ${{ matrix.version }} - uses: julia-actions/cache@v3 - - name: "Instantiate test environment" - run: | - wget https://raw.githubusercontent.com/JuliaQuantumControl/JuliaQuantumControl/master/scripts/installorg.jl - julia --project=test installorg.jl --no-precompile - - name: "Run tests" - shell: julia --color=yes --project=test --code-coverage="@" --depwarn="yes" --check-bounds="yes" {0} + - name: "Check for unreleased sibling packages" run: | - include(joinpath(pwd(), "test", "runtests.jl")) - - name: "Run upstream GRAPE tests" - shell: julia --color=yes --project=test --code-coverage="@" --depwarn="yes" --check-bounds="yes" {0} - run: | - import GRAPE - include(pkgdir(GRAPE, "test", "runtests.jl")) + curl -fsSL -o "$RUNNER_TEMP/envcheck.jl" "$ENVCHECK_URL" + julia --startup-file=no "$RUNNER_TEMP/envcheck.jl" warn-sources test + - uses: julia-actions/julia-runtest@v1 + - name: "Check for held-back dependencies" + run: julia --startup-file=no "$RUNNER_TEMP/envcheck.jl" held-back test - uses: julia-actions/julia-processcoverage@v1 - name: "Summarize coverage" - run: julia --project=test -e 'using QuantumControlTestUtils; show_coverage();' + shell: julia --startup-file=no {0} + run: | + import Pkg + Pkg.activate(; temp = true) + Pkg.add(["CoverageTools", "LocalCoverage"]) + import CoverageTools + import LocalCoverage + coverage = CoverageTools.LCOV.readfile("lcov.info") + show(stdout, LocalCoverage.eval_coverage_metrics(coverage, pwd())) - uses: codecov/codecov-action@v7 with: files: lcov.info token: ${{ secrets.CODECOV_TOKEN }} + testoldest: + name: Test (oldest Julia, lowest compat bounds) + runs-on: ubuntu-latest + timeout-minutes: 60 + permissions: + actions: write # for julia-actions/cache to delete the caches it created + contents: read + steps: + - uses: actions/checkout@v7 + - uses: julia-actions/setup-julia@v3 + with: + version: 'min' + - uses: julia-actions/cache@v3 + - name: "Check for unreleased sibling packages" + run: | + curl -fsSL -o "$RUNNER_TEMP/envcheck.jl" "$ENVCHECK_URL" + julia --startup-file=no "$RUNNER_TEMP/envcheck.jl" warn-sources test + - name: "Resolve lowest compatible versions" + uses: julia-actions/julia-downgrade-compat@v2 + with: + projects: ".,test" + mode: "alldeps" + julia_version: "min" # must match the Julia version of the job + - name: "Instantiate test environment" + # Julia 1.10 ignores `[sources]`, so they are applied explicitly. The + # downgrade also floors the test-only dependencies (including sibling + # packages) to versions that may not be compatible with the package; + # pinning the dependencies of the package to their lowest versions + # re-resolves the remaining test dependencies. + run: | + cp test/Manifest.toml test/Manifest.lowest.toml + julia --startup-file=no "$RUNNER_TEMP/envcheck.jl" apply-sources test + julia --startup-file=no "$RUNNER_TEMP/envcheck.jl" pin-lowest test test/Manifest.lowest.toml + - name: "Run tests" + run: julia --color=yes --project=test --depwarn=yes --check-bounds=yes -e 'include("test/runtests.jl")' docs: name: Documentation runs-on: ubuntu-latest + timeout-minutes: 60 + permissions: + actions: write # for julia-actions/cache to delete the caches it created + contents: write # for Documenter to deploy to the `gh-pages` branch + statuses: write steps: - uses: actions/checkout@v7 - uses: julia-actions/setup-julia@v3 with: version: '1' - uses: julia-actions/cache@v3 - - run: | - # Install Python dependencies - set -x - /usr/bin/python3 -m pip install zip-files - - name: Instantiate Pkg + - name: "Check for unreleased sibling packages" run: | - wget https://raw.githubusercontent.com/JuliaQuantumControl/JuliaQuantumControl/master/scripts/installorg.jl - julia --project=docs installorg.jl - - name: Make documentations + curl -fsSL -o "$RUNNER_TEMP/envcheck.jl" "$ENVCHECK_URL" + julia --startup-file=no "$RUNNER_TEMP/envcheck.jl" warn-sources docs + - name: "Instantiate build environment" + run: julia --project=docs -e 'using Pkg; Pkg.instantiate()' + - name: "Build documentation" run: julia --project=docs docs/make.jl env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} DOCUMENTER_KEY: ${{ secrets.DOCUMENTER_KEY }} + - name: "Install Python dependencies" + run: | + set -x + /usr/bin/python3 -m pip install zip-files - name: Zip the HTML documentation run: zip-folder --debug --auto-root --outfile "docs.zip" docs/build - uses: actions/upload-artifact@v7 @@ -90,15 +147,20 @@ jobs: codestyle: name: Codestyle runs-on: ubuntu-latest + timeout-minutes: 20 + permissions: + actions: write # for julia-actions/cache to delete the caches it created + contents: read steps: - uses: actions/checkout@v7 - uses: julia-actions/setup-julia@v3 with: version: '1' + - uses: julia-actions/cache@v3 - name: Get typos settings run: wget https://raw.githubusercontent.com/JuliaQuantumControl/JuliaQuantumControl/master/typos.toml - name: Spell Check - uses: crate-ci/typos@master + uses: crate-ci/typos@v1.50.0 - name: Version Check shell: julia {0} run: | @@ -117,7 +179,9 @@ jobs: @error "Invalid version $VERSION on release branch" exit(1) end - elseif (ENV["GITHUB_REF_TYPE"] == "branch") && (BRANCH != "master") + elseif ENV["GITHUB_REF_TYPE"] == "branch" + # Any branch other than a release branch (master included) must + # carry a dev suffix; release versions live only on release-* branches. if ("dev" in VERSION.prerelease) || ("dev" in VERSION.build) println("Version $VERSION OK with dev-suffix on $BRANCH") else @@ -128,17 +192,12 @@ jobs: println("Version $VERSION OK on $BRANCH") end exit(0) - - name: Changelog Check - run: julia test/check_changelog.jl - - name: Get codestyle settings - run: wget https://raw.githubusercontent.com/JuliaQuantumControl/JuliaQuantumControl/master/.JuliaFormatter.toml - - name: Install JuliaFormatter and format - shell: julia {0} + - name: "Check [sources]" run: | - using Pkg - Pkg.add(PackageSpec(name="JuliaFormatter", version="2.3.0")) - using JuliaFormatter - format(".", verbose=true) + curl -fsSL -o "$RUNNER_TEMP/envcheck.jl" "$ENVCHECK_URL" + julia --startup-file=no "$RUNNER_TEMP/envcheck.jl" lint + - name: "Apply code style and check changelog" + run: make codestyle - name: Format Check shell: julia {0} run: | diff --git a/.github/workflows/GRAPE.yml b/.github/workflows/GRAPE.yml new file mode 100644 index 0000000..d5c8307 --- /dev/null +++ b/.github/workflows/GRAPE.yml @@ -0,0 +1,63 @@ +# SPDX-FileCopyrightText: © 2022 Michael Goerz +# +# SPDX-License-Identifier: MIT OR CC0-1.0 + +# Run the tests of the downstream GRAPE package (master branch) against the +# current QuantumGradientGenerators. This is informational: a failure indicates +# that GRAPE must be adapted, which does not necessarily block changes in +# QuantumGradientGenerators. +name: Test downstream GRAPE +on: + push: + branches: + - master + - dev + - 'release-*' + tags: + - '*' + pull_request: + branches: + - master + workflow_dispatch: +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: ${{ startsWith(github.ref, 'refs/pull/') }} +permissions: + contents: read +env: + GKSwstype: 100 +jobs: + test-grape: + name: Test GRAPE + runs-on: ubuntu-latest + timeout-minutes: 60 + continue-on-error: true + permissions: + actions: write # for julia-actions/cache to delete the caches it created + contents: read + steps: + - uses: actions/checkout@v7 + with: + path: QuantumGradientGenerators.jl + - uses: actions/checkout@v7 + with: + repository: JuliaQuantumControl/GRAPE.jl + path: GRAPE.jl + - uses: julia-actions/setup-julia@v3 + with: + # Requires Julia >= 1.13: `Pkg.develop` fails on earlier versions if + # the GRAPE test environment has a URL `[sources]` entry for + # QuantumGradientGenerators + version: '1' + - uses: julia-actions/cache@v3 + - name: "Instantiate GRAPE test environment with the current QuantumGradientGenerators" + working-directory: GRAPE.jl + shell: julia --color=yes --project=test {0} + run: | + import Pkg + Pkg.develop(path = joinpath("..", "QuantumGradientGenerators.jl")) + Pkg.instantiate() + Pkg.status() + - name: "Run GRAPE tests" + working-directory: GRAPE.jl + run: julia --color=yes --project=test --depwarn=yes --check-bounds=yes -e 'include("test/runtests.jl")' diff --git a/.gitignore b/.gitignore index fba114e..3b2ae44 100644 --- a/.gitignore +++ b/.gitignore @@ -4,9 +4,11 @@ *.jl.*.cov *.jl.cov +*.jl.*.mem *.jl.mem +/lcov.info Manifest.toml /docs/build/ +/coverage/ /gh-pages/ /.JuliaFormatter.toml -/lcov.info diff --git a/CHANGELOG.md b/CHANGELOG.md index 0436e83..73b7d64 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,6 +15,7 @@ Also see the [GitHub Releases](https://github.com/JuliaQuantumControl/QuantumGra * Fixed: `eachindex` is now defined for a `GradVector` that supports the vector interface. This is required for propagation with ExponentialUtilities ≥ 1.34 * Changed: The minimum supported Julia version is now 1.10 (LTS) +* Fixed: The lower compat bound for `QuantumControl` is now 0.11.4. Earlier versions of `QuantumControl` allow `QuantumPropagators` < 0.9, which lacks `supports_matrix_interface` ## [v0.1.9] — 2026-06-20 diff --git a/Makefile b/Makefile index 76e75b0..950304c 100644 --- a/Makefile +++ b/Makefile @@ -2,11 +2,15 @@ # # SPDX-License-Identifier: MIT OR CC0-1.0 -.PHONY: help test docs clean distclean devrepl codestyle check-changelog changelog servedocs reuse +.PHONY: help test coverage htmlcoverage docs devrepl codestyle check-changelog changelog reuse clean distclean .DEFAULT_GOAL := help JULIA ?= julia -PORT ?= 8000 + +# The version of JuliaFormatter that the CI code style check uses +JULIAFORMATTER_VERSION := 2.3.0 + +ORG_URL := https://raw.githubusercontent.com/JuliaQuantumControl/JuliaQuantumControl/refs/heads/master define PRINT_HELP_JLSCRIPT rx = r"^([a-z0-9A-Z_-]+):.*?##[ ]+(.*)$$" @@ -20,60 +24,179 @@ end endef export PRINT_HELP_JLSCRIPT +# Instantiate the environment given as the first argument +define INSTANTIATE_JLSCRIPT +import Pkg +env = ARGS[1] +if VERSION < v"1.11" + # Julia 1.10 ignores `[sources]`, see CONTRIBUTING.md + envcheck = joinpath("..", "scripts", "envcheck.jl") + isfile(envcheck) || error( + "On Julia $$VERSION, instantiating the `$$env` environment requires ../scripts/envcheck.jl from the JuliaQuantumControl development environment. See CONTRIBUTING.md." + ) + run(`$$(Base.julia_cmd()) --startup-file=no $$envcheck apply-sources $$env`) +end +Pkg.activate(env) +Pkg.resolve() +Pkg.instantiate() +endef +export INSTANTIATE_JLSCRIPT + +# Write lcov.info from the .cov files of a test run and show a summary. The +# coverage tools run in a temporary environment, so that they cannot restrict +# the versions of any package in the test environment. +define COVERAGE_JLSCRIPT +import Pkg +Pkg.activate(; temp = true, io = devnull) +Pkg.add(["CoverageTools", "LocalCoverage"]; io = devnull) +import CoverageTools +import LocalCoverage +folders = filter(isdir, ["src", "ext"]) +coverage = reduce(vcat, [CoverageTools.process_folder(folder) for folder in folders]) +CoverageTools.LCOV.writefile("lcov.info", coverage) +show(stdout, LocalCoverage.eval_coverage_metrics(coverage, pwd())) +println() +endef +export COVERAGE_JLSCRIPT + +# Format all files with the JuliaFormatter version given as the first argument, +# in a temporary environment +define CODESTYLE_JLSCRIPT +import Pkg +Pkg.activate(; temp = true, io = devnull) +Pkg.add(Pkg.PackageSpec(; name = "JuliaFormatter", version = ARGS[1]); io = devnull) +import JuliaFormatter +JuliaFormatter.format("."; verbose = true) +endef +export CODESTYLE_JLSCRIPT + +# Initialize the development REPL. The `docs` environment is stacked after the +# active `test` environment, and before the global environment that provides +# Revise. See CONTRIBUTING.md. +define DEVREPL_JLSCRIPT +insert!(LOAD_PATH, 2, abspath("docs")) +ENV["DOCUMENTER_CHECK_LINKS"] = "0" +import TOML +let + # Report packages that are in more than one of the stacked environments with + # different versions: only one of these versions can be loaded. For the + # global environment, only Revise and its dependencies are relevant. + function manifest_entries(env; roots = nothing) + entries = Dict{String,Tuple{String,String}}() + project_file = Base.env_project_file(env) + (project_file isa String) || return entries + manifest_file = Base.project_file_manifest_path(project_file) + (isnothing(manifest_file) || !isfile(manifest_file)) && return entries + deps = get(TOML.parsefile(manifest_file), "deps", Dict()) + names = isnothing(roots) ? Set(keys(deps)) : Set{String}() + todo = isnothing(roots) ? String[] : filter(in(keys(deps)), roots) + while !isempty(todo) + name = pop!(todo) + (name in names) && continue + push!(names, name) + for info in deps[name] + depnames = get(info, "deps", String[]) + (depnames isa AbstractDict) && (depnames = collect(keys(depnames))) + append!(todo, filter(in(keys(deps)), depnames)) + end + end + for name in names + for info in deps[name] + id = get(info, "git-tree-sha1", get(info, "path", "")) + entries[info["uuid"]] = (name, "$$(get(info, "version", "")) $$id") + end + end + return entries + end + entries = [ + "test" => manifest_entries("test"), + "docs" => manifest_entries("docs"), + "global" => manifest_entries(Base.load_path_expand("@v#.#"); roots = ["Revise"]), + ] + mismatches = String[] + for uuid in union([keys(e) for (_, e) in entries]...) + found = [(label, e[uuid]) for (label, e) in entries if haskey(e, uuid)] + length(unique([version for (_, (_, version)) in found])) > 1 || continue + name = found[1][2][1] + versions = join(["$$label: $$(split(version)[1])" for (label, (_, version)) in found], ", ") + push!(mismatches, "* $$name ($$versions)") + end + if !isempty(mismatches) + @warn "Packages with different versions in the stacked test/docs/global environments. Tests or docs in this REPL may not run against the same versions as `make test` or `make docs`. For exact results, use `julia --project=test` or `julia --project=docs`.\n$$(join(sort(mismatches), "\n"))" + end +end +try + @eval using Revise +catch + @warn "Revise is not available. Install it in your global environment." +end +println(""" +**Development REPL for $$(TOML.parsefile("Project.toml")["name"])** -help: ## show this help - @julia -e "$$PRINT_HELP_JLSCRIPT" < $(MAKEFILE_LIST) - +* `include("test/runtests.jl")` – Run the test suite +* `include("test/.jl")` – Run an individual test file +* `include("docs/make.jl")` – Build the documentation (without checking links) +""") +endef +export DEVREPL_JLSCRIPT -test: test/Manifest.toml ## Run the test suite - $(JULIA) --project=test --banner=no --startup-file=yes -e 'include("devrepl.jl"); test()' - @echo "Done. Consider using 'make devrepl'" +help: ## Show this help + @if [ -f .git-blame-ignore-revs ]; then git config --local blame.ignoreRevsFile .git-blame-ignore-revs; fi + @$(JULIA) --startup-file=no -e "$$PRINT_HELP_JLSCRIPT" < $(MAKEFILE_LIST) -test/Manifest.toml: test/Project.toml ../scripts/installorg.jl - $(JULIA) --project=test ../scripts/installorg.jl +test/Manifest.toml: test/Project.toml + @if [ -f .git-blame-ignore-revs ]; then git config --local blame.ignoreRevsFile .git-blame-ignore-revs; fi + $(JULIA) --startup-file=no -e "$$INSTANTIATE_JLSCRIPT" test @touch $@ +docs/Manifest.toml: docs/Project.toml + $(JULIA) --startup-file=no -e "$$INSTANTIATE_JLSCRIPT" docs + @touch $@ -devrepl: ## Start an interactive REPL for testing and building documentation - $(JULIA) --project=test --banner=no --startup-file=yes -i devrepl.jl +# `make test` and `make coverage` put only the `test` environment on the LOAD_PATH +# (like `Pkg.test` on CI), so that a dependency missing from test/Project.toml is +# an error +test: test/Manifest.toml ## Run the test suite + JULIA_LOAD_PATH="@" $(JULIA) --project=test --startup-file=no --check-bounds=yes --depwarn=yes -e 'include("test/runtests.jl")' +coverage: test/Manifest.toml ## Run the test suite with coverage, write lcov.info, and show a summary + @find . \( -name '*.jl.*.cov' -o -name '*.jl.cov' \) -type f -delete + JULIA_LOAD_PATH="@" $(JULIA) --project=test --startup-file=no --check-bounds=yes --depwarn=yes --code-coverage=@ -e 'include("test/runtests.jl")' + $(JULIA) --startup-file=no -e "$$COVERAGE_JLSCRIPT" -docs/Manifest.toml: docs/Project.toml ../scripts/installorg.jl - $(JULIA) --project=docs ../scripts/installorg.jl - @touch $@ +htmlcoverage: coverage ## Run the test suite with coverage and write an HTML report to ./coverage (requires genhtml) + genhtml -o coverage lcov.info -docs: docs/Manifest.toml ## Build the documentation +docs: docs/Manifest.toml ## Build the documentation $(JULIA) --project=docs docs/make.jl - @echo "Done. Consider using 'make devrepl'" - -servedocs: test/Manifest.toml ## Build (auto-rebuild) and serve documentation at PORT=8000 - $(JULIA) --project=test -e 'include("devrepl.jl"); servedocs(port=$(PORT), verbose=true)' -clean: ## Clean up build/doc/testing artifacts - $(JULIA) -e 'include("test/clean.jl"); clean()' +devrepl: test/Manifest.toml docs/Manifest.toml ## Start a REPL for running tests and building the documentation + $(JULIA) --project=test --banner=no -e "$$DEVREPL_JLSCRIPT" -i .JuliaFormatter.toml: @if [ -e ../.JuliaFormatter.toml ]; then \ ln -sf ../.JuliaFormatter.toml .JuliaFormatter.toml; \ echo "Linked to ../.JuliaFormatter.toml"; \ else \ - curl -fsSL -o .JuliaFormatter.toml https://raw.githubusercontent.com/JuliaQuantumControl/JuliaQuantumControl/refs/heads/master/.JuliaFormatter.toml; \ - echo "Downloaded .JuliaFormatter.toml from JuliaQuantumControl repository"; \ + curl -fsSL -o .JuliaFormatter.toml $(ORG_URL)/.JuliaFormatter.toml; \ + echo "Downloaded .JuliaFormatter.toml from $(ORG_URL)"; \ fi -codestyle: test/Manifest.toml .JuliaFormatter.toml ## Apply the codestyle to the entire project - $(JULIA) --project=test -e 'using JuliaFormatter; format(".", verbose=true)' - $(MAKE) check-changelog - @echo "Done. Consider using 'make devrepl'" +codestyle: .JuliaFormatter.toml ## Apply the code style, and check CHANGELOG.md and [sources] + $(JULIA) --startup-file=no -e "$$CODESTYLE_JLSCRIPT" $(JULIAFORMATTER_VERSION) + $(JULIA) --startup-file=no test/check_changelog.jl + @if [ -e ../scripts/envcheck.jl ]; then \ + $(JULIA) --startup-file=no ../scripts/envcheck.jl lint --no-remote; \ + fi -check-changelog: ## Validate the links in CHANGELOG.md - $(JULIA) test/check_changelog.jl +check-changelog: ## Validate the links in CHANGELOG.md (no network) + $(JULIA) --startup-file=no test/check_changelog.jl -changelog: ## Validate CHANGELOG.md and add any missing issue/PR link targets - $(JULIA) test/check_changelog.jl --fix +changelog: ## Validate CHANGELOG.md and add any missing issue/PR link targets + $(JULIA) --startup-file=no test/check_changelog.jl --fix -reuse: ## Check REUSE/SPDX licensing compliance (requires uv or pipx) +reuse: ## Check REUSE compliance (SPDX copyright and licensing information) @if command -v reuse >/dev/null 2>&1; then \ reuse lint; \ elif command -v uvx >/dev/null 2>&1; then \ @@ -81,9 +204,13 @@ reuse: ## Check REUSE/SPDX licensing compliance (requires uv or pipx) elif command -v pipx >/dev/null 2>&1; then \ pipx run reuse lint; \ else \ - echo "Please install 'reuse' (https://reuse.software), or 'uv'/'pipx'"; \ - exit 1; \ + echo "Error: 'reuse' is not installed (see https://reuse.software)"; exit 1; \ fi -distclean: clean ## Restore to a clean checkout state - $(JULIA) -e 'include("test/clean.jl"); clean(distclean=true)' +clean: ## Clean up build/doc/testing artifacts + find . \( -name '*.jl.*.cov' -o -name '*.jl.cov' -o -name '*.jl.*.mem' -o -name '*.jl.mem' \) -type f -delete + rm -f lcov.info + rm -rf coverage docs/build + +distclean: clean ## Restore to a clean checkout state + rm -f Manifest.toml test/Manifest.toml docs/Manifest.toml .JuliaFormatter.toml diff --git a/Project.toml b/Project.toml index 0872f54..043bc6c 100644 --- a/Project.toml +++ b/Project.toml @@ -18,7 +18,7 @@ QuantumGradientGeneratorsArrayInterfaceExt = "ArrayInterface" [compat] ArrayInterface = "7.0" LinearAlgebra = "1" -QuantumControl = ">=0.11.0" +QuantumControl = ">=0.11.4" Random = "1" SparseArrays = "1" julia = "1.10" diff --git a/devrepl.jl b/devrepl.jl deleted file mode 100644 index 31ade5b..0000000 --- a/devrepl.jl +++ /dev/null @@ -1,49 +0,0 @@ -# SPDX-FileCopyrightText: © 2022 Michael Goerz -# -# SPDX-License-Identifier: MIT OR CC0-1.0 - -# Source this script as e.g. -# -# include("PATH/TO/devrepl.jl") -# -# from *any* Julia REPL or run it as e.g. -# -# julia -i --banner=no PATH/TO/devrepl.jl -# -# from anywhere. This will change the current working directory and -# activate/initialize the correct Julia environment for you. -# -# You may also run this in vscode to initialize a development REPL -# -using Pkg -using Downloads: download - -cd(@__DIR__) -Pkg.activate("test") - -function _instantiate() - installorg_script = joinpath("..", "scripts", "installorg.jl") - if !isfile(installorg_script) - @warn "$(@__DIR__) should be inside the JuliaQuantumControl development environment. See https://github.com/JuliaQuantumControl/JuliaQuantumControl#readme" - installorg_script = download( - "https://raw.githubusercontent.com/JuliaQuantumControl/JuliaQuantumControl/master/scripts/installorg.jl", - ) - end - if !isfile(joinpath("..", ".JuliaFormatter.toml")) - download( - "https://raw.githubusercontent.com/JuliaQuantumControl/JuliaQuantumControl/master/.JuliaFormatter.toml", - ".JuliaFormatter.toml" - ) - end - include(installorg_script) - eval(:(installorg())) -end - -if !isfile(joinpath("test", "Manifest.toml")) - _instantiate() -end -include("test/init.jl") - -if abspath(PROGRAM_FILE) == @__FILE__ - help() -end diff --git a/docs/Project.toml b/docs/Project.toml index b6cdf7b..72bf35b 100644 --- a/docs/Project.toml +++ b/docs/Project.toml @@ -12,4 +12,4 @@ QuantumGradientGenerators = {path = ".."} [compat] Documenter = "1.4" DocumenterInterLinks = "1.1" -julia = "1.11" +julia = "1.10" diff --git a/test/Project.toml b/test/Project.toml index 03efed4..6633bc6 100644 --- a/test/Project.toml +++ b/test/Project.toml @@ -1,33 +1,18 @@ [deps] -Coverage = "a2441757-f6aa-5fb2-8edb-039e3f45d037" -Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4" -DocumenterCitations = "daee34ce-89f3-4625-b898-19384cb65244" -DocumenterInterLinks = "d12716ef-a0f6-4df4-a9f1-a5a34e75c656" -GRAPE = "6b52fcaf-80fe-489a-93e9-9f92080510be" -IOCapture = "b5f81e59-6552-4d32-b1f0-c071b021bf89" -JuliaFormatter = "98e50ef6-434e-11e9-1051-2b60c6c9e899" -Krotov = "b05dcdc7-62f6-4360-bf2c-0898bba419de" -LBFGSB = "5be7bae1-8223-5378-bac3-9e7378a2f6e6" -LineSearches = "d3d80556-e9d4-5f37-9878-2ab0fcc64255" LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e" -LiveServer = "16fef848-5104-11e9-1b77-fb7a48bbb589" -NLSolversBase = "d41bc354-129a-5804-8e4c-c37616107c6c" -LocalCoverage = "5f6e1e16-694c-5876-87ef-16b5274f298e" -Optim = "429524aa-4258-5aef-a3af-852621145aeb" -Plots = "91a5bcdd-55d7-5caf-9e0b-520d859cae80" QuantumControl = "8a270532-f23f-47a8-83a9-b33d10cad486" QuantumControlTestUtils = "d3fd27c9-1dfb-4e67-b0c0-90d0d87a1e48" QuantumGradientGenerators = "a563f35e-61db-434d-8c01-8b9e3ccdfd85" QuantumPropagators = "7bf12567-5742-4b91-a078-644e72a65fc1" SafeTestsets = "1bc83da4-3b8d-516f-aca4-4fe02f6d838f" -SparseArrays = "2f01184e-e22b-5df5-ae63-d93ebab69eaf" StableRNGs = "860ef19b-820b-49d6-a774-d7a799459cd3" StaticArrays = "90137ffa-7385-5640-81b9-e52037218182" Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" -UnicodePlots = "b8865327-cd53-5732-bb35-84acbb429228" Zygote = "e88e6eb3-aa80-5325-afca-941959d7151f" +[sources] +QuantumGradientGenerators = {path = ".."} + [compat] -Documenter = "1.1" -JuliaFormatter = "=2.3.0" +QuantumPropagators = "0.9" julia = "1.10" diff --git a/test/clean.jl b/test/clean.jl deleted file mode 100644 index f3472b5..0000000 --- a/test/clean.jl +++ /dev/null @@ -1,55 +0,0 @@ -# SPDX-FileCopyrightText: © 2022 Michael Goerz -# -# SPDX-License-Identifier: MIT - -""" - clean([distclean=false]) - -Clean up build/doc/testing artifacts. Restore to clean checkout state -(distclean) -""" -function clean(; distclean = false, _exit = true) - - _glob(folder, ending) = - [name for name in readdir(folder; join = true) if (name |> endswith(ending))] - _exists(name) = isfile(name) || isdir(name) - _push!(lst, name) = _exists(name) && push!(lst, name) - - ROOT = dirname(@__DIR__) - - ########################################################################### - CLEAN = String[] - for folder in [ROOT, joinpath(ROOT, "src"), joinpath(ROOT, "test")] - append!(CLEAN, _glob(folder, ".cov")) - end - _push!(CLEAN, joinpath(ROOT, "docs", "build")) - append!(CLEAN, _glob(ROOT, ".info")) - append!(CLEAN, _glob(joinpath(ROOT, ".coverage"), ".info")) - ########################################################################### - - ########################################################################### - DISTCLEAN = String[] - for folder in [ROOT, joinpath(ROOT, "docs"), joinpath(ROOT, "test")] - push!(DISTCLEAN, joinpath(folder, "Manifest.toml")) - end - _push!(DISTCLEAN, joinpath(ROOT, ".JuliaFormatter.toml")) - ########################################################################### - - for name in CLEAN - @info "rm $name" - rm(name, force = true, recursive = true) - end - if distclean - for name in DISTCLEAN - @info "rm $name" - rm(name, force = true, recursive = true) - end - if _exit - @info "Exiting" - exit(0) - end - end - -end - -distclean() = clean(distclean = true) diff --git a/test/init.jl b/test/init.jl deleted file mode 100644 index 56d359d..0000000 --- a/test/init.jl +++ /dev/null @@ -1,35 +0,0 @@ -# SPDX-FileCopyrightText: © 2022 Michael Goerz -# -# SPDX-License-Identifier: MIT - -# init file for "make devrepl" -using Revise -using JuliaFormatter -using QuantumControlTestUtils: test, show_coverage, generate_coverage_html -using LiveServer: LiveServer, serve, servedocs -include(joinpath(@__DIR__, "clean.jl")) - - -REPL_MESSAGE = """ -******************************************************************************* -DEVELOPMENT REPL - -Revise, JuliaFormatter, LiveServer, Plots with unicode backend are active. - -* `help()` – Show this message -* `include("test/runtests.jl")` – Run the entire test suite -* `test()` – Run the entire test suite in a subprocess with coverage -* `show_coverage()` – Print a tabular overview of coverage data -* `generate_coverage_html()` – Generate an HTML coverage report -* `include("docs/make.jl")` – Generate the documentation -* `format(".")` – Apply code formatting to all files -* `servedocs([port=8000, verbose=false])` – - Build and serve the documentation. Automatically recompile and redisplay on - changes -* `clean()` – Clean up build/doc/testing artifacts -* `distclean()` – Restore to a clean checkout state -******************************************************************************* -""" - -"""Show help""" -help() = println(REPL_MESSAGE)