Skip to content

Commit

Permalink
Merge branch 'main' into semaphore-hang
Browse files Browse the repository at this point in the history
  • Loading branch information
pquentin authored Feb 6, 2024
2 parents bcdca23 + 57ee5cf commit bd72631
Show file tree
Hide file tree
Showing 31 changed files with 652 additions and 124 deletions.
4 changes: 3 additions & 1 deletion .buildkite/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,7 @@ RUN apt-get clean -y && \

WORKDIR /usr/src/app

COPY . .
COPY package.json .
RUN npm install --production=false

COPY . .
3 changes: 1 addition & 2 deletions .buildkite/pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,13 @@ steps:
env:
NODE_VERSION: "{{ matrix.nodejs }}"
TEST_SUITE: "{{ matrix.suite }}"
STACK_VERSION: 8.8.0-SNAPSHOT
STACK_VERSION: 8.12.0-SNAPSHOT
matrix:
setup:
suite:
- "free"
- "platinum"
nodejs:
- "16"
- "18"
- "20"
command: ./.buildkite/run-tests.sh
Expand Down
22 changes: 13 additions & 9 deletions .ci/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
ARG NODE_JS_VERSION=18
ARG NODE_JS_VERSION=${NODE_JS_VERSION:-18}
FROM node:${NODE_JS_VERSION}

ARG BUILDER_UID=1000
Expand All @@ -12,15 +12,19 @@ RUN apt-get clean -y && \
apt-get install -y zip

# Set user permissions and directory
RUN groupadd --system -g ${BUILDER_GID} ${BUILDER_GROUP} \
&& useradd --system --shell /bin/bash -u ${BUILDER_UID} -g ${BUILDER_GROUP} -m elastic 1>/dev/null 2>/dev/null \
RUN (id -g ${BUILDER_GID} || groupadd --system -g ${BUILDER_GID} ${BUILDER_GROUP}) \
&& (id -u ${BUILDER_UID} || useradd --system --shell /bin/bash -u ${BUILDER_UID} -g ${BUILDER_GID} -m elastic) \
&& mkdir -p /usr/src/elasticsearch-js \
&& chown -R ${BUILDER_USER}:${BUILDER_GROUP} /usr/src/
&& chown -R ${BUILDER_UID}:${BUILDER_GID} /usr/src/

WORKDIR /usr/src/elasticsearch-js
USER ${BUILDER_USER}:${BUILDER_GROUP}

# Install app dependencies
COPY --chown=$BUILDER_USER:$BUILDER_GROUP package*.json ./
RUN npm install
# run remainder of commands as non-root user
USER ${BUILDER_UID}:${BUILDER_GID}

# install dependencies
COPY package.json .
RUN npm install --production=false

COPY --chown=$BUILDER_USER:$BUILDER_GROUP . .
# copy project files
COPY . .
9 changes: 7 additions & 2 deletions .ci/make.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,11 @@ import assert from 'assert'
import { join } from 'desm'
import semver from 'semver'

// xz/globals loads minimist-parsed args as a global `argv`, but it
// interprets args like '8.10' as numbers and shortens them to '8.1'.
// so we have to import and configure minimist ourselves.
import minimist from 'minimist'
const argv = minimist(process.argv.slice(2), { string: ['_', 'task'] })
assert(typeof argv.task === 'string', 'Missing task parameter')

switch (argv.task) {
Expand Down Expand Up @@ -86,10 +91,10 @@ async function bump (args) {
'utf8'
)

const pipeline = await readFile(join(import.meta.url, '..', '.buildkite', 'pipeline.yml'))
const pipeline = await readFile(join(import.meta.url, '..', '.buildkite', 'pipeline.yml'), 'utf8')
await writeFile(
join(import.meta.url, '..', '.buildkite', 'pipeline.yml'),
pipeline.replace(/STACK_VERSION: [0-9]+[0-9\.]*[0-9](?:\-SNAPSHOT)?/, `STACK_VERSION: ${cleanVersion}-SNAPSHOT`), // eslint-disable-line
pipeline.replace(/STACK_VERSION: [0-9]+[0-9\.]*[0-9](?:\-SNAPSHOT)?/, `STACK_VERSION: ${cleanVersion}-SNAPSHOT`),
'utf8'
)
}
Expand Down
42 changes: 29 additions & 13 deletions .ci/make.sh
Original file line number Diff line number Diff line change
Expand Up @@ -144,19 +144,35 @@ docker build \

echo -e "\033[34;1mINFO: running $product container\033[0m"

docker run \
--volume "$repo:/usr/src/elasticsearch-js" \
--volume /usr/src/elasticsearch-js/node_modules \
-u "$(id -u):$(id -g)" \
--env "WORKFLOW=$WORKFLOW" \
--name make-elasticsearch-js \
--rm \
$product \
/bin/bash -c "cd /usr/src && \
git clone https://$CLIENTS_GITHUB_TOKEN@github.com/elastic/elastic-client-generator-js.git && \
mkdir -p /usr/src/elastic-client-generator-js/output && \
cd /usr/src/elasticsearch-js && \
node .ci/make.mjs --task $TASK ${TASK_ARGS[*]}"
if [[ -z "${BUILDKITE+x}" ]] && [[ -z "${CI+x}" ]] && [[ -z "${GITHUB_ACTIONS+x}" ]]; then
echo -e "\033[34;1mINFO: Running in local mode"
docker run \
-u "$(id -u):$(id -g)" \
--volume "$repo:/usr/src/elasticsearch-js" \
--volume /usr/src/elasticsearch-js/node_modules \
--volume "$(realpath $repo/../elastic-client-generator-js):/usr/src/elastic-client-generator-js" \
--env "WORKFLOW=$WORKFLOW" \
--name make-elasticsearch-js \
--rm \
$product \
/bin/bash -c "mkdir -p /usr/src/elastic-client-generator-js/output && \
node .ci/make.mjs --task $TASK ${TASK_ARGS[*]}"
else
echo -e "\033[34;1mINFO: Running in CI mode"
docker run \
--volume "$repo:/usr/src/elasticsearch-js" \
--volume /usr/src/elasticsearch-js/node_modules \
-u "$(id -u):$(id -g)" \
--env "WORKFLOW=$WORKFLOW" \
--name make-elasticsearch-js \
--rm \
$product \
/bin/bash -c "cd /usr/src && \
git clone https://$CLIENTS_GITHUB_TOKEN@github.com/elastic/elastic-client-generator-js.git && \
mkdir -p /usr/src/elastic-client-generator-js/output && \
cd /usr/src/elasticsearch-js && \
node .ci/make.mjs --task $TASK ${TASK_ARGS[*]}"
fi

# ------------------------------------------------------- #
# Post Command tasks & checks
Expand Down
2 changes: 2 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,5 @@ npm-debug.log
test/benchmarks
elasticsearch
.git
lib
junit-output
19 changes: 15 additions & 4 deletions .github/workflows/backport.yml
Original file line number Diff line number Diff line change
@@ -1,16 +1,27 @@
---
name: Backport
on:
pull_request:
pull_request_target:
types:
- closed
- labeled

jobs:
backport:
runs-on: ubuntu-latest
name: Backport
runs-on: ubuntu-latest
# Only react to merged PRs for security reasons.
# See https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#pull_request_target.
if: >
github.event.pull_request.merged
&& (
github.event.action == 'closed'
|| (
github.event.action == 'labeled'
&& contains(github.event.label.name, 'backport')
)
)
steps:
- name: Backport
uses: tibdex/backport@7005ef85c4562bc23b0e9b4a9940d5922f439750
- uses: tibdex/backport@9565281eda0731b1d20c4025c43339fb0a23812e # v2.0.4
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
25 changes: 22 additions & 3 deletions .github/workflows/nodejs.yml
Original file line number Diff line number Diff line change
@@ -1,21 +1,40 @@
---
name: Node CI

on: [push, pull_request]
on:
pull_request: {}

jobs:
paths-filter:
name: Detect files changed
runs-on: ubuntu-latest
outputs:
src-only: '${{ steps.changes.outputs.src-only }}'
steps:
- uses: actions/checkout@v4
- uses: dorny/paths-filter/@v2.11.1
id: changes
with:
filters: |
src-only:
- '!(**/*.{md,asciidoc,txt}|*.{md,asciidoc,txt}|{docs,.ci,.buildkite,scripts}/**/*|catalog-info.yaml)'
- '.github/workflows/**'
test:
name: Test
runs-on: ${{ matrix.os }}
needs: paths-filter
# only run if code relevant to unit tests was changed
if: needs.paths-filter.outputs.src-only == 'true'

strategy:
fail-fast: false
matrix:
node-version: [14.x, 16.x, 18.x, 20.x]
node-version: [18.x, 20.x]
os: [ubuntu-latest, windows-latest, macOS-latest]

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
Expand Down
27 changes: 27 additions & 0 deletions .github/workflows/npm-publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: Publish Package to npm
on:
workflow_dispatch:
inputs:
branch:
description: 'Git branch to build and publish'
required: true
jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: read
id-token: write
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.event.inputs.branch }}
- uses: actions/setup-node@v3
with:
node-version: '20.x'
registry-url: 'https://registry.npmjs.org'
- run: npm install -g npm
- run: npm install
- run: npm test
- run: npm publish --provenance --access public
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
21 changes: 21 additions & 0 deletions .github/workflows/stale.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
---
name: 'Close stale issues and PRs'
on:
schedule:
- cron: '30 1 * * *'

jobs:
stale:
runs-on: ubuntu-latest
steps:
- uses: actions/stale@v8
with:
stale-issue-label: stale
stale-pr-label: stale
days-before-stale: 90
days-before-close: 14
exempt-issue-labels: 'good first issue'
close-issue-label: closed-stale
close-pr-label: closed-stale
stale-issue-message: 'This issue is stale because it has been open 90 days with no activity. Remove the `stale` label, or leave a comment, or this will be closed in 14 days.'
stale-pr-message: 'This pull request is stale because it has been open 90 days with no activity. Remove the `stale` label, or leave a comment, or this will be closed in 14 days.'
8 changes: 7 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@

[![js-standard-style](https://img.shields.io/badge/code%20style-standard-brightgreen.svg?style=flat)](http://standardjs.com/) [![Build Status](https://badge.buildkite.com/15e4246eb268ea78f6e10aa90bce38c1abb0a4489e79f5a0ac.svg)](https://buildkite.com/elastic/elasticsearch-javascript-client-integration-tests/builds?branch=main) [![Node CI](https://github.com/elastic/elasticsearch-js/actions/workflows/nodejs.yml/badge.svg)](https://github.com/elastic/elasticsearch-js/actions/workflows/nodejs.yml) [![codecov](https://codecov.io/gh/elastic/elasticsearch-js/branch/master/graph/badge.svg)](https://codecov.io/gh/elastic/elasticsearch-js) [![NPM downloads](https://img.shields.io/npm/dm/@elastic/elasticsearch.svg?style=flat)](https://www.npmjs.com/package/@elastic/elasticsearch)

**[Download the latest version of Elasticsearch](https://www.elastic.co/downloads/elasticsearch)**
or
**[sign-up](https://cloud.elastic.co/registration?elektra=en-ess-sign-up-page)**
**for a free trial of Elastic Cloud**.

The official Node.js client for Elasticsearch.

## Installation
Expand All @@ -28,7 +33,7 @@ of the getting started documentation.

### Node.js support

NOTE: The minimum supported version of Node.js is `v14`.
NOTE: The minimum supported version of Node.js is `v18`.

The client versioning follows the Elastic Stack versioning, this means that
major, minor, and patch releases are done following a precise schedule that
Expand All @@ -53,6 +58,7 @@ of `^7.10.0`).
| `10.x` | `April 2021` | `7.12` (mid 2021) |
| `12.x` | `April 2022` | `8.2` (early 2022) |
| `14.x` | `April 2023` | `8.8` (early 2023) |
| `16.x` | `September 2023` | `8.11` (late 2023) |

### Compatibility

Expand Down
8 changes: 4 additions & 4 deletions catalog-info.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@ spec:
main_semi_daily:
branch: 'main'
cronline: '0 */12 * * *'
8_9_semi_daily:
branch: '8.9'
8_12_semi_daily:
branch: '8.12'
cronline: '0 */12 * * *'
8_8_daily:
branch: '8.8'
8_11_daily:
branch: '8.11'
cronline: '@daily'
Loading

0 comments on commit bd72631

Please sign in to comment.