From d8d525ba16cd0365809f6833eeac038063edd983 Mon Sep 17 00:00:00 2001 From: Jose Daniel Lara Date: Wed, 10 Jan 2024 14:08:24 -0700 Subject: [PATCH] Initial commit --- .editorconfig | 13 +++ .github/pull_request_template.md | 3 + .github/workflows/TagBot.yml | 15 +++ .github/workflows/cross-package-test.yml | 47 +++++++++ .github/workflows/docs.yml | 25 +++++ .github/workflows/format-check.yml | 43 ++++++++ .github/workflows/main-tests.yml | 40 ++++++++ .github/workflows/pr_testing.yml | 36 +++++++ .gitignore | 125 +++++++++++++++++++++++ CONTRIBUTING.md | 6 ++ LICENSE | 29 ++++++ Project.toml | 11 ++ README.md | 23 +++++ codecov.yml | 38 +++++++ docs/Makefile | 14 +++ docs/Project.toml | 6 ++ docs/make.jl | 27 +++++ docs/src/api/internal.md | 6 ++ docs/src/api/public.md | 6 ++ docs/src/index.md | 14 +++ docs/src/quick_start_guide.md | 3 + docs/src/tutorials/intro_page.md | 4 + scripts/formatter/Project.toml | 10 ++ scripts/formatter/formatter_code.jl | 41 ++++++++ src/SIIP-PACKAGE.jl | 11 ++ test/Project.toml | 6 ++ test/runtests.jl | 107 +++++++++++++++++++ test/test_file.jl | 2 + 28 files changed, 711 insertions(+) create mode 100644 .editorconfig create mode 100644 .github/pull_request_template.md create mode 100644 .github/workflows/TagBot.yml create mode 100644 .github/workflows/cross-package-test.yml create mode 100644 .github/workflows/docs.yml create mode 100644 .github/workflows/format-check.yml create mode 100644 .github/workflows/main-tests.yml create mode 100644 .github/workflows/pr_testing.yml create mode 100644 .gitignore create mode 100644 CONTRIBUTING.md create mode 100644 LICENSE create mode 100644 Project.toml create mode 100644 README.md create mode 100644 codecov.yml create mode 100644 docs/Makefile create mode 100644 docs/Project.toml create mode 100644 docs/make.jl create mode 100644 docs/src/api/internal.md create mode 100644 docs/src/api/public.md create mode 100644 docs/src/index.md create mode 100644 docs/src/quick_start_guide.md create mode 100644 docs/src/tutorials/intro_page.md create mode 100644 scripts/formatter/Project.toml create mode 100644 scripts/formatter/formatter_code.jl create mode 100644 src/SIIP-PACKAGE.jl create mode 100644 test/Project.toml create mode 100644 test/runtests.jl create mode 100644 test/test_file.jl diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..770d0c8 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,13 @@ +# top-most EditorConfig file +root = true + +# Unix-style newlines with a newline ending every file +[*] +end_of_line = lf +insert_final_newline = true + +# Julia files +[*.jl] +indent_style = space +indent_size = 4 +trim_trailing_whitespace = true diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md new file mode 100644 index 0000000..522703b --- /dev/null +++ b/.github/pull_request_template.md @@ -0,0 +1,3 @@ +Thanks for opening a PR to SIIP-PACKAGE.jl, please take note of the following when making a PR: + +Check the [contributor guidelines](https://nrel-siip.github.io/SIIP-PACKAGE.jl/stable/code_base_developer_guide/developer/) diff --git a/.github/workflows/TagBot.yml b/.github/workflows/TagBot.yml new file mode 100644 index 0000000..f49313b --- /dev/null +++ b/.github/workflows/TagBot.yml @@ -0,0 +1,15 @@ +name: TagBot +on: + issue_comment: + types: + - created + workflow_dispatch: +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/cross-package-test.yml b/.github/workflows/cross-package-test.yml new file mode 100644 index 0000000..2875945 --- /dev/null +++ b/.github/workflows/cross-package-test.yml @@ -0,0 +1,47 @@ +name: CrossPackageTest + +on: + push: + branches: [master] + tags: [v*] + pull_request: + +jobs: + test: + name: Julia v${{ matrix.julia-version }} - ${{ matrix.package_name }} + runs-on: ${{ matrix.os }} + strategy: + matrix: + julia-version: [1] + os: [ubuntu-latest] + package_name: [PowerSimulations, PowerSystemCaseBuilder] + continue-on-error: true + steps: + - uses: actions/checkout@v2 + - uses: julia-actions/setup-julia@v1 + with: + version: ${{ matrix.julia-version }} + arch: x64 + - uses: julia-actions/julia-buildpkg@latest + - name: Clone ${{matrix.package_name}} + uses: actions/checkout@v2 + with: + repository: NREL-SIIP/${{matrix.package_name}}.jl + path: downstream + - name: Run the tests + shell: julia --project=downstream {0} + run: | + using Pkg + try + # Force it to use this PR's version of the package + Pkg.develop(PackageSpec(path=".")) # resolver may fail with main deps + Pkg.update() + Pkg.test() # resolver may fail with test time deps + catch err + err isa Pkg.Resolve.ResolverError || rethrow() + # If we can't resolve that means this is incompatible by SemVer, and this is fine. + # It means we marked this as a breaking change, so we don't need to worry about + # mistakenly introducing a breaking change as we have intentionally made one. + @info "Not compatible with this release. No problem." exception=err + exit(0) # Exit immediately, as a success + end diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml new file mode 100644 index 0000000..261b424 --- /dev/null +++ b/.github/workflows/docs.yml @@ -0,0 +1,25 @@ +name: Documentation + +on: + push: + branches: + - master + - 'release-' + tags: '*' + pull_request: + +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: julia-actions/setup-julia@v1 + with: + version: '1.6' + - 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 }} + run: julia --project=docs --color=yes docs/make.jl diff --git a/.github/workflows/format-check.yml b/.github/workflows/format-check.yml new file mode 100644 index 0000000..75786f5 --- /dev/null +++ b/.github/workflows/format-check.yml @@ -0,0 +1,43 @@ +name: Format Check + +on: + push: + branches: + - 'master' + - 'release-' + tags: '*' + pull_request: + +jobs: + build: + runs-on: ${{ matrix.os }} + strategy: + matrix: + julia-version: [1] + julia-arch: [x86] + os: [ubuntu-latest] + steps: + - uses: julia-actions/setup-julia@latest + with: + version: ${{ matrix.julia-version }} + + - uses: actions/checkout@v2 + - name: Install JuliaFormatter and format + run: | + julia -e 'include("scripts/formatter/formatter_code.jl")' + - uses: reviewdog/action-suggester@v1 + if: github.event_name == 'pull_request' + with: + tool_name: JuliaFormatter + fail_on_error: true + - 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/main-tests.yml b/.github/workflows/main-tests.yml new file mode 100644 index 0000000..e78f8d2 --- /dev/null +++ b/.github/workflows/main-tests.yml @@ -0,0 +1,40 @@ +name: Main - CI + +on: + schedule: + - cron: "0 0 * * 1-5" + push: + branches: + - main + +jobs: + test: + name: Julia ${{ matrix.julia-version }} - ${{ matrix.os }} + runs-on: ${{ matrix.os }} + strategy: + matrix: + julia-version: ['1', 'nightly'] + julia-arch: [x64] + os: [ubuntu-latest, windows-latest, macOS-latest] + + steps: + - uses: actions/checkout@v2 + - uses: julia-actions/setup-julia@latest + with: + version: ${{ matrix.julia-version }} + arch: ${{ matrix.julia-arch }} + - uses: julia-actions/julia-buildpkg@latest + env: + PYTHON: "" + - uses: julia-actions/julia-runtest@latest + continue-on-error: ${{ matrix.julia-version == 'nightly' }} + env: + PYTHON: "" + - uses: julia-actions/julia-processcoverage@v1 + - uses: codecov/codecov-action@v1 + with: + file: ./lcov.info + flags: unittests + name: codecov-umbrella + fail_ci_if_error: false + token: ${{ secrets.CODECOV_TOKEN }} diff --git a/.github/workflows/pr_testing.yml b/.github/workflows/pr_testing.yml new file mode 100644 index 0000000..2debe86 --- /dev/null +++ b/.github/workflows/pr_testing.yml @@ -0,0 +1,36 @@ +name: Test-CI + +on: + pull_request: + types: [opened, synchronize, reopened] + +jobs: + test: + name: Julia ${{ matrix.julia-version }} - ${{ matrix.os }} + runs-on: ${{ matrix.os }} + strategy: + matrix: + julia-version: ['1'] + julia-arch: [x64] + os: [ubuntu-latest, windows-latest, macOS-latest] + + steps: + - uses: actions/checkout@v2 + - uses: julia-actions/setup-julia@latest + with: + version: ${{ matrix.julia-version }} + arch: ${{ matrix.julia-arch }} + - uses: julia-actions/julia-buildpkg@latest + env: + PYTHON: "" + - uses: julia-actions/julia-runtest@latest + env: + PYTHON: "" + - uses: julia-actions/julia-processcoverage@v1 + - uses: codecov/codecov-action@v1 + with: + file: ./lcov.info + flags: unittests + name: codecov-umbrella + fail_ci_if_error: false + token: ${{ secrets.CODECOV_TOKEN }} diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..a2917e1 --- /dev/null +++ b/.gitignore @@ -0,0 +1,125 @@ +#Files generated by invoking Julia with --code-coverage +*.jl.cov +*.jl.*.cov +*.log +_*.jl +# Files generated by invoking Julia with --track-allocation +*.jl.mem + +## Autogenerated code during the documentation process +generated*.md + +# Test data +data + +# System-specific files and directories generated by the BinaryProvider and BinDeps packages +# They contain absolute paths specific to the host computer, and so should not be committed +deps/deps.jl +deps/build.log +deps/downloads/ +deps/usr/ +deps/src/ + +# Build artifacts for creating documentation generated by the Documenter package +docs/build/ +docs/site/ + +#Jupyter Ignores +.ipynb_checkpoints/ +.ipynb_checkpoints + +#Mac temp ignores +.DS_Store + +#Figures +*.pdf +*.ipynb + +Manifest.toml +.vscode +*.h5 + +################################################################################ +# Operating systems # +################################################################################ + +######################################## +# Linux # +######################################## + +*~ + +# temporary files which can be created if a process still has a handle open of +# a deleted file +.fuse_hidden* + +# KDE directory preferences +.directory + +# Linux trash folder which might appear on any partition or disk +.Trash-* + +# .nfs files are created when an open file is removed but is still being accessed +.nfs* + +######################################## +# macOS # +######################################## + +# General +.DS_Store +.AppleDouble +.LSOverride + +# Icon must end with two \r +Icon + +# Thumbnails +._* + +# Files that might appear in the root of a volume +.DocumentRevisions-V100 +.fseventsd +.Spotlight-V100 +.TemporaryItems +.Trashes +.VolumeIcon.icns +.com.apple.timemachine.donotpresent + +# Directories potentially created on remote AFP share +.AppleDB +.AppleDesktop +Network Trash Folder +Temporary Items +.apdisk + +######################################## +# Windows # +######################################## + +# Windows thumbnail cache files +Thumbs.db +ehthumbs.db +ehthumbs_vista.db + +# Dump file +*.stackdump + +# Folder config file +[Dd]esktop.ini + +# Recycle Bin used on file shares +$RECYCLE.BIN/ + +# Windows Installer files +*.cab +*.msi +*.msix +*.msm +*.msp + +# Windows shortcuts +*.lnk + +## Acknowledgements +# Many thanks to `https://gitignore.io/`, written and maintained by Joe Blau, which contributed much material to this gitignore file. diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 0000000..91c9631 --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,6 @@ +# Contributing + +Community driven development of this package is encouraged. To maintain code quality standards, please adhere to the following guidlines when contributing: + - To get started, sign the Contributor License Agreement. + - Please do your best to adhere to our [coding style guide](docs/src/developer/style.md). + - To submit code contributions, [fork](https://help.github.com/articles/fork-a-repo/) the repository, commit your changes, and [submit a pull request](https://help.github.com/articles/creating-a-pull-request-from-a-fork/). diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..280cae4 --- /dev/null +++ b/LICENSE @@ -0,0 +1,29 @@ +BSD 3-Clause License + +Copyright (c) 2018, Alliance for Sustainable Energy, LLC +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + +* Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + +* Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + +* Neither the name of the copyright holder nor the names of its + contributors may be used to endorse or promote products derived from + this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE +FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/Project.toml b/Project.toml new file mode 100644 index 0000000..b236ab7 --- /dev/null +++ b/Project.toml @@ -0,0 +1,11 @@ +name = "SIIP-Package" +uuid = "bed98974-b02a-5e2f-9ee0-a103f5c450dd" +authors = ["YOUR_NAME"] +version = "0.1.0" + +[deps] +DocStringExtensions = "ffbed154-4ef7-542d-bbb7-c09d3a79fcae" + +[compat] +DocStringExtensions = "~0.8, ~0.9" +julia = "^1.6" diff --git a/README.md b/README.md new file mode 100644 index 0000000..4f84f5e --- /dev/null +++ b/README.md @@ -0,0 +1,23 @@ +# SIIP-Template + +[![Master - CI](https://github.com/NREL-Sienna/Sienna-PACKAGE.jl/workflows/Master%20-%20CI/badge.svg)](https://github.com/NREL-Sienna/Sienna-PACKAGE.jl/actions/workflows/main-tests.yml) +[![codecov](https://codecov.io/gh/NREL-Sienna/Sienna-PACKAGE.jl/branch/master/graph/badge.svg)](https://codecov.io/gh/NREL-SIIP/SIIP-PACKAGE.jl) +[![Documentation Build](https://github.com/NREL-Sienna/Sienna-PACKAGE.jl/workflows/Documentation/badge.svg?)](https://nrel-sienna.github.io/Sienna-PACKAGE.jl/stable) +[](https://join.slack.com/t/nrel-siip/shared_invite/zt-glam9vdu-o8A9TwZTZqqNTKHa7q3BpQ) +[![Sienna-PACKAGE.jl Downloads](https://shields.io/endpoint?url=https://pkgs.genieframework.com/api/v1/badge/SIIP-PACKAGE)](https://pkgs.genieframework.com?packages=Sienna-PACKAGE) + + +This repository contains the template files for a dummy package called SIIP-PACKAGE. IT contains the required files for + +- Testing +- Documentation +- Formatting +- CI/CD to follow Sienna practices + +## Development + +Contributions to the development and enahancement of Sienna-PACKAGE is welcome. Please see [CONTRIBUTING.md](https://github.com/NREL-Sienna/Sienna-PACKAGE.jl/blob/master/CONTRIBUTING.md) for code contribution guidelines. + +## License + +SIIP-PACKAGE is released under a BSD [license](https://github.com/NREL/SIIP-PACKAGE/blob/master/LICENSE). Sienna PACKAGE has been developed as part of A PROJECT at the U.S. Department of Energy's National Renewable Energy Laboratory ([NREL](https://www.nrel.gov/)) diff --git a/codecov.yml b/codecov.yml new file mode 100644 index 0000000..69e3a59 --- /dev/null +++ b/codecov.yml @@ -0,0 +1,38 @@ +codecov: + require_ci_to_pass: yes + +coverage: + precision: 2 + round: down + range: "70...100" + + status: + project: # measuring the overall project coverage + default: # context, you can create multiple ones with custom titles + enabled: yes # must be yes|true to enable this status + target: auto # specify the target coverage for each commit status + # option: "auto" (must increase from parent commit or pull request base) + # option: "X%" a static target percentage to hit + threshold: 5 # allowed to drop X% and still result in a "success" commit status + if_not_found: success # if parent is not found report status as success, error, or failure + if_ci_failed: error # if ci fails report status as success, error, or failure + patch: + default: + target: 70 + +parsers: + gcov: + branch_detection: + conditional: yes + loop: yes + method: no + macro: no + +comment: + layout: "reach,diff,flags,tree" + behavior: default + require_changes: no + +ignore: + - "src/parsers/pm_io/" + - "src/parsers/im_io/" diff --git a/docs/Makefile b/docs/Makefile new file mode 100644 index 0000000..b3e41c1 --- /dev/null +++ b/docs/Makefile @@ -0,0 +1,14 @@ +BRANCH := $(shell git rev-parse --abbrev-ref HEAD) + +html: + julia make.jl + +github: html + -git branch -D gh-pages + -git push origin --delete gh-pages + ghp-import -n -b gh-pages -m "Update documentation" ./build + git checkout gh-pages + git push --set-upstream origin gh-pages + git checkout ${BRANCH} + +all: github diff --git a/docs/Project.toml b/docs/Project.toml new file mode 100644 index 0000000..3cc884d --- /dev/null +++ b/docs/Project.toml @@ -0,0 +1,6 @@ +[deps] +Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4" + +[compat] +Documenter = "0.27" +julia = "^1.6" diff --git a/docs/make.jl b/docs/make.jl new file mode 100644 index 0000000..949908c --- /dev/null +++ b/docs/make.jl @@ -0,0 +1,27 @@ +using Documenter, SIIP - PACKAGE + +pages = OrderedDict( + "Welcome Page" => "index.md", + "Quick Start Guide" => "quick_start_guide.md", + "Tutorials" => "tutorials/intro_page.md", + "Public API Reference" => "api/public.md", + "Internal API Reference" => "api/internal.md", +) + +makedocs( + modules=[SIIP-PACKAGE], + format=Documenter.HTML(prettyurls=haskey(ENV, "GITHUB_ACTIONS")), + sitename="SIIP-PACKAGE.jl", + authors="Freddy Mercury, Nikola Tesla, Leonard Bernestein", + pages=Any[p for p in pages], +) + +deploydocs( + repo="github.com/NREL-SIIP/SIIP-PACKAGE.git", + target="build", + branch="gh-pages", + devbranch="master", + devurl="dev", + push_preview=true, + versions=["stable" => "v^", "v#.#"], +) diff --git a/docs/src/api/internal.md b/docs/src/api/internal.md new file mode 100644 index 0000000..97b37f4 --- /dev/null +++ b/docs/src/api/internal.md @@ -0,0 +1,6 @@ +# Internal API + +```@autodocs +Modules = [SIIP-Package] +Public = false +``` diff --git a/docs/src/api/public.md b/docs/src/api/public.md new file mode 100644 index 0000000..3375250 --- /dev/null +++ b/docs/src/api/public.md @@ -0,0 +1,6 @@ +# Public API Reference + +```@autodocs +Modules = [SIIP-Package] +Public = true +``` diff --git a/docs/src/index.md b/docs/src/index.md new file mode 100644 index 0000000..625aa94 --- /dev/null +++ b/docs/src/index.md @@ -0,0 +1,14 @@ +# PowerSystems.jl + +```@meta +CurrentModule = SIIP_PACKAGE +``` + +## Overview + +`PSIIP-PACKAGE .jl` is a [`Julia`](http://www.julialang.org) package that provides blah blah + +------------ +SIIP-PACKAGE has been developed as part of the Scalable Integrated Infrastructure Planning +(SIIP) initiative at the U.S. Department of Energy's National Renewable Energy +Laboratory ([NREL](https://www.nrel.gov/)). diff --git a/docs/src/quick_start_guide.md b/docs/src/quick_start_guide.md new file mode 100644 index 0000000..eea644d --- /dev/null +++ b/docs/src/quick_start_guide.md @@ -0,0 +1,3 @@ +# Quick Start Guide + +SIIP-PACKAGE.jl is structured to enable stuff diff --git a/docs/src/tutorials/intro_page.md b/docs/src/tutorials/intro_page.md new file mode 100644 index 0000000..695be32 --- /dev/null +++ b/docs/src/tutorials/intro_page.md @@ -0,0 +1,4 @@ +# SIIP-Examples + +All the tutorials for the SIIP project are part of a separate repository +[SIIP-Examples](https://github.com/NREL-SIIP/SIIPExamples.jl). diff --git a/scripts/formatter/Project.toml b/scripts/formatter/Project.toml new file mode 100644 index 0000000..a33f747 --- /dev/null +++ b/scripts/formatter/Project.toml @@ -0,0 +1,10 @@ +uuid = "c6367ca8-164d-4469-afe3-c91cf8860505" +authors = ["Jose Daniel Lara "] + +[deps] +JuliaFormatter = "98e50ef6-434e-11e9-1051-2b60c6c9e899" +Pkg = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f" + +[compat] +JuliaFormatter = "1.0" +julia = "^1.7" diff --git a/scripts/formatter/formatter_code.jl b/scripts/formatter/formatter_code.jl new file mode 100644 index 0000000..2caa269 --- /dev/null +++ b/scripts/formatter/formatter_code.jl @@ -0,0 +1,41 @@ +using Pkg +Pkg.activate(@__DIR__) +Pkg.instantiate() +using JuliaFormatter + +main_paths = [".", "./docs/src"] +for main_path in main_paths + format( + main_path; + whitespace_ops_in_indices=true, + remove_extra_newlines=true, + verbose=true, + always_for_in=true, + whitespace_typedefs=true, + whitespace_in_kwargs=false, + format_docstrings=true, + always_use_return=false, # removed since it has false positives. + ) +end + +# Documentation Formatter +main_paths = ["./docs/src"] +for main_path in main_paths + for folder in readdir(main_path) + @show folder_path = joinpath(main_path, folder) + if isfile(folder_path) + !occursin(".md", folder_path) && continue + end + format( + folder_path; + format_markdown=true, + whitespace_ops_in_indices=true, + remove_extra_newlines=true, + verbose=true, + always_for_in=true, + whitespace_typedefs=true, + whitespace_in_kwargs=false, + # always_use_return = true # removed since it has false positives. + ) + end +end diff --git a/src/SIIP-PACKAGE.jl b/src/SIIP-PACKAGE.jl new file mode 100644 index 0000000..6a9ae3a --- /dev/null +++ b/src/SIIP-PACKAGE.jl @@ -0,0 +1,11 @@ +module SIIP +-PACKAGE + +using DocStringExtensions + +@template (FUNCTIONS, METHODS) = """ + $(TYPEDSIGNATURES) + $(DOCSTRING) + """ + +end diff --git a/test/Project.toml b/test/Project.toml new file mode 100644 index 0000000..153933c --- /dev/null +++ b/test/Project.toml @@ -0,0 +1,6 @@ +[deps] +Aqua = "4c88cf16-eb10-579e-8560-4a9242c79595" +Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" + +[compat] +julia = "^1.6" diff --git a/test/runtests.jl b/test/runtests.jl new file mode 100644 index 0000000..92321be --- /dev/null +++ b/test/runtests.jl @@ -0,0 +1,107 @@ +using Test +import Logging + +import Aqua +Aqua.test_unbound_args(SIIP - PACKAGE) +Aqua.test_undefined_exports(SIIP - PACKAGE) +Aqua.test_ambiguities(SIIP - PACKAGE) +Aqua.test_stale_deps(SIIP - PACKAGE) +Aqua.test_deps_compat(SIIP - PACKAGE) + +LOG_FILE = "power-systems.log" +LOG_LEVELS = Dict( + "Debug" => Logging.Debug, + "Info" => Logging.Info, + "Warn" => Logging.Warn, + "Error" => Logging.Error, +) + +""" +Copied @includetests from https://github.com/ssfrr/TestSetExtensions.jl. +Ideally, we could import and use TestSetExtensions. Its functionality was broken by changes +in Julia v0.7. Refer to https://github.com/ssfrr/TestSetExtensions.jl/pull/7. +""" + +""" +Includes the given test files, given as a list without their ".jl" extensions. +If none are given it will scan the directory of the calling file and include all +the julia files. +""" +macro includetests(testarg...) + if length(testarg) == 0 + tests = [] + elseif length(testarg) == 1 + tests = testarg[1] + else + error("@includetests takes zero or one argument") + end + + quote + tests = $tests + rootfile = @__FILE__ + if length(tests) == 0 + tests = readdir(dirname(rootfile)) + tests = filter( + f -> + startswith(f, "test_") && endswith(f, ".jl") && f != basename(rootfile), + tests, + ) + else + tests = map(f -> string(f, ".jl"), tests) + end + println() + for test in tests + print(splitext(test)[1], ": ") + include(test) + println() + end + end +end + +function get_logging_level_from_env(env_name::String, default) + level = get(ENV, env_name, default) + return IS.get_logging_level(level) +end + +function run_tests() + logging_config_filename = get(ENV, "SIIP_LOGGING_CONFIG", nothing) + if logging_config_filename !== nothing + config = IS.LoggingConfiguration(logging_config_filename) + else + config = IS.LoggingConfiguration(; + filename=LOG_FILE, + file_level=Logging.Info, + console_level=Logging.Error, + ) + end + console_logger = ConsoleLogger(config.console_stream, config.console_level) + + IS.open_file_logger(config.filename, config.file_level) do file_logger + levels = (Logging.Info, Logging.Warn, Logging.Error) + multi_logger = + IS.MultiLogger([console_logger, file_logger], IS.LogEventTracker(levels)) + global_logger(multi_logger) + + if !isempty(config.group_levels) + IS.set_group_levels!(multi_logger, config.group_levels) + end + + # Testing Topological components of the schema + @time @testset "Begin SIIP-PACKAGE tests" begin + @includetests ARGS + end + + @test length(IS.get_log_events(multi_logger.tracker, Logging.Error)) == 0 + @info IS.report_log_summary(multi_logger) + end +end + +logger = global_logger() + +try + run_tests() +finally + # Guarantee that the global logger is reset. + global_logger(logger) + nothing +end diff --git a/test/test_file.jl b/test/test_file.jl new file mode 100644 index 0000000..ab9151b --- /dev/null +++ b/test/test_file.jl @@ -0,0 +1,2 @@ +# Put your tests here +@test 1 == 1