Skip to content

Commit

Permalink
ci: add some tests to run on Node.js 18 and later
Browse files Browse the repository at this point in the history
  • Loading branch information
striezel committed Dec 1, 2023
1 parent de69d91 commit 9b9e0f8
Show file tree
Hide file tree
Showing 4 changed files with 375 additions and 2 deletions.
8 changes: 6 additions & 2 deletions .github/workflows/node.js.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ jobs:
runs-on: ubuntu-22.04
strategy:
matrix:
node-version: [12.x, 14.x, 16.x, 18.x, 20.x]
node-version: [12, 14, 16, 18, 20]
steps:
- uses: actions/checkout@v4
- name: Use Node.js ${{ matrix.node-version }}
Expand All @@ -18,4 +18,8 @@ jobs:
run: |
sudo apt-get update
sudo apt-get install -y build-essential libcairo2-dev libgif-dev libpango1.0-dev
- run: cd "$GITHUB_WORKSPACE"/export-server && npm install
- name: Install NPM packages
run: cd "$GITHUB_WORKSPACE"/export-server && npm install
- name: Tests
run: cd "$GITHUB_WORKSPACE"/export-server && ./test.sh
if: matrix.node-version >= 18
4 changes: 4 additions & 0 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,10 @@ node_18:
- node --version
- npm --version
script:
- apt-get update && apt-get install -y procps
- cd ./export-server
- npm install
- ./test.sh

node_20:
image: node:20-slim
Expand All @@ -45,5 +47,7 @@ node_20:
- node --version
- npm --version
script:
- apt-get update && apt-get install -y procps
- cd ./export-server
- npm install
- ./test.sh
30 changes: 30 additions & 0 deletions export-server/test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#!/bin/sh

# Start the server.
npm run start &
# Give server some time to start completely.
sleep 3
SERVER_PID=$(pgrep node)
echo "Server process id is $SERVER_PID."

# Run actual tests.
node --test
EXIT_CODE=$?

# Stop / kill server process.
kill $SERVER_PID
if [ $? -ne 0 ]
then
kill -9 $SERVER_PID
fi

sleep 1

if [ $EXIT_CODE -eq 0 ]
then
echo Tests were successful.
exit 0
else
echo Tests have failed.
exit 1
fi
Loading

0 comments on commit 9b9e0f8

Please sign in to comment.