pelias-schema 9.0.1 → 10.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,21 @@
1
+ name: Unit Tests
2
+ on: workflow_call
3
+ jobs:
4
+ unit-tests:
5
+ runs-on: '${{ matrix.os }}'
6
+ strategy:
7
+ matrix:
8
+ os:
9
+ - ubuntu-24.04
10
+ node-version: [ 22.x, 24.x, 26.x ]
11
+ steps:
12
+ - uses: actions/checkout@v6
13
+ - name: 'Install node.js ${{ matrix.node-version }}'
14
+ uses: actions/setup-node@v6
15
+ with:
16
+ node-version: '${{ matrix.node-version }}'
17
+ - name: Run unit tests
18
+ run: |
19
+ [[ -f ./bin/ci-setup ]] && ./bin/ci-setup
20
+ npm install
21
+ npm run ci
@@ -4,8 +4,4 @@ jobs:
4
4
  unit-tests:
5
5
  # only run this job for forks
6
6
  if: github.event.pull_request.head.repo.full_name != github.repository
7
- uses: ./.github/workflows/_unit_tests.yml
8
- integration-tests:
9
- # only run this job for forks
10
- if: github.event.pull_request.head.repo.full_name != github.repository
11
- uses: ./.github/workflows/_integration_tests.yml
7
+ uses: ./.github/workflows/_test.yml
@@ -1,37 +1,36 @@
1
- name: 'Continuous Integration'
2
- on:
3
- push:
4
- branches-ignore:
5
- - 'v[0-9]+.[0-9]+.[0-9]+'
1
+ name: Continuous Integration
2
+ on: push
6
3
  jobs:
7
4
  unit-tests:
8
- uses: ./.github/workflows/_unit_tests.yml
9
- integration-tests:
10
- uses: ./.github/workflows/_integration_tests.yml
5
+ uses: ./.github/workflows/_test.yml
11
6
  npm-publish:
12
- needs: [unit-tests, integration-tests]
13
- if: github.ref == 'refs/heads/master' && github.event_name == 'push'
14
- runs-on: ubuntu-22.04
7
+ needs: unit-tests
8
+ if: github.ref == 'refs/heads/master' && needs.unit-tests.result == 'success'
9
+ runs-on: ubuntu-24.04
10
+ permissions:
11
+ id-token: write
12
+ contents: write
15
13
  steps:
16
- - uses: actions/checkout@v4
17
- - name: Install Node.js
18
- uses: actions/setup-node@v4
19
- with:
20
- node-version: 20.x
21
- - name: Run semantic-release
22
- env:
23
- GH_TOKEN: ${{ secrets.GH_SEMANTIC_RELEASE_TOKEN }}
24
- NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
25
- run: |
26
- curl "https://raw.githubusercontent.com/pelias/ci-tools/master/semantic-release.sh" | bash -
14
+ - uses: actions/checkout@v6
15
+ - name: Install Node.js
16
+ uses: actions/setup-node@v6
17
+ with:
18
+ node-version: 22.x
19
+ - name: Run semantic-release
20
+ env:
21
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
22
+ run: >
23
+ if [[ "${{ github.repository_owner }}" == "pelias" ]]; then
24
+ curl "https://raw.githubusercontent.com/pelias/ci-tools/master/semantic-release.sh" | bash -
25
+ fi
27
26
  build-docker-images:
28
27
  # run this job if the unit tests passed and the npm-publish job was a success or was skipped
29
28
  # note: github actions won't run a job if you don't call one of the status check functions, so `always()` is called since it evalutes to `true`
30
29
  if: ${{ always() && needs.unit-tests.result == 'success' && (needs.npm-publish.result == 'success' || needs.npm-publish.result == 'skipped') }}
31
- needs: [unit-tests, integration-tests, npm-publish]
32
- runs-on: ubuntu-22.04
30
+ needs: [unit-tests, npm-publish]
31
+ runs-on: ubuntu-24.04
33
32
  steps:
34
- - uses: actions/checkout@v4
33
+ - uses: actions/checkout@v6
35
34
  - name: Build Docker images
36
35
  env:
37
36
  DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
package/.jshintrc CHANGED
@@ -2,7 +2,7 @@
2
2
  "node": true,
3
3
  "curly": true,
4
4
  "eqeqeq": true,
5
- "esversion": 6,
5
+ "esversion": 11,
6
6
  "freeze": true,
7
7
  "immed": true,
8
8
  "indent": 2,
@@ -13,8 +13,10 @@
13
13
  "nonbsp": true,
14
14
  "nonew": true,
15
15
  "plusplus": false,
16
+ "quotmark": "single",
16
17
  "undef": true,
17
18
  "unused": false,
18
19
  "maxparams": 4,
19
- "maxdepth": 4
20
+ "maxdepth": 4,
21
+ "maxlen": 140
20
22
  }
package/bin/ci ADDED
@@ -0,0 +1,29 @@
1
+ #!/bin/bash
2
+
3
+ # run the unit and integration tests against both icuTokenizer settings
4
+ set -euo pipefail
5
+
6
+ BASE_CONFIG="${PELIAS_CONFIG:-${HOME}/pelias.json}"
7
+ WORKDIR="$(mktemp -d)"
8
+ trap 'rm -rf "${WORKDIR}"' EXIT
9
+
10
+ # write a copy of the config with the icuTokenizer setting overridden
11
+ write_config() {
12
+ local base='{}'
13
+ if [[ -f "${BASE_CONFIG}" ]]; then base="$(cat "${BASE_CONFIG}")"; fi
14
+ jq -n --argjson base "${base}" --argjson icu "$1" \
15
+ '$base * { schema: { icuTokenizer: $icu } }' > "${WORKDIR}/pelias.json"
16
+ }
17
+
18
+ for ICU_TOKENIZER in false true; do
19
+ echo "--- icuTokenizer: ${ICU_TOKENIZER} ---"
20
+ write_config "${ICU_TOKENIZER}"
21
+ export PELIAS_CONFIG="${WORKDIR}/pelias.json"
22
+
23
+ npm run test
24
+
25
+ # the index is recreated per variant to assert the schema is valid for both
26
+ node scripts/drop_index --force-yes &> /dev/null || true
27
+ npm run create_index
28
+ npm run integration
29
+ done
@@ -1,8 +1,11 @@
1
1
  #!/bin/bash
2
- set -e
2
+ set -eo pipefail
3
+
4
+ # the integration tests require a running elasticsearch server
5
+ ES_VERSION="${ES_VERSION:-7.6.1}"
3
6
 
4
7
  # create elasticsearch directory
5
- mkdir /tmp/elasticsearch
8
+ mkdir -p /tmp/elasticsearch
6
9
 
7
10
  # download and install elasticsearch with ICU plugin
8
11
  FILENAME="elasticsearch-${ES_VERSION}-linux-x86_64.tar.gz"
@@ -25,7 +28,7 @@ wget -O - "https://artifacts.elastic.co/downloads/elasticsearch/${FILENAME}" \
25
28
 
26
29
  # wait for server to boot up
27
30
  # logs show that on travis-ci it can take ~17s to boot an ES6 server
28
- source "${BASH_SOURCE%/*}/elastic_wait.sh"
31
+ source "${BASH_SOURCE%/*}/../scripts/elastic_wait.sh"
29
32
  (elastic_wait)
30
33
 
31
34
  # set the correct esclient.apiVersion in pelias.json
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pelias-schema",
3
- "version": "9.0.1",
3
+ "version": "10.0.0",
4
4
  "author": "pelias",
5
5
  "description": "Elasticsearch schema files and tooling for Pelias",
6
6
  "homepage": "https://github.com/pelias/schema",
@@ -8,6 +8,7 @@
8
8
  "main": "schema.js",
9
9
  "scripts": {
10
10
  "test": "./bin/test",
11
+ "ci": "./bin/ci",
11
12
  "integration": "./bin/integration",
12
13
  "create_index": "./bin/create_index",
13
14
  "drop_index": "node scripts/drop_index",
@@ -25,7 +26,7 @@
25
26
  "url": "https://github.com/pelias/schema/issues"
26
27
  },
27
28
  "engines": {
28
- "node": ">=10.0.0"
29
+ "node": ">=22.0.0"
29
30
  },
30
31
  "dependencies": {
31
32
  "@hapi/joi": "^16.1.8",
@@ -33,8 +34,8 @@
33
34
  "elasticsearch": "^16.0.0",
34
35
  "glob": "^7.1.6",
35
36
  "lodash": "^4.17.15",
36
- "pelias-config": "^6.0.0",
37
- "pelias-logger": "^1.3.0",
37
+ "pelias-config": "^7.0.0",
38
+ "pelias-logger": "^2.0.0",
38
39
  "semver": "^7.1.1"
39
40
  },
40
41
  "devDependencies": {
@@ -1,32 +0,0 @@
1
- name: Integration Tests
2
- on: workflow_call
3
- jobs:
4
- integration-tests:
5
- runs-on: ${{ matrix.os }}
6
- strategy:
7
- matrix:
8
- os:
9
- - ubuntu-22.04
10
- node-version: [ 20.x, 22.x, 24.x ]
11
- es-version: [7.6.1]
12
- icuTokenizer: [true, false]
13
- steps:
14
- - uses: actions/checkout@v4
15
- - name: Install node.js ${{ matrix.node-version }}
16
- uses: actions/setup-node@v4
17
- with:
18
- node-version: ${{ matrix.node-version }}
19
- - name: Start elasticsearch ${{ matrix.es-version }}
20
- env:
21
- ES_VERSION: ${{ matrix.es-version }}
22
- run: ./scripts/setup_ci.sh
23
- - name: Run integration tests
24
- run: |
25
- if [ "${{ matrix.icuTokenizer }}" = "true" ]; then
26
- jq -n '{ schema: { icuTokenizer: true } }' > $(pwd)/config-icu.json
27
- export PELIAS_CONFIG=$(pwd)/config-icu.json
28
- fi
29
- npm install
30
- curl http://127.0.0.1:9200/
31
- ./bin/create_index
32
- npm run integration
@@ -1,25 +0,0 @@
1
- name: Unit Tests
2
- on: workflow_call
3
- jobs:
4
- unit-tests:
5
- runs-on: ${{ matrix.os }}
6
- strategy:
7
- matrix:
8
- os:
9
- - ubuntu-22.04
10
- node-version: [ 20.x, 22.x, 24.x ]
11
- icuTokenizer: [true, false]
12
- steps:
13
- - uses: actions/checkout@v4
14
- - name: Install node.js ${{ matrix.node-version }}
15
- uses: actions/setup-node@v4
16
- with:
17
- node-version: ${{ matrix.node-version }}
18
- - name: Run unit tests
19
- run: |
20
- npm install
21
- if [ "${{ matrix.icuTokenizer }}" = "true" ]; then
22
- jq -n '{ schema: { icuTokenizer: true } }' > $(pwd)/config-icu.json
23
- export PELIAS_CONFIG=$(pwd)/config-icu.json
24
- fi
25
- npm run test