Skip to content

Commit

Permalink
chore(tidy): clean up README and badges (#72)
Browse files Browse the repository at this point in the history
## Summary

**_What's changed?_**

- Fix paths in top-level `package.json`
- Split examples into separate workflow (with its own badge
:sunglasses:)
- Fix tests badge which was broken in last PR
- Add npm badge
- Give workflows consistent names

**_Why do we need this?_**

- Bad paths in top-level `package.json` broke imports
- Badges were broken 
- Didn't have a link to the npm package 
- Workflows were named using relative paths to YAML

**_How have you tested it?_**

See branch version here:
https://github.com/scaleway/serverless-functions-node/tree/readme-fix

## Checklist

- [x] I have reviewed this myself
- [ ] There is a unit test covering every change in this PR
- [x] I have updated the relevant documentation
  • Loading branch information
Shillaker authored Nov 9, 2023
1 parent 514a1c1 commit 17e849c
Show file tree
Hide file tree
Showing 11 changed files with 186 additions and 161 deletions.
4 changes: 3 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
---
name: "build"

on:
push:
branches: ["main"]
Expand All @@ -9,7 +11,7 @@ permissions:
contents: read

jobs:
test:
build:
strategy:
matrix:
node-version: ["16.x", "18.x"]
Expand Down
73 changes: 73 additions & 0 deletions .github/workflows/examples.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
---
name: "examples"

on:
push:
branches: ["main"]
pull_request:
branches: ["main"]

jobs:
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: "Install framework dependencies"
run: npm ci

- name: "Build framework"
run: npm run build

- name: "Install examples dependencies"
run: npm ci
working-directory: examples

- name: "Link framework"
run: npm link

- name: "Link framework in examples"
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: "Send a GET request"
run: curl http://localhost:8080
working-directory: examples

- name: "Send a POST request"
run: >
curl -X POST
-d '{"foo": "bar"}'
http://localhost:8080
working-directory: examples
2 changes: 2 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
---
name: "publish"

on:
release:
types: [published]
Expand Down
57 changes: 2 additions & 55 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
---
name: "tests"

on:
push:
branches: ["main"]
Expand Down Expand Up @@ -26,58 +28,3 @@ jobs:

- 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"
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
# Serverless Functions Node

[![build-and-test](https://github.com/scaleway/serverless-functions-node/actions/workflows/npmtest.yml/badge.svg)](https://github.com/scaleway/serverless-functions-node/actions/workflows/npmtest.yml)
![node](https://img.shields.io/badge/node-16_|_18-blue.svg)
![Tests](https://github.com/scaleway/serverless-functions-node/actions/workflows/tests.yml/badge.svg)
![Examples](https://github.com/scaleway/serverless-functions-node/actions/workflows/examples.yml/badge.svg)
[![NPM Version](https://img.shields.io/npm/v/@scaleway/serverless-functions.svg)](https://www.npmjs.com/package/@scaleway/serverless-functions)
![Node](https://img.shields.io/badge/node-16_|_18-blue.svg)

Scaleway Serverless Functions Node is a framework which simplifies working with [Scaleway Serverless Functions](https://www.scaleway.com/en/serverless-functions/).

Expand Down
1 change: 1 addition & 0 deletions docs/dev.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ To release a new version:
- 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)
- Check that the `publish` pipeline succeeded

Please follow [Semantic Versioning](https://semver.org/) guidelines when deciding which version to go to.

Expand Down
6 changes: 2 additions & 4 deletions examples/README.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
# Examples

Each example contains a `handler.js` file.

To run them, you first need to install the dependencies in this directory:
To run the examples, you first need to install the examples dependencies:

```console
npm i
```

Then you can run examples with:
You can then run each example with:

```console
node <example_name>/handler.js
Expand Down
30 changes: 15 additions & 15 deletions examples/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion examples/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"license": "ISC",
"dependencies": {
"@aws-sdk/client-s3": "^3.305.0",
"@scaleway/serverless-functions": "^1.0.2",
"@scaleway/serverless-functions": "^1.1.0",
"https": "^1.0.0",
"parse-multipart-data": "^1.5.0"
}
Expand Down
Loading

0 comments on commit 17e849c

Please sign in to comment.