Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add nph formatting linter #48

Merged
merged 2 commits into from
Aug 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,22 @@ jobs:
env TEST_LANG="c" nimble test
env TEST_LANG="cpp" nimble test


lint:
name: "Check formatting"
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 2 # In PR, has extra merge commit: ^1 = PR, ^2 = base

- name: Check nph formatting
# Pin nph to a specific version to avoid sudden style differences.
run: |
VERSION="v0.6.0"
ARCHIVE="nph-linux_x64.tar.gz"
curl -L "https://github.com/arnetheduck/nph/releases/download/${VERSION}/${ARCHIVE}" -o ${ARCHIVE}
tar -xzf ${ARCHIVE}
./nph .
git diff --exit-code
15 changes: 7 additions & 8 deletions results.nimble
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
# Package

version = "0.4.0"
author = "Jacek Sieka"
description = "Friendly, exception-free value-or-error returns, similar to Option[T]"
license = "MIT"
skipDirs = @["benchmarks", "tests"]
installFiles = @["results.nim"]
version = "0.4.0"
author = "Jacek Sieka"
description = "Friendly, exception-free value-or-error returns, similar to Option[T]"
license = "MIT"
skipDirs = @["benchmarks", "tests"]
installFiles = @["results.nim"]
# Dependencies

requires "nim >= 1.2"
Expand All @@ -15,8 +15,7 @@ proc test(env, path: string) =
var lang = "c"
if existsEnv"TEST_LANG":
lang = getEnv"TEST_LANG"
exec "nim " & lang & " " & env &
" -r " & path
exec "nim " & lang & " " & env & " -r " & path

task test, "Runs the test suite":
for f in ["test_results.nim", "test_results2.nim"]:
Expand Down
8 changes: 5 additions & 3 deletions tests/test_results.nim
Original file line number Diff line number Diff line change
Expand Up @@ -502,6 +502,7 @@ block: # Result[T, void] aka `Opt`
$x
)
.get() == $oOk.get()

oOk
.map(
proc(x: int) =
Expand Down Expand Up @@ -593,10 +594,11 @@ block: # Result[T, void] aka `Opt`
doAssert oOk.value() + 1 notin oOk

block: # Nested `?`
proc inside: Opt[int] =
proc inside(): Opt[int] =
ok(5)
proc kput: Opt[int] =
ok(? inside())

proc kput(): Opt[int] =
ok(?inside())

doAssert kput() == Opt.some(5)

Expand Down