Skip to content

Commit

Permalink
Add spell check and format check workflows (#17)
Browse files Browse the repository at this point in the history
* add permissions for cache deletion

* add format check workflow

* add spell check

* fix typo

* apply formatter

* Update .github/workflows/FormatCheck.yml

* apply formatter

---------

Co-authored-by: Andrew Winters <[email protected]>
Co-authored-by: Michael Schlottke-Lakemper <[email protected]>
  • Loading branch information
3 people authored Jan 31, 2024
1 parent cd51eff commit 6bb65dd
Show file tree
Hide file tree
Showing 7 changed files with 79 additions and 22 deletions.
41 changes: 41 additions & 0 deletions .github/workflows/FormatCheck.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: format-check

on:
push:
branches:
- 'main'
tags: '*'
pull_request:

jobs:
check-format:
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@v4
- 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"))'
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'
13 changes: 13 additions & 0 deletions .github/workflows/SpellCheck.yml
Original file line number Diff line number Diff line change
@@ -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/[email protected]
5 changes: 5 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,11 @@ concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: ${{ startsWith(github.ref, 'refs/pull/') }}

# needed to allow julia-actions/cache to delete old caches that it has created
permissions:
actions: write
contents: read

jobs:
test:
if: "!contains(github.event.head_commit.message, 'skip ci')"
Expand Down
34 changes: 16 additions & 18 deletions docs/make.jl
Original file line number Diff line number Diff line change
@@ -1,25 +1,23 @@
using TrixiShallowWater
using Documenter

DocMeta.setdocmeta!(TrixiShallowWater, :DocTestSetup, :(using TrixiShallowWater); recursive=true)
DocMeta.setdocmeta!(TrixiShallowWater, :DocTestSetup, :(using TrixiShallowWater);
recursive = true)

makedocs(;
modules=[TrixiShallowWater],
authors="Andrew R. Winters <[email protected]>, Michael Schlottke-Lakemper <[email protected]>",
repo="https://github.com/trixi-framework/TrixiShallowWater.jl/blob/{commit}{path}#{line}",
sitename="TrixiShallowWater.jl",
format=Documenter.HTML(;
prettyurls=get(ENV, "CI", "false") == "true",
canonical="https://trixi-framework.github.io/TrixiShallowWater.jl",
edit_link="main",
assets=String[],
),
pages=[
"Home" => "index.md",
],
)
modules = [TrixiShallowWater],
authors = "Andrew R. Winters <[email protected]>, Michael Schlottke-Lakemper <[email protected]>",
repo = "https://github.com/trixi-framework/TrixiShallowWater.jl/blob/{commit}{path}#{line}",
sitename = "TrixiShallowWater.jl",
format = Documenter.HTML(;
prettyurls = get(ENV, "CI", "false") == "true",
canonical = "https://trixi-framework.github.io/TrixiShallowWater.jl",
edit_link = "main",
assets = String[],),
pages = [
"Home" => "index.md",
],)

deploydocs(;
repo="github.com/trixi-framework/TrixiShallowWater.jl",
devbranch="main",
)
repo = "github.com/trixi-framework/TrixiShallowWater.jl",
devbranch = "main",)
2 changes: 1 addition & 1 deletion src/equations/shallow_water_wet_dry_1d.jl
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ end

# This equation set extends the basic ShallowWaterEquations1D from Trixi.jl with additional functionality
# for wet/dry transitions. Since many functions correspond to the fully wet case, we make use of the
# exisiting functionality and introduce a number of wrapper functions, that dispatch to the
# existing functionality and introduce a number of wrapper functions, that dispatch to the
# ShallowWaterEquations1D.

# Set initial conditions at physical location `x` for time `t`
Expand Down
4 changes: 2 additions & 2 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ const TRIXI_NTHREADS = clamp(Sys.CPU_THREADS, 2, 3)
@test !(name in names(TrixiShallowWater))
end
end

# Run upstream tests for each mesh and dimension to test compatibility with Trixi.jl
include("test_upstream.jl")
include("test_upstream.jl")
end
end
2 changes: 1 addition & 1 deletion test/test_upstream.jl
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ isdir(outdir) && rm(outdir, recursive = true)
# Shallow water wet/dry 1D
@trixi_testset "1D-Test: elixir_shallowwater_well_balanced_nonperiodic.jl with wall boundary" begin
@test_trixi_include(joinpath(EXAMPLES_DIR, "tree_1d_dgsem",
"elixir_shallowwater_well_balanced_nonperiodic.jl"),
"elixir_shallowwater_well_balanced_nonperiodic.jl"),
l2=[
1.7259643614361866e-8,
3.5519018243195145e-16,
Expand Down

0 comments on commit 6bb65dd

Please sign in to comment.