generated from TBD54566975/tbd-project-template
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
open PRs on known SDKs when the vectors change
- Loading branch information
1 parent
9482707
commit eab9104
Showing
9 changed files
with
402 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
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 ( | ||
gh *github.Client | ||
ghTransport *ghinstallation.Transport | ||
ghAppName = os.Getenv("CICD_ROBOT_GITHUB_APP_NAME") | ||
ghUserName = fmt.Sprintf("%s[bot]", ghAppName) | ||
ghAppPrivateKey = os.Getenv("CICD_ROBOT_GITHUB_APP_PRIVATE_KEY") | ||
) | ||
|
||
func init() { | ||
ghAppID, err := strconv.ParseInt(os.Getenv("CICD_ROBOT_GITHUB_APP_ID"), 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(os.Getenv("CICD_ROBOT_GITHUB_APP_INSTALLATION_ID"), 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 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.