-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
tests(ci): add basic CI tests and fix POST requests bug (#68)
* Update everything * Fix POST requests * Formatting * Formatting * Resurrect POST example * Fix formatting * Add simple test * Working local test * Docs and formatting * Self-review * Review comments * Add examples checks * npm cache * Default dir * More GHA syntax * Formatting * Tests only with 18 * Install local version of framework * Link in script * Reduce sleep * Remove workflow names * Update test * try to retrigger GHA * Reinstate example runner * self-hosted runners * Revert self-hosted change * Fix package-locks * Add scope to link command * Attempt linking * Avoid starting twice * Revert dodgy package-lock changes
- Loading branch information
Showing
15 changed files
with
9,296 additions
and
613 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
--- | ||
on: | ||
push: | ||
branches: ["main"] | ||
pull_request: | ||
branches: ["main"] | ||
|
||
jobs: | ||
test: | ||
runs-on: ubuntu-22.04 | ||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- name: "Set up node ${{ matrix.node-version }}" | ||
id: setup-node | ||
uses: actions/setup-node@v4 | ||
with: | ||
node-version: "18.x" | ||
cache: "npm" | ||
|
||
- name: "Install dependencies" | ||
run: npm ci | ||
|
||
- name: "Check formatting" | ||
run: npx prettier --check . | ||
|
||
- name: "Run tests" | ||
run: npm test | ||
|
||
examples: | ||
defaults: | ||
run: | ||
working-directory: ./examples | ||
|
||
strategy: | ||
matrix: | ||
node-version: ["16.x", "18.x"] | ||
example: | ||
[ | ||
"not_stringified_body", | ||
"print_event_context", | ||
"stringified_body", | ||
"upload_file_multipart", | ||
"with_callback", | ||
"with_event_components", | ||
"with_http_get", | ||
"with_http_post", | ||
"with_object", | ||
"with_promise", | ||
] | ||
|
||
runs-on: ubuntu-22.04 | ||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- name: "Set up node ${{ matrix.node-version }}" | ||
id: setup-node | ||
uses: actions/setup-node@v4 | ||
with: | ||
node-version: "${{ matrix.node-version }}" | ||
cache: "npm" | ||
|
||
- name: "Link top-level" | ||
run: npm link | ||
|
||
- name: "Install dependencies" | ||
run: npm ci | ||
working-directory: "examples" | ||
|
||
- name: "Link local framework" | ||
run: npm link @scaleway/serverless-functions | ||
working-directory: "examples" | ||
|
||
- name: "Run example" | ||
run: node ${{ matrix.example }}/handler.js & | ||
working-directory: "examples" | ||
|
||
- name: "Wait for it to start" | ||
run: sleep 1 | ||
|
||
- name: "Launch a request" | ||
run: curl http://localhost:8080 | ||
working-directory: "examples" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
# Development | ||
|
||
To test your local version of this package, you can use [`npm link`](https://docs.npmjs.com/cli/v6/commands/npm-link). | ||
|
||
You can do this from the `examples` directory with: | ||
|
||
```sh | ||
cd examples | ||
npm link .. | ||
|
||
node with_object/handler.js | ||
``` | ||
|
||
## Tests | ||
|
||
You can run tests locally with: | ||
|
||
```sh | ||
npm test | ||
``` | ||
|
||
Make sure you have at least Node 18 installed (see below). | ||
|
||
## Releasing | ||
|
||
To release a new version: | ||
|
||
- Update the version in `package.json` | ||
- Create a PR (or add to an existing PR) | ||
- Merge the PR to `main` | ||
- Create a new Release [in Github](https://github.com/scaleway/serverless-functions-node/releases) | ||
|
||
Please follow [Semantic Versioning](https://semver.org/) guidelines when deciding which version to go to. | ||
|
||
## Managing multiple Node versions | ||
|
||
The build runs on multiple versions of Node. To manage multiple Node versions locally, you can use [`nvm`](https://github.com/nvm-sh/nvm). | ||
|
||
Once installed, you can install versions with: | ||
|
||
```sh | ||
# Install versions | ||
nvm install 16 | ||
nvm install 18 | ||
|
||
# Check | ||
nvm use 16 | ||
npm i | ||
which node | ||
|
||
nvm use 18 | ||
npm i | ||
which node | ||
``` | ||
|
||
From there, you can check the build: | ||
|
||
```sh | ||
nvm use 16 | ||
npm run build | ||
|
||
nvm use 18 | ||
npm run build | ||
``` |
Oops, something went wrong.