stable

Clone or download

Read-only

feat: Add pipeline to call WASM module

Part of story #35093 execute custom code as artifact post action This pipeline is called asynchronously when a user create or update an artifact. *Implementation notes:* - WASM module is stored on server under the path `/var/lib/tuleap/tracker_cce/<tracker_id>/post-action.wasm`. It may change in future. - The pipeline uses NeverThrow and calls to injected object to ease reading and maintenance of code. - The output of module (its answer) is currently only parsed to an object corresponding to input of `PUT /artifacts/:id`, the use of this object to update (or not) the artifact will come later. *Testing:* You need Redis container running Log file is: `/var/log/tuleap/worker_log` Case without module: - If you update an artifact, in logs you can read: `[warning] WASM module for tracker #1 not found or not readable: :` with a stack trace Case with a module: - Go inside `plugins/tracker_cce/wasm_modules/post-action-add-comment` `nix-shell && cargo build --target wasm32-wasi --release` - In your container copy the file `target/wasm32-wasi/release/post-action-add-comment.wasm` to `/var/lib/tuleap/tracker_cce/<tracker_id>/post-action.wasm` - Update you artifact in the corresponding tracker - Logs contains : [debug] CustomCodeExecutionTask called on artifact #14 for changeset #481 [debug] Receive response from WASM module: {"values":[],"comment":{"body":"Artifact #id updated by user","format":"text"}} Change-Id: I3d43422f61a238c2233240d08755b424a3605fcd

Modified Files

Name
M plugins/git/tests/unit/Hook/PreReceive/PreReceiveActionTest.php +1 −1 Go to diff View file
R plugins/tracker_cce/tests/unit/CustomCodeExecutionTaskTest.php Go to diff View file
M plugins/tracker_cce/composer.json +1 −1 Go to diff View file
M plugins/tracker_cce/include/TrackerCCE/CustomCodeExecutionTask.php +52 −0 Go to diff View file
A plugins/tracker_cce/include/TrackerCCE/WASM/CallWASMModule.php +48 −0 Go to diff View file
A plugins/tracker_cce/include/TrackerCCE/WASM/FindWASMModulePath.php +40 −0 Go to diff View file
A plugins/tracker_cce/include/TrackerCCE/WASM/ProcessWASMResponse.php +68 −0 Go to diff View file
A plugins/tracker_cce/include/TrackerCCE/WASM/WASMModuleCaller.php +35 −0 Go to diff View file
A plugins/tracker_cce/include/TrackerCCE/WASM/WASMModulePathHelper.php +30 −0 Go to diff View file
A plugins/tracker_cce/include/TrackerCCE/WASM/WASMResponseProcessor.php +36 −0 Go to diff View file
A plugins/tracker_cce/include/TrackerCCE/WASM/WASMResponseRepresentation.php +38 −0 Go to diff View file
M plugins/tracker_cce/include/tracker_ccePlugin.php +39 −3 Go to diff View file
A plugins/tracker_cce/tests/unit/Stub/WASM/WASMModuleCallerStub.php +69 −0 Go to diff View file
A plugins/tracker_cce/tests/unit/Stub/WASM/WASMModulePathHelperStub.php +44 −0 Go to diff View file
A plugins/tracker_cce/tests/unit/TrackerCCE/CustomCodeExecutionTaskTest.php +117 −0 Go to diff View file
A plugins/tracker_cce/tests/unit/TrackerCCE/WASM/CallWASMModuleTest.php +60 −0 Go to diff View file
A plugins/tracker_cce/tests/unit/TrackerCCE/WASM/ProcessWASMResponseTest.php +61 −0 Go to diff View file
A plugins/tracker_cce/wasm_modules/post-action-add-comment/.gitignore +1 −0 Go to diff View file
A plugins/tracker_cce/wasm_modules/post-action-add-comment/Cargo.lock +88 −0 Go to diff View file
A plugins/tracker_cce/wasm_modules/post-action-add-comment/Cargo.toml +7 −0 Go to diff View file
A plugins/tracker_cce/wasm_modules/post-action-add-comment/shell.nix +10 −0 Go to diff View file
A plugins/tracker_cce/wasm_modules/post-action-add-comment/src/main.rs +41 −0 Go to diff View file
A src/common/User/CCEUser.php +28 −0 Go to diff View file
M tests/unit/common/WebAssembly/WASMCallerStub.php +2 −2 Go to diff View file