From 93b45d39f4550f8f4d5bc2ac1012da1a80fad78f Mon Sep 17 00:00:00 2001 From: Finn <139806439+finn-tbd@users.noreply.github.com> Date: Tue, 9 Jan 2024 08:40:34 -0800 Subject: [PATCH 1/2] Allow authenticating to GitHub with a Personal Access Token for ease of use while testing (#97) --- reports/README.md | 14 +++++++++++--- reports/github.go | 8 ++++++++ reports/sdks.go | 9 ++++++--- reports/sync.go | 3 +++ 4 files changed, 28 insertions(+), 6 deletions(-) diff --git a/reports/README.md b/reports/README.md index f7f25d3..80f0766 100644 --- a/reports/README.md +++ b/reports/README.md @@ -2,7 +2,15 @@ This tool reads junit XML reports from different SDKs and generates an HTML report showing which SDKs support which features. -## Current Status - `./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` +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. diff --git a/reports/github.go b/reports/github.go index 9065f5c..3b484e1 100644 --- a/reports/github.go +++ b/reports/github.go @@ -18,6 +18,8 @@ var ( 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 @@ -25,6 +27,12 @@ var ( ) 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") diff --git a/reports/sdks.go b/reports/sdks.go index 6cf0620..d638569 100644 --- a/reports/sdks.go +++ b/reports/sdks.go @@ -82,9 +82,12 @@ func downloadArtifact(ctx context.Context, sdk SDKMeta) ([]byte, error) { if err != nil { return nil, err } - bearer, err := ghTransport.Token(ctx) - if err != nil { - return nil, fmt.Errorf("error getting github token: %v", 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) diff --git a/reports/sync.go b/reports/sync.go index 388bc9b..0e7bea6 100644 --- a/reports/sync.go +++ b/reports/sync.go @@ -200,6 +200,9 @@ func ConfigureGitAuth() error { } 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") From 6b3ef98225e39188f77bada6f51aecf89eb205ba Mon Sep 17 00:00:00 2001 From: Andres Uribe Date: Tue, 9 Jan 2024 11:57:10 -0500 Subject: [PATCH 2/2] Standardize resolution for "empty". (#77) * Standardize resolution to use `{}` for empty. * Update resolve.json * Make didDocument have null values --- web5-test-vectors/did_jwk/resolve.json | 4 ++-- web5-test-vectors/did_web/resolve.json | 21 +++++++++++++++------ 2 files changed, 17 insertions(+), 8 deletions(-) diff --git a/web5-test-vectors/did_jwk/resolve.json b/web5-test-vectors/did_jwk/resolve.json index 51fe927..b1aec6b 100644 --- a/web5-test-vectors/did_jwk/resolve.json +++ b/web5-test-vectors/did_jwk/resolve.json @@ -101,7 +101,7 @@ }, "didDocumentMetadata": {} }, - "errors": false + "errors": true } ] -} \ No newline at end of file +} diff --git a/web5-test-vectors/did_web/resolve.json b/web5-test-vectors/did_web/resolve.json index 3288428..a4b6633 100644 --- a/web5-test-vectors/did_web/resolve.json +++ b/web5-test-vectors/did_web/resolve.json @@ -12,10 +12,11 @@ } }, "output": { - "didResolutionMetadata": {}, "didDocument": { "id": "did:web:example.com" - } + }, + "didDocumentMetadata": {}, + "didResolutionMetadata": {} } }, { @@ -29,10 +30,11 @@ } }, "output": { - "didResolutionMetadata": {}, "didDocument": { "id": "did:web:w3c-ccg.github.io:user:alice" - } + }, + "didDocumentMetadata": {}, + "didResolutionMetadata": {} } }, { @@ -46,10 +48,11 @@ } }, "output": { - "didResolutionMetadata": {}, "didDocument": { "id": "did:web:example.com%3A3000:user:alice" - } + }, + "didDocumentMetadata": {}, + "didResolutionMetadata": {} } }, { @@ -58,6 +61,8 @@ "didUri": "did:dht:gb46emk73wkenrut43ii67a3o5qctojcaucebth7r83pst6yeh8o" }, "output": { + "didDocument": null, + "didDocumentMetadata": {}, "didResolutionMetadata": { "error": "methodNotSupported" } @@ -70,6 +75,8 @@ "didUri": "did:web:doesnotexist.com" }, "output": { + "didDocument": null, + "didDocumentMetadata": {}, "didResolutionMetadata": { "error": "notFound" } @@ -82,6 +89,8 @@ "didUri": "did:web:invalidcharø.com" }, "output": { + "didDocument": null, + "didDocumentMetadata": {}, "didResolutionMetadata": { "error": "invalidDid" }