From ee0f018148d9909071cf190e29221ff04a4415fd Mon Sep 17 00:00:00 2001 From: Jacek Sieka Date: Wed, 14 Aug 2024 07:35:43 +0200 Subject: [PATCH 1/2] add `nph` formatting linter --- .github/workflows/ci.yml | 19 +++++++++++++++++++ results.nimble | 15 +++++++-------- tests/test_results.nim | 8 +++++--- 3 files changed, 31 insertions(+), 11 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 6908df0..44e0d88 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -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 \ No newline at end of file diff --git a/results.nimble b/results.nimble index ab87fa2..8ce6d28 100644 --- a/results.nimble +++ b/results.nimble @@ -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" @@ -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"]: diff --git a/tests/test_results.nim b/tests/test_results.nim index ec00174..d434e73 100644 --- a/tests/test_results.nim +++ b/tests/test_results.nim @@ -502,6 +502,7 @@ block: # Result[T, void] aka `Opt` $x ) .get() == $oOk.get() + oOk .map( proc(x: int) = @@ -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) From 6239ea35ba93894ec7f8146c7b2e3261b27338b3 Mon Sep 17 00:00:00 2001 From: Jacek Sieka Date: Wed, 14 Aug 2024 07:36:55 +0200 Subject: [PATCH 2/2] missing directory --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 44e0d88..c61c445 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -55,5 +55,5 @@ jobs: ARCHIVE="nph-linux_x64.tar.gz" curl -L "https://github.com/arnetheduck/nph/releases/download/${VERSION}/${ARCHIVE}" -o ${ARCHIVE} tar -xzf ${ARCHIVE} - ./nph + ./nph . git diff --exit-code \ No newline at end of file