Skip to content

Commit d92a20c

Browse files
committed
ci: add linting for maximum filename length
Related to #1659
1 parent 0a9259e commit d92a20c

File tree

4 files changed

+34
-0
lines changed

4 files changed

+34
-0
lines changed

.github/workflows/lint.yml

+11
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,17 @@ jobs:
5656
- name: Lint new commits
5757
run: make --silent lintcommit-ci
5858

59+
lint-filename-length:
60+
name: Lint filename lengths
61+
runs-on: ubuntu-latest
62+
steps:
63+
- uses: actions/checkout@v4
64+
with:
65+
fetch-depth: 0
66+
ref: ${{ github.event.pull_request.head.sha || github.ref }}
67+
- name: Lint filename legnths
68+
run: make --silent lint-filename-length-ci
69+
5970
case-sensitivity:
6071
name: File case sensitivity
6172
runs-on: ubuntu-latest

Makefile

+3
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@ documentation:
3030
lintcommit-ci:
3131
export LINTCOMMIT_STRICT=true && chmod u+x scripts/lintcommit-ci.sh && scripts/lintcommit-ci.sh
3232

33+
lint-filename-length-ci:
34+
chmod u+x scripts/lint-filename-length.sh && scripts/lint-filename-length.sh
35+
3336
dual_sync:
3437
chmod u+x scripts/dual_sync.sh && scripts/dual_sync.sh
3538

TESTING.md

+4
Original file line numberDiff line numberDiff line change
@@ -987,3 +987,7 @@ return Helpers
987987
-- Some code setting up `child`
988988
local set_lines = function(lines) child.api.nvim_buf_set_lines(0, 0, -1, true, lines) end
989989
```
990+
991+
- When working with automatically named screenshots, beware of the following caveats:
992+
- Some systems are case insensitive (like usually Windows and MacOS). So having two different file names which are the same ignoring case will introduce problems for users to properly install plugin.
993+
- Some system setups have restrictions on full path length (like 260 bytes on some Git+Windows combinations) or file name length (like 255 bytes on ext4 Windows partitions and 143 bytes on eCryptfs Linux partitions). Restriction on full path is hard to accommodate for (apart from limiting file name size to some reasonable number), but trying to not have file names longer than 143 bytes (by having shorter test case names) should be reasonable.

scripts/lint-filename-length.sh

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#!/usr/bin/env bash
2+
3+
# Exact value of maximum length is chosen as a "reasonably high but not bigger
4+
# than 143 (maximum filename length on eCryptfs systmes) number".
5+
# Having low-ish value also helps with restirctions on full path length.
6+
max_filename_length=125
7+
8+
exit_code=0
9+
for filename in $(find . -not -path './.git/**' -not -path './dual/**' -printf %f\\n); do
10+
if [ "${#filename}" -gt $max_filename_length ]; then
11+
echo "Too long file name: $filename"
12+
exit_code=1
13+
fi
14+
done
15+
16+
exit $exit_code

0 commit comments

Comments
 (0)