Skip to content

Switch from yarn to npm, improve workflows, add provenance to published package #1899

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 0 additions & 5 deletions .code-samples.meilisearch.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -422,11 +422,6 @@ getting_started_add_documents_md: |-
npm install meilisearch
```

Or, if you are using `yarn`
```bash
yarn add meilisearch
```

**Import**

`require` syntax:
Expand Down
18 changes: 18 additions & 0 deletions .github/actions/set-up-node/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: "Set up Node.js"
inputs:
node-version:
default: "lts/*"
registry-url:
default: ""
runs:
using: "composite"
steps:
- name: Set up Node.js ${{ inputs.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ inputs.node-version }}
registry-url: ${{ inputs.registry-url }}
cache: "npm"
- name: Install dependencies
shell: bash
run: npm install
13 changes: 3 additions & 10 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
name: Build documentation

env:
HUSKY: 0

on:
push:
branches:
Expand All @@ -11,16 +8,12 @@ on:
jobs:
build:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Install dependencies
run: yarn install
- uses: actions/checkout@v4
- uses: ./.github/actions/set-up-node

- name: Generate Documentation
run: yarn build:docs
run: npm run build:docs

- name: Deploy to GitHub Pages
uses: peaceiris/actions-gh-pages@v4
Expand Down
40 changes: 17 additions & 23 deletions .github/workflows/meilisearch-prototype-tests.yml
Original file line number Diff line number Diff line change
@@ -1,17 +1,14 @@
# Testing the code base against a specific Meilisearch feature
name: Meilisearch prototype tests

env:
HUSKY: 0

# Will only run for PRs and pushes to *-beta
on:
pull_request:
branches:
- 'prototype-beta/**'
- "prototype-beta/**"
push:
branches:
- 'prototype-beta/**'
- "prototype-beta/**"

jobs:
meilisearch-version:
Expand All @@ -34,37 +31,34 @@ jobs:
echo "meilisearch_version=$MEILISEARCH_VERSION" >> $GITHUB_OUTPUT
integration_tests:
runs-on: ubuntu-latest
needs: ['meilisearch-version']
needs: ["meilisearch-version"]
services:
meilisearch:
image: getmeili/meilisearch:${{ needs.meilisearch-version.outputs.version }}
env:
MEILI_MASTER_KEY: 'masterKey'
MEILI_NO_ANALYTICS: 'true'
MEILI_MASTER_KEY: "masterKey"
MEILI_NO_ANALYTICS: "true"
ports:
- '7700:7700'
- "7700:7700"
strategy:
matrix:
node: ['18', '20', '22']
name: integration-tests (Node.js ${{ matrix.node }})
node-version: ["18", "20", "22"]
name: integration-tests (Node.js ${{ matrix.node-version }})
steps:
- uses: actions/checkout@v4
- name: Setup node
uses: actions/setup-node@v4
- uses: ./.github/actions/set-up-node
with:
node-version: ${{ matrix.node }}
cache: yarn
- name: Install dependencies
run: yarn --dev
node-version: ${{ matrix.node-version }}

- name: Run tests
run: yarn test
run: npm test
- name: Build project
run: yarn build
run: npm run build
- name: Run ESM env
run: yarn test:env:esm
run: npm run test:env:esm
- name: Run Node.js env
run: yarn test:env:nodejs
run: npm run test:env:nodejs
- name: Run node typescript env
run: yarn test:env:node-ts
run: npm run test:env:node-ts
- name: Run Browser env
run: yarn test:env:browser
run: npm run test:env:browser
44 changes: 19 additions & 25 deletions .github/workflows/pre-release-tests.yml
Original file line number Diff line number Diff line change
@@ -1,19 +1,16 @@
# Testing the code base against the Meilisearch pre-releases
name: Pre-Release Tests

env:
HUSKY: 0

# Will only run for PRs and pushes to bump-meilisearch-v*
on:
pull_request:
branches:
- 'bump-meilisearch-v**'
- 'pre-release-beta/**'
- "bump-meilisearch-v**"
- "pre-release-beta/**"
push:
branches:
- 'bump-meilisearch-v**'
- 'pre-release-beta/**'
- "bump-meilisearch-v**"
- "pre-release-beta/**"

jobs:
meilisearch-version:
Expand All @@ -31,37 +28,34 @@ jobs:
integration_tests:
runs-on: ubuntu-latest
if: github.event_name != 'pull_request' || startsWith(github.base_ref, 'bump-meilisearch-v') || startsWith(github.base_ref, 'pre-release-beta')
needs: ['meilisearch-version']
needs: ["meilisearch-version"]
services:
meilisearch:
image: getmeili/meilisearch:${{ needs.meilisearch-version.outputs.version }}
env:
MEILI_MASTER_KEY: 'masterKey'
MEILI_NO_ANALYTICS: 'true'
MEILI_MASTER_KEY: "masterKey"
MEILI_NO_ANALYTICS: "true"
ports:
- '7700:7700'
- "7700:7700"
strategy:
matrix:
node: ['18', '20', '22']
name: integration-tests (Node.js ${{ matrix.node }})
node-version: ["18", "20", "22"]
name: integration-tests (Node.js ${{ matrix.node-version }})
steps:
- uses: actions/checkout@v4
- name: Setup node
uses: actions/setup-node@v4
- uses: ./.github/actions/set-up-node
with:
node-version: ${{ matrix.node }}
cache: yarn
- name: Install dependencies
run: yarn --dev
node-version: ${{ matrix.node-version }}

- name: Run tests
run: yarn test
run: npm test
- name: Build project
run: yarn build
run: npm run build
- name: Run ESM env
run: yarn test:env:esm
run: npm run test:env:esm
- name: Run Node.js env
run: yarn test:env:nodejs
run: npm run test:env:nodejs
- name: Run node typescript env
run: yarn test:env:node-ts
run: npm run test:env:node-ts
- name: Run Browser env
run: yarn test:env:browser
run: npm run test:env:browser
32 changes: 15 additions & 17 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,34 +3,32 @@ on:
release:
types: [published]

env:
HUSKY: 0

jobs:
publish-npm:
runs-on: ubuntu-latest
permissions:
contents: read
id-token: write
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 22
registry-url: https://registry.npmjs.org/
cache: 'yarn'
- name: Check release validity
run: sh .github/scripts/check-release.sh
- name: Check tag format
run: sh .github/scripts/check-tag-format.sh "${{ github.event.release.prerelease }}"
- name: Install dependencies
run: yarn install

- uses: ./.github/actions/set-up-node
with:
registry-url: https://registry.npmjs.org/

- name: Build meilisearch-js
run: yarn build
run: npm run build
- name: Publish with latest tag
if: '!github.event.release.prerelease'
run: npm publish .
if: !github.event.release.prerelease
run: npm publish --provenance --access public
env:
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: Publish with beta tag
if: 'github.event.release.prerelease'
run: npm publish . --tag beta
if: github.event.release.prerelease
run: npm publish --provenance --access public --tag beta
env:
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
62 changes: 24 additions & 38 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
name: Tests

env:
HUSKY: 0

on:
pull_request:
merge_group:
push:
# trying and staging branches are for BORS config
branches:
- trying
- staging
- main

jobs:
Expand All @@ -28,36 +27,33 @@ jobs:
meilisearch:
image: getmeili/meilisearch:latest
env:
MEILI_MASTER_KEY: 'masterKey'
MEILI_NO_ANALYTICS: 'true'
MEILI_MASTER_KEY: "masterKey"
MEILI_NO_ANALYTICS: "true"
ports:
- '7700:7700'
- "7700:7700"
strategy:
fail-fast: false
matrix:
node: ['18', '20', '22']
name: integration-tests (Node.js ${{ matrix.node }})
node-version: ["18", "20", "22"]
name: integration-tests (Node.js ${{ matrix.node-version }})
steps:
- uses: actions/checkout@v4
- name: Setup node
uses: actions/setup-node@v4
- uses: ./.github/actions/set-up-node
with:
node-version: ${{ matrix.node }}
cache: 'yarn'
- name: Install dependencies
run: yarn --dev
node-version: ${{ matrix.node-version }}

- name: Run tests
run: yarn test
run: npm test
- name: Build project
run: yarn build
run: npm run build
- name: Run ESM env
run: yarn test:env:esm
run: npm run test:env:esm
- name: Run Node.js env
run: yarn test:env:nodejs
run: npm run test:env:nodejs
- name: Run node typescript env
run: yarn test:env:node-ts
run: npm run test:env:node-ts
- name: Run Browser env
run: yarn test:env:browser
run: npm run test:env:browser
- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v5
env:
Expand All @@ -67,15 +63,10 @@ jobs:
name: style-check
steps:
- uses: actions/checkout@v4
- name: Setup node
uses: actions/setup-node@v4
with:
node-version: 22
cache: 'yarn'
- name: Install dependencies
run: yarn --dev
- uses: ./.github/actions/set-up-node

- name: Run code style check
run: yarn style
run: npm run style
- name: Run yaml style check
uses: ibiqlik/action-yamllint@v3
with:
Expand All @@ -85,14 +76,9 @@ jobs:
name: types-check
steps:
- uses: actions/checkout@v4
- name: Setup node
uses: actions/setup-node@v4
with:
node-version: 22
cache: 'yarn'
- name: Install dependencies
run: yarn --dev
- uses: ./.github/actions/set-up-node

- name: Build project
run: yarn build
run: npm run build
- name: Run types check
run: yarn types
run: npm run types
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -132,4 +132,3 @@ package
.idea
dist_default_export_in_index
no_default_export_in_index
playgrounds/javascript/yarn.lock
2 changes: 1 addition & 1 deletion .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -1 +1 @@
yarn lint-staged
npm exec lint-staged
Loading