From b5d0222e83b3432f966827175b02d0a439adf1b1 Mon Sep 17 00:00:00 2001 From: JP Dillingham Date: Sat, 31 Oct 2026 20:04:24 -0500 Subject: lint the web project, too --- bin/lint | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'bin') diff --git a/bin/lint b/bin/lint index ffb49b35..e31fd7b6 100644 --- a/bin/lint +++ b/bin/lint @@ -28,3 +28,11 @@ else echo $'\n🛠️ dotnet format --verbosity normal\n' dotnet format --verbosity normal fi + +if [ "$fix" == false ]; then + echo $'\n🛠️ npm run lint\n' + (cd src/web && npm run lint) +else + echo $'\n🛠️ npm run lint:fix\n' + (cd src/web && npm run lint:fix) +fi -- cgit v1.2.3 From 6cd4e00b709ee0d6f9e399b343f5d91195ef3e82 Mon Sep 17 00:00:00 2001 From: JP Dillingham Date: Sat, 31 Oct 2026 20:04:33 -0500 Subject: add a test script --- bin/test | 121 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 121 insertions(+) create mode 100644 bin/test (limited to 'bin') diff --git a/bin/test b/bin/test new file mode 100644 index 00000000..1c4ccb6d --- /dev/null +++ b/bin/test @@ -0,0 +1,121 @@ +#!/usr/bin/env bash +set -e +set -o pipefail + +affected=false +from="" +unit=false +integration=false +web=false + +while test $# -gt 0; do + case "$1" in + -h|--help) + echo '' + echo 'usage: test [options]' + echo '' + echo 'options:' + echo '-h, --help show help' + echo '--unit run only unit tests' + echo '--integration run only integration tests' + echo '--dotnet run only unit and integration tests' + echo '--web run only frontend tests' + echo '--all run unit, integration, and frontend tests' + echo '--affected run only tests for projects affected by changes (uses dotnet-affected)' + echo '--from REF branch or commit to compare against when using --affected. defaults to HEAD' + echo '' + echo 'with no options, only unit tests are run.' + echo '' + echo 'examples:' + echo ' test' + echo ' test --all' + echo ' test --web' + echo ' test --affected --from master' + echo '' + exit 0 + ;; + --unit) + unit=true + shift + ;; + --integration) + integration=true + shift + ;; + --dotnet) + unit=true + integration=true + shift + ;; + --web) + web=true + shift + ;; + --all) + unit=true + integration=true + web=true + shift + ;; + --affected) + affected=true + shift + ;; + --from) + shift + from=$1 + shift + ;; + *) + echo "error: unknown option '$1'" + exit 1 + ;; + esac +done + +if [ "$unit" == false ] && [ "$integration" == false ] && [ "$web" == false ]; then + unit=true +fi + +if [ "$unit" == true ] || [ "$integration" == true ]; then + pattern="" + + if [ "$unit" == true ]; then + pattern="Tests\.Unit\.csproj$" + fi + + if [ "$integration" == true ]; then + pattern="${pattern:+$pattern|}Tests\.Integration\.csproj$" + fi + + if [ "$affected" == true ]; then + args=(--format text --dry-run) + + if [ -n "$from" ]; then + args+=(--from "$from") + fi + + echo $'\n🔍 dotnet tool run dotnet-affected --' "${args[@]}" $'\n' + + dotnet tool restore > /dev/null + projects=$(dotnet tool run dotnet-affected -- "${args[@]}" | tr -d '\r' | grep -E '\.csproj$' | grep -E "$pattern" || true) + else + projects=$(find tests -name '*.csproj' | grep -E "$pattern" || true) + fi + + if [ -z "$projects" ]; then + echo $'\n🤷 no test projects to run\n' + else + while IFS= read -r project; do + echo $'\n\t🧪 dotnet test' "$project" $'\n' + dotnet test "$project" + done <<< "$projects" + fi +fi + +if [ "$web" == true ]; then + echo $'\n\t🧪 npm run test-unattended\n' + (cd src/web && npm run test-unattended) +fi + +echo $'\n\t🎉 tests passed!\n' -- cgit v1.2.3