Skip to content

Commit 764003a

Browse files
✨ feat: add workflow to test all solutions (#41)
* ✨ feat: add workflow to test all solutions * ♻️ refactor: move script to bash file, run all tests (don't exit on first fail) * ♻️ refactor: run solutions test runner script from ci * 🎨 chore: add prettier plugin for shell scripts * ♻️ refactor: run prettier format * 🐛 fix: ignore husky setup scripts on prettier * 🎨 chore: prettify husky config from CI * ♻️ chore: make check-solutions script executable * ♻️ fix: use .prettierignore to ignore husky config files on CI Co-authored-by: Josh Goldberg <me@joshuakgoldberg.com>
1 parent 7871235 commit 764003a

File tree

5 files changed

+89
-0
lines changed

5 files changed

+89
-0
lines changed

.github/workflows/solutions.yml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
name: Solutions
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
pull_request:
8+
9+
jobs:
10+
test:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- uses: actions/checkout@v3
14+
- uses: actions/setup-node@v3
15+
with:
16+
node-version: "16"
17+
cache: "npm"
18+
- run: npm ci
19+
- name: Run all solutions tests
20+
run: |
21+
chmod +x ./scripts/check-solutions.sh
22+
./scripts/check-solutions.sh
23+
shell: bash

.prettierignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
**/.husky

package-lock.json

Lines changed: 37 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
"jest": "28.1.0",
88
"markdownlint-cli": "^0.31.1",
99
"prettier": "^2.6.2",
10+
"prettier-plugin-sh": "^0.11.0",
1011
"pretty-quick": "^3.1.3",
1112
"ts-jest": "28.0.0",
1213
"tsd": "0.20.0",

scripts/check-solutions.sh

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
root_dir=$(pwd)
2+
failed_tests=()
3+
4+
for path in $(find projects/ -depth); do
5+
if [ -e $path/package.json ]; then
6+
echo -e "\nRunning test for $path"
7+
cd $path
8+
npm run test:solutions
9+
exit_code=$?
10+
11+
if [ $exit_code -ne 0 ]; then
12+
failed_tests+=("$path")
13+
fi
14+
cd $root_dir
15+
fi
16+
done
17+
18+
echo ""
19+
for path in ${failed_tests[@]}; do
20+
echo "Tests failed at $path"
21+
done
22+
23+
if [ ${#failed_tests[@]} -gt 0 ]; then
24+
exit 1
25+
else
26+
exit 0
27+
fi

0 commit comments

Comments
 (0)