Fastly Compute template kit for Rust
- Fastly CLI
- We uses the laetst one.
- Install rustup
- We uses the laetst stable toolchain.
- Node.js (for integration tests)
- The version is here.
Run make help
.
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.
This repository prodvides these way for testing:
- Unit tests per function level (limited)
- Integration tests with mock servers.
You can write unit test per function level with a language integrated way by Rust.
However, we can write only limited case by this way as what fasly's document said. 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.
So you should write a unit test only if you need to test a platform agnostic logic like parsing a string.
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/
.