-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add an artifact auto-assignment example
The example comes with a minimal test pipeline. It will be extended to the other modules in another contribution.
- Loading branch information
Showing
13 changed files
with
1,836 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
name: Tests | ||
|
||
permissions: read-all | ||
|
||
on: | ||
push: | ||
branches: | ||
pull_request: | ||
|
||
jobs: | ||
tests: | ||
strategy: | ||
matrix: | ||
tuleap_functions: | ||
- "artifact-post-action/auto-assign" | ||
build: | ||
runs-on: ubuntu-22.04 | ||
name: Tests (${{ matrix.tuleap_functions }}) | ||
steps: | ||
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 | ||
- uses: cachix/install-nix-action@6004951b182f8860210c8d6f0d808ec5b1a33d28 # v25 | ||
- run: cd "${{ matrix.tuleap_functions }}" | ||
- name: Prepare | ||
run: nix-shell --pure --run "make prepare" | ||
- name: Tests | ||
run: nix-shell --pure --run "make tests" | ||
- name: Build | ||
run: nix-shell --pure --run "make build" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
dist/ | ||
node_modules/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
.PHONY: prepare | ||
prepare: | ||
pnpm install --frozen-lockfile | ||
|
||
.PHONY: tests | ||
tests: | ||
pnpm run typecheck | ||
pnpm run test | ||
|
||
.PHONY: build | ||
build: | ||
pnpm run build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
# Artifact post action: automatically assign a contributor | ||
|
||
This Function automatically assigns the creator of an artifact as the contributor/assignee. | ||
The contributor/assignee is only set when the artifact is created if no other contributors | ||
have been designed. | ||
|
||
The code expects the tracker to have the [contributor/assignee semantic](https://docs.tuleap.org/user-guide/trackers/administration/configuration/semantics.html#contributor-assignee) set. | ||
|
||
## How to test | ||
|
||
First you need to run `nix-shell` to have all needed tools. | ||
|
||
Then build the Tuleap Function with: | ||
```shell | ||
make prepare | ||
make build | ||
``` | ||
|
||
You can then run it with: | ||
|
||
```shell | ||
wasmtime run ./dist/function.wasm < sample.json | ||
``` | ||
|
||
You can run unit tests with: | ||
|
||
```shell | ||
make tests | ||
``` | ||
|
||
## How to use | ||
|
||
Create a tracker and define the [contributor/assignee semantic](https://docs.tuleap.org/user-guide/trackers/administration/configuration/semantics.html#contributor-assignee). | ||
|
||
Then build the function: | ||
|
||
```shell | ||
make prepare | ||
make build | ||
``` | ||
|
||
Then upload the binary result file (`dist/function.wasm`) to your Tracker | ||
administration (Administration > Workflow > Tuleap Functions). | ||
|
||
And finally, create an artifact, shortly after the creation, the contributor field will automatically be set to yourself. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
# TODO: | ||
# * build from sources | ||
# * upstream to nixpkgs | ||
{ stdenv | ||
, lib | ||
, fetchurl | ||
, autoPatchelfHook | ||
, gzip | ||
}: | ||
|
||
stdenv.mkDerivation rec { | ||
pname = "javy"; | ||
version = "1.4.0"; | ||
|
||
src = fetchurl { | ||
url = "https://github.com/bytecodealliance/javy/releases/download/v${version}/javy-x86_64-linux-v${version}.gz"; | ||
hash = "sha256-NZIzT8BdtgKiE3RbePWEY1E5TWe9mr2LSRhhmxzWzd8="; | ||
}; | ||
|
||
nativeBuildInputs = [ | ||
autoPatchelfHook | ||
gzip | ||
]; | ||
|
||
buildInputs = [ | ||
stdenv.cc.cc.lib | ||
]; | ||
|
||
unpackPhase = '' | ||
runHook preUnpack | ||
gzip -cd "${src}" > javy | ||
runHook postUnpack | ||
''; | ||
|
||
installPhase = '' | ||
runHook preInstall | ||
install -m755 -D javy $out/bin/javy | ||
runHook postInstall | ||
''; | ||
|
||
meta = with lib; { | ||
homepage = "https://github.com/bytecodealliance/javy"; | ||
description = "JS to WebAssembly toolchain"; | ||
license = licenses.asl20; | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
{ | ||
"name": "@tuleap/functions-post-action-auto-assign", | ||
"version": "0.0.0", | ||
"private": true, | ||
"scripts": { | ||
"build": "pnpm run build:bundle && pnpm run build:js2wasm && pnpm run build:wasmopt", | ||
"build:bundle": "esbuild src/main.ts --platform=node --bundle --target=es2022 --minify --outfile=dist/function.js", | ||
"build:js2wasm": "javy compile ./dist/function.js -o ./dist/function-unoptimized.wasm", | ||
"build:wasmopt": "wasm-opt -O2 ./dist/function-unoptimized.wasm -o ./dist/function.wasm", | ||
"typecheck": "tsc --noEmit", | ||
"test": "vitest run" | ||
}, | ||
"keywords": [], | ||
"author": "Enalean Team", | ||
"license": "MIT", | ||
"devDependencies": { | ||
"esbuild": "^0.20.0", | ||
"typescript": "^5.3.3", | ||
"vitest": "^1.2.2" | ||
}, | ||
"dependencies": { | ||
"javy": "^0.1.2" | ||
} | ||
} |
Oops, something went wrong.