Skip to content

Commit bcf2faa

Browse files
committed
Add GitHub Actions workflow config
First pass; this could probably be better - e.g. test across multiple shell intalls in each environment. But, eh, all in good time.
1 parent 54dfdaf commit bcf2faa

2 files changed

Lines changed: 68 additions & 18 deletions

File tree

.github/workflows/ci.yml

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
name: ci.yml
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
pull_request:
7+
branches: [ main ]
8+
workflow_dispatch: # Allows manual triggering
9+
10+
jobs:
11+
12+
test:
13+
runs-on: ${{ matrix.os }}
14+
strategy:
15+
fail-fast: false # Continue testing other platforms even if one fails
16+
matrix:
17+
os:
18+
- ubuntu-latest
19+
- macos-latest
20+
- windows-latest
21+
steps:
22+
- name: Checkout repository
23+
uses: actions/checkout@v4
24+
- name: Display environment
25+
run: |
26+
echo "Runner OS: ${{ runner.os }}"
27+
echo "Matrix OS: ${{ matrix.os }}"
28+
if command -v uname >/dev/null 2>&1; then
29+
echo "System: $(uname -a)"
30+
fi
31+
echo "Shell: $0"
32+
echo "Working directory: $(pwd)"
33+
echo "User: $(whoami)"
34+
- name: Run ./ff-test
35+
run: ./ff-test
36+
37+
shellcheck:
38+
runs-on: ubuntu-latest
39+
steps:
40+
- name: Checkout repository
41+
uses: actions/checkout@v4
42+
- name: Install shellcheck
43+
run: |
44+
sudo apt-get update
45+
sudo apt-get install --assume-yes --no-install-recommends shellcheck
46+
- name: Run shellcheck
47+
run: shellcheck --shell=sh ./ff ./ff-test

ff-test

Lines changed: 21 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ fi
3939
TESTS_RUN=0
4040
TESTS_PASSED=0
4141
TESTS_FAILED=0
42-
TEST_FAILURES=""
4342

4443
run_test() {
4544
# Parse arguments:
@@ -74,16 +73,20 @@ run_test() {
7473
;;
7574
esac
7675
done
76+
7777
# Print test pre-amble:
7878
TESTS_RUN=$((TESTS_RUN + 1))
79+
7980
# Run command and capture its stdout, stderr and exit code:
8081
_stdout_file="$(mktemp)"
8182
_stderr_file="$(mktemp)"
8283
_exit_code=0
8384
eval "$_test_command" >"$_stdout_file" 2>"$_stderr_file" || _exit_code=$?
85+
8486
# Check the command's output:
85-
_test_stdout="$(cat "$_stdout_file")"
87+
_test_stdout="$(LC_COLLATE=C sort < "$_stdout_file")"
8688
_test_stderr="$(cat "$_stderr_file")"
89+
8790
_test_passed=true
8891
_failure_reason=""
8992
# Check stdout - either exact match or pattern match:
@@ -183,39 +186,39 @@ cleanup_test_dir() {
183186
test_basic_functionality() {
184187
run_test "List specific file" "$FF_PATH file1.txt" --stdout "./file1.txt"
185188
run_test "Simple pattern - just script files" "$FF_PATH script" --stdout "./script.sh"
186-
run_test "Pattern with extension" "$FF_PATH '*.py'" --stdout "./file2.py
187-
./dir1/subdir1/deep_file.py"
189+
run_test "Pattern with extension" "$FF_PATH '*.py'" --stdout "./dir1/subdir1/deep_file.py
190+
./file2.py"
188191
run_test "Pattern with glob" "$FF_PATH 'config*'" --stdout "./config"
189-
run_test "All files with 'file' in name" "$FF_PATH -d 2 file" --stdout "./file1.txt
190-
./file2.py
191-
./file3.log
192+
run_test "All files with 'file' in name" "$FF_PATH -d 2 file" --stdout "./dir1/nested_file.txt
193+
./dir2/another_file.log
192194
./file with spaces.txt
193195
./file-with-dashes.txt
196+
./file1.txt
197+
./file2.py
198+
./file3.log
194199
./file_with_underscores.txt
195-
./dir1/nested_file.txt
196-
./dir2/another_file.log
197200
./link_to_file1"
198201
}
199202

200203
test_options() {
201-
run_test "Hidden files included" "$FF_PATH -H hidden" --stdout "./.hidden_file
202-
./.hidden_dir"
204+
run_test "Hidden files included" "$FF_PATH -H hidden" --stdout "./.hidden_dir
205+
./.hidden_file"
203206
run_test "Hidden files excluded by default" "$FF_PATH hidden" --stdout ""
204207
run_test "Type file - limited to specific files" "$FF_PATH -t f -e txt file1" --stdout "./file1.txt"
205208
run_test "Type directory" "$FF_PATH -t d dir" --stdout "./dir1
206209
./dir1/subdir1
207210
./dir2
208211
./dir2/subdir2"
209-
run_test "Extension py" "$FF_PATH -e py" --stdout "./file2.py
210-
./dir1/subdir1/deep_file.py"
212+
run_test "Extension py" "$FF_PATH -e py" --stdout "./dir1/subdir1/deep_file.py
213+
./file2.py"
211214
run_test "Extension txt" "$FF_PATH -e txt file1" --stdout "./file1.txt"
212215
run_test "Max depth 1" "$FF_PATH -d 1 -t f script" --stdout "./script.sh"
213-
run_test "Max depth 2" "$FF_PATH -d 2 nested" --stdout "./dir1/nested_file.txt
214-
./deep/nested"
216+
run_test "Max depth 2" "$FF_PATH -d 2 nested" --stdout "./deep/nested
217+
./dir1/nested_file.txt"
215218
run_test "Full path matching" "$FF_PATH -p dir1" --stdout "./dir1
219+
./dir1/nested_file.txt
216220
./dir1/subdir1
217221
./dir1/subdir1/deep_file.py
218-
./dir1/nested_file.txt
219222
./link_to_dir1"
220223
run_test "Exclude pattern - log files" "$FF_PATH -E '*log*' script" --stdout "./script.sh"
221224
run_test "Follow links" "$FF_PATH -L -t f link" --stdout "./link_to_file1"
@@ -243,8 +246,8 @@ test_color_options() {
243246

244247
test_path_formats() {
245248
run_test "Absolute paths" "$FF_PATH -a file1.txt" --stdout "$TEST_DIR/file1.txt"
246-
run_test "Specific search path" "$FF_PATH file dir1" --stdout "dir1/subdir1/deep_file.py
247-
dir1/nested_file.txt"
249+
run_test "Specific search path" "$FF_PATH file dir1" --stdout "dir1/nested_file.txt
250+
dir1/subdir1/deep_file.py"
248251
}
249252

250253
test_complex_scenarios() {

0 commit comments

Comments
 (0)