test #11
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: server-run-check | |
on: | |
pull_request: | |
branches: [main] | |
push: | |
branches: | |
- main | |
jobs: | |
check-server: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v2 | |
- name: Install Node.js | |
uses: actions/setup-node@v2 | |
with: | |
node-version: '14.x' | |
- name: Install dependencies | |
run: | | |
npm install | |
- name: Start server | |
run: | | |
node server.js & | |
sleep 5 | |
- name: Check server and error handling | |
run: | | |
echo "Checking server status..." | |
if ! curl -sSf http://localhost:3000; then | |
echo "Server is not running properly." | |
exit 1 | |
fi | |
if pgrep -f "node server.js" && curl -sSf http://localhost:3000 | grep -q "SyntaxError: Invalid regular expression"; then | |
echo "Error encountered while starting server." | |
exit 1 | |
fi | |
echo "Server is running." | |
- name: Stop server | |
run: | | |
kill $(lsof -t -i:3000) |