Skip to content

Commit

Permalink
CLIENT-2758
Browse files Browse the repository at this point in the history
Added mocha --dry-run
Added test.yml
  • Loading branch information
DomPeliniAerospike committed Jan 25, 2024
1 parent 417856f commit b2616e3
Show file tree
Hide file tree
Showing 2 changed files with 293 additions and 0 deletions.
292 changes: 292 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,292 @@
name: PR pre-merge tests

env:
LOWEST_SUPPORTED_NODEJS_VERSION: '18'
LOWEST_SUPPORTED_NODE_MODULE: 'v108'

# Trigger test workflow whenever:
# 1. A pull request is updated (e.g with new commits)
# 2. Commits are pushed directly to the stage or master branch
on:
push:
branches: ["stage", "master"]
pull_request:
branches: ["stage"]
types: [
# Default triggers
opened,
synchronize,
reopened,
# Additional triggers
labeled,
unlabeled
]
workflow_dispatch:

jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
- uses: actions/setup-node@v4
with:
node-version: '18'
architecture: 'x64'
- uses: pre-commit/[email protected]

build:
runs-on: ubuntu-latest
strategy:
matrix:
nodejs-version: ["18", "20", "21"]
fail-fast: false

steps:
- uses: actions/checkout@v4
with:
submodules: recursive

- uses: actions/setup-node@v4
with:
node-version: ${{ matrix.nodejs-version }}
architecture: 'x64'

- run: sudo apt update
- name: Install build dependencies (C Client dependency packages)
run: sudo apt install g++ libssl-dev zlib1g-dev;
- name: Install build dependencies (make)
run: sudo apt-get install -y make;
- name: Install build dependencies (make)
run: sudo apt install build-essential;

- name: Build client
run: ./scripts/build-c-client
env:
CFLAGS: '-Werror'

- name: Send binding to test jobs
uses: actions/upload-artifact@v4
with:
name: binding-${{ matrix.nodejs-version }}
path: ./lib/binding/node-*-linux-arm64

# test-memray:
# needs: build
# runs-on: ubuntu-latest
# steps:
# - uses: actions/checkout@v4
#
# - uses: actions/setup-node@v4
# with:
# python-version: ${{ matrix.nodejs-version }}
# architecture: 'x64'
#
# - uses: actions/download-artifact@v3
# with:
# name: binding-18
#
# - name: make binding folder
# run: mkdir lib/binding
#
# - name: Install client
# run: cp -r install node-v108-linux-x64 lib/binding/node-v108-linux-x64
#
# - name: Install client
# run: npm install .
#
# - name: Run Aerospike server
# run: docker run -d --name aerospike -p 3000-3002:3000-3002 aerospike/aerospike-server
#
# - name: Wait for database to be ready
# # Should be ready after 3 seconds
# run: sleep 3
#
# - name: Get number of tests
# run: echo "NUM_TESTS=$(npm test-dry-run | grep -oP '\d+ (passing|pending)' | awk '{ sum += $1 } END { print sum }')" >> $GITHUB_ENV
# working-directory: test
#
# - name: Run tests
# # Get number of tests since setting to 0 doesn't work properly
# # pytest-memray currently throws a ZeroDivision error due to having a bug
# # We ignore this for now
# run: python -m pytest ./new_tests --memray --memray-bin-path=./ --most-allocations=${{ env.NUM_TESTS }} || true
# working-directory: test

# Run this when testing new server features on server release candidate
# to make sure the tests don't regress on the last server release.
test-ce-latest-release:
runs-on: ubuntu-latest
if: ${{ contains(github.event.pull_request.labels.*.name, 'new-server-features') }}
needs: build

steps:
- uses: actions/checkout@v4
with:
submodules: recursive

- uses: actions/setup-node@v4
with:
node-version: ${{ env.LOWEST_SUPPORTED_NODEJS_VERSION }}
architecture: 'x64'

- uses: actions/download-artifact@v3
with:
name: binding-${{ env.LOWEST_SUPPORTED_NODEJS_VERSION }}

- name: make binding folder
run: mkdir lib/binding

- name: Install client
run: cp -r node-${{ env.LOWEST_SUPPORTED_NODE_MODULE }}-linux-x64 lib/binding/node-${{ env.LOWEST_SUPPORTED_NODE_MODULE }}-linux-x64

- name: Run Aerospike server
run: docker run -d --name aerospike -p 3000-3002:3000-3002 aerospike/aerospike-server

- name: Wait for database to be ready
# Should be ready after 3 seconds
run: sleep 3

- name: Run tests
run: npm test
working-directory: test

test-ce:
runs-on: ubuntu-latest
needs: build
strategy:
matrix:
node-version: [
"18",
"20",
"21"
]
fail-fast: false

steps:
- uses: actions/checkout@v2
with:
submodules: recursive

- uses: actions/setup-node@v4
with:
python-version: ${{ matrix.node-version }}
architecture: 'x64'

- uses: actions/download-artifact@v3
with:
name: binding-${{ matrix.py-version }}

- name: make binding folder
run: mkdir lib/binding

- name: Install client
#fix the convention here
run: |
if [ "${{ matrix.node-version }}" = "18" ]; then
cp -r node-v108-linux-x64 lib/binding/node-v108-linux-x64
elif [ "${{ matrix.node-version }}" = "20" ]; then
cp -r node-v108-linux-x64 lib/binding/node-v115-linux-x64
elif [ "${{ matrix.node-version }}" = "21" ]; then
cp -r node-v108-linux-x64 lib/binding/node-v120-linux-x64
fi
- if: ${{ contains(github.event.pull_request.labels.*.name, 'new-server-features') }}
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_HUB_BOT_USERNAME }}
password: ${{ secrets.DOCKER_HUB_BOT_PW }}

- name: Run Aerospike server release candidate with latest tag
if: ${{ contains(github.event.pull_request.labels.*.name, 'new-server-features') }}
run: docker run -d --name aerospike -p 3000-3002:3000-3002 aerospike/aerospike-server-rc:latest

- name: Run Aerospike server
if: ${{ !contains(github.event.pull_request.labels.*.name, 'new-server-features') }}
run: docker run -d --name aerospike -p 3000-3002:3000-3002 aerospike/aerospike-server

- name: Wait for database to be ready
# Should be ready after 3 seconds
run: sleep 3

- name: Run tests
run: npm test

test-lowest-supported-server:
runs-on: ubuntu-latest
needs: build
steps:
- uses: actions/checkout@v2
with:
submodules: recursive

- uses: actions/setup-node@v4
with:
node-version: ${{ env.LOWEST_SUPPORTED_NODEJS_VERSION }}
architecture: 'x64'

- uses: actions/download-artifact@v3
with:
name: binding-${{ env.LOWEST_SUPPORTED_NODEJS_VERSION }}

- name: make binding folder
run: mkdir lib/binding

- name: Install client
#fix the convention here
run: cp -r node-${{ env.LOWEST_SUPPORTED_NODE_MODULE }}-linux-x64 lib/binding/node-${{ env.LOWEST_SUPPORTED_NODE_MODULE }}-linux-x64

- name: Run lowest supported server
run: |
SERVER_VERSION=$(curl -s "https://registry.hub.docker.com/v2/repositories/aerospike/aerospike-server/tags?page_size=100" | jq '.results[] | select(.name | startswith("6.0")).name' -r | head -n 1)
docker run -d --name aerospike -p 3000-3002:3000-3002 aerospike/aerospike-server:$SERVER_VERSION
- name: Wait for database to be ready
# Should be ready after 3 seconds
run: sleep 3

- name: Run tests
run: npm test

test-ee:
runs-on: ubuntu-latest
needs: build
steps:
- uses: actions/checkout@v2
with:
submodules: recursive

- uses: actions/setup-node@v4
with:
node-version: ${{ env.LOWEST_SUPPORTED_NODEJS_VERSION }}
architecture: 'x64'

- uses: actions/download-artifact@v3
with:
name: binding-${{ env.LOWEST_SUPPORTED_NODEJS_VERSION }}

- name: make binding folder
run: mkdir lib/binding

- name: Install client
#fix the convention here
run: cp -r node-${{ env.LOWEST_SUPPORTED_NODE_MODULE }}-linux-x64 lib/binding/node-${{ env.LOWEST_SUPPORTED_NODE_MODULE }}-linux-x64

- uses: ./.github/actions/run-ee-server
with:
use-server-rc: ${{ contains(github.event.pull_request.labels.*.name, 'new-server-features') }}
docker-hub-username: ${{ secrets.DOCKER_HUB_BOT_USERNAME }}
docker-hub-password: ${{ secrets.DOCKER_HUB_BOT_PW }}

- name: Wait for server to start
run: sleep 5

- name: Run tests
run: npm test

- name: Show logs if failed
if: ${{ failure() }}
run: |
docker container logs aerospike
cat ./configs/aerospike.conf
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
"install": "npm run build",
"build": "node-pre-gyp install --fallback-to-build",
"test": "mocha",
"test-dry-run": "mocha --dry-run",
"test-noserver": "GLOBAL_CLIENT=false mocha -g '#noserver'",
"lint": "standard",
"posttest": "npm run lint",
Expand Down

0 comments on commit b2616e3

Please sign in to comment.