diff --git a/.github/_ISSUE_TEMPLATE/bug-report.md b/.github/_ISSUE_TEMPLATE/bug-report.md deleted file mode 100644 index 8c37af0..0000000 --- a/.github/_ISSUE_TEMPLATE/bug-report.md +++ /dev/null @@ -1,33 +0,0 @@ ---- -name: 🐛 Bug Report -about: Thank you for taking the time, please report a reproducible bug -title: "[Bug] " -labels: bug -assignees: add codeowner's @name here - ---- - -**Describe the bug** -*A clear and concise description of what the bug is.* - -**To Reproduce:** -*Steps to reproduce the behavior:* - -1. Go to '...' -2. Click on '....' -3. Scroll down to '....' -4. See error - -**Expected behavior:** -*A clear and concise description of what you expected to happen.* - -**Supporting Material** -*If applicable, add screenshots, output log and/or other documentation to help explain your problem.* - -**Environment (please complete the following information):** - -- OS: [ex: iOS] -- Version - -**Additional context** -Add any other context that you feel is relevant about the problem here. diff --git a/.github/_ISSUE_TEMPLATE/config.yml b/.github/_ISSUE_TEMPLATE/config.yml deleted file mode 100644 index ce71f10..0000000 --- a/.github/_ISSUE_TEMPLATE/config.yml +++ /dev/null @@ -1,4 +0,0 @@ -contact_links: - - name: ❓ Questions and Help 🤔 - url: https://discord.gg/tbd (/add your discord channel if applicable) - about: This issue tracker is not for support questions. Please refer to the community for more help. diff --git a/.github/workflows/build-report.yaml b/.github/workflows/build-report.yaml deleted file mode 100644 index 24d3aec..0000000 --- a/.github/workflows/build-report.yaml +++ /dev/null @@ -1,32 +0,0 @@ -name: build html report - -on: - push: - workflow_dispatch: - -jobs: - build-report: - runs-on: ubuntu-latest - permissions: - id-token: write - contents: read - pages: write - steps: - - uses: actions/checkout@v3 - - uses: actions/setup-go@v4 - - name: build html - run: | - cd reports - go run ./cmd/build-html - cp -r ./static/* _site - mv _site ../ - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - CICD_ROBOT_GITHUB_APP_NAME: ${{ secrets.CICD_ROBOT_GITHUB_APP_NAME }} - CICD_ROBOT_GITHUB_APP_PRIVATE_KEY: ${{ secrets.CICD_ROBOT_GITHUB_APP_PRIVATE_KEY }} - CICD_ROBOT_GITHUB_APP_ID: ${{ secrets.CICD_ROBOT_GITHUB_APP_ID }} - CICD_ROBOT_GITHUB_APP_INSTALLATION_ID: ${{ secrets.CICD_ROBOT_GITHUB_APP_INSTALLATION_ID }} - - uses: actions/upload-pages-artifact@v2 - - name: deploy GitHub Pages - uses: actions/deploy-pages@v3 - if: github.ref == 'refs/heads/main' diff --git a/.github/workflows/lint.yaml b/.github/workflows/lint.yaml deleted file mode 100644 index 61fdcc2..0000000 --- a/.github/workflows/lint.yaml +++ /dev/null @@ -1,13 +0,0 @@ -name: Lint - -on: [push, pull_request] - -jobs: - lint: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - - uses: DavidAnson/markdownlint-cli2-action@v13 - with: - globs: "**/*.md" diff --git a/.markdownlint-cli2.yaml b/.markdownlint-cli2.yaml deleted file mode 100644 index cb6053b..0000000 --- a/.markdownlint-cli2.yaml +++ /dev/null @@ -1,4 +0,0 @@ -config: - line-length: false - no-duplicate-heading: - siblings_only: true diff --git a/README.md b/README.md index ee423d5..5fdd028 100644 --- a/README.md +++ b/README.md @@ -1,11 +1,8 @@ -# SDK Development +# Web5-Spec - [Purpose](#purpose) -- [Known Unknowns](#known-unknowns) - [Requirements](#requirements) - [Feature Tracking](#feature-tracking) - - [Labels](#labels) - - [Milestones](#milestones) - [Feature Acceptance](#feature-acceptance) - [Work Prioritization](#work-prioritization) - [Implementation Criteria](#implementation-criteria) @@ -16,10 +13,8 @@ - [Publishing API Reference Documentation](#publishing-api-reference-documentation) - [Example Feature Usage](#example-feature-usage) - [Test Vectors](#test-vectors) - - [Usage](#usage) - - [Local Dev](#local-dev) - - [Adding/Updating Vectors](#addingupdating-vectors) - - [Feature Completeness By SDK](#feature-completeness-by-sdk) + - [Adding/Updating Vectors](#addingupdating-vectors) + - [Feature Completeness By SDK](#feature-completeness-by-sdk) - [Web5 SDK Features](#web5-sdk-features) - [Cryptographic Digital Signature Algorithms (DSA)](#cryptographic-digital-signature-algorithms-dsa) - [Key Management](#key-management) @@ -38,28 +33,14 @@ ## Purpose -This repo sets forth the development process and requirements for the following SDKs: +This repo sets forth the development process, requirements, and the desired feature for the following SDKs: -- [tbdex-js](https://github.com/TBD54566975/tbdex-js) -- [tbdex-kt](https://github.com/TBD54566975/tbdex-kt) -- [tbdex-rs](https://github.com/TBD54566975/tbdex-rs) - [web5-js](https://github.com/TBD54566975/web5-js) - [web5-kt](https://github.com/TBD54566975/web5-kt) +- [web5-go](https://github.com/TBD54566975/web5-go) - [web5-rs](https://github.com/TBD54566975/web5-rs) +- [web5-swift](https://github.com/TBD54566975/web5-swift) -It contains the desired feature set for: - -- [web5-js](https://github.com/TBD54566975/web5-js) -- [web5-kt](https://github.com/TBD54566975/web5-kt) -- [web5-rs](https://github.com/TBD54566975/web5-rs) - -Github Issues and PRs created in this repo address topics that impact / span all SDKs we have in development. See section on [Feature Acceptance](#feature-acceptance) for information on submitting proposals for new features across all of our SDKs (e.g. implement Presentation Exchange v9) - -## Known Unknowns - -- We don't yet have a cemented path for supporting Android. It could either be through our pre-existing Kotlin SDK or bindings exposed via Rust - -- We're not yet in a place where we can confidently state that a rust core can support a broad surface area of target languages. We're confident in pursuing rust development for the purposes of surfacing swift bindings. ## Requirements @@ -67,79 +48,6 @@ Github Issues and PRs created in this repo address topics that impact / span all Feature tracking will take place entirely on GitHub through Github Issues and the [SDK development Github project](https://github.com/orgs/TBD54566975/projects/29). ---- - -Work items that impact all SDKs should be created as issues in _this_ Github Repo. e.g. "produce test vectors for `did:web` - ---- - -Work items that are specific to an individual SDK should be created as an issue in the respective sdk's Github Repo - -> [!IMPORTANT] -> Each individual SDK's DRI will be responsible for creating all of the relevant github issues in their respective repo by using the tables below. After all issues are created for a given feature, create a PR for this repo to delete the relevant table. - ---- - -All relevant Github Issues will be tracked in the [SDK Development](https://github.com/orgs/TBD54566975/projects/29) Project. Issues can be associated to the project through the sidebar on an individual issue page. If a new issue is created in any of the SDK repos with one of the below feature labels, it will _automatically_ be added to the project board via GH project workflows. _New_ features lables should be added to the [workflows](https://github.com/orgs/TBD54566975/projects/29/workflows). - ---- - -Work item progress is tracked using the `Status` attribute on a GH issue. This should automatically be reflected on the kanban view on the GH project. PRs should be linked to their respective issue via the PR description. - ---- - -#### Labels - -> [!IMPORTANT] -> A label should be created for each feature, in each respective repo. - -The following labels should exist in all relevant repos - -| Label | Color Hex | Description | -| -------------------- | --------- | ------------------------------------------ | -| `dsa` | `#7FDBFF` | Cryptographic Digital Signature Algorithms | -| `key-mgmt` | `#0074D9` | Key Management | -| `did:web` | `#2ECC40` | did:web | -| `did:jwk` | `#FFDC00` | did:jwk | -| `did:dht` | `#FF851B` | did:dht | -| `did:key` | `#F012BE` | did:key | -| `did:ion` | `#B10DC9` | did:ion | -| `did-doc-validation` | `#3D9970` | DID Document & Resolution Validation | -| `w3c-vc-dm-1.1` | `#39CCCC` | W3C Verifiable Credential Data Model 1.1 | -| `w3c-vc-dm-2.0` | `#01FF70` | W3C Verifiable Credential Data Model 2.0 | -| `sd-jwt` | `#85144B` | SD-JWT / SD-JWT-VC | -| `pd-v2` | `#F9A602` | Presentation Definition V2 | -| `vc-json-schema` | `#C86F42` | VC JSON Schema | -| `tbdex-message` | `#70DB93` | tbDEX Message | -| `tbdex-resource` | `#5B2C6F` | tbDEX Resource | -| `tbdex-offering` | `#E59866` | tbDEX Offering Resource | -| `tbdex-rfq` | `#1F618D` | tbDEX RFQ Message | -| `tbdex-quote` | `#186A3B` | tbDEX Quote Message | -| `tbdex-order` | `#28B463` | tbDEX Order Message | -| `tbdex-orderstatus` | `#D68910` | tbDEX Order-Status Message | -| `tbdex-close` | `#34495E` | tbDEX Close Message | -| `tbdex-server` | `#3498DB` | HTTP server for tbDEX PFIs | -| `tbdex-client` | `#E74C3C` | HTTP client for tbDEX wallets | - -> [!NOTE] -> This list will change over time as features are added or removed - ---- - -#### Milestones - -Github Repo Milestones will be used to track work for specific codenamed projects (e.g. Eagle, Pigeon, Black Swan, etc.). - -The following milestones should exist in all relevant repos - -| Milestone | -| --------- | -| `Eagle` | -| `ABC` | - -> [!NOTE] -> This list will change over time as projects are added - ### Feature Acceptance Proposing new features that impact all SDKs will occur by creating a Github Issue in this repo. The Issue should include motivation or rationale in addition to any relevant reading material. New features will be discussed and decided upon during weekly syncs @@ -147,6 +55,8 @@ Proposing new features that impact all SDKs will occur by creating a Github Issu > [!IMPORTANT] > Language agnostic test vectors **must** be produced _prior_ to commencing implementation beyond the first SDK +Test vectors are in the test-vector directory. More info on test vectors can be found there. + ### Work Prioritization Prioritization of features or specific work items will be reflected during weekly sync meetings. @@ -182,17 +92,17 @@ Each SDK will use Github Actions for CI/CD and other automations | Feature | Typescript | Kotlin | Rust | Swift | | ----------------------------- | ---------- | ------ | ---- | ----- | -| OSS License Check | ❌ | ❌ | ✅ | ❌ | -| Security Scanning | ❌ | ❌ | ⛔️ | ❌ | -| Static Analysis Linting/Style | ❌ | ❌ | ✅ | ❌ | +| OSS License Check | ✅ | ✅ | ✅ | ❌ | +| Security Scanning | ✅ | ✅ | ⛔️ | ❌ | +| Static Analysis Linting/Style | ✅ | ✅ | ✅ | ❌ | | Running Unit Tests | ✅ | ✅ | ✅ | ❌ | -| Publishing Tests Reports | ❌ | ❌ | ❌ | ❌ | -| Code Coverage (CodeCov) | ❌ | ❌ | ❌ | ❌ | -| Publishing Artifacts | ❓ | ❌ | ❌ | ❌ | +| Publishing Tests Reports | ✅ | ✅ | ❌ | ❌ | +| Code Coverage (CodeCov) | ✅ | ✅ | ❌ | ❌ | +| Publishing Artifacts | ✅ | ✅ | ❌ | ❌ | | Release Template Checklist | ❌ | ❌ | ❌ | ❌ | | Automated GH Release Tag | ❌ | ❌ | ❌ | ❌ | -| Publishing API Reference Docs | ❌ | ✅ | ❌ | ❌ | -| Publish Example Feature Usage | ❌ | ✅ | ❌ | ❌ | +| Publishing API Reference Docs | ✅ | ✅ | ❌ | ❌ | +| Publish Example Feature Usage | ✅ | ✅ | ❌ | ❌ | > [!CAUTION] > Security scanning via Snyk is currently not supported in Rust @@ -215,6 +125,7 @@ Each SDK will be published to the most widely adopted registry/repository for th | Kotlin | maven central | | Rust | crates.io | | Swift | swift package index | +| Go | tbd | ### Publishing API Reference Documentation @@ -233,6 +144,7 @@ Each SDK will auto generate API reference documentation using the respective lan | Kotlin | KDoc | Dokka | | Rust | Documentation comments | rustdoc | | Swift | Swift Markup | DocC | +| Go | tbd | tbd | > [!IMPORTANT] > Producing API reference documentation is the responsibility of an _implementer_ @@ -245,39 +157,19 @@ Each SDK will **publish** example usage for _each_ implemented feature. This can Test vectors ensure interoporability of features across SDKs and language implementations by providing common test cases with an input and expected output pair. They include both success and failure cases that can be vectorized. -This repo serves as the home for all web5 feature related vectors. They are available in the [web5-test-vectors](./web5-test-vectors/) directory and hosted on [Github Pages](https://tbd54566975.github.io/sdk-development/web5-test-vectors). - -The `tbdex` repo houses tbdex feature related vectors. They are available in the [test-vectors](https://github.com/TBD54566975/tbdex/test-vectors) directory and hosted on [Github Pages](https://tbdex.dev/). - -### Usage - -#### Local Dev - -SDK implementers should import vectors in order to test their implementation. The recommended pathway to consume them is as follows: - -Fetch the vector and read it into a data model representing the vector structure or a JSON object like so: - -```kt -// for web5 vectors -val stream = URL("https://tbd54566975.github.io/sdk-development/web5-test-vectors/did-jwk/resolve.json").openStream() -val vectorsJson = BufferedReader(InputStreamReader(stream)).readText() -return Json.jsonMapper.readTree(vectorsJson) +This repo serves as the home for all web5 feature related vectors. They are available in the [test-vectors](./test-vectors/) directory -// for tbdex vectors -val stream = URL("https://tbdex.dev/test-vectors/resources/marshal.json").openStream() -val vectorsJson = BufferedReader(InputStreamReader(stream)).readText() -return Json.jsonMapper.readTree(vectorsJson) -``` +The `tbdex` repo houses tbdex feature related vectors. They are available in the [test-vectors](https://github.com/TBD54566975/tbdex/test-vectors) directory -The data model or JSON object can then be used in the implementer's unit testing framework of choice. +The `sdk-report-runner` repo consumes the output tests for these test vectors in each repo and generates a report - [report-runner](https://github.com/TBD54566975/sdk-report-runner) -#### Adding/Updating Vectors +### Adding/Updating Vectors -New test vectors should follow the standard [vector structure](./web5-test-vectors/vectors.schema.json). Vectors are automatically validated against the JSON schema via CI. +New test vectors should follow the standard [vector structure](./test-vectors/). Vectors are automatically validated against the JSON schema via CI. -Create a PR in this repo for web5 vectors, or in [`tbdex`](https://github.com/TBD54566975/tbdex) for tbdex vectors with the proposed changes or additions. +Create a PR in this repo for adding / updating web5 test vectors -#### Feature Completeness By SDK +### Feature Completeness By SDK Test vectors are also used to determine feature completeness via our [test harness](./test-harness/README.md). Results of test harness runs can be found [here](https://tbd54566975.github.io/sdk-development/). diff --git a/action.yml b/action.yml deleted file mode 100644 index 8f15a3a..0000000 --- a/action.yml +++ /dev/null @@ -1,12 +0,0 @@ -name: Web5 Spec Conformance Test -description: test that this web5 component conforms to the expected spec -runs: - using: composite - steps: - - run: | - spec_test_version="$(basename "${GITHUB_ACTION_PATH}")" - bin="${GITHUB_ACTION_PATH}/web5-test-harness" - wget --quiet -O "${bin}" "https://github.com/TBD54566975/sdk-development/releases/download/${spec_test_version}/web5-test-harness-linux-amd64" - chmod +x "${bin}" - "${bin}" one - shell: bash diff --git a/bin/.go-1.21.5.pkg b/bin/.go-1.21.5.pkg deleted file mode 120000 index 383f451..0000000 --- a/bin/.go-1.21.5.pkg +++ /dev/null @@ -1 +0,0 @@ -hermit \ No newline at end of file diff --git a/bin/README.hermit.md b/bin/README.hermit.md deleted file mode 100644 index e889550..0000000 --- a/bin/README.hermit.md +++ /dev/null @@ -1,7 +0,0 @@ -# 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 deleted file mode 100755 index fe28214..0000000 --- a/bin/activate-hermit +++ /dev/null @@ -1,21 +0,0 @@ -#!/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 deleted file mode 120000 index 7da5509..0000000 --- a/bin/go +++ /dev/null @@ -1 +0,0 @@ -.go-1.21.5.pkg \ No newline at end of file diff --git a/bin/gofmt b/bin/gofmt deleted file mode 120000 index 7da5509..0000000 --- a/bin/gofmt +++ /dev/null @@ -1 +0,0 @@ -.go-1.21.5.pkg \ No newline at end of file diff --git a/bin/hermit b/bin/hermit deleted file mode 100755 index 7fef769..0000000 --- a/bin/hermit +++ /dev/null @@ -1,43 +0,0 @@ -#!/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 deleted file mode 100644 index e69de29..0000000 diff --git a/reports/README.md b/reports/README.md deleted file mode 100644 index 86d77c5..0000000 --- a/reports/README.md +++ /dev/null @@ -1,27 +0,0 @@ -# SDK Feature Report Generator - -This tool reads junit XML reports from different SDKs and generates an HTML report showing which SDKs support which features. - -`./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`. For local testing, generate a -[GitHub Personal Access Token](https://github.com/settings/tokens?type=beta) and put it in an environment variable named -`GITHUB_TOKEN`. It doesn't need any special permissions ("Public Repositories (read-only)"). Note that a GitHub app (explained below) can also be used. - -`./cmd/sync-vectors` will check the `main` branch of all SDKs listed in `sdks.go` and ensure their vectors match the ones in this repo. -For local testing, a [GitHub App](https://github.com/settings/apps) must be created. Put it's credentials in the following environment variables: - -* `CICD_ROBOT_GITHUB_APP_ID` - shown on the edit page of the app, where you are sent right after app creation. -* `CICD_ROBOT_GITHUB_APP_PRIVATE_KEY` - this should be the contents of the private key, not the path to the file. -* `CICD_ROBOT_GITHUB_APP_NAME` - this is used as a display name and should match the name in the URL of the edit page for the app. -* `CICD_ROBOT_GITHUB_APP_INSTALLATION_ID` - click "Install App" on the sidebar while editing the app in GitHub to install it on your own account. - -## 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/). diff --git a/reports/cmd/build-html/main.go b/reports/cmd/build-html/main.go deleted file mode 100644 index 8e68166..0000000 --- a/reports/cmd/build-html/main.go +++ /dev/null @@ -1,30 +0,0 @@ -package main - -import ( - "errors" - "os" - "path/filepath" - - "golang.org/x/exp/slog" - - "github.com/TBD54566975/sdk-development/reports" -) - -func main() { - allReports, err := reports.GetAllReports() - if err != nil { - slog.Error("error downloading/parsing reports") - panic(err) - } - - if err = os.Mkdir("_site", 0755); err != nil && !errors.Is(err, os.ErrExist) { - slog.Error("error making output directory") - panic(err) - } - - err = reports.WriteHTML(allReports, filepath.Join("_site", "index.html")) - if err != nil { - slog.Error("error writing html output") - panic(err) - } -} diff --git a/reports/cmd/sync-vectors/main.go b/reports/cmd/sync-vectors/main.go deleted file mode 100644 index abeedfe..0000000 --- a/reports/cmd/sync-vectors/main.go +++ /dev/null @@ -1,33 +0,0 @@ -package main - -import ( - "os" - - "github.com/TBD54566975/sdk-development/reports" - "golang.org/x/exp/slog" -) - -func main() { - defer reports.CleanupGitAuth() - if err := reports.ConfigureGitAuth(); err != nil { - panic(err) - } - - errs := make(map[string]error) - for _, sdk := range reports.SDKs { - if err := reports.SyncSDK(sdk); err != nil { - errs[sdk.Name] = err - } - } - - if err := reports.CleanupGitAuth(); err != nil { - panic(err) - } - - if len(errs) > 0 { - for sdk, err := range errs { - slog.Error("error", "sdk", sdk, "error", err) - } - os.Exit(1) - } -} diff --git a/reports/github.go b/reports/github.go deleted file mode 100644 index 3b484e1..0000000 --- a/reports/github.go +++ /dev/null @@ -1,64 +0,0 @@ -package reports - -import ( - "context" - "fmt" - "net/http" - "os" - "strconv" - - ghinstallation "github.com/bradleyfalzon/ghinstallation/v2" - "github.com/google/go-github/v57/github" - "golang.org/x/exp/slog" -) - -var ( - ghAppName = os.Getenv("CICD_ROBOT_GITHUB_APP_NAME") - ghAppPrivateKey = os.Getenv("CICD_ROBOT_GITHUB_APP_PRIVATE_KEY") - ghAppIDString = os.Getenv("CICD_ROBOT_GITHUB_APP_ID") - ghAppInstallationIDString = os.Getenv("CICD_ROBOT_GITHUB_APP_INSTALLATION_ID") - - ghToken = os.Getenv("GITHUB_TOKEN") - - gh *github.Client - ghTransport *ghinstallation.Transport - - ghUserName = fmt.Sprintf("%s[bot]", ghAppName) -) - -func init() { - if ghToken != "" { - slog.Info("using GITHUB_TOKEN for auth") - gh = github.NewTokenClient(context.Background(), ghToken) - return - } - - ghAppID, err := strconv.ParseInt(ghAppIDString, 10, 32) - if err != nil { - slog.Error("invalid or unset app ID. Please set environment variable CICD_ROBOT_GITHUB_APP_ID to a valid integer") - panic(err) - } - - ghInstallationID, err := strconv.ParseInt(ghAppInstallationIDString, 10, 32) - if err != nil { - slog.Error("invalid or unset installation ID. Please set environment variable CICD_ROBOT_GITHUB_APP_INSTALLATION_ID to a valid integer") - panic(err) - } - - ghTransport, err = ghinstallation.New(http.DefaultTransport, ghAppID, ghInstallationID, []byte(ghAppPrivateKey)) - if err != nil { - slog.Error("error initializing github auth transport.") - panic(err) - } - - gh = github.NewClient(&http.Client{Transport: ghTransport}) - - user, _, err := gh.Users.Get(context.Background(), ghUserName) - if err != nil { - slog.Error("error getting own (app) user info") - panic(err) - } - - gitConfig["user.email"] = fmt.Sprintf("%d+%s@users.noreply.github.com", user.GetID(), ghUserName) - gitConfig["user.name"] = ghUserName -} diff --git a/reports/go.mod b/reports/go.mod deleted file mode 100644 index 82e2535..0000000 --- a/reports/go.mod +++ /dev/null @@ -1,17 +0,0 @@ -module github.com/TBD54566975/sdk-development/reports - -go 1.21 - -require ( - github.com/bradleyfalzon/ghinstallation/v2 v2.8.0 - github.com/google/go-github/v57 v57.0.0 - github.com/joshdk/go-junit v1.0.0 - golang.org/x/exp v0.0.0-20231127185646-65229373498e -) - -require ( - github.com/golang-jwt/jwt/v4 v4.5.0 // indirect - github.com/google/go-github/v56 v56.0.0 // indirect - github.com/google/go-querystring v1.1.0 // indirect - github.com/stretchr/testify v1.8.4 // indirect -) diff --git a/reports/go.sum b/reports/go.sum deleted file mode 100644 index 31b35c3..0000000 --- a/reports/go.sum +++ /dev/null @@ -1,29 +0,0 @@ -github.com/bradleyfalzon/ghinstallation/v2 v2.8.0 h1:yUmoVv70H3J4UOqxqsee39+KlXxNEDfTbAp8c/qULKk= -github.com/bradleyfalzon/ghinstallation/v2 v2.8.0/go.mod h1:fmPmvCiBWhJla3zDv9ZTQSZc8AbwyRnGW1yg5ep1Pcs= -github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= -github.com/golang-jwt/jwt/v4 v4.5.0 h1:7cYmW1XlMY7h7ii7UhUyChSgS5wUJEnm9uZVTGqOWzg= -github.com/golang-jwt/jwt/v4 v4.5.0/go.mod h1:m21LjoU+eqJr34lmDMbreY2eSTRJ1cv77w39/MY0Ch0= -github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= -github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= -github.com/google/go-github/v56 v56.0.0 h1:TysL7dMa/r7wsQi44BjqlwaHvwlFlqkK8CtBWCX3gb4= -github.com/google/go-github/v56 v56.0.0/go.mod h1:D8cdcX98YWJvi7TLo7zM4/h8ZTx6u6fwGEkCdisopo0= -github.com/google/go-github/v57 v57.0.0 h1:L+Y3UPTY8ALM8x+TV0lg+IEBI+upibemtBD8Q9u7zHs= -github.com/google/go-github/v57 v57.0.0/go.mod h1:s0omdnye0hvK/ecLvpsGfJMiRt85PimQh4oygmLIxHw= -github.com/google/go-querystring v1.1.0 h1:AnCroh3fv4ZBgVIf1Iwtovgjaw/GiKJo8M8yD/fhyJ8= -github.com/google/go-querystring v1.1.0/go.mod h1:Kcdr2DB4koayq7X8pmAG4sNG59So17icRSOU623lUBU= -github.com/joshdk/go-junit v1.0.0 h1:S86cUKIdwBHWwA6xCmFlf3RTLfVXYQfvanM5Uh+K6GE= -github.com/joshdk/go-junit v1.0.0/go.mod h1:TiiV0PqkaNfFXjEiyjWM3XXrhVyCa1K4Zfga6W52ung= -github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= -github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= -github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= -github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= -github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= -golang.org/x/exp v0.0.0-20231127185646-65229373498e h1:Gvh4YaCaXNs6dKTlfgismwWZKyjVZXwOPfIyUaqU3No= -golang.org/x/exp v0.0.0-20231127185646-65229373498e/go.mod h1:iRJReGqOEeBhDZGkGbynYwcHlctCvnjTYIamk7uXpHI= -golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= -gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= diff --git a/reports/html.go b/reports/html.go deleted file mode 100644 index fc4037d..0000000 --- a/reports/html.go +++ /dev/null @@ -1,79 +0,0 @@ -package reports - -import ( - "fmt" - "os" - "strings" - - "golang.org/x/exp/slog" -) - -func sanatizeHTML(dirty error) string { - clean := strings.ReplaceAll(dirty.Error(), "<", "<") - clean = strings.ReplaceAll(clean, ">", ">") - clean = strings.ReplaceAll(clean, "\n", "\\\\n") - - return clean -} - -type htmlTemplateInput struct { - Reports []Report - Web5Tests 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 { - if report.SDK.Type == "web5" { - testmap[category] = map[string]bool{} - } else { - tbdexTestMap[category] = map[string]bool{} - } - } - - for test := range tests { - if report.SDK.Type == "web5" { - testmap[category][test] = true - } else { - tbdexTestMap[category][test] = true - } - } - } - } - - templateInput := htmlTemplateInput{ - Reports: reports, - Web5Tests: make(map[string][]string), - TbDEXTests: make(map[string][]string), - } - - for category, tests := range testmap { - for test := range tests { - templateInput.Web5Tests[category] = append(templateInput.Web5Tests[category], test) - } - } - - 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) - } - defer f.Close() - - if err := htmlTemplates.ExecuteTemplate(f, "report-template.html", templateInput); err != nil { - return err - } - - return nil -} diff --git a/reports/junit-reader.go b/reports/junit-reader.go deleted file mode 100644 index 61a7f03..0000000 --- a/reports/junit-reader.go +++ /dev/null @@ -1,51 +0,0 @@ -package reports - -import ( - "archive/zip" - "bytes" - "fmt" - "strings" - - junit "github.com/joshdk/go-junit" - "golang.org/x/exp/slog" -) - -func readArtifactZip(artifact []byte) ([]junit.Suite, error) { - z, err := zip.NewReader(bytes.NewReader(artifact), int64(len(artifact))) - if err != nil { - return nil, err - } - - suites := []junit.Suite{} - for _, f := range z.File { - if !strings.HasSuffix(f.Name, ".xml") { - continue - } - - s, err := readJunit(f) - if err != nil { - return nil, fmt.Errorf("error reading %s: %v", f.Name, err) - } - - slog.Info("read", "suites", len(s), "file", f.Name) - - suites = append(suites, s...) - } - - return suites, nil -} - -func readJunit(f *zip.File) ([]junit.Suite, error) { - r, err := f.Open() - if err != nil { - return []junit.Suite{}, err - } - defer r.Close() - - suites, err := junit.IngestReader(r) - if err != nil { - return []junit.Suite{}, err - } - - return suites, nil -} diff --git a/reports/report-template.html b/reports/report-template.html deleted file mode 100644 index fd83032..0000000 --- a/reports/report-template.html +++ /dev/null @@ -1,103 +0,0 @@ - - - - TBD SDKs spec compliance report - - - - - - -
-

web5 spec compliance report

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

{{ $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 }} - -

tbdex spec compliance report

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

{{ $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/reports.go b/reports/reports.go deleted file mode 100644 index a156318..0000000 --- a/reports/reports.go +++ /dev/null @@ -1,160 +0,0 @@ -package reports - -import ( - "embed" - "errors" - htmltemplate "html/template" - "regexp" - "time" - - junit "github.com/joshdk/go-junit" - "golang.org/x/exp/slog" -) - -var ( - ErrNotSupported = errors.New("test not supported by this SDK") - - //go:embed report-template.html - templatesFS embed.FS - - htmlTemplates = htmltemplate.New("") - funcmap = map[string]any{ - "sanatizeHTML": sanatizeHTML, - } -) - -func init() { - htmlTemplates.Funcs(funcmap) - if _, err := htmlTemplates.ParseFS(templatesFS, "report-template.html"); err != nil { - panic(err) - } -} - -type SDKMeta struct { - Name string - Repo string - ArtifactName string - FeatureRegex *regexp.Regexp - VectorRegex *regexp.Regexp - VectorPath string - Type string -} - -type Report struct { - SDK SDKMeta - Results map[string]map[string]Result -} - -type Result struct { - Exists bool - Errors []error - Time time.Duration -} - -func (r Report) IsPassing() bool { - for _, results := range r.Results { - for _, result := range results { - if result.IsSkipped() { - continue - } - - if len(result.Errors) > 0 { - return false - } - } - - } - - return true -} - -func (r Result) IsSkipped() bool { - return len(r.Errors) == 1 && r.Errors[0] == ErrNotSupported -} - -func (r Result) GetEmoji() string { - if !r.Exists { - return "🚧" - } - - if len(r.Errors) == 0 { - return "✅" - } - - return "❌" -} - -func (r Result) GetEmojiAriaLabel() string { - if !r.Exists { - return "In progress" - } - - if len(r.Errors) == 0 { - return "Success" - } - - return "Failed" -} - -func (s SDKMeta) buildReport(suites []junit.Suite) (Report, error) { - results := make(map[string]map[string]Result) - - for feature, vectors := range knownVectors { - results[feature] = make(map[string]Result) - for vector := range vectors { - results[feature][vector] = Result{} - } - } - - for _, suite := range suites { - suiteName := suite.Name - if s.FeatureRegex != nil { - matches := s.FeatureRegex.FindStringSubmatch(suite.Name) - if len(matches) < 2 { - slog.Info("suite did not match feature regex for sdk, skipping", "sdk", s.Name, "suite", suite.Name, "matches", matches) - continue - } - suiteName = matches[1] - slog.Info("regex success for suite", "sdk", s.Name, "before", suite.Name, "after", suiteName) - } - - if knownVectors[suiteName] == nil { - slog.Info("ignoring test suite that does not correspond to known feature", "suite", suiteName) - continue - } - - for _, test := range suite.Tests { - testName := test.Name - if s.VectorRegex != nil { - matches := s.VectorRegex.FindStringSubmatch(test.Name) - if len(matches) < 2 { - slog.Info("test did not match feature regex for sdk, skipping", "sdk", s.Name, "suite", suiteName, "test", test.Name, "matches", matches) - continue - } - testName = matches[1] - slog.Info("regex success for test", "sdk", s.Name, "before", test.Name, "after", testName) - } - - if !knownVectors[suiteName][testName] { - slog.Info("ignoring test that does not correspond to known vector", "suite", suiteName, "test", testName) - continue - } - - errs := []error{} - if test.Error != nil { - errs = append(errs, test.Error) - } - - results[suiteName][testName] = Result{ - Exists: true, - Errors: errs, - Time: test.Duration, - } - } - } - - return Report{ - SDK: s, - Results: results, - }, nil -} diff --git a/reports/sdks.go b/reports/sdks.go deleted file mode 100644 index 7c63355..0000000 --- a/reports/sdks.go +++ /dev/null @@ -1,127 +0,0 @@ -package reports - -import ( - "context" - "fmt" - "io" - "net/http" - "regexp" - "strings" - - "golang.org/x/exp/slog" -) - -var ( - SDKs = []SDKMeta{ - { - Name: "web5-js", - Repo: "TBD54566975/web5-js", - ArtifactName: "junit-results", - FeatureRegex: regexp.MustCompile(`Web5TestVectors(\w+)`), - VectorRegex: regexp.MustCompile(`.* Web5TestVectors\w+ (\w+)`), - VectorPath: "test-vectors", - Type: "web5", - }, - { - Name: "web5-kt", - Repo: "TBD54566975/web5-kt", - ArtifactName: "test-results", - FeatureRegex: regexp.MustCompile(`web5\.sdk\.\w+.Web5TestVectors(\w+)`), - VectorRegex: regexp.MustCompile(`(\w+)\(\)`), - VectorPath: "test-vectors", - Type: "web5", - }, - { - Name: "tbdex-js", - Repo: "TBD54566975/tbdex-js", - ArtifactName: "junit-results", - FeatureRegex: regexp.MustCompile(`TbdexTestVectors(\w+)`), - VectorRegex: regexp.MustCompile(`.* TbdexTestVectors\w+ (\w+)`), - VectorPath: "test-vectors", - Type: "tbdex", - }, - { - Name: "tbdex-kt", - Repo: "TBD54566975/tbdex-kt", - ArtifactName: "test-results", - FeatureRegex: regexp.MustCompile(`tbdex\.sdk\.\w+.TbdexTestVectors(\w+)`), - VectorRegex: regexp.MustCompile(`(\w+)\(\)`), - VectorPath: "test-vectors", - Type: "tbdex", - }, - } -) - -func GetAllReports() ([]Report, error) { - ctx := context.Background() - - var reports []Report - for _, sdk := range SDKs { - artifact, err := downloadArtifact(ctx, sdk) - if err != nil { - return nil, fmt.Errorf("error downloading artifact from %s: %v", sdk.Repo, err) - } - - suites, err := readArtifactZip(artifact) - if err != nil { - return nil, fmt.Errorf("error parsing artifact from %s: %v", sdk.Repo, err) - } - - report, err := sdk.buildReport(suites) - if err != nil { - return nil, fmt.Errorf("error processing data from %s: %v", sdk.Repo, err) - } - - reports = append(reports, report) - } - - return reports, nil -} - -func downloadArtifact(ctx context.Context, sdk SDKMeta) ([]byte, error) { - owner, repo, _ := strings.Cut(sdk.Repo, "/") - artifacts, _, err := gh.Actions.ListArtifacts(ctx, owner, repo, nil) - if err != nil { - slog.Error("error listing artifacts", "") - return nil, fmt.Errorf("error getting artifact list: %v", err) - } - - var artifactURL string - for _, a := range artifacts.Artifacts { - if a.GetWorkflowRun().GetHeadBranch() != "main" { - continue - } - if *a.Name == sdk.ArtifactName { - artifactURL = *a.ArchiveDownloadURL - slog.Info("downloading artifact", "repo", sdk.Repo, "commit", a.GetWorkflowRun().GetHeadSHA()) - break - } - } - - req, err := http.NewRequest(http.MethodGet, artifactURL, nil) - if err != nil { - return nil, err - } - bearer := ghToken - if ghToken == "" { - bearer, err = ghTransport.Token(ctx) - if err != nil { - return nil, fmt.Errorf("error getting github token: %v", err) - } - } - req.Header.Add("Authorization", fmt.Sprintf("Bearer %s", bearer)) - resp, err := http.DefaultClient.Do(req) - if err != nil { - return nil, fmt.Errorf("error making http request to %s: %v", artifactURL, err) - } - defer resp.Body.Close() - - artifact, err := io.ReadAll(resp.Body) - if err != nil { - return nil, fmt.Errorf("error reading response body: %v", err) - } - - slog.Info("downloaded artifact", "sdk", sdk.Repo, "size", len(artifact)) - - return artifact, nil -} diff --git a/reports/static/PressStart2P-Regular.ttf b/reports/static/PressStart2P-Regular.ttf deleted file mode 100644 index 2442aff..0000000 Binary files a/reports/static/PressStart2P-Regular.ttf and /dev/null differ diff --git a/reports/static/favicon.svg b/reports/static/favicon.svg deleted file mode 100644 index 6ae6ca2..0000000 --- a/reports/static/favicon.svg +++ /dev/null @@ -1,26 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/reports/static/styles.css b/reports/static/styles.css deleted file mode 100644 index abb128d..0000000 --- a/reports/static/styles.css +++ /dev/null @@ -1,223 +0,0 @@ -@font-face { - font-family: "Press Start 2P"; - src: url("PressStart2P-Regular.ttf"); -} - -/* Variables */ -:root { - /* Fonts */ - --font-primary: monospace; - --font-decorative: "Press Start 2P", var(--font-primary); - - /* Colors */ - --color-background: #161616; - --color-background-shade: #272727; - --color-background-tint: #1e1e1e; - --color-text: #cecece; - --color-cyan: #24f2ff; - --color-cyan-filter: invert(98%) sepia(87%) saturate(4083%) hue-rotate(127deg) - brightness(100%) contrast(101%); - - /* Layout */ - --layout-max-width: 680px; - --table-min-width: 375px; -} - -/* Reset */ -*, -*::before, -*::after { - box-sizing: border-box; -} - -* { - margin: 0; -} - -html { - font-size: 100%; -} - -body { - line-height: 1.5; - -webkit-font-smoothing: antialiased; -} - -img, -picture, -video, -canvas, -svg { - display: block; - max-width: 100%; -} - -input, -button, -textarea, -select { - font: inherit; - color: inherit; -} - -button { - cursor: pointer; -} - -p, -h1, -h2, -h3, -h4, -h5, -h6 { - overflow-wrap: break-word; -} - -/* Container */ - -body { - background: var(--color-background); - color: var(--color-text); - font-family: var(--font-primary); - padding: 1rem; -} - -main { - max-width: var(--layout-max-width); - margin: 4rem auto; -} - -/* Table */ - -table { - min-width: var(--table-min-width); - width: 100%; - overflow-x: scroll; - border-spacing: 1px; - margin-block: 2rem; -} - -caption, -th, -td { - text-align: start; - word-break: break-all; -} - -th, -td { - padding: 1rem; - vertical-align: unset; -} - -th[scope="row"] { - font-weight: normal; -} - -thead { - background: var(--color-background-tint); -} - -thead th:first-child { - border-start-start-radius: 4px; -} - -thead th:last-child { - border-start-end-radius: 4px; -} - -tbody { - background: var(--color-background-shade); -} - -col[span="1"] { - width: 50%; -} - -col[span="2"] { - width: 25%; -} - -/* Accordion */ - -details { - cursor: pointer; - appearance: none; - -webkit-appearance: none; -} - -summary { - list-style: none; - display: flex; - justify-content: space-between; - align-items: center; - gap: 1rem; -} - -summary::-webkit-details-marker { - display: none; -} - -summary::after { - content: ""; - display: inline-block; - width: 0; - height: 0; - border-inline: 6px solid transparent; - border-top: 6px solid var(--color-text); - transition: 0.2s ease-in-out all; -} - -details[open] summary::after { - transform: rotate(-180deg); -} - -details:not(:has(li)) { - cursor: default; -} - -details:not(:has(li)) summary { - pointer-events: none; -} - -details:not(:has(li)) summary::after { - display: none; -} - -/* List */ - -ul { - padding-inline-start: 1rem; - word-break: break-word; - list-style: square; -} - -li { - margin-block: 1rem; -} - -/* Type */ - -h1 { - font-family: var(--font-decorative); - margin-block: 2rem; -} - -h2 { - font-family: var(--font-decorative); - font-size: 1.25rem; - margin-block: 1rem; -} - -a { - color: var(--color-cyan); - border-bottom: 1px solid; - text-decoration: none; -} - -a[target="_blank"]::after { - content: url('data:image/svg+xml;utf8,'); - margin-inline-start: 0.25rem; - filter: var(--color-cyan-filter); -} diff --git a/reports/sync.go b/reports/sync.go deleted file mode 100644 index 0e7bea6..0000000 --- a/reports/sync.go +++ /dev/null @@ -1,261 +0,0 @@ -package reports - -import ( - "context" - "errors" - "fmt" - "io" - "io/fs" - "os" - "os/exec" - "path/filepath" - "strings" - - "github.com/google/go-github/v57/github" - "golang.org/x/exp/slog" -) - -const ( - vectorUpdateBranch = "vector-update" - gitConfigCredentialHelper = "credential.helper" - vectorUpdateCommitMessage = "update test vectors" -) - -// these should be consts but the library expects a pointer to a string, which cannot be done with a const -var ( - vectorUpdatePRTitle = "Update Test Vectors - Out of Sync" - vectorUpdatePRBody = "Some test vectors were changed or added to the sdk-development repo, so they need to be updated in this repo. This is an automated PR that keeps the test vectors in sync from the [main test-vectors location](https://github.com/TBD54566975/sdk-development/tree/main/web5-test-vectors)" - vectorUpdatePRBaseBranch = "main" -) - -var gitCredentialStoreFile string - -var gitConfig = make(map[string]string) - -func SyncSDK(sdk SDKMeta) error { - slog.Info("syncing vectors", "repo", sdk.Repo) - - tmpdir, err := os.MkdirTemp("", "vector-update") - if err != nil { - return fmt.Errorf("error making a temp dir: %v", err) - } - defer os.RemoveAll(tmpdir) - - // clone sdk.Repo - // check if a vector update branch already exists. - // If vector update branch exists, check it out + rebase on default branch - // if vector update branch does not exist, make it - err = clone(fmt.Sprintf("https://github.com/%s", sdk.Repo), tmpdir) - if err != nil { - return fmt.Errorf("error cloning repo %s: %v", sdk.Repo, err) - } - - // copy ../../web5-test-vectors/* to sdk.VectorPath - err = copyDir("../web5-test-vectors", filepath.Join(tmpdir, sdk.VectorPath)) - if err != nil { - return fmt.Errorf("error copying current vectors to cloned repo: %v", err) - } - - // check if git says the repo has changed - return if it hasn't - err = git("-C", tmpdir, "diff-index", "--quiet", "HEAD") - if err != nil { - exitError := new(exec.ExitError) - if !errors.As(err, &exitError) { - return fmt.Errorf("error checking if repo changed: %v", err) - } - - slog.Info("repo changed after copying current vectors in") - } else { - slog.Info("repo did not change after copying current vectors in, not taking further action") - return nil - } - - // commit - if err := git("-C", tmpdir, "commit", "-a", "-m", vectorUpdateCommitMessage); err != nil { - return fmt.Errorf("error committing changes: %v", err) - } - - // push - if err := git("-C", tmpdir, "push", "origin", vectorUpdateBranch, "--force"); err != nil { - return fmt.Errorf("error pushing changes: %v", err) - } - - // open a pull request if one isn't already open - if err := openPRIfNeeded(sdk.Repo); err != nil { - return fmt.Errorf("error opening PR: %v", err) - } - return nil -} - -// clone the repo and checkout the correct branch and rebase it on main -func clone(url string, dest string) error { - if err := git("clone", url, dest); err != nil { - return err - } - - if err := git("-C", dest, "checkout", vectorUpdateBranch); err != nil { - exitError := &exec.ExitError{} - if !errors.As(err, &exitError) { - return err - } - - err = git("-C", dest, "checkout", "-b", vectorUpdateBranch) - if err != nil { - return err - } - } - - if err := git("-C", dest, "rebase", "main"); err != nil { - slog.Warn("rebase failed") - return err - } - - return nil -} - -func git(args ...string) error { - cmd := exec.Command("git", args...) - cmd.Stderr = os.Stderr - cmd.Stdout = os.Stdout - cmd.Env = []string{fmt.Sprintf("GIT_CONFIG_COUNT=%d", len(gitConfig))} - i := 0 - for k, v := range gitConfig { - cmd.Env = append(cmd.Env, - fmt.Sprintf("GIT_CONFIG_KEY_%d=%s", i, k), - fmt.Sprintf("GIT_CONFIG_VALUE_%d=%s", i, v), - ) - i = i + 1 - } - - slog.Info("invoking", "git", args) - if err := cmd.Run(); err != nil { - exitError := &exec.ExitError{} - if !errors.As(err, &exitError) { - return err - } - slog.Info("command did not succeed", "exit_code", exitError.ExitCode()) - return err - } - - return nil -} - -func copyDir(src, dest string) error { - return filepath.WalkDir(src, func(path string, _ fs.DirEntry, err error) error { - if err != nil { - slog.Error("error from walkdir") - return err - } - - if !strings.HasSuffix(path, ".json") { - return nil - } - - relativePath, _ := filepath.Rel(src, path) - destPath := filepath.Join(dest, relativePath) - - slog.Info("mkdir", "dir", filepath.Dir(destPath)) - err = os.MkdirAll(filepath.Dir(destPath), 0755) - if err != nil && !errors.Is(err, os.ErrExist) { - slog.Error("error creating dir", "dir", destPath) - return err - } - - s, err := os.Open(path) - if err != nil { - slog.Error("error opening source vector", "file", path) - return err - } - defer s.Close() - - d, err := os.Create(destPath) - if err != nil { - slog.Error("error opening dest vector", "file", destPath) - return err - } - defer d.Close() - - _, err = io.Copy(d, s) - if err != nil { - slog.Error("error copying vector contents", "src", path, "dest", destPath) - return err - } - - if err := git("-C", dest, "add", destPath); err != nil { - slog.Error("error git add'ing vector", "file", destPath) - return err - } - - slog.Info("copied vector", "file", relativePath) - return nil - }) -} - -func ConfigureGitAuth() error { - slog.Info("telling git about our github token") - - f, err := os.CreateTemp("", "git-credentials") - if err != nil { - return err - } - gitCredentialStoreFile = f.Name() - - if ghTransport == nil { - panic("syncing vecotrs with a PAT not supported. See reports/README.md for instructions to create a GitHub app.") - } - authToken, err := ghTransport.Token(context.Background()) - if err != nil { - slog.Error("error getting github auth token") - return err - } - - cmd := exec.Command("git", "credential-store", "--file", gitCredentialStoreFile, "store") - cmd.Stdin = strings.NewReader(fmt.Sprintf("protocol=https\nhost=github.com\nusername=%s\npassword=%s", fmt.Sprintf("%s[bot]", ghAppName), authToken)) - cmd.Stdout = os.Stdout - cmd.Stderr = os.Stderr - if err := cmd.Run(); err != nil { - return err - } - - gitConfig[gitConfigCredentialHelper] = fmt.Sprintf("store --file %s", gitCredentialStoreFile) - - return nil -} - -func CleanupGitAuth() error { - return os.Remove(gitCredentialStoreFile) -} - -func openPRIfNeeded(repo string) error { - ctx := context.Background() - owner, repo, _ := strings.Cut(repo, "/") - head := fmt.Sprintf("%s:%s", owner, vectorUpdateBranch) - existing, _, err := gh.PullRequests.List(ctx, owner, repo, &github.PullRequestListOptions{ - State: "open", - Head: head, - }) - if err != nil { - slog.Error("error checking for existing PR") - return err - } - - if len(existing) > 0 { - slog.Info("a PR for that branch already exists, not opening a new one", "pr", existing[0].GetURL()) - return nil - } - - pr, _, err := gh.PullRequests.Create(ctx, owner, repo, &github.NewPullRequest{ - Title: &vectorUpdatePRTitle, - Body: &vectorUpdatePRBody, - Head: &head, - Base: &vectorUpdatePRBaseBranch, - }) - if err != nil { - slog.Error("error creating PR") - return err - } - - slog.Info("opened PR", "pr", pr.GetURL()) - - return nil -} diff --git a/reports/test.html b/reports/test.html deleted file mode 100644 index b001420..0000000 --- a/reports/test.html +++ /dev/null @@ -1,133 +0,0 @@ - - - - - web5 spec compliance report - - - - - -
-

web5 spec compliance report

- -

Credentials

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
test vectorweb5-jsweb5-kt
create -
- 🚧 -
    - -
-
-
- -
    - -
-
verify -
- 🚧 -
    - -
-
-
- -
    - -
-
- -

PresentationExchange

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
testweb5-jsweb5-kt
create_presentation_from_credentials -
- 🚧 -
    - -
-
-
- 🚧 -
    -
  • najdsa adadsa asdsadsa dasda
  • - -
-
-
select_credentials -
- -
    - -
-
-
- -
    - -
-
-
- - - \ No newline at end of file diff --git a/reports/vectors.go b/reports/vectors.go deleted file mode 100644 index 8b18f29..0000000 --- a/reports/vectors.go +++ /dev/null @@ -1,48 +0,0 @@ -package reports - -import ( - "io/fs" - "path/filepath" - "strings" -) - -var knownVectors = readKnownVectors() - -func readKnownVectors() map[string]map[string]bool { - knownVectors := make(map[string]map[string]bool) - dir := "../web5-test-vectors" - err := filepath.Walk(dir, func(path string, info fs.FileInfo, err error) error { - if !strings.HasSuffix(path, ".json") || strings.HasSuffix(path, ".schema.json") { - return nil - } - - feature, vector := parseVectorPath(strings.TrimPrefix(path, dir)) - if knownVectors[feature] == nil { - knownVectors[feature] = make(map[string]bool) - } - knownVectors[feature][vector] = true - - return nil - }) - - if err != nil { - panic(err) - } - - return knownVectors -} - -func parseVectorPath(path string) (feature string, vector string) { - feature, vector = filepath.Split(path) - vector = strings.TrimSuffix(vector, ".json") - feature = strings.Trim(feature, "/") - - featureWords := []string{} - for _, word := range strings.Split(feature, "_") { - featureWords = append(featureWords, strings.Title(word)) // TODO: strings.Title is deprecated - } - - feature = strings.Join(featureWords, "") - - return feature, vector -} diff --git a/scripts/github/.env.example b/scripts/github/.env.example deleted file mode 100644 index b27467e..0000000 --- a/scripts/github/.env.example +++ /dev/null @@ -1,4 +0,0 @@ -# environment info -GH_OWNER=TBD54566975 -GH_REPO= -GH_TOKEN= \ No newline at end of file diff --git a/scripts/github/.gitignore b/scripts/github/.gitignore deleted file mode 100644 index 37d7e73..0000000 --- a/scripts/github/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -node_modules -.env diff --git a/scripts/github/README.md b/scripts/github/README.md deleted file mode 100644 index 6579b40..0000000 --- a/scripts/github/README.md +++ /dev/null @@ -1,28 +0,0 @@ -# GitHub Repository Scripts - -This directory contains scripts that help with individual SDK repo management. - -## Scripts Description - -| Script Name | Description | -| --------------------------- | ----------------------------------------------------------------------------- | -| `npm run create-labels` | Creates GitHub labels from a predefined list if they don't already exist. | -| `npm run create-milestones` | Creates GitHub milestones from a predefined list if they don't already exist. | - -## Installation and Usage - -To run the scripts, first install the necessary dependencies: - -```bash -npm install -``` - -## Environment Variables - -Before running the scripts, ensure that a `.env` file exists and has the following variables set. You can copy `.env.example`: - -| Environment Variable | Description | -| -------------------- | -------------------------------------------- | -| `GH_TOKEN` | Your GitHub personal access token. | -| `GH_OWNER` | The owner username of the GitHub repository. | -| `GH_REPO` | The name of the GitHub repository. | diff --git a/scripts/github/github-create-labels.js b/scripts/github/github-create-labels.js deleted file mode 100644 index b8c6f7a..0000000 --- a/scripts/github/github-create-labels.js +++ /dev/null @@ -1,81 +0,0 @@ -import 'dotenv/config'; -import { Octokit } from '@octokit/core'; - -const octokit = new Octokit({ - auth: process.env['GH_TOKEN'] // Your GitHub token from environment variable -}); - -const owner = process.env['GH_OWNER']; // Owner of the repository from environment variable -const repo = process.env['GH_REPO']; // Name of the repository from environment variable - -const labelsToCreate = [ - { "name": "dsa", "color": "7FDBFF", "description": "Cryptographic Digital Signature Algorithms" }, - { "name": "key-mgmt", "color": "0074D9", "description": "Key Management" }, - { "name": "did:web", "color": "2ECC40", "description": "did:web" }, - { "name": "did:jwk", "color": "FFDC00", "description": "did:jwk" }, - { "name": "did:dht", "color": "FF851B", "description": "did:dht" }, - { "name": "did:key", "color": "F012BE", "description": "did:key" }, - { "name": "did:ion", "color": "B10DC9", "description": "did:ion" }, - { "name": "did-doc-validation", "color": "3D9970", "description": "DID Document & Resolution Validation" }, - { "name": "w3c-vc-dm-1.1", "color": "39CCCC", "description": "W3C Verifiable Credential Data Model 1.1" }, - { "name": "w3c-vc-dm-2.0", "color": "01FF70", "description": "W3C Verifiable Credential Data Model 2.0" }, - { "name": "sd-jwt", "color": "85144B", "description": "SD-JWT / SD-JWT-VC" }, - { "name": "pd-v2", "color": "F9A602", "description": "Presentation Definition V2" }, - { "name": "tbdex-message", "color": "70DB93", "description": "tbDEX Message" }, - { "name": "tbdex-resource", "color": "5B2C6F", "description": "tbDEX Resource" }, - { "name": "tbdex-offering", "color": "E59866", "description": "tbDEX Offering Resource" }, - { "name": "tbdex-rfq", "color": "1F618D", "description": "tbDEX RFQ Message" }, - { "name": "tbdex-quote", "color": "186A3B", "description": "tbDEX Quote Message" }, - { "name": "tbdex-order", "color": "28B463", "description": "tbDEX Order Message" }, - { "name": "tbdex-orderstatus", "color": "D68910", "description": "tbDEX Order-Status Message" }, - { "name": "tbdex-close", "color": "34495E", "description": "tbDEX Close Message" }, - { "name": "tbdex-server", "color": "3498DB", "description": "HTTP server for tbDEX PFIs " }, - { "name": "tbdex-client", "color": "E74C3C", "description": "HTTP client for tbDEX wallets" } -]; - -async function fetchExistingLabels() { - const response = await octokit.request('GET /repos/{owner}/{repo}/labels', { - owner, - repo, - headers: { - 'X-GitHub-Api-Version': '2022-11-28' - } - }); - - return response.data.map(label => label.name); -} - -async function createLabels() { - const existingLabels = await fetchExistingLabels(); - - for (const label of labelsToCreate) { - // Check if the label already exists - if (existingLabels.includes(label.name)) { - console.log(`Label "${label.name}" already exists.`); - continue; // Skip creating this label - } - - try { - const response = await octokit.request('POST /repos/{owner}/{repo}/labels', { - owner, - repo, - name: label.name, - color: label.color, - description: label.description, - headers: { - 'X-GitHub-Api-Version': '2022-11-28' - } - }); - - if (response.status === 201) { - console.log(`Created label: ${label.name}`); - } else { - console.log(`Failed to create label: ${label.name}. Status: ${response.status}`); - } - } catch (error) { - console.error(`Failed to create label: ${label.name}. Error: ${error.message}`); - } - } -} - -createLabels().catch(console.error); diff --git a/scripts/github/github-create-milestones.js b/scripts/github/github-create-milestones.js deleted file mode 100644 index abbec67..0000000 --- a/scripts/github/github-create-milestones.js +++ /dev/null @@ -1,60 +0,0 @@ -import 'dotenv/config'; -import { Octokit } from '@octokit/core'; - -const octokit = new Octokit({ - auth: process.env['GH_TOKEN'] // Your GitHub token from environment variable -}); - -const owner = process.env['GH_OWNER']; // Owner of the repository from environment variable -const repo = process.env['GH_REPO']; // Name of the repository from environment variable - -const newMilestones = [ - { "title": "Eagle" }, - { "title": "ABC" } - // Add more milestones here if needed -]; - -async function fetchExistingMilestones() { - const response = await octokit.request('GET /repos/{owner}/{repo}/milestones', { - owner, - repo, - headers: { - 'X-GitHub-Api-Version': '2022-11-28' - } - }); - - return response.data.map(milestone => milestone.title); -} - -async function createMilestones() { - const existingMilestones = await fetchExistingMilestones(); - - for (const milestone of newMilestones) { - // Check if the milestone already exists - if (existingMilestones.includes(milestone.title)) { - console.log(`Milestone "${milestone.title}" already exists.`); - continue; // Skip creating this milestone - } - - try { - const response = await octokit.request('POST /repos/{owner}/{repo}/milestones', { - owner, - repo, - title: milestone.title, - headers: { - 'X-GitHub-Api-Version': '2022-11-28' - } - }); - - if (response.status === 201) { - console.log(`Created milestone: ${milestone.title}`); - } else { - console.log(`Failed to create milestone: ${milestone.title}. Status: ${response.status}`); - } - } catch (error) { - console.error(`Failed to create milestone: ${milestone.title}. Error: ${error.message}`); - } - } -} - -createMilestones().catch(console.error); diff --git a/scripts/github/package-lock.json b/scripts/github/package-lock.json deleted file mode 100644 index 6875d28..0000000 --- a/scripts/github/package-lock.json +++ /dev/null @@ -1,152 +0,0 @@ -{ - "name": "github", - "lockfileVersion": 3, - "requires": true, - "packages": { - "": { - "dependencies": { - "@octokit/core": "5.0.1", - "dotenv": "16.3.1" - } - }, - "node_modules/@octokit/auth-token": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/@octokit/auth-token/-/auth-token-4.0.0.tgz", - "integrity": "sha512-tY/msAuJo6ARbK6SPIxZrPBms3xPbfwBrulZe0Wtr/DIY9lje2HeV1uoebShn6mx7SjCHif6EjMvoREj+gZ+SA==", - "engines": { - "node": ">= 18" - } - }, - "node_modules/@octokit/core": { - "version": "5.0.1", - "resolved": "https://registry.npmjs.org/@octokit/core/-/core-5.0.1.tgz", - "integrity": "sha512-lyeeeZyESFo+ffI801SaBKmCfsvarO+dgV8/0gD8u1d87clbEdWsP5yC+dSj3zLhb2eIf5SJrn6vDz9AheETHw==", - "dependencies": { - "@octokit/auth-token": "^4.0.0", - "@octokit/graphql": "^7.0.0", - "@octokit/request": "^8.0.2", - "@octokit/request-error": "^5.0.0", - "@octokit/types": "^12.0.0", - "before-after-hook": "^2.2.0", - "universal-user-agent": "^6.0.0" - }, - "engines": { - "node": ">= 18" - } - }, - "node_modules/@octokit/endpoint": { - "version": "9.0.2", - "resolved": "https://registry.npmjs.org/@octokit/endpoint/-/endpoint-9.0.2.tgz", - "integrity": "sha512-qhKW8YLIi+Kmc92FQUFGr++DYtkx/1fBv+Thua6baqnjnOsgBYJDCvWZR1YcINuHGOEQt416WOfE+A/oG60NBQ==", - "dependencies": { - "@octokit/types": "^12.0.0", - "is-plain-object": "^5.0.0", - "universal-user-agent": "^6.0.0" - }, - "engines": { - "node": ">= 18" - } - }, - "node_modules/@octokit/graphql": { - "version": "7.0.2", - "resolved": "https://registry.npmjs.org/@octokit/graphql/-/graphql-7.0.2.tgz", - "integrity": "sha512-OJ2iGMtj5Tg3s6RaXH22cJcxXRi7Y3EBqbHTBRq+PQAqfaS8f/236fUrWhfSn8P4jovyzqucxme7/vWSSZBX2Q==", - "dependencies": { - "@octokit/request": "^8.0.1", - "@octokit/types": "^12.0.0", - "universal-user-agent": "^6.0.0" - }, - "engines": { - "node": ">= 18" - } - }, - "node_modules/@octokit/openapi-types": { - "version": "19.0.2", - "resolved": "https://registry.npmjs.org/@octokit/openapi-types/-/openapi-types-19.0.2.tgz", - "integrity": "sha512-8li32fUDUeml/ACRp/njCWTsk5t17cfTM1jp9n08pBrqs5cDFJubtjsSnuz56r5Tad6jdEPJld7LxNp9dNcyjQ==" - }, - "node_modules/@octokit/request": { - "version": "8.1.5", - "resolved": "https://registry.npmjs.org/@octokit/request/-/request-8.1.5.tgz", - "integrity": "sha512-zVKbNbX1xUluD9ZR4/tPs1yuYrK9xeh5fGZUXA6u04XGsTvomg0YO8/ZUC0FqAd49hAOEMFPAVUTh+2lBhOhLA==", - "dependencies": { - "@octokit/endpoint": "^9.0.0", - "@octokit/request-error": "^5.0.0", - "@octokit/types": "^12.0.0", - "is-plain-object": "^5.0.0", - "universal-user-agent": "^6.0.0" - }, - "engines": { - "node": ">= 18" - } - }, - "node_modules/@octokit/request-error": { - "version": "5.0.1", - "resolved": "https://registry.npmjs.org/@octokit/request-error/-/request-error-5.0.1.tgz", - "integrity": "sha512-X7pnyTMV7MgtGmiXBwmO6M5kIPrntOXdyKZLigNfQWSEQzVxR4a4vo49vJjTWX70mPndj8KhfT4Dx+2Ng3vnBQ==", - "dependencies": { - "@octokit/types": "^12.0.0", - "deprecation": "^2.0.0", - "once": "^1.4.0" - }, - "engines": { - "node": ">= 18" - } - }, - "node_modules/@octokit/types": { - "version": "12.2.0", - "resolved": "https://registry.npmjs.org/@octokit/types/-/types-12.2.0.tgz", - "integrity": "sha512-ZkdHqHJdifVndN7Pha10+qrgAjy3AcG//Vmjr/o5UFuTiYCcMhqDj39Yr9VM9zJ/42KO2xAYhV7cvLnLI9Kvwg==", - "dependencies": { - "@octokit/openapi-types": "^19.0.2" - } - }, - "node_modules/before-after-hook": { - "version": "2.2.3", - "resolved": "https://registry.npmjs.org/before-after-hook/-/before-after-hook-2.2.3.tgz", - "integrity": "sha512-NzUnlZexiaH/46WDhANlyR2bXRopNg4F/zuSA3OpZnllCUgRaOF2znDioDWrmbNVsuZk6l9pMquQB38cfBZwkQ==" - }, - "node_modules/deprecation": { - "version": "2.3.1", - "resolved": "https://registry.npmjs.org/deprecation/-/deprecation-2.3.1.tgz", - "integrity": "sha512-xmHIy4F3scKVwMsQ4WnVaS8bHOx0DmVwRywosKhaILI0ywMDWPtBSku2HNxRvF7jtwDRsoEwYQSfbxj8b7RlJQ==" - }, - "node_modules/dotenv": { - "version": "16.3.1", - "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-16.3.1.tgz", - "integrity": "sha512-IPzF4w4/Rd94bA9imS68tZBaYyBWSCE47V1RGuMrB94iyTOIEwRmVL2x/4An+6mETpLrKJ5hQkB8W4kFAadeIQ==", - "engines": { - "node": ">=12" - }, - "funding": { - "url": "https://github.com/motdotla/dotenv?sponsor=1" - } - }, - "node_modules/is-plain-object": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/is-plain-object/-/is-plain-object-5.0.0.tgz", - "integrity": "sha512-VRSzKkbMm5jMDoKLbltAkFQ5Qr7VDiTFGXxYFXXowVj387GeGNOCsOH6Msy00SGZ3Fp84b1Naa1psqgcCIEP5Q==", - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/once": { - "version": "1.4.0", - "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", - "integrity": "sha512-lNaJgI+2Q5URQBkccEKHTQOPaXdUxnZZElQTZY0MFUAuaEqe1E+Nyvgdz/aIyNi6Z9MzO5dv1H8n58/GELp3+w==", - "dependencies": { - "wrappy": "1" - } - }, - "node_modules/universal-user-agent": { - "version": "6.0.1", - "resolved": "https://registry.npmjs.org/universal-user-agent/-/universal-user-agent-6.0.1.tgz", - "integrity": "sha512-yCzhz6FN2wU1NiiQRogkTQszlQSlpWaw8SvVegAc+bDxbzHgh1vX8uIe8OYyMH6DwH+sdTJsgMl36+mSMdRJIQ==" - }, - "node_modules/wrappy": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", - "integrity": "sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ==" - } - } -} diff --git a/scripts/github/package.json b/scripts/github/package.json deleted file mode 100644 index ccc50c8..0000000 --- a/scripts/github/package.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "type": "module", - "scripts": { - "create-labels": "node github-create-labels.js", - "create-milestones": "node github-create-milestones.js" - }, - "dependencies": { - "@octokit/core": "5.0.1", - "dotenv": "16.3.1" - } -} \ No newline at end of file diff --git a/test-vectors/README.md b/test-vectors/README.md index 3aa93c4..b23ce5e 100644 --- a/test-vectors/README.md +++ b/test-vectors/README.md @@ -49,9 +49,15 @@ Should `errors` be set to `true`, the `output` field may optionally be used to i ## Creating New Test Vector Full Walkthrough -### Step 1: Create New Test Vector +### Step 1: Pull down the sdk repo with submouldes you are working with +1. git clone --recurse-submodules git@github.com:TBD54566975/web5-kt.git -1. Navigate to the GitHub repository: sdk-development[https://github.com/TBD54566975/sdk-development/tree/main/web5-test-vectors] +Or if you already cloned it, and just want to pull down the submodules: +1. git submodule update --init + +### Step 2: Create New Test Vector in submodule folder + +1. Navigate to web5-spec in your local directory 2. Create a new folder and JSON file with the structure example_feature/hello_world.json. @@ -71,13 +77,9 @@ Should `errors` be set to `true`, the `output` field may optionally be used to i } ``` -### Step 2: Copy JSON to Local Test-Vectors Directory - -Copy the `hello_world.json` file from `example_feature` directory into your SDK's test-vectors folder. make sure the file -and file name are both identical to that in the sdk-development repo. - -### Step 3: Create Unit Test in web5-kt +### Step 3: Create Unit Test +#### in Web5-kt 1. In the `web5-kt` project, create a new unit test class. 1. Name the class following the given pattern: @@ -94,13 +96,13 @@ and file name are both identical to that in the sdk-development repo. class Web5TestVectorsExampleFeature { @Test fun hello_world() { - val testVectors = mapper.readValue(File("../test-vectors/example_feature/hello_world.json"), typeRef) + val testVectors = mapper.readValue(File("../web5-spec/test-vectors/example_feature/hello_world.json"), typeRef) assertEquals(testVectors.vectors[0].input, testVectors.vectors[0].output) } } ``` -### Step 4: Create Unit Test in web5-js +#### in Web5-js 1. In the `web5-js` project, create a new unit test class. @@ -115,7 +117,7 @@ class Web5TestVectorsExampleFeature { 1. Implement the class and test method as follows: ```javascript - import ExampleFeatureHelloWorldSpecJson from '../../../test-vectors/example_feature/hello_world.json' assert { type: 'json' }; + import ExampleFeatureHelloWorldSpecJson from '../../../web5-spec/test-vectors/example_feature/hello_world.json' assert { type: 'json' }; describe('Web5TestVectorsExampleFeature', () => { it('hello_world', async () => { @@ -125,10 +127,10 @@ class Web5TestVectorsExampleFeature { }); ``` -### Step 5: Completion +### Step 4: Completion -* Once the above steps are completed, the `sdk-development` repository will automatically detect the new test vectors by consuming artifacts generated by a github action (No action by you required) -* Once the new vector merges into the sdk-development repo, PRs will be automatically opened on all SDKs that don't have it yet. -* The system will indicate whether the test passes or fails with a checkmark or an 'x' on the [test vectors dashboard](https://tbd54566975.github.io/sdk-development/). +* Create a pr for the web5-spec submodules if you added new test vectors +* Create a pr for the web5-* sdk to add the test vector new unit tests you created +* The system will indicate whether the test passes or fails with a checkmark or an 'x' on the [sdk-report-runner](https://tbd54566975.github.io/sdk-report-runner/). Your new test vector system is now set up and ready for use!