Skip to content

Commit b44822e

Browse files
refactor: change minimum required Nim version to 1.6.0 (#29)
* chore: import notcurses/abi/coverage in extras/lsp * build: detect platform and download matching codecov uploader binary * chore: in extras scripts do not echo unnecessarily for release build * build: use lcov option `--ignore-errors unused` together with `--extract` in coverage script * ci: revise usage of choosenim in Builds workflow * refactor: change minimum required Nim version to 1.6.0
1 parent 881d3fe commit b44822e

File tree

24 files changed

+75
-128
lines changed

24 files changed

+75
-128
lines changed

.github/workflows/builds.yml

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ jobs:
1919
strategy:
2020
fail-fast: false
2121
matrix:
22-
cache_marker: [ 34 ]
22+
cache_marker: [ 40 ]
2323
platform:
2424
- {
2525
icon: 🐧,
@@ -39,7 +39,7 @@ jobs:
3939
os: windows,
4040
shell: msys2
4141
}
42-
nim_version: [ v1.2.8, version-1-2, version-1-4, version-1-6, version-2-0, devel ]
42+
nim_version: [ v1.6.0, version-1-6, version-2-0, devel ]
4343
name: ${{ matrix.platform.icon }} ${{ matrix.platform.label }} - Nim ${{ matrix.nim_version }}
4444
runs-on: ${{ matrix.platform.os }}-latest
4545
defaults:
@@ -100,7 +100,7 @@ jobs:
100100
git clone --depth 1 $2 $1 \
101101
--branch $3 2>/dev/null && \
102102
cd $1 && git rev-parse HEAD \
103-
| cut -c1-7)" >> ${GITHUB_OUTPUT}
103+
| cut -c1-10)" >> ${GITHUB_OUTPUT}
104104
}
105105
clone1b choosenim \
106106
https://github.com/dom96/choosenim.git \
@@ -194,14 +194,20 @@ jobs:
194194
if [[ ${{ matrix.platform.os }} = windows ]]; then
195195
mkdir -p "$(cygpath "${USERPROFILE}")/.nimble/bin"
196196
fi
197-
CHOOSENIM_CHOOSE_VERSION=\#${{ matrix.nim_version }} \
198-
CHOOSENIM_NO_ANALYTICS=1 \
197+
export CHOOSENIM_CHOOSE_VERSION=\#${{ steps.cache-key.outputs.nim_commit }}
198+
export CHOOSENIM_NO_ANALYTICS=1
199199
./init.sh -y
200200
if [[ ${{ matrix.platform.os }} = windows ]]; then
201201
mv "$(cygpath "${USERPROFILE}")/.nimble" "${HOME}/"
202202
fi
203+
export NIMBLE_DIR="${HOME}/.nimble"
204+
export PATH="${NIMBLE_DIR}/bin:${PATH}"
203205
echo 'export NIMBLE_DIR="${HOME}/.nimble"' >> "${HOME}/.bash_env"
204206
echo 'export PATH="${NIMBLE_DIR}/bin:${PATH}"' >> "${HOME}/.bash_env"
207+
echo
208+
nim --version
209+
echo
210+
nimble --version
205211
206212
# maybe can be reworked (along with caching logic) re: Nimble
207213
# corresponding to Nim v2, with conditional logic for older Nim/Nimble
@@ -222,14 +228,13 @@ jobs:
222228
# Nim's version-2-0 branch still sets package search path to pkgs instead
223229
# of pkgs2 when NIMBLE_DIR environment variable is set
224230
# https://github.com/nim-lang/nimble/issues/1061
225-
# https://github.com/nim-lang/Nim/blob/version-2-0/compiler/commands.nim#L613
231+
# https://github.com/nim-lang/Nim/blob/version-2-0/compiler/commands.nim#L614-L616
226232
# it's harmless to set an additional --nimblePath that isn't relevant
227233
# (doesn't exist) for a particular version of Nim/Nimble
228234
- name: Build examples
229235
run: |
230236
source "${HOME}/.bash_env"
231237
extras/build_examples.sh --nimblePath:"${NIMBLE_DIR}/pkgs2"
232-
echo
233238
extras/build_examples.sh -d:release --nimblePath:"${NIMBLE_DIR}/pkgs2"
234239
235240
# Notcurses is currently not able to access Windows ConPTY in GitHub Actions

README.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -149,27 +149,27 @@ $ nim c --passC:"-I${HOME}/repos/notcurses/include" \
149149

150150
To build all the examples do
151151

152-
``` text
152+
```text
153153
$ extras/build_examples.sh
154154
```
155155

156156
Additional options are supported
157157

158-
``` text
158+
```text
159159
$ extras/build_examples.sh -d:release --passC ...
160160
```
161161

162162
## Tests
163163

164164
Unit tests for nim-notcurses can be run with [`nimble`](https://github.com/nim-lang/nimble#readme)
165165

166-
``` text
166+
```text
167167
$ nimble test
168168
```
169169

170170
You can use additional `nimble` and compiler options
171171

172-
``` text
172+
```text
173173
$ nimble --verbose test --passC ...
174174
```
175175

@@ -183,13 +183,13 @@ Most of Notcurses' facilities expect a proper terminal. Also, given the nature o
183183

184184
Currently, most of the coverage data is generated by building and running the [examples](#examples), with unit [tests](#tests) filling in a few gaps
185185

186-
``` text
186+
```text
187187
$ extras/coverage.sh
188188
```
189189

190190
Additional options are supported
191191

192-
``` text
192+
```text
193193
$ extras/coverage.sh --passC ...
194194
```
195195

examples/config.nims

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,7 @@ else:
2525
--threads:on
2626
--tlsEmulation:off
2727

28-
when (NimMajor, NimMinor) == (1, 2):
29-
switch("hint", "Processing:off")
30-
switch("hint", "XDeclaredButNotUsed:off")
31-
switch("warning", "ObservableStores:off")
32-
elif (NimMajor, NimMinor) == (1, 4):
33-
switch("hint", "XCannotRaiseY:off")
34-
else:
35-
--hint:"XCannotRaiseY:off"
28+
--hint:"XCannotRaiseY:off"
3629
when (NimMajor, NimMinor, NimPatch) > (1, 6, 10):
3730
--warning:"BareExcept:on"
3831

extras/build_examples.sh

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@ source extras/examples.sh
77
for module in ${modules[@]}; do
88
echo
99
echo nim c "$@" examples/${module}.nim
10-
echo
10+
if [[ ! ("$@" = *"-d:release"* || "$@" = *"--define:release"*) ]]; then
11+
echo
12+
fi
1113
nim c "$@" examples/${module}.nim
1214
done
1315

extras/coverage.sh

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,9 @@ for module in ${modules[@]}; do
1818
fi
1919
echo
2020
echo nim c -d:coverage "$@" examples/${module}.nim
21-
echo
21+
if [[ ! ("$@" = *"-d:release"* || "$@" = *"--define:release"*) ]]; then
22+
echo
23+
fi
2224
nim c -d:coverage "$@" examples/${module}.nim
2325
done
2426

@@ -84,6 +86,7 @@ lcov --add-tracefile \
8486

8587
echo
8688
lcov --extract coverage/coverage.info \
89+
--ignore-errors unused \
8790
"${PWD}"/notcurses.nim \
8891
"${PWD}"/notcurses/\*.nim \
8992
>> coverage/extracted.info
@@ -97,7 +100,17 @@ genhtml coverage/extracted.info \
97100

98101
if [[ ! -z "${CODECOV_TOKEN}" ]]; then
99102
cd coverage
100-
curl -Os https://uploader.codecov.io/latest/macos/codecov
103+
if [[ $(uname) = "Linux" ]]; then
104+
curl -Os https://uploader.codecov.io/latest/linux/codecov
105+
elif [[ $(uname) = "Darwin" ]]; then
106+
curl -Os https://uploader.codecov.io/latest/macos/codecov
107+
elif [[ -v MSYSTEM ]]; then
108+
curl -Os https://uploader.codecov.io/latest/windows/codecov.exe
109+
else
110+
echo -e ${bred}Error${none}: codecov uploader binary is only available for \
111+
Linux, macOS, and Windows
112+
exit 1
113+
fi
101114
chmod +x codecov
102115
cd - 1>/dev/null
103116
echo

extras/lsp.nim

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import
2525
notcurses,
2626
notcurses/abi,
2727
notcurses/abi/core,
28+
notcurses/abi/coverage,
2829
notcurses/abi/direct,
2930
notcurses/abi/direct/core as notcurses_abi_direct_core,
3031
notcurses/core as notcurses_core,

notcurses.nim

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
{.passL: "-lnotcurses -lnotcurses-core".}
22

3-
when (NimMajor, NimMinor) >= (1, 4):
4-
{.push raises: [].}
5-
else:
6-
{.push raises: [Defect].}
3+
{.push raises: [].}
74

85
import ./notcurses/abi/impl as abi_impl
96
import ./notcurses/api/impl

notcurses.nimble

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ license = "Apache License 2.0 or MIT"
66
installDirs = @["notcurses"]
77
installFiles = @["LICENSE", "LICENSE-APACHEv2", "LICENSE-MIT", "LICENSE-NOTCURSES", "notcurses.nim"]
88

9-
requires "nim >= 1.2.8",
9+
requires "nim >= 1.6.0",
10+
"results",
1011
"stew",
1112
"unittest2"

notcurses/abi/common.nim

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
11
# L[num] comments below pertain to sources for Notcurses v3.0.9
22
# https://github.com/dankamongmen/notcurses/tree/v3.0.9/include
33

4-
when (NimMajor, NimMinor) >= (1, 4):
5-
{.push raises: [].}
6-
else:
7-
{.push raises: [Defect].}
4+
{.push raises: [].}
85

96
import std/[strutils, terminal]
107
import ./constants

notcurses/abi/constants/nckeys.nim

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,7 @@
33

44
# this module uses extra whitespace so it can be visually scanned more easily
55

6-
when (NimMajor, NimMinor) >= (1, 4):
7-
{.push raises: [].}
8-
else:
9-
{.push raises: [Defect].}
6+
{.push raises: [].}
107

118
# L31 - notcurses/nckeys.h
129
const PRETERUNICODEBASE* = 1115000'u32

0 commit comments

Comments
 (0)