From 4a5735cc4dfe083e1b3fe1a54d4292419df5b506 Mon Sep 17 00:00:00 2001 From: Erik Faulhaber <44124897+efaulhaber@users.noreply.github.com> Date: Sat, 4 May 2024 00:38:31 +0200 Subject: [PATCH] Initial Commit --- .JuliaFormatter.toml | 11 ++++ .codecov.yml | 5 ++ .github/dependabot.yml | 7 +++ .github/workflows/CompatHelper.yml | 45 +++++++++++++++ .github/workflows/Documenter.yml | 46 +++++++++++++++ .github/workflows/FormatCheck.yml | 40 +++++++++++++ .github/workflows/SpellCheck.yml | 13 +++++ .github/workflows/TagBot.yml | 31 ++++++++++ .github/workflows/ci.yml | 91 ++++++++++++++++++++++++++++++ .gitignore | 15 +++++ AUTHORS.md | 8 +++ LICENSE.md | 22 ++++++++ Project.toml | 7 +++ README.md | 8 +++ SECURITY.md | 30 ++++++++++ docs/Project.toml | 5 ++ docs/make.jl | 60 ++++++++++++++++++++ docs/src/reference.md | 9 +++ src/TrixiNeighborhoodSearch.jl | 3 + test/Project.toml | 5 ++ test/runtests.jl | 5 ++ test/test_util.jl | 76 +++++++++++++++++++++++++ 22 files changed, 542 insertions(+) create mode 100644 .JuliaFormatter.toml create mode 100644 .codecov.yml create mode 100644 .github/dependabot.yml create mode 100644 .github/workflows/CompatHelper.yml create mode 100644 .github/workflows/Documenter.yml create mode 100644 .github/workflows/FormatCheck.yml create mode 100644 .github/workflows/SpellCheck.yml create mode 100644 .github/workflows/TagBot.yml create mode 100644 .github/workflows/ci.yml create mode 100644 .gitignore create mode 100644 AUTHORS.md create mode 100644 LICENSE.md create mode 100644 Project.toml create mode 100644 README.md create mode 100644 SECURITY.md create mode 100644 docs/Project.toml create mode 100644 docs/make.jl create mode 100644 docs/src/reference.md create mode 100644 src/TrixiNeighborhoodSearch.jl create mode 100644 test/Project.toml create mode 100644 test/runtests.jl create mode 100644 test/test_util.jl diff --git a/.JuliaFormatter.toml b/.JuliaFormatter.toml new file mode 100644 index 00000000..7b97a515 --- /dev/null +++ b/.JuliaFormatter.toml @@ -0,0 +1,11 @@ +# Use SciML style: https://github.com/SciML/SciMLStyle +style = "sciml" + +# Python style alignment. See https://github.com/domluna/JuliaFormatter.jl/pull/732. +yas_style_nesting = true + +# Align struct fields for better readability of large struct definitions +align_struct_field = true + +# Allow Dict definitions to be aligned like arrays. See https://github.com/domluna/JuliaFormatter.jl/pull/676 +variable_call_indent = ["Dict"] diff --git a/.codecov.yml b/.codecov.yml new file mode 100644 index 00000000..93fc0407 --- /dev/null +++ b/.codecov.yml @@ -0,0 +1,5 @@ +# xref: https://docs.codecov.io/docs/codecovyml-reference + +# Disable annotations (annoying!) +github_checks: + annotations: false diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 00000000..d60f0707 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,7 @@ +# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates +version: 2 +updates: + - package-ecosystem: "github-actions" + directory: "/" # Location of package manifests + schedule: + interval: "monthly" diff --git a/.github/workflows/CompatHelper.yml b/.github/workflows/CompatHelper.yml new file mode 100644 index 00000000..d8148512 --- /dev/null +++ b/.github/workflows/CompatHelper.yml @@ -0,0 +1,45 @@ +name: CompatHelper +on: + schedule: + - cron: 0 0 * * * + workflow_dispatch: +permissions: + contents: write + pull-requests: write +jobs: + CompatHelper: + runs-on: ubuntu-latest + steps: + - name: Check if Julia is already available in the PATH + id: julia_in_path + run: which julia + continue-on-error: true + - name: Install Julia, but only if it is not already available in the PATH + uses: julia-actions/setup-julia@v2 + with: + version: '1' + arch: ${{ runner.arch }} + if: steps.julia_in_path.outcome != 'success' + - name: "Add the General registry via Git" + run: | + import Pkg + ENV["JULIA_PKG_SERVER"] = "" + Pkg.Registry.add("General") + shell: julia --color=yes {0} + - name: "Install CompatHelper" + run: | + import Pkg + name = "CompatHelper" + uuid = "aa819f21-2bde-4658-8897-bab36330d9b7" + version = "3" + Pkg.add(; name, uuid, version) + shell: julia --color=yes {0} + - name: "Run CompatHelper" + run: | + import CompatHelper + CompatHelper.main(; subdirs=["", "test", "docs"]) + shell: julia --color=yes {0} + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + COMPATHELPER_PRIV: ${{ secrets.DOCUMENTER_KEY }} + # COMPATHELPER_PRIV: ${{ secrets.COMPATHELPER_PRIV }} diff --git a/.github/workflows/Documenter.yml b/.github/workflows/Documenter.yml new file mode 100644 index 00000000..4cc31a61 --- /dev/null +++ b/.github/workflows/Documenter.yml @@ -0,0 +1,46 @@ +name: Documentation + +on: + push: + branches: + - 'main' + tags: '*' + paths-ignore: + - '.github/workflows/ci.yml' + - '.github/workflows/CompatHelper.yml' + - '.github/workflows/TagBot.yml' + pull_request: + paths-ignore: + - '.github/workflows/ci.yml' + - '.github/workflows/CompatHelper.yml' + - '.github/workflows/TagBot.yml' + 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/') }} + +jobs: + build-docs: + name: Build and Deploy Documentation + runs-on: ubuntu-latest + steps: + - name: Check out project + uses: actions/checkout@v4 + - name: Set up Julia + uses: julia-actions/setup-julia@v2 + with: + version: '1' + show-versioninfo: true + - uses: julia-actions/cache@v1 + - name: Build package + uses: julia-actions/julia-buildpkg@v1 + - name: Install dependencies + run: julia --project=docs/ -e 'using Pkg; Pkg.develop(PackageSpec(path=pwd())); Pkg.instantiate()' + - name: Build and deploy + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + DOCUMENTER_KEY: ${{ secrets.DOCUMENTER_KEY }} # For authentication with SSH deploy key + run: julia --project=docs --color=yes docs/make.jl diff --git a/.github/workflows/FormatCheck.yml b/.github/workflows/FormatCheck.yml new file mode 100644 index 00000000..5000913d --- /dev/null +++ b/.github/workflows/FormatCheck.yml @@ -0,0 +1,40 @@ +name: Format Check + +on: + push: + branches: + - 'main' + tags: '*' + pull_request: + +jobs: + check-format: + name: Check format with JuliaFormatter.jl + runs-on: ubuntu-latest + steps: + - name: Check out project + uses: actions/checkout@v4 + - name: Set up Julia + uses: julia-actions/setup-julia@v2 + with: + version: '1' + - run: julia -e 'using InteractiveUtils; versioninfo(verbose=true)' + - uses: julia-actions/cache@v1 + - 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", version="1.0.45"))' + julia -e 'using JuliaFormatter; format(".")' + - 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' diff --git a/.github/workflows/SpellCheck.yml b/.github/workflows/SpellCheck.yml new file mode 100644 index 00000000..10bcc227 --- /dev/null +++ b/.github/workflows/SpellCheck.yml @@ -0,0 +1,13 @@ +name: Spell Check + +on: [pull_request, workflow_dispatch] + +jobs: + typos-check: + name: Spell Check with Typos + runs-on: ubuntu-latest + steps: + - name: Checkout Actions Repository + uses: actions/checkout@v4 + - name: Check spelling + uses: crate-ci/typos@v1.21.0 diff --git a/.github/workflows/TagBot.yml b/.github/workflows/TagBot.yml new file mode 100644 index 00000000..2bacdb87 --- /dev/null +++ b/.github/workflows/TagBot.yml @@ -0,0 +1,31 @@ +name: TagBot +on: + issue_comment: + types: + - created + workflow_dispatch: + inputs: + lookback: + default: 3 +permissions: + actions: read + checks: read + contents: write + deployments: read + issues: read + discussions: read + packages: read + pages: read + pull-requests: read + repository-projects: read + security-events: read + statuses: read +jobs: + TagBot: + if: github.event_name == 'workflow_dispatch' || github.actor == 'JuliaTagBot' + runs-on: ubuntu-latest + steps: + - uses: JuliaRegistries/TagBot@v1 + with: + token: ${{ secrets.GITHUB_TOKEN }} + ssh: ${{ secrets.DOCUMENTER_KEY }} diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 00000000..f777738c --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,91 @@ +name: CI + +on: + push: + branches: + - main + tags: ['*'] + paths-ignore: + - 'CITATION.bib' + - 'LICENSE.md' + - 'README.md' + - '.zenodo.json' + - '.github/workflows/CompatHelper.yml' + - '.github/workflows/SpellCheck.yml' + - '.github/workflows/TagBot.yml' + - 'docs/**' + pull_request: + paths-ignore: + - 'CITATION.bib' + - 'LICENSE.md' + - 'README.md' + - '.zenodo.json' + - '.github/workflows/CompatHelper.yml' + - '.github/workflows/SpellCheck.yml' + - '.github/workflows/TagBot.yml' + - 'docs/**' + 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/') }} + +jobs: + build: + name: Run Tests (Julia ${{ matrix.version }} - ${{ matrix.os }} - ${{ matrix.arch }}) + runs-on: ubuntu-latest + strategy: + # Don't cancel all running jobs when one job fails + fail-fast: false + matrix: + version: + - '1.9' + - '1' + os: + - ubuntu-latest + arch: + - x64 + include: + # Also run tests on Windows and macOS-ARM, but only with the latest Julia version + - version: '1' + os: windows-latest + arch: x64 + - version: '1' + os: macos-14 + arch: arm64 + + steps: + - name: Check out project + uses: actions/checkout@v4 + - name: Set up Julia + uses: julia-actions/setup-julia@v2 + with: + version: ${{ matrix.version }} + - run: julia -e 'using InteractiveUtils; versioninfo(verbose=true)' + - uses: julia-actions/cache@v1 + - name: Build package + uses: julia-actions/julia-buildpkg@v1 + - name: Run tests + uses: julia-actions/julia-runtest@v1 + with: + annotate: true + # Only run coverage in one Job (Ubuntu and latest Julia version) + coverage: ${{ matrix.os == 'ubuntu-latest' && matrix.version == '1' }} + - name: Process coverage results + # Only run coverage in one Job (Ubuntu and latest Julia version) + if: matrix.os == 'ubuntu-latest' && matrix.version == '1' + uses: julia-actions/julia-processcoverage@v1 + with: + directories: src,test + - name: Upload coverage report to Codecov + # Only run coverage in one Job (Ubuntu and latest Julia version) + if: matrix.os == 'ubuntu-latest' && matrix.version == '1' + uses: codecov/codecov-action@v4 + with: + files: lcov.info + fail_ci_if_error: true + flags: unit + env: + CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} diff --git a/.gitignore b/.gitignore new file mode 100644 index 00000000..47327812 --- /dev/null +++ b/.gitignore @@ -0,0 +1,15 @@ +Manifest.toml +docs/build +docs/src/index.md +docs/src/authors.md +docs/src/license.md +public/ +coverage/ +coverage_report/ +*.jl.*.cov +.vscode/ +run + +.DS_Store + +LocalPreferences.toml diff --git a/AUTHORS.md b/AUTHORS.md new file mode 100644 index 00000000..7995e19f --- /dev/null +++ b/AUTHORS.md @@ -0,0 +1,8 @@ +# Authors + +This package is maintained by the authors of +[TrixiParticles.jl](https://github.com/trixi-framework/TrixiParticles.jl). +For a full list of authors, see +[AUTHORS.md](https://github.com/trixi-framework/TrixiParticles.jl/blob/main/AUTHORS.md) +in the TrixiParticles.jl repository. +These authors form "The TrixiParticles.jl Authors", as mentioned in the [LICENSE.md](LICENSE.md) file. diff --git a/LICENSE.md b/LICENSE.md new file mode 100644 index 00000000..573a00a8 --- /dev/null +++ b/LICENSE.md @@ -0,0 +1,22 @@ +MIT License + +Copyright (c) 2023-present The TrixiParticles.jl Authors (see [AUTHORS.md](AUTHORS.md)) \ +Copyright (c) 2023-present Helmholtz-Zentrum hereon GmbH, Institute of Surface Science \ + \ +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/Project.toml b/Project.toml new file mode 100644 index 00000000..99cba0d0 --- /dev/null +++ b/Project.toml @@ -0,0 +1,7 @@ +name = "TrixiNeighborhoodSearch" +uuid = "1c4d5385-0a27-49de-8e2c-43b175c8985c" +authors = ["Erik Faulhaber <44124897+efaulhaber@users.noreply.github.com>"] +version = "0.1.0-pre" + +[compat] +julia = "1.9" diff --git a/README.md b/README.md new file mode 100644 index 00000000..688b28f3 --- /dev/null +++ b/README.md @@ -0,0 +1,8 @@ +# TrixiNeighborhoodSearch.jl + +[![Docs-stable](https://img.shields.io/badge/docs-stable-blue.svg)](https://trixi-framework.github.io/TrixiNeighborhoodSearch.jl/stable) +[![Docs-dev](https://img.shields.io/badge/docs-dev-blue.svg)](https://trixi-framework.github.io/TrixiNeighborhoodSearch.jl/dev) +[![Build Status](https://github.com/trixi-framework/TrixiNeighborhoodSearch.jl/workflows/CI/badge.svg)](https://github.com/trixi-framework/TrixiNeighborhoodSearch.jl/actions?query=workflow%3ACI) +[![Coveralls](https://coveralls.io/repos/github/trixi-framework/TrixiNeighborhoodSearch.jl/badge.svg)](https://coveralls.io/github/trixi-framework/TrixiNeighborhoodSearch.jl) +[![Codecov](https://codecov.io/gh/trixi-framework/TrixiNeighborhoodSearch.jl/branch/main/graph/badge.svg)](https://codecov.io/gh/trixi-framework/TrixiNeighborhoodSearch.jl) +[![License: MIT](https://img.shields.io/badge/License-MIT-success.svg)](https://opensource.org/license/mit/) diff --git a/SECURITY.md b/SECURITY.md new file mode 100644 index 00000000..332f0cf3 --- /dev/null +++ b/SECURITY.md @@ -0,0 +1,30 @@ +# Security Policy + +The Trixi.jl development team takes security issues seriously. We appreciate +all efforts to responsibly disclose any security issues and will make every +effort to acknowledge contributions. + + +## Supported Versions + +The current stable release following the interpretation of +[semantic versioning (SemVer)](https://julialang.github.io/Pkg.jl/dev/compatibility/#Version-specifier-format-1) +used in the Julia ecosystem is supported with security updates. + + +## Reporting a Vulnerability + +To report a security issue, please use the GitHub Security Advisory +["Report a Vulnerability"](https://github.com/trixi-framework/TrixiNeighborhoodSearch.jl/security/advisories/new) +tab. + +We will send a response indicating the next steps in handling your report. +After the initial reply to your report, we will keep you informed of the +progress towards a fix and full announcement, and may ask for additional +information or guidance. + +Please report security bugs in third-party modules directly to the person +or team maintaining the module. + +Public notifications of vulnerabilities will be shared in community channels +such as Slack. diff --git a/docs/Project.toml b/docs/Project.toml new file mode 100644 index 00000000..1814eb33 --- /dev/null +++ b/docs/Project.toml @@ -0,0 +1,5 @@ +[deps] +Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4" + +[compat] +Documenter = "1" diff --git a/docs/make.jl b/docs/make.jl new file mode 100644 index 00000000..66943df8 --- /dev/null +++ b/docs/make.jl @@ -0,0 +1,60 @@ +using Documenter + +# Get TrixiNeighborhoodSearch.jl root directory +trixibase_root_dir = dirname(@__DIR__) + +# Fix for https://github.com/trixi-framework/Trixi.jl/issues/668 +if (get(ENV, "CI", nothing) != "true") && + (get(ENV, "TRIXIBASE_DOC_DEFAULT_ENVIRONMENT", nothing) != "true") + push!(LOAD_PATH, trixibase_root_dir) +end + +using TrixiNeighborhoodSearch + +# Define module-wide setups such that the respective modules are available in doctests +DocMeta.setdocmeta!(TrixiNeighborhoodSearch, :DocTestSetup, :(using TrixiNeighborhoodSearch); recursive = true) + +# Copy files to not need to synchronize them manually +function copy_file(filename, replaces...; new_filename = lowercase(filename)) + content = read(joinpath(trixibase_root_dir, filename), String) + content = replace(content, replaces...) + + header = """ + ```@meta + EditURL = "https://github.com/trixi-framework/TrixiNeighborhoodSearch.jl/blob/main/$filename" + ``` + """ + content = header * content + + write(joinpath(@__DIR__, "src", new_filename), content) +end + +copy_file("README.md", new_filename = "index.md") +copy_file("AUTHORS.md", + "in the [LICENSE.md](LICENSE.md) file" => "under [License](@ref)") +# Add section `# License` and add `>` in each line to add a quote +copy_file("LICENSE.md", + "[AUTHORS.md](AUTHORS.md)" => "[Authors](@ref)", + "\n" => "\n> ", r"^" => "# License\n\n> ") + +# Make documentation +makedocs(modules = [TrixiNeighborhoodSearch], + sitename = "TrixiNeighborhoodSearch.jl", + # Provide additional formatting options + format = Documenter.HTML( + # Disable pretty URLs during manual testing + prettyurls = get(ENV, "CI", nothing) == "true", + # Set canonical URL to GitHub pages URL + canonical = "https://trixi-framework.github.io/TrixiNeighborhoodSearch.jl/stable"), + # Explicitly specify documentation structure + pages = [ + "Home" => "index.md", + "API reference" => "reference.md", + "Authors" => "authors.md", + "License" => "license.md", + ]) + +deploydocs(; + repo = "github.com/trixi-framework/TrixiNeighborhoodSearch.jl", + devbranch = "main", + push_preview = true) diff --git a/docs/src/reference.md b/docs/src/reference.md new file mode 100644 index 00000000..239c67ad --- /dev/null +++ b/docs/src/reference.md @@ -0,0 +1,9 @@ +# API reference + +```@meta +CurrentModule = TrixiNeighborhoodSearch +``` + +```@autodocs +Modules = [TrixiNeighborhoodSearch] +``` diff --git a/src/TrixiNeighborhoodSearch.jl b/src/TrixiNeighborhoodSearch.jl new file mode 100644 index 00000000..a8b01844 --- /dev/null +++ b/src/TrixiNeighborhoodSearch.jl @@ -0,0 +1,3 @@ +module TrixiNeighborhoodSearch + +end # module TrixiNeighborhoodSearch diff --git a/test/Project.toml b/test/Project.toml new file mode 100644 index 00000000..ec848198 --- /dev/null +++ b/test/Project.toml @@ -0,0 +1,5 @@ +[deps] +Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" + +[compat] +Test = "1" diff --git a/test/runtests.jl b/test/runtests.jl new file mode 100644 index 00000000..64c4e52c --- /dev/null +++ b/test/runtests.jl @@ -0,0 +1,5 @@ +include("test_util.jl") + +@testset verbose=true "TrixiNeighborhoodSearch.jl Tests" begin + +end diff --git a/test/test_util.jl b/test/test_util.jl new file mode 100644 index 00000000..99f166ce --- /dev/null +++ b/test/test_util.jl @@ -0,0 +1,76 @@ +# All `using` calls are in this file, so that one can run any test file +# after running only this file. +using Test: @test, @testset +using TrixiNeighborhoodSearch + +""" + @trixi_testset "name of the testset" #= code to test #= + +Similar to `@testset`, but wraps the code inside a temporary module to avoid +namespace pollution. +""" +macro trixi_testset(name, expr) + @assert name isa String + + mod = gensym() + + # TODO: `@eval` is evil + quote + @eval module $mod + using Test + using TrixiNeighborhoodSearch + + # We also include this file again to provide the definition of + # the other testing macros. This allows to use `@trixi_testset` + # in a nested fashion and also call `@test_nowarn_mod` from + # there. + include(@__FILE__) + + @testset verbose=true $name $expr + end + + nothing + end +end + +""" + @test_nowarn_mod expr + +Modified version of `@test_nowarn expr` that prints the content of `stderr` when +it is not empty and ignores some common info statements printed in Trixi.jl +uses. +""" +macro test_nowarn_mod(expr, additional_ignore_content = String[]) + quote + let fname = tempname() + try + ret = open(fname, "w") do f + redirect_stderr(f) do + $(esc(expr)) + end + end + stderr_content = read(fname, String) + if !isempty(stderr_content) + println("Content of `stderr`:\n", stderr_content) + end + + # Patterns matching the following ones will be ignored. Additional patterns + # passed as arguments can also be regular expressions, so we just use the + # type `Any` for `ignore_content`. + ignore_content = Any["[ Info: You just called `trixi_include`. Julia may now compile the code, please be patient.\n"] + append!(ignore_content, $additional_ignore_content) + for pattern in ignore_content + stderr_content = replace(stderr_content, pattern => "") + end + + # We also ignore simple module redefinitions for convenience. Thus, we + # check whether every line of `stderr_content` is of the form of a + # module replacement warning. + @test occursin(r"^(WARNING: replacing module .+\.\n)*$", stderr_content) + ret + finally + rm(fname, force = true) + end + end + end +end