Add 'ops/' directory and sqlite_lint integration test
All checks were successful
CI / release-test (push) Successful in 24s

This commit is contained in:
wispem-wantex 2025-11-08 17:19:11 -08:00
parent 6624b5794f
commit 8c6d8354df
3 changed files with 82 additions and 0 deletions

View File

@ -20,7 +20,12 @@ jobs:
env
GOBIN=/usr/local/go/bin go install git.offline-twitter.com/offline-labs/gocheckout@v0.0.1
gocheckout
- name: test
run: go test ./...
- name: lint
run: golangci-lint run
- name: Run sqlite_lint integration test
run: ops/sqlite_lint_test.sh

30
ops/README.md Normal file
View File

@ -0,0 +1,30 @@
# ops/
The ops/ directory is intended as a semi-organized dumping ground for various types of programs and scripts that exist around the application, but are not actually part of it. (E.g., they will not get deployed, but they might be used *to* deploy the app.)
It's intended to be neither totally chaotic, nor totally pristine.
Stuff in this directory is expected to begin life as crappy Shell scripts, and, depending on needs, possibly evolve into e.g. Python or Go programs.
It can be used for
- development tools and helpers
- build and CI scripts
- unwieldy integration tests
- environment setup / teardown
- recurring complex operations that are part of the dev flow (e.g., testing out the schema of an external API)
- data visualizations
## Purpose
This is an experimental pattern that I'm trying out. It's basically like "scripts/", but it follows the "3-letter top level directory" convention.
It's also less constraining than "scripts", which would appear to disallow things like full Go programs, which I explicitly want to allow, and would actually consider desirable.
Shell scripts are fragile and finicky by nature. For example, any kind of error handling is notoriously difficult in Shell. Yet, error states are *extremely common* in anything that you're using Shell for:
- network failures
- some file doesn't exist / already exists
- permission denied
- some string variable is empty
Therefore, it's natural that important tasks should eventually be implemented using a proper programming language. Beyond a certain level of effort, "Just write it in Go" is actually easier. Or at least Python.

47
ops/sqlite_lint_test.sh Executable file
View File

@ -0,0 +1,47 @@
#!/bin/bash
# ------------------
# This is a test script that checks that `sqlite_lint` subcommand works as expected.
# ------------------
set -e
set -x
PS4='+(${BASH_SOURCE}:${LINENO}): '
cd "$(dirname ${BASH_SOURCE[0]})/.."
# Compile `gas`
program="/tmp/gas"
go build -o $program ./cmd
test_schema_dir="pkg/schema/lint/test_schemas"
# Check all failure cases
for test_schema in $test_schema_dir/failure-*; do
output=$($program sqlite_lint $test_schema) && {
echo "Expected test to fail"
exit 9
}
# Should print the name of the file being linted
if ! echo "$output" | grep -Fxq "Linting $test_schema"; then
echo "Expected 'Linting $test_schema' in output"
exit 10
fi
done
# Check success case
success_schema="$test_schema_dir/success.sql"
output=$($program sqlite_lint $success_schema) || {
echo "Expected test to succeed"
exit 9
}
# Should print the name of the file being linted
if ! echo "$output" | grep -Fxq "Linting $success_schema"; then
echo "Expected 'Linting $success_schema' in output"
exit 10
fi
# Notify success in green
echo -e "\033[32mAll tests passed. Finished successfully.\033[0m"