From 0291a69973b21b23b29fccdc3d4db6a6fff2d4fd Mon Sep 17 00:00:00 2001 From: Phoebe Lew Date: Mon, 8 Jan 2024 12:59:43 +1100 Subject: [PATCH 1/7] WIP --- .gitignore | 1 + bin/.go-1.21.5.pkg | 1 + bin/README.hermit.md | 7 ++++++ bin/activate-hermit | 21 ++++++++++++++++ bin/go | 1 + bin/gofmt | 1 + bin/hermit | 43 +++++++++++++++++++++++++++++++++ bin/hermit.hcl | 0 reports/go.mod | 2 +- reports/report-template.html | 47 +++++++++++++++++++++++++++++++++++- reports/sdks.go | 16 ++++++++++++ 11 files changed, 138 insertions(+), 2 deletions(-) create mode 120000 bin/.go-1.21.5.pkg create mode 100644 bin/README.hermit.md create mode 100755 bin/activate-hermit create mode 120000 bin/go create mode 120000 bin/gofmt create mode 100755 bin/hermit create mode 100644 bin/hermit.hcl diff --git a/.gitignore b/.gitignore index ca35be0..4efacd2 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ _site +.idea diff --git a/bin/.go-1.21.5.pkg b/bin/.go-1.21.5.pkg new file mode 120000 index 0000000..383f451 --- /dev/null +++ b/bin/.go-1.21.5.pkg @@ -0,0 +1 @@ +hermit \ No newline at end of file diff --git a/bin/README.hermit.md b/bin/README.hermit.md new file mode 100644 index 0000000..e889550 --- /dev/null +++ b/bin/README.hermit.md @@ -0,0 +1,7 @@ +# Hermit environment + +This is a [Hermit](https://github.com/cashapp/hermit) bin directory. + +The symlinks in this directory are managed by Hermit and will automatically +download and install Hermit itself as well as packages. These packages are +local to this environment. diff --git a/bin/activate-hermit b/bin/activate-hermit new file mode 100755 index 0000000..fe28214 --- /dev/null +++ b/bin/activate-hermit @@ -0,0 +1,21 @@ +#!/bin/bash +# This file must be used with "source bin/activate-hermit" from bash or zsh. +# You cannot run it directly +# +# THIS FILE IS GENERATED; DO NOT MODIFY + +if [ "${BASH_SOURCE-}" = "$0" ]; then + echo "You must source this script: \$ source $0" >&2 + exit 33 +fi + +BIN_DIR="$(dirname "${BASH_SOURCE[0]:-${(%):-%x}}")" +if "${BIN_DIR}/hermit" noop > /dev/null; then + eval "$("${BIN_DIR}/hermit" activate "${BIN_DIR}/..")" + + if [ -n "${BASH-}" ] || [ -n "${ZSH_VERSION-}" ]; then + hash -r 2>/dev/null + fi + + echo "Hermit environment $("${HERMIT_ENV}"/bin/hermit env HERMIT_ENV) activated" +fi diff --git a/bin/go b/bin/go new file mode 120000 index 0000000..7da5509 --- /dev/null +++ b/bin/go @@ -0,0 +1 @@ +.go-1.21.5.pkg \ No newline at end of file diff --git a/bin/gofmt b/bin/gofmt new file mode 120000 index 0000000..7da5509 --- /dev/null +++ b/bin/gofmt @@ -0,0 +1 @@ +.go-1.21.5.pkg \ No newline at end of file diff --git a/bin/hermit b/bin/hermit new file mode 100755 index 0000000..7fef769 --- /dev/null +++ b/bin/hermit @@ -0,0 +1,43 @@ +#!/bin/bash +# +# THIS FILE IS GENERATED; DO NOT MODIFY + +set -eo pipefail + +export HERMIT_USER_HOME=~ + +if [ -z "${HERMIT_STATE_DIR}" ]; then + case "$(uname -s)" in + Darwin) + export HERMIT_STATE_DIR="${HERMIT_USER_HOME}/Library/Caches/hermit" + ;; + Linux) + export HERMIT_STATE_DIR="${XDG_CACHE_HOME:-${HERMIT_USER_HOME}/.cache}/hermit" + ;; + esac +fi + +export HERMIT_DIST_URL="${HERMIT_DIST_URL:-https://github.com/cashapp/hermit/releases/download/stable}" +HERMIT_CHANNEL="$(basename "${HERMIT_DIST_URL}")" +export HERMIT_CHANNEL +export HERMIT_EXE=${HERMIT_EXE:-${HERMIT_STATE_DIR}/pkg/hermit@${HERMIT_CHANNEL}/hermit} + +if [ ! -x "${HERMIT_EXE}" ]; then + echo "Bootstrapping ${HERMIT_EXE} from ${HERMIT_DIST_URL}" 1>&2 + INSTALL_SCRIPT="$(mktemp)" + # This value must match that of the install script + INSTALL_SCRIPT_SHA256="180e997dd837f839a3072a5e2f558619b6d12555cd5452d3ab19d87720704e38" + if [ "${INSTALL_SCRIPT_SHA256}" = "BYPASS" ]; then + curl -fsSL "${HERMIT_DIST_URL}/install.sh" -o "${INSTALL_SCRIPT}" + else + # Install script is versioned by its sha256sum value + curl -fsSL "${HERMIT_DIST_URL}/install-${INSTALL_SCRIPT_SHA256}.sh" -o "${INSTALL_SCRIPT}" + # Verify install script's sha256sum + openssl dgst -sha256 "${INSTALL_SCRIPT}" | \ + awk -v EXPECTED="$INSTALL_SCRIPT_SHA256" \ + '$2!=EXPECTED {print "Install script sha256 " $2 " does not match " EXPECTED; exit 1}' + fi + /bin/bash "${INSTALL_SCRIPT}" 1>&2 +fi + +exec "${HERMIT_EXE}" --level=fatal exec "$0" -- "$@" diff --git a/bin/hermit.hcl b/bin/hermit.hcl new file mode 100644 index 0000000..e69de29 diff --git a/reports/go.mod b/reports/go.mod index 62b77be..82e2535 100644 --- a/reports/go.mod +++ b/reports/go.mod @@ -1,6 +1,6 @@ module github.com/TBD54566975/sdk-development/reports -go 1.20 +go 1.21 require ( github.com/bradleyfalzon/ghinstallation/v2 v2.8.0 diff --git a/reports/report-template.html b/reports/report-template.html index 3ff8857..5756df1 100644 --- a/reports/report-template.html +++ b/reports/report-template.html @@ -1,7 +1,7 @@ - web5 spec compliance report + TBD SDKs spec compliance report @@ -53,6 +53,51 @@

{{ $category }}

{{ end }} {{ end }} + +

tbdex spec compliance report

+ + {{ range $category, $tests := .Tests }} +

{{ $category }}

+ + + + + + + + + {{ range $.Reports }} + + {{ end }} + + + + {{ range $i, $test := $tests }} + + + {{ range $_, $report := $.Reports }} + + {{ end }} + + + {{ end }} +
test vector + {{ .SDK.Name }} +
{{ $test }} + + + {{ (index (index .Results $category) $test).GetEmoji }} + +
    + {{ range (index (index .Results $category) $test).Errors }} +
  • {{ . }}
  • + {{ end }} +
+ +
+ {{ end }} diff --git a/reports/sdks.go b/reports/sdks.go index 6cf0620..787b885 100644 --- a/reports/sdks.go +++ b/reports/sdks.go @@ -29,6 +29,22 @@ var ( VectorRegex: regexp.MustCompile(`(\w+)\(\)`), VectorPath: "test-vectors", }, + { + Name: "tbdex-js", + Repo: "TBD54566975/tbdex-js", + ArtifactName: "junit-results", + FeatureRegex: regexp.MustCompile(`TbdexTestVectors(\w+)`), + VectorRegex: regexp.MustCompile(`\w+ \w+ (\w+)`), + VectorPath: "test-vectors", + }, + { + Name: "tbdex-kt", + Repo: "TBD54566975/tbdex-kt", + ArtifactName: "test-results", + FeatureRegex: regexp.MustCompile(`web5\.sdk\.\w+.TbdexTestVectors(\w+)`), + VectorRegex: regexp.MustCompile(`(\w+)\(\)`), + VectorPath: "test-vectors", + }, } ) From e4d8b37a922780922537fbd4370902585ecce652 Mon Sep 17 00:00:00 2001 From: Phoebe Lew Date: Mon, 8 Jan 2024 15:21:08 +1100 Subject: [PATCH 2/7] Readme and some report gen changes --- reports/README.md | 12 ++++++++++++ reports/html.go | 12 +++++++----- reports/sdks.go | 2 +- 3 files changed, 20 insertions(+), 6 deletions(-) diff --git a/reports/README.md b/reports/README.md index f7f25d3..e066c44 100644 --- a/reports/README.md +++ b/reports/README.md @@ -6,3 +6,15 @@ This tool reads junit XML reports from different SDKs and generates an HTML repo `./cmd/build-html` will iterate over the repos listed in `sdk.go` and download the most recent junit artifact. It will read all junit results from it and produce a report to `_site/index.html` + +## Tooling + +This project uses [hermit](https://cashapp.github.io/hermit/usage/get-started/), an open source toolchain manager, which pins and automatically downloads and installs tooling for a repo, including compiler toolchains, utilities, etc. + +To install hermit, run: + +```bash +https://github.com/cashapp/hermit/releases/download/stable/install.sh | /bin/bash +``` + +If using goland or intellij, also install the hermit plugin via [these instructions](https://cashapp.github.io/hermit/usage/ide/). \ No newline at end of file diff --git a/reports/html.go b/reports/html.go index d5f36d6..750a2b3 100644 --- a/reports/html.go +++ b/reports/html.go @@ -17,8 +17,9 @@ func sanatizeHTML(dirty error) string { } type htmlTemplateInput struct { - Reports []Report - Tests map[string][]string + Reports []Report + Web5Tests map[string][]string + TbdexTests map[string][]string } func WriteHTML(reports []Report, filename string) error { @@ -38,13 +39,14 @@ func WriteHTML(reports []Report, filename string) error { } templateInput := htmlTemplateInput{ - Reports: reports, - Tests: make(map[string][]string), + Reports: reports, + Web5Tests: make(map[string][]string), + TbdexTests: make(map[string][]string), } for category, tests := range testmap { for test := range tests { - templateInput.Tests[category] = append(templateInput.Tests[category], test) + templateInput.Web5Tests[category] = append(templateInput.Web5Tests[category], test) } } diff --git a/reports/sdks.go b/reports/sdks.go index 787b885..74854a6 100644 --- a/reports/sdks.go +++ b/reports/sdks.go @@ -41,7 +41,7 @@ var ( Name: "tbdex-kt", Repo: "TBD54566975/tbdex-kt", ArtifactName: "test-results", - FeatureRegex: regexp.MustCompile(`web5\.sdk\.\w+.TbdexTestVectors(\w+)`), + FeatureRegex: regexp.MustCompile(`tbdex\.sdk\.\w+.TbdexTestVectors(\w+)`), VectorRegex: regexp.MustCompile(`(\w+)\(\)`), VectorPath: "test-vectors", }, From 684c7cbb841f758a95caa14277fced25f28525e0 Mon Sep 17 00:00:00 2001 From: Phoebe Lew Date: Tue, 9 Jan 2024 11:33:45 +1100 Subject: [PATCH 3/7] Handle tbdex test results Co-authored-by: Finn Herzfeld --- reports/html.go | 23 +++++++++++++++++++---- reports/report-template.html | 4 ++-- reports/reports.go | 1 + reports/sdks.go | 4 ++++ 4 files changed, 26 insertions(+), 6 deletions(-) diff --git a/reports/html.go b/reports/html.go index 750a2b3..fc4037d 100644 --- a/reports/html.go +++ b/reports/html.go @@ -19,21 +19,30 @@ func sanatizeHTML(dirty error) string { type htmlTemplateInput struct { Reports []Report Web5Tests map[string][]string - TbdexTests map[string][]string + TbDEXTests map[string][]string } func WriteHTML(reports []Report, filename string) error { slog.Info("writing html report", "reports", len(reports)) testmap := make(map[string]map[string]bool) + tbdexTestMap := make(map[string]map[string]bool) for _, report := range reports { for category, tests := range report.Results { if _, ok := tests[category]; !ok { - testmap[category] = map[string]bool{} + if report.SDK.Type == "web5" { + testmap[category] = map[string]bool{} + } else { + tbdexTestMap[category] = map[string]bool{} + } } for test := range tests { - testmap[category][test] = true + if report.SDK.Type == "web5" { + testmap[category][test] = true + } else { + tbdexTestMap[category][test] = true + } } } } @@ -41,7 +50,7 @@ func WriteHTML(reports []Report, filename string) error { templateInput := htmlTemplateInput{ Reports: reports, Web5Tests: make(map[string][]string), - TbdexTests: make(map[string][]string), + TbDEXTests: make(map[string][]string), } for category, tests := range testmap { @@ -50,6 +59,12 @@ func WriteHTML(reports []Report, filename string) error { } } + for category, tests := range tbdexTestMap { + for test := range tests { + templateInput.TbDEXTests[category] = append(templateInput.TbDEXTests[category], test) + } + } + f, err := os.Create(filename) if err != nil { return fmt.Errorf("error opening %s: %v", filename, err) diff --git a/reports/report-template.html b/reports/report-template.html index 5756df1..be458f3 100644 --- a/reports/report-template.html +++ b/reports/report-template.html @@ -11,7 +11,7 @@

web5 spec compliance report

- {{ range $category, $tests := .Tests }} + {{ range $category, $tests := .Web5Tests }}

{{ $category }}

@@ -56,7 +56,7 @@

{{ $category }}

tbdex spec compliance report

- {{ range $category, $tests := .Tests }} + {{ range $category, $tests := .TbdexTests }}

{{ $category }}

diff --git a/reports/reports.go b/reports/reports.go index f379a58..a156318 100644 --- a/reports/reports.go +++ b/reports/reports.go @@ -37,6 +37,7 @@ type SDKMeta struct { FeatureRegex *regexp.Regexp VectorRegex *regexp.Regexp VectorPath string + Type string } type Report struct { diff --git a/reports/sdks.go b/reports/sdks.go index 74854a6..1e3fda6 100644 --- a/reports/sdks.go +++ b/reports/sdks.go @@ -20,6 +20,7 @@ var ( FeatureRegex: regexp.MustCompile(`Web5TestVectors(\w+)`), VectorRegex: regexp.MustCompile(`\w+ \w+ (\w+)`), VectorPath: "test-vectors", + Type: "web5", }, { Name: "web5-kt", @@ -28,6 +29,7 @@ var ( FeatureRegex: regexp.MustCompile(`web5\.sdk\.\w+.Web5TestVectors(\w+)`), VectorRegex: regexp.MustCompile(`(\w+)\(\)`), VectorPath: "test-vectors", + Type: "web5", }, { Name: "tbdex-js", @@ -36,6 +38,7 @@ var ( FeatureRegex: regexp.MustCompile(`TbdexTestVectors(\w+)`), VectorRegex: regexp.MustCompile(`\w+ \w+ (\w+)`), VectorPath: "test-vectors", + Type: "tbdex", }, { Name: "tbdex-kt", @@ -44,6 +47,7 @@ var ( FeatureRegex: regexp.MustCompile(`tbdex\.sdk\.\w+.TbdexTestVectors(\w+)`), VectorRegex: regexp.MustCompile(`(\w+)\(\)`), VectorPath: "test-vectors", + Type: "tbdex", }, } ) From 3592be1df29934e284e91dacd74a430ee7967802 Mon Sep 17 00:00:00 2001 From: Phoebe Lew Date: Thu, 11 Jan 2024 13:57:15 +1100 Subject: [PATCH 4/7] lint error --- README.md | 1 - 1 file changed, 1 deletion(-) diff --git a/README.md b/README.md index fd31255..ee423d5 100644 --- a/README.md +++ b/README.md @@ -421,4 +421,3 @@ Further, the key manager interface **must** be passed as an argument to _all_ pu | [Predicates](https://identity.foundation/presentation-exchange/spec/v2.0.0/#predicate-feature) | ✅ | ✅ | ❌ | ❌ | | [Relational Constraints](https://identity.foundation/presentation-exchange/spec/v2.0.0/#relational-constraint-feature) | ✅ | ❌ | ❌ | ❌ | | [Credential Status](https://identity.foundation/presentation-exchange/spec/v2.0.0/#credential-status-constraint-feature) | ❌ | ❌ | ❌ | ❌ | - From a7a742fb6ebd4aecdb720bd3c37557d06ff9fa53 Mon Sep 17 00:00:00 2001 From: Phoebe Lew Date: Thu, 18 Jan 2024 15:48:16 +1100 Subject: [PATCH 5/7] Casing --- reports/report-template.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/reports/report-template.html b/reports/report-template.html index be458f3..fd83032 100644 --- a/reports/report-template.html +++ b/reports/report-template.html @@ -56,7 +56,7 @@

{{ $category }}

tbdex spec compliance report

- {{ range $category, $tests := .TbdexTests }} + {{ range $category, $tests := .TbDEXTests }}

{{ $category }}

From 14af74683f9cb7c9ae572f5f12cfe532a8619593 Mon Sep 17 00:00:00 2001 From: Phoebe Lew Date: Fri, 19 Jan 2024 15:22:44 +1100 Subject: [PATCH 6/7] Update regex --- reports/sdks.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/reports/sdks.go b/reports/sdks.go index 474452c..7c63355 100644 --- a/reports/sdks.go +++ b/reports/sdks.go @@ -36,7 +36,7 @@ var ( Repo: "TBD54566975/tbdex-js", ArtifactName: "junit-results", FeatureRegex: regexp.MustCompile(`TbdexTestVectors(\w+)`), - VectorRegex: regexp.MustCompile(`\w+ \w+ (\w+)`), + VectorRegex: regexp.MustCompile(`.* TbdexTestVectors\w+ (\w+)`), VectorPath: "test-vectors", Type: "tbdex", }, From ab1e08bde4a062938b59d11fb4067974edf78161 Mon Sep 17 00:00:00 2001 From: Phoebe Lew Date: Fri, 19 Jan 2024 15:31:15 +1100 Subject: [PATCH 7/7] update filepath --- scripts/test-vector-validation/main.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/test-vector-validation/main.js b/scripts/test-vector-validation/main.js index 410d072..ef045df 100644 --- a/scripts/test-vector-validation/main.js +++ b/scripts/test-vector-validation/main.js @@ -7,7 +7,7 @@ import { fileURLToPath } from 'node:url' const __filename = fileURLToPath(import.meta.url) const __dirname = path.dirname(__filename) -const vectorsDir = `${__dirname}/../../web5-test-vectors` +const vectorsDir = `${__dirname}/../../test-vectors` let vectorsSchema = fs.readFileSync(`${vectorsDir}/vectors.schema.json`, 'utf8') vectorsSchema = JSON.parse(vectorsSchema)