Skip to content

Commit

Permalink
Merge branch 'main' into issue_76
Browse files Browse the repository at this point in the history
  • Loading branch information
andresuribe87 committed Jan 8, 2024
2 parents c72bfbb + 001fea0 commit 609e1ba
Show file tree
Hide file tree
Showing 90 changed files with 2,125 additions and 7,352 deletions.
32 changes: 32 additions & 0 deletions .github/workflows/build-report.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
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'
52 changes: 0 additions & 52 deletions .github/workflows/build.yaml

This file was deleted.

23 changes: 0 additions & 23 deletions .github/workflows/pages.yaml

This file was deleted.

24 changes: 0 additions & 24 deletions .github/workflows/self-test.yaml

This file was deleted.

23 changes: 23 additions & 0 deletions .github/workflows/sync-vectors.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: sync vectors

on:
push:
branches: [main]
paths:
- 'web5-test-vectors/**/*.json'
workflow_dispatch:

jobs:
build-report:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-go@v4
- name: sync vectors
run: cd reports && go run ./cmd/sync-vectors
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 }}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
_site
2 changes: 2 additions & 0 deletions .markdownlint-cli2.yaml
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
config:
line-length: false
no-duplicate-heading:
siblings_only: true
8 changes: 8 additions & 0 deletions reports/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# SDK Feature Report Generator

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`
30 changes: 30 additions & 0 deletions reports/cmd/build-html/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
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)
}
}
33 changes: 33 additions & 0 deletions reports/cmd/sync-vectors/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
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)
}
}
56 changes: 56 additions & 0 deletions reports/github.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
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")

gh *github.Client
ghTransport *ghinstallation.Transport

ghUserName = fmt.Sprintf("%s[bot]", ghAppName)
)

func init() {
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+%[email protected]", user.GetID(), ghUserName)
gitConfig["user.name"] = ghUserName
}
17 changes: 17 additions & 0 deletions reports/go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
module github.com/TBD54566975/sdk-development/reports

go 1.20

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
)
29 changes: 29 additions & 0 deletions reports/go.sum
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
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=
2 changes: 1 addition & 1 deletion test-harness/reports/html.go → reports/html.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ type htmlTemplateInput struct {
}

func WriteHTML(reports []Report, filename string) error {
slog.Info("writing html report")
slog.Info("writing html report", "reports", len(reports))

testmap := make(map[string]map[string]bool)
for _, report := range reports {
Expand Down
Loading

0 comments on commit 609e1ba

Please sign in to comment.