Skip to content

Commit

Permalink
Update test-on-push.yml with selenium services
Browse files Browse the repository at this point in the history
- Add services.selenium to set up the Selenium server using the selenium/standalone-chrome:latest Docker image. The server will be accessible on port 4444.
- Add enchancement step "Wait for Selenium" to run a loop to check if the Selenium server is ready. It uses nc (Netcat) to test the connection to localhost:4444 and waits until it is available.
  • Loading branch information
akarsh authored Jun 22, 2024
1 parent 8823004 commit 437e296
Showing 1 changed file with 20 additions and 6 deletions.
26 changes: 20 additions & 6 deletions .github/workflows/test-on-push.yml
Original file line number Diff line number Diff line change
@@ -1,25 +1,39 @@
name: test-on-push
run-name: Test on push to ${{ github.ref }} by ${{ github.actor }}
run-name: Test on push to ${{ github.ref_name }} by ${{ github.actor }}
on: push
jobs:
test:
runs-on: ubuntu-latest

services:
selenium:
image: selenium/standalone-chrome:latest
ports:
- 4444:4444
strategy:
matrix:
node-version: [20.x, 21.x, 22.x]

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

- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}

- name: Cache Node.js modules
uses: actions/cache@v4
with:
path: node_modules
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-
- name: Install dependencies
run: npm install

- name: Wait for Selenium
run: |
while ! nc -z localhost 4444; do
echo "Waiting for Selenium to be ready..."
sleep 1
done
echo "Selenium is ready!"
- name: Run tests
run: npm run test

0 comments on commit 437e296

Please sign in to comment.