Repository navigation
JSCO-82: Update development dependencies and resolve npm audit findin… #20
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: tests | |
| on: | |
| push: | |
| branches: | |
| - main | |
| pull_request: | |
| branches: | |
| - main | |
| workflow_dispatch: | |
| inputs: | |
| is_release: | |
| description: "Set to true if a release version." | |
| required: false | |
| default: false | |
| type: boolean | |
| sha: | |
| description: "The git SHA to use for release. Only set if needing to publish" | |
| required: false | |
| default: "" | |
| type: string | |
| version: | |
| description: "The Release version. Allowed format: x.y.z" | |
| required: false | |
| default: "" | |
| type: string | |
| workflow_call: | |
| inputs: | |
| is_release: | |
| description: "Set to true if a release version." | |
| required: false | |
| default: false | |
| type: boolean | |
| sha: | |
| description: "The git SHA to use for release. Only set if needing to publish" | |
| required: false | |
| default: "" | |
| type: string | |
| version: | |
| description: "The Release version. Allowed format: x.y.z" | |
| required: false | |
| default: "" | |
| type: string | |
| outputs: | |
| workflow_run_id: | |
| description: "The workflow run ID" | |
| value: ${{ github.run_id }} | |
| jobs: | |
| validate-input: | |
| runs-on: ubuntu-24.04 | |
| steps: | |
| - name: If release, verify SHA is provided | |
| if: inputs.is_release && inputs.sha == '' | |
| run: | | |
| echo "::error If releasing, must provide a SHA." | |
| exit 1 | |
| - name: If release, verify SHA is correct length | |
| if: inputs.is_release && inputs.sha != '' | |
| run: | | |
| echo '"${{ inputs.sha }}"' | jq -e '. | length == 40' | |
| lint: | |
| runs-on: ubuntu-24.04 | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Setup Node.js ${{ env.DEFAULT_NODE }} | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: ${{ env.DEFAULT_NODE }} | |
| - name: Confirm Node version | |
| run: node --version | |
| - name: Install dependencies | |
| run: | | |
| npm ci --ignore-scripts | |
| - name: Run lint | |
| run: npm run lint | |
| - name: Check deps | |
| if: inputs.is_release | |
| run: | |
| npm run check-deps | |
| npm audit --omit=dev | |
| npm run check-types | |
| package: | |
| runs-on: ubuntu-24.04 | |
| needs: [validate-input, lint] | |
| steps: | |
| - name: Checkout (with SHA) | |
| if: ${{ inputs.sha != '' }} | |
| uses: actions/checkout@v4 | |
| with: | |
| ref: ${{ inputs.sha }} | |
| fetch-depth: 0 | |
| - name: Checkout (no SHA) | |
| if: ${{ inputs.sha == '' }} | |
| uses: actions/checkout@v4 | |
| - name: Setup Node.js ${{ env.DEFAULT_NODE }} | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: ${{ env.DEFAULT_NODE }} | |
| - name: Confirm Node version | |
| run: node --version | |
| - name: Install dependencies | |
| run: | | |
| npm ci --ignore-scripts | |
| filename=$(npm pack | tail -n 1) | |
| echo "filename=$filename" >> "$GITHUB_ENV" | |
| - name: Upload package tarball | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: cboi-package | |
| path: ${{ env.filename }} | |
| test-setup: | |
| runs-on: ubuntu-24.04 | |
| needs: package | |
| steps: | |
| - name: Checkout (with SHA) | |
| if: inputs.sha != '' | |
| uses: actions/checkout@v4 | |
| with: | |
| ref: ${{ inputs.sha }} | |
| fetch-depth: 0 | |
| fetch-tags: true | |
| - name: Checkout (no SHA) | |
| if: inputs.sha == '' | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| fetch-tags: true | |
| - name: Setup test environment | |
| run: | | |
| mkdir ncboi-test | |
| cp -r test ncboi-test | |
| cp -r lib ncboi-test | |
| cp -r scripts ncboi-test | |
| cp package.json ncboi-test | |
| cp package-lock.json ncboi-test | |
| cp tsconfig.json ncboi-test | |
| cp tsup.config.mjs ncboi-test | |
| - name: Build testConfig.ini | |
| run: | | |
| cat > testConfig.ini <<EOF | |
| username = Administrator | |
| password = password | |
| fqdn = travel-sample.inventory.fqdn | |
| EOF | |
| echo "Output testConfig.ini" | |
| cat testConfig.ini | |
| mv testConfig.ini ncboi-test/test | |
| echo "ncboi-test/test contents" | |
| ls -alh ncboi-test/test | |
| - name: Rewrite imports in test files | |
| run: | | |
| FROM="../lib/operationalinsights.js" | |
| TO="couchbase-operational-insights" | |
| for file in ncboi-test/test/harness.ts ncboi-test/test/query.test.ts ncboi-test/test/cluster.test.ts ncboi-test/test/asyncquery.test.ts; do | |
| echo "Rewriting import in $file" | |
| sed -i'' -e "s|from '$FROM'|from '$TO'|g" "$file" | |
| done | |
| - name: Upload test setup | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| retention-days: 1 | |
| name: ncboi-test-setup | |
| path: | | |
| ncboi-test/ | |
| test-linux: | |
| runs-on: ${{ matrix.os }} | |
| needs: test-setup | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| os: ['ubuntu-24.04'] | |
| node-version: ["22", "24", "26"] | |
| arch: ['x86_64', 'arm64'] | |
| image-type: ['bullseye-slim', 'alpine'] | |
| steps: | |
| - name: Set up QEMU | |
| if: ${{ matrix.arch == 'arm64' }} | |
| uses: docker/setup-qemu-action@v3 | |
| with: | |
| platforms: arm64 | |
| - uses: actions/download-artifact@v4 | |
| with: | |
| name: ncboi-test-setup | |
| - name: Download package tarball | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: cboi-package | |
| - name: Run in docker | |
| uses: addnab/docker-run-action@v3 | |
| with: | |
| image: node:${{ matrix.node-version }}-${{ matrix.image-type }} | |
| options: >- | |
| --platform linux/${{ matrix.arch == 'x86_64' && 'amd64' || 'arm64'}} | |
| -v ${{ github.workspace }}:/work | |
| run: | | |
| node --version | |
| cd /work | |
| ls -alh | |
| npm install | |
| npm install couchbase-operational-insights*.tgz | |
| npm run test | |
| test-macos: | |
| runs-on: ${{ matrix.os }} | |
| needs: test-setup | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| os: ["macos-15", "macos-15-intel"] | |
| node-version: ["22", "24", "26"] | |
| steps: | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: ${{ matrix.node-version }} | |
| - name: Confirm Node version | |
| run: | | |
| node --version | |
| node -p "process.arch" | |
| - uses: actions/download-artifact@v4 | |
| with: | |
| name: ncboi-test-setup | |
| - name: Download package tarball | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: cboi-package | |
| - name: Run tests | |
| timeout-minutes: 30 | |
| run: | | |
| node --version | |
| npm install | |
| npm install couchbase-operational-insights*.tgz | |
| npm run test | |
| test-windows: | |
| runs-on: ${{ matrix.os }} | |
| needs: test-setup | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| os: ["windows-latest"] | |
| node-version: ["22", "24", "26"] | |
| arch: ["x86_64"] | |
| steps: | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: ${{ matrix.node-version }} | |
| - name: Confirm Node version | |
| run: | | |
| node --version | |
| node -p "process.arch" | |
| - uses: actions/download-artifact@v4 | |
| with: | |
| name: ncboi-test-setup | |
| - name: Download package tarball | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: cboi-package | |
| - name: Run tests | |
| timeout-minutes: 30 | |
| run: | | |
| node --version | |
| npm install | |
| npm install couchbase-operational-insights*.tgz | |
| npm run test | |
| test-integration-cbdinocluster: | |
| needs: [ validate-input, lint, test-setup ] | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| node-version: ["22", "24", "26"] | |
| runs-on: ubuntu-24.04 | |
| steps: | |
| - name: Install cbdinocluster | |
| run: | | |
| mkdir -p "$HOME/bin" | |
| wget -nv -O $HOME/bin/cbdinocluster https://github.com/couchbaselabs/cbdinocluster/releases/download/v0.0.113/cbdinocluster-linux-amd64 | |
| chmod +x $HOME/bin/cbdinocluster | |
| echo "$HOME/bin" >> $GITHUB_PATH | |
| - name: Install s3mock | |
| run: | | |
| docker pull adobe/s3mock | |
| docker pull nginx | |
| - name: Initialize cbdinocluster | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: | | |
| cbdinocluster -v init --auto | |
| - name: Start couchbase cluster | |
| env: | |
| CLUSTERCONFIG: | | |
| columnar: true | |
| nodes: | |
| - count: 3 | |
| version: 2.2.0 | |
| docker: | |
| image: ghcr.io/cb-vanilla/enterprise-analytics:2.2.0-1314 | |
| docker: | |
| load-balancer: true | |
| use-dino-certs: true | |
| run: | | |
| CBDC_ID=$(cbdinocluster -v alloc --def="${CLUSTERCONFIG}") | |
| CBDC_CONNSTR=$(cbdinocluster -v connstr --tls --analytics $CBDC_ID) | |
| echo "CBDC_ID=$CBDC_ID" >> "$GITHUB_ENV" | |
| echo "CBDC_CONNSTR=$CBDC_CONNSTR" >> "$GITHUB_ENV" | |
| echo "NCBOICSTR=$CBDC_CONNSTR" >> "$GITHUB_ENV" | |
| echo "NCBOIUSER=Administrator" >> "$GITHUB_ENV" | |
| echo "NCBOIPASS=password" >> "$GITHUB_ENV" | |
| - name: Set up Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: ${{ matrix.node-version }} | |
| - name: Download test setup | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: ncboi-test-setup | |
| - name: Download package tarball | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: cboi-package | |
| - name: Run tests | |
| timeout-minutes: 30 | |
| env: | |
| NCBOICSTR: ${{ env.CBDC_CONNSTR || '' }} | |
| NCBOIUSER: 'Administrator' | |
| NCBOIPASS: 'password' | |
| run: | | |
| ls -alh | |
| node --version | |
| npm install | |
| npm install couchbase-operational-insights*.tgz | |
| npm run test |