Skip to content

Commit

Permalink
test
Browse files Browse the repository at this point in the history
  • Loading branch information
QuiteAFancyEmerald committed Jul 8, 2024
1 parent dd1aeba commit 649b6b7
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 16 deletions.
45 changes: 31 additions & 14 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,22 +11,39 @@ jobs:
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Checkout repository
uses: actions/checkout@v2

- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: '20.8.0'
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: '20'

- name: Install dependencies
- name: Install dependencies
run: npm install

- name: Build project
run: npm run build
- name: Check if server is already running
id: check-server
run: |
if lsof -Pi :8080 -sTCP:LISTEN -t >/dev/null ; then
echo "Server is already running"
exit 0
else
echo "Server is not running"
exit 1
fi
- name: Start server and run tests
run: |
npm run start-test-server
sleep 10 # Wait for the server to start
npm run test-400
- name: Start server if not already running
if: steps.check-server.outcome == 'failure'
run: npm run start-test-server

- name: Wait for server to start
if: steps.check-server.outcome == 'failure'
run: sleep 30

- name: Test server response
run: npm run test-400

- name: Stop server after testing
if: steps.check-server.outcome == 'failure'
run: pkill node || true
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
"main": "backend.js",
"scripts": {
"start": "node backend.js",
"build": "echo 'Building project...' && exit 0",
"test": "echo 'Running tests...' && exit 0",
"build": "npm run start",
"test": "npm run test-400",
"start-test-server": "node backend.js &",
"test-400": "curl -s -o /dev/null -w '%{http_code}' http://localhost:8080/ | grep 400"
},
Expand Down

0 comments on commit 649b6b7

Please sign in to comment.