Skip to content

Commit f312b91

Browse files
#339 Make the nimforum Nim2 compatible (#340)
* Update db_sqlite import to work for nim 2.0 With nim2.0 the database module db_sqlite was removed from the std-lib It now resides in the db_connector package. This change was introduced with nim 1.9.1. That is the upcoming nim 2 version In order to make the nimforum thus compatible with the upcoming nim2 version, we therefore add a when switch to allow compilation for it. * ADD gc safety to procs used by jester GC-safety checks with nim 2.0 appear to have gotten stricter. So procs that prior were able to compile now dont. That is because they are fundamentally not gcsafe. That is because they access global state unnecessarily. As it worked fine before I opted to just cast them to gcsafe for now. In the long term a refactor should be done though to reduce global state * Change MM to refc instead of using ORC ORC is the new default for nim2.0, where refc was the default before. The issue is that with ORC under nim2, compiling causes errors. Specifically: In file included from /home/philipp/.cache/nim/forum_d/@m..@s..@s[email protected]@[email protected]@ssass.nim.c:7: /home/philipp/.cache/nim/forum_d/@m..@s..@s[email protected]@[email protected]@ssass.nim.c:147:27: error: conflicting types for ‘strdup’; have ‘char *(char *)’ 147 | N_NIMCALL(NCSTRING, strdup)(NCSTRING str__CVkfoDo9b9cQv7TZWHHhqk6w); | ^~~~~~ /home/philipp/.choosenim/toolchains/nim-#devel/lib/nimbase.h:257:44: note: in definition of macro ‘N_NIMCALL’ 257 | # define N_NIMCALL(rettype, name) rettype name /* no modifier */ I can't deal with this, so for now the forum goes back to using refc. That fixes the issue (for now). * FIX set_nimforum exitcode being > 0 when returning correctly When running nimble testdb, nimble displays an error in the terminal. That is not because of an actual error. That is because echo and other things like it affect which exit code gets returned. It is unclear as to why that is, as that makes no sense. However, you can *force* which exitCode should be returned. The proc for that is "quit()", which returns exitCode 0 by default. * FIX nimble frontend task Nim 1 ran with memory management being refc by default. Nim 2 changed that to be ORC instead. This appears to have an effect on the "nimble c -r src/buildcss" command. With ORC it throws hard to debug errors. Therefore the command was moved back to refc * ADD JS compile command back This is a command to compile the JS for the forum. This was accidentally removed during the update to nim 2.0. * Update db_sqlite import to work for nim 2.0 With nim2.0 the database module db_sqlite was removed from the std-lib It now resides in the db_connector package. This change was introduced with nim 1.9.1. That is the upcoming nim 2 version In order to make the nimforum thus compatible with the upcoming nim2 version, we therefore add a when switch to allow compilation for it. * Change set MM in pipeline explicitly to refc ORC is the new default for nim2.0, where refc was the default before. The issue is that with ORC under nim2, compiling causes errors. This also affects the nimble install command of the github pipeline. To fix this, we just explicitly provide a flag that set mm to refc. This does not change anything when testing under 1.6.10. For nim devel/nim 2.0 it'll enforce using refc over orc. * UPDATE webdriver version The previous webdriver version could not compile with nim 2.0. That was due to equality checks between enums and strings. Those used to be implicitly allowed in nim1 but no longer are. Thus we changed this to explicit equality there. This version update should transfer those changes to here as well. Thus tests should be able to run again.
1 parent 3eadc55 commit f312b91

File tree

6 files changed

+115
-85
lines changed

6 files changed

+115
-85
lines changed

.github/workflows/main.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,14 @@ on:
1212

1313
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
1414
jobs:
15-
test_stable:
15+
test_stable_and_devel:
1616
runs-on: ubuntu-latest
1717
strategy:
1818
matrix:
1919
chrome: [ 'stable' ]
20+
nim-version: ['1.6.10', 'devel']
2021
include:
21-
- nim-version: '1.6.10'
22-
cache-key: 'stable'
22+
- cache-key: 'stable'
2323
steps:
2424
- uses: actions/checkout@v2
2525
- name: Checkout submodules
@@ -68,5 +68,5 @@ jobs:
6868
run: |
6969
export PATH=$HOME/.nimble/bin:$PATH
7070
export MOZ_HEADLESS=1
71-
nimble -y install
71+
nimble -y --mm:refc install
7272
nimble -y test

nimforum.nimble

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,22 +22,26 @@ requires "sass#649e0701fa5c"
2222

2323
requires "karax#45bac6b"
2424

25-
requires "webdriver#429933a"
25+
requires "webdriver#c5e4182"
26+
27+
when NimMajor >= 1 and NimMinor >= 9:
28+
requires "db_connector >= 0.1.0"
29+
requires "smtp >= 0.1.0"
2630

2731
# Tasks
2832

2933
task backend, "Compiles and runs the forum backend":
30-
exec "nimble c src/forum.nim"
34+
exec "nimble c --mm:refc src/forum.nim"
3135
exec "./src/forum"
3236

3337
task runbackend, "Runs the forum backend":
3438
exec "./src/forum"
3539

3640
task testbackend, "Runs the forum backend in test mode":
37-
exec "nimble c -r -d:skipRateLimitCheck src/forum.nim"
41+
exec "nimble c -r --mm:refc -d:skipRateLimitCheck src/forum.nim"
3842

3943
task frontend, "Builds the necessary JS frontend (with CSS)":
40-
exec "nimble c -r src/buildcss"
44+
exec "nimble c -r --mm:refc src/buildcss"
4145
exec "nimble js -d:release src/frontend/forum.nim"
4246
mkDir "public/js"
4347
cpFile "src/frontend/forum.js", "public/js/forum.js"
@@ -58,7 +62,7 @@ task blankdb, "Creates a blank DB":
5862
exec "./src/setup_nimforum --blank"
5963

6064
task test, "Runs tester":
61-
exec "nimble c -y src/forum.nim"
65+
exec "nimble c -y --mm:refc src/forum.nim"
6266
exec "nimble c -y -r -d:actionDelayMs=0 tests/browsertester"
6367

6468
task fasttest, "Runs tester without recompiling backend":

0 commit comments

Comments
 (0)