Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
91 changes: 91 additions & 0 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
name: Test

# Runs the tests on each pull request and merge, nightly, and after each pull
# request merged in super (sent by super's notify-downstream-merge.yaml). Since
# super-ts decodes and formats what super writes, the tests also run against
# fixtures made fresh by super, so a change in super that super-ts doesn't
# match yet fails here.

on:
schedule:
- cron: '5 8 * * *'
workflow_dispatch:
inputs:
super_ref:
description: 'superdb/super branch, tag, or SHA to test against'
default: main
required: false
repository_dispatch:
types: [super-pr-merged]
push:
branches: [main]
pull_request:

permissions:
contents: read

jobs:
test:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
with:
path: super-ts

- name: Check out super
uses: actions/checkout@v4
with:
repository: superdb/super
# After a merge in super, test the commit that merged.
ref: ${{ inputs.super_ref || github.event.client_payload.merge_commit_sha || 'main' }}
path: super
# Tags are needed for the version super reports.
fetch-depth: 0

- uses: actions/setup-go@v5
with:
go-version-file: super/go.mod
cache-dependency-path: super/go.sum

# The oldest Node that super-ts supports (see engines in package.json).
- uses: actions/setup-node@v4
with:
node-version: '22.18'

- name: Install
working-directory: super-ts
run: npm ci

- name: Type check
working-directory: super-ts
run: npm run check

- name: Test with the saved fixtures
working-directory: super-ts
run: npm test

- name: Build super
run: |
make -C super build
super/dist/super -version

- name: Make the reference fixtures with super
working-directory: super-ts
run: SUPER="$GITHUB_WORKSPACE/super/dist/super" npm run fixtures

- name: Test with super's fixtures
working-directory: super-ts
run: npm test

# Runs by hand, e.g., against an old super, are watched by whoever ran
# them.
- name: Inform Slack users of test failures
uses: tiloio/slack-webhook-action@v1.1.2
if: failure() && github.ref_name == 'main' && github.event_name != 'workflow_dispatch'
with:
slack_web_hook_url: ${{ secrets.SLACK_WEBHOOK_BRIMLABS_TEST }}
slack_json: |
{
"username": "super-ts",
"text": "super-ts tests failed: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}"
}
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -202,9 +202,16 @@ The tests check the decoder against three kinds of fixtures:
produced from them. The tests decode the BSUP and require that the
formatted text match super's byte for byte. To regenerate the output with
your `super` build, run `npm run fixtures` (or `SUPER=/path/to/super npm run fixtures`).
It exits nonzero if `super` can't make all of them.
* Hand-built row and column frames (`test/helpers/encode.ts`) for cases that
are easier to construct directly.

CI runs the tests on each pull request and merge, nightly, and after each
pull request merged in super, first with the saved fixtures and then with
fixtures made by `super` from its `main` branch (or, when run by hand, from a
branch, tag, or commit you choose). So a change in super that super-ts
doesn't match yet makes CI fail, even on a pull request that didn't cause it.

## Notes and known gaps

* The decoder reads BSUP version 0.31 only, and it rejects other 0.x versions
Expand Down
50 changes: 50 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 11 additions & 2 deletions scripts/gen-fixtures.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@
# If test/reference/sup/NAME.args exists, its contents are extra arguments
# for super (e.g., `-c fuse` or `-fusion`).
#
# If super can't make a fixture, the script goes on to the next one, and at
# the end it exits nonzero, since the tests skip missing fixtures.
#
# Usage: npm run fixtures (or SUPER=/path/to/super sh scripts/gen-fixtures.sh)

set -u
Expand All @@ -20,17 +23,23 @@ out=test/reference/out
rm -rf "$out"
mkdir -p "$out"
"$SUPER" -version 2>/dev/null > "$out/VERSION" || true
failed=0
for src in "$in"/*.sup; do
name=$(basename "$src" .sup)
args=""
[ -f "$in/$name.args" ] && args=$(cat "$in/$name.args")
if ! "$SUPER" $args -f sup -pretty 0 -o "$out/$name.sup" "$src" 2> "$out/$name.err"; then
echo "skipping $name: $(head -1 "$out/$name.err")"
rm -f "$out/$name.sup"
failed=1
continue
fi
rm -f "$out/$name.err"
"$SUPER" $args -f bsup -o "$out/$name.col.bsup" "$src"
"$SUPER" $args -f bsup -rows -o "$out/$name.row.bsup" "$src"
"$SUPER" $args -f bsup -o "$out/$name.col.bsup" "$src" || failed=1
"$SUPER" $args -f bsup -rows -o "$out/$name.row.bsup" "$src" || failed=1
done
echo "wrote fixtures to $out"
if [ $failed -ne 0 ]; then
echo "super couldn't make some of the fixtures" >&2
exit 1
fi
Loading