From 55426ed05c35a27ce7c16107f387dcb870f71d24 Mon Sep 17 00:00:00 2001 From: Michael Schlottke-Lakemper Date: Thu, 25 Jan 2024 10:04:58 +0100 Subject: [PATCH] Add basic CI infrastructure --- .codecov.yml | 5 ++ .github/dependabot.yml | 7 +++ .github/workflows/CompatHelper.yml | 45 ++++++++++++++++++ .github/workflows/Documenter.yml | 41 +++++++++++++++++ .github/workflows/SpellCheck.yml | 13 ++++++ .github/workflows/TagBot.yml | 33 +++++++++++++ .github/workflows/ci.yml | 74 ++++++++++++++++++++++++++++++ Project.toml | 7 +++ docs/.gitignore | 1 + docs/Project.toml | 5 ++ docs/make.jl | 73 +++++++++++++++++++++++++++++ docs/src/.gitignore | 2 + docs/src/reference.md | 9 ++++ examples/dummy.jl | 3 ++ src/Smesh.jl | 5 ++ test/Project.toml | 5 ++ test/runtests.jl | 7 +++ test/test_examples.jl | 15 ++++++ test/test_unit.jl | 15 ++++++ 19 files changed, 365 insertions(+) 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/SpellCheck.yml create mode 100644 .github/workflows/TagBot.yml create mode 100644 .github/workflows/ci.yml create mode 100644 docs/.gitignore create mode 100644 docs/Project.toml create mode 100644 docs/make.jl create mode 100644 docs/src/.gitignore create mode 100644 docs/src/reference.md create mode 100644 examples/dummy.jl create mode 100644 test/Project.toml create mode 100644 test/runtests.jl create mode 100644 test/test_examples.jl create mode 100644 test/test_unit.jl diff --git a/.codecov.yml b/.codecov.yml new file mode 100644 index 0000000..93fc040 --- /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 0000000..d60f070 --- /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 0000000..98e1e3b --- /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@v1 + 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 0000000..3cfbcdb --- /dev/null +++ b/.github/workflows/Documenter.yml @@ -0,0 +1,41 @@ +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: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: julia-actions/setup-julia@v1 + with: + version: '1' + show-versioninfo: true + - 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/SpellCheck.yml b/.github/workflows/SpellCheck.yml new file mode 100644 index 0000000..2bae695 --- /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.17.1 diff --git a/.github/workflows/TagBot.yml b/.github/workflows/TagBot.yml new file mode 100644 index 0000000..90dc100 --- /dev/null +++ b/.github/workflows/TagBot.yml @@ -0,0 +1,33 @@ +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 }} + # Edit the following line to reflect the actual name of the GitHub Secret containing your private key + ssh: ${{ secrets.DOCUMENTER_KEY }} + # ssh: ${{ secrets.NAME_OF_MY_SSH_PRIVATE_KEY_SECRET }} diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..7e48445 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,74 @@ +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: + test: + name: ${{ matrix.os }} - Julia ${{ matrix.version }} - ${{ github.event_name }} + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + version: + - '1.8' + - '1.9' + - '1.10' + os: + - ubuntu-latest + - macOS-latest + - windows-latest + steps: + - uses: actions/checkout@v4 + - uses: julia-actions/setup-julia@v1 + with: + version: ${{ matrix.version }} + - run: julia -e 'using InteractiveUtils; versioninfo(verbose=true)' + - uses: julia-actions/cache@v1 + - uses: julia-actions/julia-buildpkg@v1 + - uses: julia-actions/julia-runtest@v1 + - uses: julia-actions/julia-processcoverage@v1 + with: + directories: src,examples + - uses: codecov/codecov-action@v3 + with: + files: lcov.info + # token: ${{ secrets.CODECOV_TOKEN }} + - uses: coverallsapp/github-action@master + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + path-to-lcov: ./lcov.info + # Enable tmate debugging of manually-triggered workflows if the input option was provided + - name: Setup tmate session for debugging + if: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.debug_enabled && always() }} + uses: mxschmitt/action-tmate@v3 + timeout-minutes: 15 diff --git a/Project.toml b/Project.toml index 4753322..9c65af9 100644 --- a/Project.toml +++ b/Project.toml @@ -2,3 +2,10 @@ name = "Smesh" uuid = "e2b06280-edec-413c-a3a2-1b4e389db7bf" authors = ["Simone Chiocchetti ", "Benjamin Bolm ", "Michael Schlottke-Lakemper "] version = "0.1.0" + +[deps] +Preferences = "21216c6a-2e73-6563-6e65-726566657250" + +[compat] +Preferences = "1" +julia = "1.8" diff --git a/docs/.gitignore b/docs/.gitignore new file mode 100644 index 0000000..567609b --- /dev/null +++ b/docs/.gitignore @@ -0,0 +1 @@ +build/ diff --git a/docs/Project.toml b/docs/Project.toml new file mode 100644 index 0000000..1814eb3 --- /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 0000000..c3ef442 --- /dev/null +++ b/docs/make.jl @@ -0,0 +1,73 @@ +using Documenter + +# Get Smesh.jl root directory +smesh_root_dir = dirname(@__DIR__) + +# Fix for https://github.com/trixi-framework/Trixi.jl/issues/668 +if (get(ENV, "CI", nothing) != "true") && (get(ENV, "SMESH_DOC_DEFAULT_ENVIRONMENT", nothing) != "true") + push!(LOAD_PATH, smesh_root_dir) +end + +using Smesh + +# Define module-wide setups such that the respective modules are available in doctests +DocMeta.setdocmeta!(Smesh, :DocTestSetup, :(using Smesh); recursive=true) + +# Copy some files from the top level directory to the docs and modify them +# as necessary +open(joinpath(@__DIR__, "src", "index.md"), "w") do io + # Point to source file + println(io, """ + ```@meta + EditURL = "https://github.com/trixi-framework/Smesh.jl/blob/main/README.md" + ``` + """) + # Write the modified contents + for line in eachline(joinpath(smesh_root_dir, "README.md")) + line = replace(line, "[LICENSE.md](LICENSE.md)" => "[License](@ref)") + println(io, line) + end +end + +open(joinpath(@__DIR__, "src", "license.md"), "w") do io + # Point to source file + println(io, """ + ```@meta + EditURL = "https://github.com/trixi-framework/Smesh/blob/main/LICENSE.md" + ``` + """) + # Write the modified contents + println(io, "# License") + println(io, "") + for line in eachline(joinpath(smesh_root_dir, "LICENSE.md")) + println(io, "> ", line) + end +end + +# Make documentation +makedocs( + # Specify modules for which docstrings should be shown + modules = [Smesh], + # Set sitename to Trixi.jl + sitename="Smesh.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/Smesh.jl/stable" + ), + # Explicitly specify documentation structure + pages = [ + "Home" => "index.md", + "API reference" => "reference.md", + "License" => "license.md" + ], +) + + +deploydocs(; + repo = "github.com/trixi-framework/Smesh.jl", + devbranch = "main", + push_preview = true +) diff --git a/docs/src/.gitignore b/docs/src/.gitignore new file mode 100644 index 0000000..312f831 --- /dev/null +++ b/docs/src/.gitignore @@ -0,0 +1,2 @@ +index.md +license.md diff --git a/docs/src/reference.md b/docs/src/reference.md new file mode 100644 index 0000000..6b4f560 --- /dev/null +++ b/docs/src/reference.md @@ -0,0 +1,9 @@ +# API reference + +```@meta +CurrentModule = Smesh +``` + +```@autodocs +Modules = [Smesh] +``` diff --git a/examples/dummy.jl b/examples/dummy.jl new file mode 100644 index 0000000..065499d --- /dev/null +++ b/examples/dummy.jl @@ -0,0 +1,3 @@ +using Smesh + +Smesh.greet() diff --git a/src/Smesh.jl b/src/Smesh.jl index ccc833f..e9fb662 100644 --- a/src/Smesh.jl +++ b/src/Smesh.jl @@ -1,5 +1,10 @@ module Smesh +""" + greet() + +Say hello to the world. +""" greet() = print("Hello World!") end # module Smesh diff --git a/test/Project.toml b/test/Project.toml new file mode 100644 index 0000000..ec84819 --- /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 0000000..0964f6e --- /dev/null +++ b/test/runtests.jl @@ -0,0 +1,7 @@ +using Test + +@time @testset verbose=true showtiming=true "Smesh.jl tests" begin + include("test_unit.jl") + include("test_examples.jl") +end + diff --git a/test/test_examples.jl b/test/test_examples.jl new file mode 100644 index 0000000..bca07d6 --- /dev/null +++ b/test/test_examples.jl @@ -0,0 +1,15 @@ +module TestExamples + +using Test +using Smesh + +@testset verbose=true showtiming=true "test_examples.jl" begin + +@testset verbose=true showtiming=true "examples/dummy.jl" begin + @test_nowarn include("../examples/dummy.jl") +end + +end # @testset "test_examples.jl" + +end # module + diff --git a/test/test_unit.jl b/test/test_unit.jl new file mode 100644 index 0000000..79cd771 --- /dev/null +++ b/test/test_unit.jl @@ -0,0 +1,15 @@ +module TestUnit + +using Test +using Smesh + +@testset verbose=true showtiming=true "test_unit.jl" begin + +@testset verbose=true showtiming=true "greet" begin + @test_nowarn Smesh.greet() +end + +end # @testset "test_unit.jl" + +end # module +