Skip to content
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

Add support for Edge Runtime #110

Merged
merged 2 commits into from
Sep 13, 2023
Merged
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
11 changes: 9 additions & 2 deletions .github/actions/npm-release/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,16 @@ runs:
run: |
git config --global user.email "${{ inputs.git_email }}"
git config --global user.name "${{ inputs.git_username }}"
- name: 'Bump version and commit'
- name: 'Bump version'
shell: bash
run: npm version ${{ inputs.releaseType }} -m '[skip ci] Publish release %s'
run: npm version ${{ inputs.releaseType }} --no-git-tag-version
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we need run here?

Suggested change
run: npm version ${{ inputs.releaseType }} --no-git-tag-version
run: npm run version ${{ inputs.releaseType }} --no-git-tag-version

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is actually a command called npm version. It knows how to bump versions and whatnot and commit those changes (unless you disabled that with a flag as we have here).

As part of that command run, it executes certain lifecycle scripts. So if you have defined a version command in the scripts section of your package.json, it will automatically be invoked. There's also a preversion hook. But you don't need to call npm run version yourself. I agree it's confusing that the command name and lifecycle script hooks have the same name.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, good to know. Thank you!

- name: 'Commit and tag version changes'
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These changes plus the addition of the version script in the package.json file are needed to update src/version.json with the new version number prior to the commit/tag. Even though the npm version command automatically invokes the npm run version script for us, it doesn't happen until after the automatic commit. So we need to tell npm not to do the auto commit with the --no-git-tag-version flag and handle it ourselves.

shell: bash
run: |
git add .
newVersion=$(jq -r '.version' package.json)
git commit -m "[skip ci] Publish release v$newVersion"
git tag "v$newVersion"
- name: 'Output release tag'
shell: bash
id: release-tag-step
Expand Down
5 changes: 4 additions & 1 deletion .github/workflows/pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ jobs:
run-integration-tests:
name: Run integration tests
runs-on: ubuntu-latest
strategy:
matrix:
jest_env: ['node', 'edge']
steps:
- name: Checkout
uses: actions/checkout@v3
Expand All @@ -50,7 +53,7 @@ jobs:
CI: true
PINECONE_API_KEY: ${{ secrets.PINECONE_API_KEY }}
PINECONE_ENVIRONMENT: ${{ secrets.PINECONE_ENVIRONMENT }}
run: npm run test:integration
run: npm run test:integration:${{ matrix.jest_env }}

unit-tests:
name: Run unit tests
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/release-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ jobs:
jq --arg newVersion "$devVersion" '.version = $newVersion' package.json > package.tmp && mv package.tmp package.json
jq --arg newVersion "$devVersion" '.version = $newVersion' package-lock.json > package-lock.tmp && mv package-lock.tmp package-lock.json
jq --arg newVersion "$devVersion" '.packages[""].version = $newVersion' package-lock.json > package-lock.tmp && mv package-lock.tmp package-lock.json
jq --null-input --arg version "$devVersion" '{"name": "@pinecone-database/pinecone", "version": $version}' > src/version.json
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For dev builds, we never relied on the npm version command to set version numbers. So we update src/version.json a little differently also. I tested this jq command on my local machine.


- name: 'Publish to npm'
run: npm publish --tag next
Expand Down
6 changes: 6 additions & 0 deletions jest.config.integration-edge.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
const config = require('./jest.config.integration-node');

module.exports = {
...config,
testEnvironment: '@edge-runtime/jest-environment',
};
8 changes: 8 additions & 0 deletions jest.config.integration-node.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
const config = require('./jest.config');

module.exports = {
...config,
setupFilesAfterEnv: ['./utils/globalIntegrationTestSetup.ts'],
testPathIgnorePatterns: [],
testEnvironment: 'node',
};
2 changes: 2 additions & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@ module.exports = {
preset: 'ts-jest',
testEnvironment: 'node',
reporters: [['github-actions', { silent: false }], 'default'],
setupFilesAfterEnv: ['./utils/globalUnitTestSetup.ts'],
transform: {
'^.+\\.ts?$': 'ts-jest',
},
transformIgnorePatterns: ['<rootDir>/node_modules/'],
testPathIgnorePatterns: ['src/integration'],
testTimeout: 100000,
verbose: true,
detectOpenHandles: true,
Expand Down
Loading