Skip to content

Commit fec3174

Browse files
authored
feat: new rawBody type on SvelteKit req (#123)
1 parent 2161d1b commit fec3174

File tree

164 files changed

+1210
-9966
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

164 files changed

+1210
-9966
lines changed

.github/workflows/test.yaml

Lines changed: 50 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,7 @@ on:
88

99
env:
1010
CI: true
11-
# ASDF_DIR: /home/runner/.asdf
12-
# FIREBASE_EMULATORS_PATH: ${{ github.workspace }}/emulator-cache
11+
FIREBASE_EMULATORS_PATH: ${{ github.workspace }}/emulator-cache
1312

1413
jobs:
1514
unit:
@@ -22,65 +21,59 @@ jobs:
2221
- run: pnpm run test
2322

2423
integration:
25-
runs-on: ${{ matrix.os }}
24+
runs-on: ubuntu-latest
25+
needs:
26+
- unit
2627
strategy:
27-
fail-fast: false
28+
fail-fast: true
2829
matrix:
29-
dirs:
30-
- examples/functions_single_site
31-
- examples/nested_app_dirs/app
32-
- examples/run_custom_build_dir
33-
- examples/run_single_site
34-
os:
35-
- ubuntu-latest
36-
- macos-latest
37-
- windows-latest
30+
params:
31+
- {
32+
test_dir: "functions_single_site",
33+
validation_app_dir: "public/about/index.html",
34+
validation_compute_dir: "functions/sveltekit/index.js",
35+
nested_dir: "."
36+
}
37+
- {
38+
test_dir: "nested_app_dirs",
39+
validation_app_dir: "public/about/index.html",
40+
validation_compute_dir: "functions/sveltekit/index.js",
41+
nested_dir: "app"
42+
}
43+
- {
44+
test_dir: "run_custom_build_dir",
45+
validation_app_dir: "public/about/index.html",
46+
validation_compute_dir: "custom-cloud-run-build-dir/index.js",
47+
nested_dir: "."
48+
}
49+
- {
50+
test_dir: "run_single_site",
51+
validation_app_dir: "public/about/index.html",
52+
validation_compute_dir: ".cloudrun/index.js",
53+
nested_dir: "."
54+
}
55+
steps:
56+
- uses: actions/checkout@v2
57+
- name: install asdf
58+
uses: asdf-vm/actions/install@v1
59+
- name: Run Integration test for ${{ matrix.params.test_dir }}
60+
run: |
61+
bash ./tests/integration/integration-test.bash ${{ matrix.params.test_dir }} ${{ matrix.params.validation_app_dir }} ${{ matrix.params.validation_compute_dir }} ${{ matrix.params.nested_dir }}
62+
63+
end-to-end:
64+
runs-on: ubuntu-latest
65+
needs:
66+
- unit
3867
steps:
3968
- uses: actions/checkout@v2
4069
- name: install asdf
41-
if: matrix.os != 'windows-latest'
4270
uses: asdf-vm/actions/install@v1
43-
# START: Windows
44-
- name: install Node.js on Windows
45-
if: matrix.os == 'windows-latest'
46-
uses: actions/setup-node@v2
71+
- name: Cache firebase emulators
72+
uses: actions/cache@v2
4773
with:
48-
node-version: 14.16.1
49-
- name: install pnpm on Windows
50-
if: matrix.os == 'windows-latest'
51-
run: curl -f https://get.pnpm.io/v6.js | node - add --global pnpm@6
52-
# END: Windows
53-
- name: Install svelte-adapter-firebase deps
54-
run: pnpm install
55-
- name: Install example app deps
56-
run: pnpm install
57-
working-directory: ${{ matrix.dirs }}
58-
- name: Build example app
59-
run: pnpm run build
60-
working-directory: ${{ matrix.dirs }}
61-
# end-to-end:
62-
# runs-on: ubuntu-latest
63-
# if: github.event_name == 'push'
64-
# needs: [unit, integration]
65-
# steps:
66-
# - uses: actions/checkout@v2
67-
# - name: install asdf
68-
# uses: asdf-vm/actions/install@v1
69-
# with:
70-
# before_install: bash -c '${ASDF_DATA_DIR:=$HOME/.asdf}/plugins/nodejs/bin/import-release-team-keyring'
71-
# - name: Cache firebase emulators
72-
# uses: actions/cache@v2
73-
# with:
74-
# path: ${{ env.FIREBASE_EMULATORS_PATH }}
75-
# key: ${{ runner.os }}-firebase-emulators-${{ hashFiles('emulator-cache/**') }}
76-
# - name: Install svelte-adapter-firebase deps
77-
# run: pnpm install
78-
# - name: Install example app deps
79-
# run: pnpm install
80-
# working-directory: examples/functions_single_site
81-
# - name: Build example app
82-
# run: pnpm run build
83-
# working-directory: examples/functions_single_site
84-
# - name: E2E tests with Firebase Emulator
85-
# run: firebase emulators:exec --only hosting,functions
86-
# working-directory: examples/functions_single_site '[ "$(curl localhost:5000/ -o /dev/stderr -w "%{http_code}")" -eq 200 ]'
74+
path: ${{ env.FIREBASE_EMULATORS_PATH }}
75+
key: ${{ runner.os }}-firebase-emulators-${{ hashFiles('emulator-cache/**') }}
76+
continue-on-error: true
77+
- name: Run end-to-end test script
78+
run: |
79+
bash ./tests/end-to-end/test.bash

.tool-versions

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
firebase 9.10.2
2-
nodejs 14.17.0
3-
pnpm 6.3.0
1+
firebase 9.16.5
2+
nodejs 14.17.5
3+
pnpm 6.13.0
4+
# use for Firebase Emulator
45
java openjdk-14.0.2

CONTRIBUTING.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,3 +27,31 @@ pnpm i
2727
See the [GitHub Issues](https://github.com/jthegedus/svelte-adatper-firebase/issues) list for any open Issue, especially those marked as `help wanted`
2828

2929
General improvements to any aspect of this adapter are welcome, just ensure major work is preceeded by a conversation in a [GitHub Issue](https://github.com/jthegedus/svelte-adatper-firebase/issues).
30+
31+
## Tests
32+
33+
As an integration point between [SvelteKit](https://kit.svelte.dev) and Firebase Hosting with Function rewrites the tests for this package are **important**.
34+
35+
The test suite is broken into three categories:
36+
37+
- **unit**: test internal functions to the CLI & entrypoint JS code
38+
- **integration**: runs the `build` command of SvelteKit with demo apps that tests each path of the src/index.js CLI entrypoint.
39+
- **end-to-end**: runs a shell script which:
40+
- creates the SvelteKit Todo skeleton app (via `npm init@svelte <dir>`)
41+
- adds Firebase configuration for Hosting & Cloud Functions
42+
- adds `svelte-adapter-firebase` (relative add of the repo root, not from `npmjs.com`, to test current code changes before publishing)
43+
- creates the Cloud Function which hosts the compiled SvelteKit app (this is the code in `functions/index.js` that the CLI would prompt the user to add)
44+
- installs all dependencies for the Todo app & Cloud Functions
45+
- builds the app
46+
- starts the Firebase Emulator with Hosting & Functions
47+
- makes `curl` requests to the Todo app
48+
- GET to `/`
49+
- GET to `/about`
50+
- GET to `/todos`
51+
- POST with formdata to `/todos`
52+
53+
- Unit tests are run pre-push. They can be run manually with `pnpm run test`
54+
- Integration tests are run in CI.
55+
- End-to-end tests are run in CI. This script can be run locally with `./tests/end-to-end/test.bash`
56+
57+
All test suites are run in CI pipelines on PR creation.

0 commit comments

Comments
 (0)