Skip to content

Commit bf8a958

Browse files
authored
add nph formatting linter (#48)
* add `nph` formatting linter * missing directory
1 parent 0313bce commit bf8a958

File tree

3 files changed

+31
-11
lines changed

3 files changed

+31
-11
lines changed

.github/workflows/ci.yml

+19
Original file line numberDiff line numberDiff line change
@@ -38,3 +38,22 @@ jobs:
3838
env TEST_LANG="c" nimble test
3939
env TEST_LANG="cpp" nimble test
4040
41+
42+
lint:
43+
name: "Check formatting"
44+
runs-on: ubuntu-latest
45+
steps:
46+
- name: Checkout
47+
uses: actions/checkout@v4
48+
with:
49+
fetch-depth: 2 # In PR, has extra merge commit: ^1 = PR, ^2 = base
50+
51+
- name: Check nph formatting
52+
# Pin nph to a specific version to avoid sudden style differences.
53+
run: |
54+
VERSION="v0.6.0"
55+
ARCHIVE="nph-linux_x64.tar.gz"
56+
curl -L "https://github.com/arnetheduck/nph/releases/download/${VERSION}/${ARCHIVE}" -o ${ARCHIVE}
57+
tar -xzf ${ARCHIVE}
58+
./nph .
59+
git diff --exit-code

results.nimble

+7-8
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
# Package
22

3-
version = "0.4.0"
4-
author = "Jacek Sieka"
5-
description = "Friendly, exception-free value-or-error returns, similar to Option[T]"
6-
license = "MIT"
7-
skipDirs = @["benchmarks", "tests"]
8-
installFiles = @["results.nim"]
3+
version = "0.4.0"
4+
author = "Jacek Sieka"
5+
description = "Friendly, exception-free value-or-error returns, similar to Option[T]"
6+
license = "MIT"
7+
skipDirs = @["benchmarks", "tests"]
8+
installFiles = @["results.nim"]
99
# Dependencies
1010

1111
requires "nim >= 1.2"
@@ -15,8 +15,7 @@ proc test(env, path: string) =
1515
var lang = "c"
1616
if existsEnv"TEST_LANG":
1717
lang = getEnv"TEST_LANG"
18-
exec "nim " & lang & " " & env &
19-
" -r " & path
18+
exec "nim " & lang & " " & env & " -r " & path
2019

2120
task test, "Runs the test suite":
2221
for f in ["test_results.nim", "test_results2.nim"]:

tests/test_results.nim

+5-3
Original file line numberDiff line numberDiff line change
@@ -502,6 +502,7 @@ block: # Result[T, void] aka `Opt`
502502
$x
503503
)
504504
.get() == $oOk.get()
505+
505506
oOk
506507
.map(
507508
proc(x: int) =
@@ -593,10 +594,11 @@ block: # Result[T, void] aka `Opt`
593594
doAssert oOk.value() + 1 notin oOk
594595

595596
block: # Nested `?`
596-
proc inside: Opt[int] =
597+
proc inside(): Opt[int] =
597598
ok(5)
598-
proc kput: Opt[int] =
599-
ok(? inside())
599+
600+
proc kput(): Opt[int] =
601+
ok(?inside())
600602

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

0 commit comments

Comments
 (0)