Skip to content

Commit bd72631

Browse files
authored
Merge branch 'main' into semaphore-hang
2 parents bcdca23 + 57ee5cf commit bd72631

31 files changed

+652
-124
lines changed

.buildkite/Dockerfile

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,7 @@ RUN apt-get clean -y && \
1010

1111
WORKDIR /usr/src/app
1212

13-
COPY . .
13+
COPY package.json .
1414
RUN npm install --production=false
15+
16+
COPY . .

.buildkite/pipeline.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,13 @@ steps:
66
env:
77
NODE_VERSION: "{{ matrix.nodejs }}"
88
TEST_SUITE: "{{ matrix.suite }}"
9-
STACK_VERSION: 8.8.0-SNAPSHOT
9+
STACK_VERSION: 8.12.0-SNAPSHOT
1010
matrix:
1111
setup:
1212
suite:
1313
- "free"
1414
- "platinum"
1515
nodejs:
16-
- "16"
1716
- "18"
1817
- "20"
1918
command: ./.buildkite/run-tests.sh

.ci/Dockerfile

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
ARG NODE_JS_VERSION=18
1+
ARG NODE_JS_VERSION=${NODE_JS_VERSION:-18}
22
FROM node:${NODE_JS_VERSION}
33

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

1414
# Set user permissions and directory
15-
RUN groupadd --system -g ${BUILDER_GID} ${BUILDER_GROUP} \
16-
&& useradd --system --shell /bin/bash -u ${BUILDER_UID} -g ${BUILDER_GROUP} -m elastic 1>/dev/null 2>/dev/null \
15+
RUN (id -g ${BUILDER_GID} || groupadd --system -g ${BUILDER_GID} ${BUILDER_GROUP}) \
16+
&& (id -u ${BUILDER_UID} || useradd --system --shell /bin/bash -u ${BUILDER_UID} -g ${BUILDER_GID} -m elastic) \
1717
&& mkdir -p /usr/src/elasticsearch-js \
18-
&& chown -R ${BUILDER_USER}:${BUILDER_GROUP} /usr/src/
18+
&& chown -R ${BUILDER_UID}:${BUILDER_GID} /usr/src/
19+
1920
WORKDIR /usr/src/elasticsearch-js
20-
USER ${BUILDER_USER}:${BUILDER_GROUP}
2121

22-
# Install app dependencies
23-
COPY --chown=$BUILDER_USER:$BUILDER_GROUP package*.json ./
24-
RUN npm install
22+
# run remainder of commands as non-root user
23+
USER ${BUILDER_UID}:${BUILDER_GID}
24+
25+
# install dependencies
26+
COPY package.json .
27+
RUN npm install --production=false
2528

26-
COPY --chown=$BUILDER_USER:$BUILDER_GROUP . .
29+
# copy project files
30+
COPY . .

.ci/make.mjs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,11 @@ import assert from 'assert'
2828
import { join } from 'desm'
2929
import semver from 'semver'
3030

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

3338
switch (argv.task) {
@@ -86,10 +91,10 @@ async function bump (args) {
8691
'utf8'
8792
)
8893

89-
const pipeline = await readFile(join(import.meta.url, '..', '.buildkite', 'pipeline.yml'))
94+
const pipeline = await readFile(join(import.meta.url, '..', '.buildkite', 'pipeline.yml'), 'utf8')
9095
await writeFile(
9196
join(import.meta.url, '..', '.buildkite', 'pipeline.yml'),
92-
pipeline.replace(/STACK_VERSION: [0-9]+[0-9\.]*[0-9](?:\-SNAPSHOT)?/, `STACK_VERSION: ${cleanVersion}-SNAPSHOT`), // eslint-disable-line
97+
pipeline.replace(/STACK_VERSION: [0-9]+[0-9\.]*[0-9](?:\-SNAPSHOT)?/, `STACK_VERSION: ${cleanVersion}-SNAPSHOT`),
9398
'utf8'
9499
)
95100
}

.ci/make.sh

Lines changed: 29 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -144,19 +144,35 @@ docker build \
144144

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

147-
docker run \
148-
--volume "$repo:/usr/src/elasticsearch-js" \
149-
--volume /usr/src/elasticsearch-js/node_modules \
150-
-u "$(id -u):$(id -g)" \
151-
--env "WORKFLOW=$WORKFLOW" \
152-
--name make-elasticsearch-js \
153-
--rm \
154-
$product \
155-
/bin/bash -c "cd /usr/src && \
156-
git clone https://$CLIENTS_GITHUB_TOKEN@github.com/elastic/elastic-client-generator-js.git && \
157-
mkdir -p /usr/src/elastic-client-generator-js/output && \
158-
cd /usr/src/elasticsearch-js && \
159-
node .ci/make.mjs --task $TASK ${TASK_ARGS[*]}"
147+
if [[ -z "${BUILDKITE+x}" ]] && [[ -z "${CI+x}" ]] && [[ -z "${GITHUB_ACTIONS+x}" ]]; then
148+
echo -e "\033[34;1mINFO: Running in local mode"
149+
docker run \
150+
-u "$(id -u):$(id -g)" \
151+
--volume "$repo:/usr/src/elasticsearch-js" \
152+
--volume /usr/src/elasticsearch-js/node_modules \
153+
--volume "$(realpath $repo/../elastic-client-generator-js):/usr/src/elastic-client-generator-js" \
154+
--env "WORKFLOW=$WORKFLOW" \
155+
--name make-elasticsearch-js \
156+
--rm \
157+
$product \
158+
/bin/bash -c "mkdir -p /usr/src/elastic-client-generator-js/output && \
159+
node .ci/make.mjs --task $TASK ${TASK_ARGS[*]}"
160+
else
161+
echo -e "\033[34;1mINFO: Running in CI mode"
162+
docker run \
163+
--volume "$repo:/usr/src/elasticsearch-js" \
164+
--volume /usr/src/elasticsearch-js/node_modules \
165+
-u "$(id -u):$(id -g)" \
166+
--env "WORKFLOW=$WORKFLOW" \
167+
--name make-elasticsearch-js \
168+
--rm \
169+
$product \
170+
/bin/bash -c "cd /usr/src && \
171+
git clone https://$CLIENTS_GITHUB_TOKEN@github.com/elastic/elastic-client-generator-js.git && \
172+
mkdir -p /usr/src/elastic-client-generator-js/output && \
173+
cd /usr/src/elasticsearch-js && \
174+
node .ci/make.mjs --task $TASK ${TASK_ARGS[*]}"
175+
fi
160176

161177
# ------------------------------------------------------- #
162178
# Post Command tasks & checks

.dockerignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,5 @@ npm-debug.log
33
test/benchmarks
44
elasticsearch
55
.git
6+
lib
7+
junit-output

.github/workflows/backport.yml

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,27 @@
1+
---
12
name: Backport
23
on:
3-
pull_request:
4+
pull_request_target:
45
types:
56
- closed
67
- labeled
78

89
jobs:
910
backport:
10-
runs-on: ubuntu-latest
1111
name: Backport
12+
runs-on: ubuntu-latest
13+
# Only react to merged PRs for security reasons.
14+
# See https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#pull_request_target.
15+
if: >
16+
github.event.pull_request.merged
17+
&& (
18+
github.event.action == 'closed'
19+
|| (
20+
github.event.action == 'labeled'
21+
&& contains(github.event.label.name, 'backport')
22+
)
23+
)
1224
steps:
13-
- name: Backport
14-
uses: tibdex/backport@7005ef85c4562bc23b0e9b4a9940d5922f439750
25+
- uses: tibdex/backport@9565281eda0731b1d20c4025c43339fb0a23812e # v2.0.4
1526
with:
1627
github_token: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/nodejs.yml

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,40 @@
11
---
22
name: Node CI
33

4-
on: [push, pull_request]
4+
on:
5+
pull_request: {}
56

67
jobs:
8+
paths-filter:
9+
name: Detect files changed
10+
runs-on: ubuntu-latest
11+
outputs:
12+
src-only: '${{ steps.changes.outputs.src-only }}'
13+
steps:
14+
- uses: actions/checkout@v4
15+
- uses: dorny/paths-filter/@v2.11.1
16+
id: changes
17+
with:
18+
filters: |
19+
src-only:
20+
- '!(**/*.{md,asciidoc,txt}|*.{md,asciidoc,txt}|{docs,.ci,.buildkite,scripts}/**/*|catalog-info.yaml)'
21+
- '.github/workflows/**'
22+
723
test:
824
name: Test
925
runs-on: ${{ matrix.os }}
26+
needs: paths-filter
27+
# only run if code relevant to unit tests was changed
28+
if: needs.paths-filter.outputs.src-only == 'true'
1029

1130
strategy:
1231
fail-fast: false
1332
matrix:
14-
node-version: [14.x, 16.x, 18.x, 20.x]
33+
node-version: [18.x, 20.x]
1534
os: [ubuntu-latest, windows-latest, macOS-latest]
1635

1736
steps:
18-
- uses: actions/checkout@v3
37+
- uses: actions/checkout@v4
1938

2039
- name: Use Node.js ${{ matrix.node-version }}
2140
uses: actions/setup-node@v3

.github/workflows/npm-publish.yml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
name: Publish Package to npm
2+
on:
3+
workflow_dispatch:
4+
inputs:
5+
branch:
6+
description: 'Git branch to build and publish'
7+
required: true
8+
jobs:
9+
build:
10+
runs-on: ubuntu-latest
11+
permissions:
12+
contents: read
13+
id-token: write
14+
steps:
15+
- uses: actions/checkout@v4
16+
with:
17+
ref: ${{ github.event.inputs.branch }}
18+
- uses: actions/setup-node@v3
19+
with:
20+
node-version: '20.x'
21+
registry-url: 'https://registry.npmjs.org'
22+
- run: npm install -g npm
23+
- run: npm install
24+
- run: npm test
25+
- run: npm publish --provenance --access public
26+
env:
27+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

.github/workflows/stale.yml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
---
2+
name: 'Close stale issues and PRs'
3+
on:
4+
schedule:
5+
- cron: '30 1 * * *'
6+
7+
jobs:
8+
stale:
9+
runs-on: ubuntu-latest
10+
steps:
11+
- uses: actions/stale@v8
12+
with:
13+
stale-issue-label: stale
14+
stale-pr-label: stale
15+
days-before-stale: 90
16+
days-before-close: 14
17+
exempt-issue-labels: 'good first issue'
18+
close-issue-label: closed-stale
19+
close-pr-label: closed-stale
20+
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.'
21+
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.'

README.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@
44

55
[![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)
66

7+
**[Download the latest version of Elasticsearch](https://www.elastic.co/downloads/elasticsearch)**
8+
or
9+
**[sign-up](https://cloud.elastic.co/registration?elektra=en-ess-sign-up-page)**
10+
**for a free trial of Elastic Cloud**.
11+
712
The official Node.js client for Elasticsearch.
813

914
## Installation
@@ -28,7 +33,7 @@ of the getting started documentation.
2833

2934
### Node.js support
3035

31-
NOTE: The minimum supported version of Node.js is `v14`.
36+
NOTE: The minimum supported version of Node.js is `v18`.
3237

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

5763
### Compatibility
5864

catalog-info.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,9 @@ spec:
4242
main_semi_daily:
4343
branch: 'main'
4444
cronline: '0 */12 * * *'
45-
8_9_semi_daily:
46-
branch: '8.9'
45+
8_12_semi_daily:
46+
branch: '8.12'
4747
cronline: '0 */12 * * *'
48-
8_8_daily:
49-
branch: '8.8'
48+
8_11_daily:
49+
branch: '8.11'
5050
cronline: '@daily'

0 commit comments

Comments
 (0)