https://github.com/tetsuharuohzeki/fastly-compute-template
Starter example repository customized heavily including an integration test infrastructure for Fastly Compute
https://github.com/tetsuharuohzeki/fastly-compute-template
fastly-compute fastly-compute-at-edge rust
Last synced: 3 months ago
JSON representation
Starter example repository customized heavily including an integration test infrastructure for Fastly Compute
- Host: GitHub
- URL: https://github.com/tetsuharuohzeki/fastly-compute-template
- Owner: tetsuharuohzeki
- License: mit
- Created: 2022-03-25T08:36:25.000Z (about 3 years ago)
- Default Branch: main
- Last Pushed: 2024-04-11T15:03:07.000Z (about 1 year ago)
- Last Synced: 2024-04-14T12:29:01.120Z (about 1 year ago)
- Topics: fastly-compute, fastly-compute-at-edge, rust
- Language: JavaScript
- Homepage: https://docs.fastly.com/products/compute
- Size: 1.42 MB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 8
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# [Fastly Compute](https://docs.fastly.com/products/compute) template kit for Rust
[](https://github.com/tetsuharuohzeki/fastly-compute-template/actions/workflows/ci_on_main.yaml)
## Prerequisites
- [Fastly CLI](https://github.com/fastly/cli)
- We uses the laetst one.
- Install [rustup](https://rustup.rs/)
- We uses the laetst _stable_ toolchain.
- Node.js (for integration tests)
- The version is [here](./integration_tests/.node-version).## How to build
Run `make help`.
### Release Channel
The current build system supports _release channel_.
Now we define these release channels.- `production`: **For production environment**.
- `canary`: **For development environment**.**These are mutually exclusive. You cannot enable both of them**.
If you want to build the artifact for `production` release channel,
you should invoke `make build_release -j RELEASE_CHANNEL=production`.
By default, `RELEASE_CHANNEL` makefile variable is `canary`.Additionaly, you can pass `ADDITIONAL_FEATURE` makefile variable (e.g. `make build_debug -j ADDITIONAL_FEATURE=barfoo`).
Then the artifact will be built with enabling `barfoo` feature.Release channel is based on [Cargo's "features" mechanism](https://doc.rust-lang.org/cargo/reference/features.html).
## Testing
This repository prodvides these way for testing:
1. Unit tests per function level (limited)
2. Integration tests with mock servers.### Unit testing
You can write unit test per function level with [a language integrated way by Rust](https://doc.rust-lang.org/book/ch11-01-writing-tests.html).
However, we can write only limited case by this way
[as what fasly's document said](https://developer.fastly.com/learning/compute/rust/#unit-testing).
This limitation comes from Fastly Compute's WASM binary requirements.Typical failure case is compile (link) error because core parts of `fasly` crates requires
some special wasi system call as a external function but they are not resolved in non `wasm32-wasip1` target
or a normal wasm runtime environment like plain [wasmtime](https://github.com/bytecodealliance/wasmtime).__So you should write a unit test only if you need to test a platform agnostic logic like parsing a string__.
### Integration testing
Our integration testing is based on a local application launched by `fastly compute serve`,
mock servers, and a test runner written as Node.js.Our test _supervisor_ make a formation of them.
Of course, this supports `RELEASE_CHANNEL`.For more details, see [`integration_tests/`](./integration_tests).
## See also
- [Compute services | Fastly Developer Hub](https://developer.fastly.com/learning/compute/)