diff --git a/.github/workflows/check.yml b/.github/workflows/check.yml index 4cf6ece..85237fc 100644 --- a/.github/workflows/check.yml +++ b/.github/workflows/check.yml @@ -1,38 +1,37 @@ name: Check on: - push: - branches: - - main - pull_request: + push: + branches: + - main + pull_request: env: EDGEE_API_TOKEN: ${{ secrets.EDGEE_API_TOKEN }} jobs: - test: - name: test - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v4 + full-ci: + name: Full CI (${{ matrix.dir }}) + runs-on: ubuntu-latest + strategy: + matrix: + dir: [consent-management, data-collection] + defaults: + run: + working-directory: ${{ matrix.dir }} + steps: + - name: Checkout + uses: actions/checkout@v4 - - name: "Set up Dotnet SDK" - run: | - wget https://download.visualstudio.microsoft.com/download/pr/c526dc3b-5240-4449-ba07-ed9a3610fe09/442f1cf6e4e832eea0b045f9e108c8b7/dotnet-sdk-10.0.100-preview.2.25164.34-linux-x64.tar.gz - mkdir -p $HOME/dotnet && tar zxf dotnet-sdk-10.0.100-preview.2.25164.34-linux-x64.tar.gz -C $HOME/dotnet + - name: "Set up Dotnet SDK" + run: | + wget https://download.visualstudio.microsoft.com/download/pr/c526dc3b-5240-4449-ba07-ed9a3610fe09/442f1cf6e4e832eea0b045f9e108c8b7/dotnet-sdk-10.0.100-preview.2.25164.34-linux-x64.tar.gz + mkdir -p $HOME/dotnet && tar zxf dotnet-sdk-10.0.100-preview.2.25164.34-linux-x64.tar.gz -C $HOME/dotnet - - name: Install edgee - uses: edgee-cloud/install-edgee-cli@v0.2.0 + - name: Install edgee + uses: edgee-cloud/install-edgee-cli@v0.2.0 - - name: Build component - run: | - export DOTNET_ROOT=$HOME/dotnet - export PATH=$HOME/dotnet:$PATH - edgee component build - - - name: Verify .wasm file exists - run: | - if [ ! -f "./dc_component.wasm" ]; then - echo "❌ Error: dc_component.wasm not found" >&2 - exit 1 - fi + - name: Build component + run: | + export DOTNET_ROOT=$HOME/dotnet + export PATH=$HOME/dotnet:$PATH + edgee component build diff --git a/.gitignore b/consent-management/.gitignore similarity index 50% rename from .gitignore rename to consent-management/.gitignore index 08f5e2a..9068194 100644 --- a/.gitignore +++ b/consent-management/.gitignore @@ -1,4 +1,4 @@ .edgee/ bin/ obj/ -dc-component.wasm +component.wasm diff --git a/consent-management/Component.cs b/consent-management/Component.cs new file mode 100644 index 0000000..f5710ca --- /dev/null +++ b/consent-management/Component.cs @@ -0,0 +1,46 @@ +namespace ConsentManagementWorld.wit.exports.edgee.components.v1_0_0; + +public struct Settings { + public string Example { get; } + + public Settings(List<(string, string)> settings) { + Example = string.Empty; + foreach (var setting in settings) { + if (setting.Item1 == "example") { + Example = setting.Item2; + } + } + } +} + +public struct Cookies { + public string Example { get; } + + public Cookies(List<(string, string)> cookies) { + Example = string.Empty; + foreach (var cookie in cookies) { + if (cookie.Item1 == "example") { + Example = cookie.Item2; + } + } + } +} + +public class ConsentManagementImpl: IConsentManagement { + public static IConsentManagement.Consent? Map(List<(string, string)> cookies, List<(string, string)> settings) { + Settings s = new Settings(settings); + Cookies c = new Cookies(cookies); + + if (c.Example == string.Empty) { + return null; + } else if (c.Example == "granted") { + return IConsentManagement.Consent.GRANTED; + } else if (c.Example == "denied") { + return IConsentManagement.Consent.DENIED; + } else { + return IConsentManagement.Consent.PENDING; + } + + } +} + diff --git a/Makefile b/consent-management/Makefile similarity index 100% rename from Makefile rename to consent-management/Makefile diff --git a/README.md b/consent-management/README.md similarity index 100% rename from README.md rename to consent-management/README.md diff --git a/consent-management/edgee-component.toml b/consent-management/edgee-component.toml new file mode 100644 index 0000000..6ce57b0 --- /dev/null +++ b/consent-management/edgee-component.toml @@ -0,0 +1,20 @@ +manifest-version = 1 + +[component] +name = "example-cs-consent-management-component" +version = "1.0.0" +category = "consent-management" +subcategory = "consent-mapping" +description = "Example CSharp component for consent management" +documentation = "https://github.com/edgee-cloud/example-cs-component" +repository = "https://github.com/edgee-cloud/example-cs-component" +language = "CSharp" +wit-version = "1.0.0" + +[component.build] +command = "dotnet build && mv ./bin/Debug/net10.0/wasi-wasm/publish/example-cs-component.wasm ./component.wasm" +output_path = "./component.wasm" + +[component.settings.example] +title = "Example Config Field" +type = "string" diff --git a/consent-management/example-cs-component.csproj b/consent-management/example-cs-component.csproj new file mode 100644 index 0000000..1446b3b --- /dev/null +++ b/consent-management/example-cs-component.csproj @@ -0,0 +1,26 @@ + + + + Library + net10.0 + example_cs_component + enable + enable + wasi-wasm + false + true + true + true + + + + + + + + + + + + + diff --git a/nuget.config b/consent-management/nuget.config similarity index 100% rename from nuget.config rename to consent-management/nuget.config diff --git a/data-collection/.gitignore b/data-collection/.gitignore new file mode 100644 index 0000000..9068194 --- /dev/null +++ b/data-collection/.gitignore @@ -0,0 +1,4 @@ +.edgee/ +bin/ +obj/ +component.wasm diff --git a/DataCollectionComponent.cs b/data-collection/Component.cs similarity index 100% rename from DataCollectionComponent.cs rename to data-collection/Component.cs diff --git a/data-collection/Makefile b/data-collection/Makefile new file mode 100644 index 0000000..c0e47ac --- /dev/null +++ b/data-collection/Makefile @@ -0,0 +1,13 @@ +.PHONY: all +MAKEFLAGS += --silent + +all: help + +help: + @grep -E '^[a-zA-Z1-9\._-]+:.*?## .*$$' $(MAKEFILE_LIST) \ + | sort \ + | sed -e "s/^Makefile://" -e "s///" \ + | awk 'BEGIN { FS = ":.*?## " }; { printf "\033[36m%-30s\033[0m %s\n", $$1, $$2 }' + +build: + edgee components build \ No newline at end of file diff --git a/data-collection/README.md b/data-collection/README.md new file mode 100644 index 0000000..5a40867 --- /dev/null +++ b/data-collection/README.md @@ -0,0 +1,30 @@ +
+

+ + + + Edgee + + +

+
+ +

Example dotnet component for Edgee

+ +This is an example of a C# Edgee Component. + +## Setup +Requirements: +- [edgee-cli](https://github.com/edgee-cloud/edgee) +- [dotnet SDK 10.0](https://dotnet.microsoft.com/en-us/download/dotnet/10.0) +- Modify the csproj file to match your OS: + - On Linux +```dotnet add package runtime.linux-x64.microsoft.dotnet.ilcompiler.llvm --prerelease``` + - On Windows +```dotnet add package runtime.win-x64.microsoft.dotnet.ilcompiler.llvm --prerelease``` + +## Building + +```shell +$ make build +``` diff --git a/edgee-component.toml b/data-collection/edgee-component.toml similarity index 92% rename from edgee-component.toml rename to data-collection/edgee-component.toml index 62ef3dd..6d70268 100644 --- a/edgee-component.toml +++ b/data-collection/edgee-component.toml @@ -1,7 +1,7 @@ manifest-version = 1 [component] -name = "example-cs-component" +name = "example-cs-data-collection-component" version = "1.0.0" category = "data-collection" subcategory = "analytics" diff --git a/example-cs-component.csproj b/data-collection/example-cs-component.csproj similarity index 100% rename from example-cs-component.csproj rename to data-collection/example-cs-component.csproj diff --git a/data-collection/nuget.config b/data-collection/nuget.config new file mode 100644 index 0000000..caa4ee8 --- /dev/null +++ b/data-collection/nuget.config @@ -0,0 +1,9 @@ + + + + + + + + +