diff --git a/.github/workflows/build-bindings.yml b/.github/workflows/build-bindings.yml index 7b846a3f0..a0be123ef 100644 --- a/.github/workflows/build-bindings.yml +++ b/.github/workflows/build-bindings.yml @@ -98,7 +98,7 @@ jobs: ] platform: [ "x86_64", - #"aarch64" + "aarch64" ] steps: @@ -134,25 +134,6 @@ jobs: 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: Set config.conf to use Docker IP address of Aerospike server -# # config.conf should be copied into the cibuildwheel Docker container -# run: | -# export SERVER_DOCKER_IP=$(docker container inspect -f '{{ .NetworkSettings.IPAddress }}' aerospike) -# # Install crudini -# pip install crudini -c ../.github/workflows/requirements.txt -# sed -i "s/127.0.0.1:3000//" config.conf -# crudini --set config.conf enterprise-edition hosts ${SERVER_DOCKER_IP}:3000 -# working-directory: test - - name: Enable tests run: echo "TEST_COMMAND=npm test -- --h 127.0.0.1 --port 3000" >> $GITHUB_ENV @@ -167,16 +148,43 @@ jobs: with: arch: aarch64 distro: ubuntu22.04 - + shell: /bin/bash # Set an output parameter `uname` for use in subsequent steps run: | + + # Add Docker's official GPG key: + apt-get update + apt-get install ca-certificates curl -y + install -m 0755 -d /etc/apt/keyrings + curl -fsSL https://download.docker.com/linux/ubuntu/gpg -o /etc/apt/keyrings/docker.asc + chmod a+r /etc/apt/keyrings/docker.asc + + # Add the repository to Apt sources: + echo \ + "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/ubuntu \ + $(. /etc/os-release && echo "$VERSION_CODENAME") stable" | \ + tee /etc/apt/sources.list.d/docker.list > /dev/null + apt-get update + apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin -y + docker run hello-world + docker run -d --name aerospike -p 3000-3002:3000-3002 aerospike/aerospike-server apt update - apt install -y g++ libssl-dev zlib1g-dev make build-essential libuv1-dev wget curl + apt install -y g++ libssl-dev zlib1g-dev make build-essential libuv1-dev wget curl python3 ./scripts/build-c-client.sh - wget https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.3/install.sh | bash; - source ~/.bashrc; + ls -a + ls -a + wget -qO- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.3/install.sh | bash + export NVM_DIR="$HOME/.nvm" + [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm + [ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion + ls nvm i 20 npm install +# ${{ env.TEST_COMMAND }} + + - name: Run Aerospike server + if: ${{ matrix.platform != 'aarch64' }} + run: docker run -d --name aerospike -p 3000-3002:3000-3002 aerospike/aerospike-server - name: Build client x64 if: ${{ matrix.platform != 'aarch64' }} @@ -191,6 +199,7 @@ jobs: CFLAGS: '-Werror' - name: Test client + if: ${{ matrix.platform != 'aarch64' }} run: | ${{ env.TEST_COMMAND }} @@ -235,35 +244,35 @@ jobs: node-version: ${{ matrix.nodejs[1] }} architecture: 'x64' -# - name: Install Docker Engine -# run: brew install colima -# -# - name: Install Docker client -# run: brew install docker -# -# - name: Start Docker Engine -# run: colima start -# -# - 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: Enable tests -# run: echo "TEST_COMMAND=npm test -- --h 127.0.0.1 --port 3000 --t 30000" >> $GITHUB_ENV + - name: Install Docker Engine + run: brew install colima -# - name: Disable tests (only run basic import test) -# if: ${{ !inputs.run_tests }} -# run: echo "TEST_COMMAND=node -e 'aerospike = require(\".\/lib\/aerospike\")'" >> $GITHUB_ENV + - name: Install Docker client + run: brew install docker + + - name: Start Docker Engine + run: colima start + + - 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: Enable tests + run: echo "TEST_COMMAND=npm test -- --h 127.0.0.1 --port 3000 --t 30000" >> $GITHUB_ENV + + - name: Disable tests (only run basic import test) + if: ${{ !inputs.run_tests }} + run: echo "TEST_COMMAND=node -e 'aerospike = require(\".\/lib\/aerospike\")'" >> $GITHUB_ENV - name: Build client run: | @@ -290,127 +299,124 @@ jobs: sha: ${{ github.sha }} context: "Build bindings (${{ matrix.nodejs[0] }}-macosx_x86_64)" -# macOS-m1: -# runs-on: [ -# self-hosted, -# macOS, -# ARM64 -# ] -# strategy: -# matrix: -# nodejs-version: [ -# ["v108", "18"], -# ["v115", "20"], -# ["v120", "21"], -# ] -# fail-fast: false -# steps: -# - name: Show job status for commit -# uses: myrotvorets/set-commit-status-action@v2.0.0 -# with: -# sha: ${{ github.sha }} -# context: "Build bindings (${{ matrix.nodejs-version[1] }}-macosx_arm64)" -# -# - uses: actions/checkout@v4 -# with: -# submodules: recursive -# ref: ${{ inputs.commit_sha }} -# -# - name: Install NVM -# run: | -# curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/install.sh | bash -# source ~/.zshrc -# nvm -v -# nvm install ${{ matrix.nodejs-version[1] }} -# -# -# - name: Setup symlink folders -# run: | -# sudo rm -rf /usr/local/opt/openssl; -# sudo rm -rf /usr/local/opt/libuv; -# sudo mkdir -p /usr/local/opt; -# sudo chown -R $(whoami) /usr/local/opt -# -# - name: Install brew packages -# run: | -# brew install openssl@3.2.1 -# brew install libuv@1.47.0 -# -# - name: Set environment for building -# run: | -# echo "export PATH="/usr/local/bin/:/usr/local/opt/openssl/bin:$PATH" -# export LDFLAGS="-L/usr/local/opt/openssl/lib" -# export CPPFLAGS="-I/usr/local/opt/openssl/include" -# export EXT_CFLAGS="-I/usr/local/opt/openssl/include"" >> ~/.zshrc; -# source ~/.zshrc; -# -# - name: Setup symlink folders -# run: | -# sudo ln -s /usr/local/Cellar/libuv/1.47.0/ /usr/local/opt/libuv; -# sudo ln -s /usr/local/Cellar/openssl@3/3.2.1/ /usr/local/opt/openssl; -# -# # Self-hosted runner only -# # Need to be able to save Docker Hub credentials to keychain -# - run: security unlock-keychain -p ${{ secrets.MAC_M1_SELF_HOSTED_RUNNER_PW }} -# if: ${{ inputs.run_tests && inputs.use-server-rc }} -# -# - if: ${{ inputs.run_tests && inputs.use-server-rc }} -# uses: docker/login-action@v3 -# with: -# username: ${{ secrets.DOCKER_HUB_BOT_USERNAME }} -# password: ${{ secrets.DOCKER_HUB_BOT_PW }} -# -# - name: Use server rc -# if: ${{ inputs.run_tests && inputs.use-server-rc }} -# run: echo IMAGE_NAME="${{ vars.SERVER_RC_REPO_LINK }}:${{ inputs.server-tag }}" >> $GITHUB_ENV -# -# - name: Use server release -# if: ${{ inputs.run_tests && !inputs.use-server-rc }} -# run: echo IMAGE_NAME="${{ vars.SERVER_REPO_LINK }}:${{ inputs.server-tag }}" >> $GITHUB_ENV -# -# - name: Run server -# if: ${{ inputs.run_tests }} -# run: docker run -d -p 3000:3000 --name aerospike ${{ env.IMAGE_NAME }} -# -# - name: Build client -# run: | -# ./scripts/build-c-client.sh -# npm install -# env: -# CFLAGS: '-Werror' -# -# - name: Enable tests -# if: ${{ inputs.run_tests }} -# run: echo "TEST_COMMAND=npm test -- --h 127.0.0.1 --port 3000" >> $GITHUB_ENV -# + macOS-m1: + runs-on: [ + self-hosted, + macOS, + ARM64 + ] + strategy: + matrix: + nodejs-version: [ + ["v108", "18"], + ["v115", "20"], + ["v120", "21"], + ] + fail-fast: false + steps: + - name: Show job status for commit + uses: myrotvorets/set-commit-status-action@v2.0.0 + with: + sha: ${{ github.sha }} + context: "Build bindings (${{ matrix.nodejs-version[1] }}-macosx_arm64)" + + - uses: actions/checkout@v4 + with: + submodules: recursive + ref: ${{ inputs.commit_sha }} + + - name: Install NVM + run: | + curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/install.sh | bash + touch ~/.zshrc + source ~/.zshrc + nvm -v + nvm install ${{ matrix.nodejs-version[1] }} + + + - name: Setup symlink folders + run: | + sudo rm -rf /usr/local/opt/openssl; + sudo rm -rf /usr/local/opt/libuv; + sudo mkdir -p /usr/local/opt; + sudo chown -R $(whoami) /usr/local/opt + + - name: Install brew packages + run: | + brew install libuv; + sudo ln -s /opt/homebrew/opt/libuv/ /usr/local/opt/libuv; + brew install openssl; + sudo ln -s /opt/homebrew/opt/openssl@3/ /usr/local/opt/openssl; + + - name: Set environment for building + run: | + echo "export PATH="/usr/local/bin/:/usr/local/opt/openssl/bin:$PATH" + export LDFLAGS="-L/usr/local/opt/openssl/lib" + export CPPFLAGS="-I/usr/local/opt/openssl/include" + export EXT_CFLAGS="-I/usr/local/opt/openssl/include"" >> ~/.zshrc; + source ~/.zshrc; + + # Self-hosted runner only + # Need to be able to save Docker Hub credentials to keychain + - run: security unlock-keychain -p ${{ secrets.MAC_M1_SELF_HOSTED_RUNNER_PW }} + if: ${{ inputs.run_tests && inputs.use-server-rc }} + + - if: ${{ inputs.run_tests && inputs.use-server-rc }} + uses: docker/login-action@v3 + with: + username: ${{ secrets.DOCKER_HUB_BOT_USERNAME }} + password: ${{ secrets.DOCKER_HUB_BOT_PW }} + + - name: Use server rc + if: ${{ inputs.run_tests && inputs.use-server-rc }} + run: echo IMAGE_NAME="${{ vars.SERVER_RC_REPO_LINK }}:${{ inputs.server-tag }}" >> $GITHUB_ENV + + - name: Use server release + if: ${{ inputs.run_tests && !inputs.use-server-rc }} + run: echo IMAGE_NAME="${{ vars.SERVER_REPO_LINK }}:${{ inputs.server-tag }}" >> $GITHUB_ENV + + - name: Run server + if: ${{ inputs.run_tests }} + run: docker run -d -p 3000:3000 --name aerospike ${{ env.IMAGE_NAME }} + + - name: Build client + run: | + ./scripts/build-c-client.sh + npm install + env: + CFLAGS: '-Werror' + + - name: Enable tests + run: echo "TEST_COMMAND=npm test -- --h 127.0.0.1 --port 3000" >> $GITHUB_ENV + # - name: Disable tests (only run basic import test) # if: ${{ !inputs.run_tests }} # run: echo "TEST_COMMAND=node -e 'aerospike = require(\".\/lib\/aerospike\")'" >> $GITHUB_ENV -# -# -# - name: Test client -# run: | -# ${{ env.TEST_COMMAND }} -# -# - name: Save macOS wheel -# uses: actions/upload-artifact@v4 -# with: -# name: ${{ matrix.nodejs-version[0] }}-macosx_arm64.build -# path: ./lib/binding/*/ -# -# - name: Stop server -# if: ${{ always() && inputs.run_tests }} -# run: | -# docker container stop aerospike -# docker container prune -f -# -# - name: Set final commit status -# uses: myrotvorets/set-commit-status-action@v2.0.0 -# if: always() -# with: -# sha: ${{ github.sha }} -# status: ${{ job.status }} -# context: "Build bindings (${{ matrix.nodejs-version[0] }}-macosx_arm64)" + + + - name: Test client + run: | + ${{ env.TEST_COMMAND }} + + - name: Save macOS wheel + uses: actions/upload-artifact@v4 + with: + name: ${{ matrix.nodejs-version[0] }}-macosx_arm64.build + path: ./lib/binding/*/ + + - name: Stop server + if: ${{ always() && inputs.run_tests }} + run: | + docker container stop aerospike + docker container prune -f + + - name: Set final commit status + uses: myrotvorets/set-commit-status-action@v2.0.0 + if: always() + with: + sha: ${{ github.sha }} + status: ${{ job.status }} + context: "Build bindings (${{ matrix.nodejs-version[0] }}-macosx_arm64)" test-npm-install: runs-on: ubuntu-latest @@ -432,10 +438,13 @@ jobs: npm install -g json json -I -f package.json -e "this.scripts.install=\"npm-run-all removeExtraBinaries build\"" - - name: Run tests + - name: make test directory + run: | + mkdir -p testDir + + - name: Install package using npm + working-directory: testDir run: | - mkdir -p testDir - cd testDir npm install .. test-yarn-install: @@ -458,12 +467,22 @@ jobs: npm install -g json json -I -f package.json -e "this.scripts.install=\"npm-run-all removeExtraBinaries build\"" - - name: Run tests + - name: make test directory + run: | + mkdir -p testDir + + - name: run yarn link on source package + run: | + yarn link + + - name: Install yarn + working-directory: testDir + run: | + npm install --global yarn + + - name: Install package using yarn + working-directory: testDir run: | - mkdir -p testDir - yarn link - cd testDir - npm install --global yarn yarn add link:.. test-pnpm-install: @@ -486,13 +505,27 @@ jobs: npm install -g json json -I -f package.json -e "this.scripts.install=\"npm-run-all removeExtraBinaries build\"" - - name: Run tests + - name: make test directory run: | mkdir -p testDir - cd testDir + + - name: Install pnpm + working-directory: testDir + run: | npm install --global pnpm + + - name: Set shell enviornment variable + working-directory: testDir + run: | SHELL=bash pnpm setup + + - name: Refresh bashrc + run: | source /home/runner/.bashrc + + - name: Install package using pnpm + working-directory: testDir + run: | pnpm install .. test-bun-install: @@ -515,36 +548,60 @@ jobs: npm install -g json json -I -f package.json -e "this.scripts.install=\"npm-run-all removeExtraBinaries build\"" - - name: Run tests + - name: Install bun run: | npm install -g bun - bun link + + - name: run bun link on source package + run: | + bun link + + - name: make test directory + run: | mkdir -p testDir - cd testDir + + - name: run bun link on source package + working-directory: testDir + run: | bun link aerospike test-typescript-install: runs-on: ubuntu-latest needs: [manylinux, macOS-x86] + strategy: + matrix: + node-version: [ + "20", + ] + fail-fast: false + steps: - uses: actions/checkout@v2 with: submodules: recursive - - uses: ./.github/workflows/combine-bindings/ - - uses: actions/setup-node@v4 with: - node-version: ${{ env.LOWEST_SUPPORTED_NODEJS_VERSION }} + node-version: ${{ matrix.node-version }} architecture: 'x64' + - uses: actions/download-artifact@v4 + with: + name: binding-${{ matrix.node-version }} + + - name: make binding folder + run: mkdir lib/binding + + - name: Install client + run: | + cp -r node-v115-linux-x64 lib/binding/node-v115-linux-x64 + - 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 @@ -557,17 +614,38 @@ jobs: run: | npm install -g json json -I -f package.json -e "this.scripts.install=\"npm-run-all removeExtraBinaries build\"" - - - name: Run tests + + - name: Make package directory run: | mkdir my-aerospike-project - cd my-aerospike-project + + - name: Initialize npm project + working-directory: my-aerospike-project + run: | npm init -y + + - name: Install typescript as a developer dependency + working-directory: my-aerospike-project + run: | npm install typescript ts-node --save-dev + + - name: Install aerospike as dependency in npm project + working-directory: my-aerospike-project + run: | npm install .. + + - name: copy typescript example to npm project + working-directory: my-aerospike-project + run: | cp ../examples/typescript.ts index.ts - npx tsc index.ts - node index.js + - name: Compile the project in typescript + working-directory: my-aerospike-project + run: | + npx tsc index.ts + - name: Run the compile javascript test + working-directory: my-aerospike-project + run: | + node index.js \ No newline at end of file diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 2b2ab7ef7..5a120a86e 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -27,9 +27,11 @@ jobs: lint: runs-on: ubuntu-latest steps: + - uses: actions/checkout@v4 with: submodules: recursive + - name: install standard run: npm install standard @@ -51,16 +53,18 @@ jobs: with: node-version: ${{ matrix.nodejs-version }} architecture: 'x64' + - name: debugging run: | echo "LOWEST_SUPPORTED_NODEJS_VERSION: $LOWEST_SUPPORTED_NODEJS_VERSION" - - run: sudo apt update + - name: Download most recent package information + 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) + - name: Install build dependencies run: sudo apt install build-essential; - name: Build client @@ -70,56 +74,12 @@ jobs: env: CFLAGS: '-Werror' - - name: list - run: ls lib/binding - name: Send binding to test jobs uses: actions/upload-artifact@v4 with: name: binding-${{ matrix.nodejs-version }} path: ./lib/binding/node-*-linux-x64/ -# test-memray: -# needs: build-ubuntu -# runs-on: ubuntu-latest -# steps: -# - uses: actions/checkout@v4 -# -# - uses: actions/setup-node@v4 -# with: -# node-version: ${{ matrix.nodejs-version }} -# architecture: 'x64' -# -# - uses: actions/download-artifact@v4 -# 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 run 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: @@ -417,13 +377,37 @@ jobs: 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: Modify the package.json + - name: Make package directory run: | mkdir my-aerospike-project - cd my-aerospike-project + + - name: Initialize npm project + working-directory: my-aerospike-project + run: | npm init -y + + - name: Install typescript as a developer dependency + working-directory: my-aerospike-project + run: | npm install typescript ts-node --save-dev + + - name: Install aerospike as dependency in npm project + working-directory: my-aerospike-project + run: | npm install .. + + - name: copy typescript example to npm project + working-directory: my-aerospike-project + run: | cp ../examples/typescript.ts index.ts + + + - name: Compile the project in typescript + working-directory: my-aerospike-project + run: | npx tsc index.ts + + - name: Run the compile javascript test + working-directory: my-aerospike-project + run: | node index.js \ No newline at end of file