Skip to content

Commit

Permalink
Merge branch 'master' into release/2024-04-11
Browse files Browse the repository at this point in the history
  • Loading branch information
ChiTimesChi committed Apr 11, 2024
2 parents 71153a9 + da2c6c3 commit c5a9c25
Show file tree
Hide file tree
Showing 404 changed files with 52,657 additions and 23,467 deletions.
5 changes: 1 addition & 4 deletions .github/workflows/go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,10 @@ jobs:
steps:
- uses: actions/checkout@v4
with:
# TODO: this can be shorter, maybe 500-1,000? This may be slower (see: https://github.com/CocoaPods/CocoaPods/issues/4989#issuecomment-193772935)
fetch-depth: 0
# TODO: is this neccesary?
submodules: 'recursive'

# note: after this action is pushed, whatever this ends up being should go back to latest.
- uses: docker://ghcr.io/synapsecns/sanguine/git-changes-action:07a4696bbbafbba2d3ad7ee828b4c8adb21b4d20
- uses: docker://ghcr.io/synapsecns/sanguine/git-changes-action:2806c6873f55ef6840e4ebea43a0f27b98f95516
id: filter_go
with:
github_token: ${{ secrets.WORKFLOW_PAT || secrets.GITHUB_TOKEN }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/goreleaser-actions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ jobs:
fetch-depth: 0
submodules: 'recursive'

- uses: docker://ghcr.io/synapsecns/sanguine/git-changes-action:07a4696bbbafbba2d3ad7ee828b4c8adb21b4d20
- uses: docker://ghcr.io/synapsecns/sanguine/git-changes-action:2806c6873f55ef6840e4ebea43a0f27b98f95516
id: filter_go
with:
github_token: ${{ secrets.WORKFLOW_PAT || secrets.GITHUB_TOKEN }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
- name: Run ShellCheck
uses: ludeeus/action-shellcheck@master
with:
ignore_paths: ./contrib/terraform-provider-iap/scripts/add-tfmac.sh ./contrib/terraform-provider-helmproxy/scripts/add-tfmac.sh ./contrib/terraform-provider-kubeproxy/scripts/add-tfmac.sh
ignore_paths: ./contrib/terraform-provider-iap/scripts/add-tfmac.sh ./contrib/terraform-provider-helmproxy/scripts/add-tfmac.sh ./contrib/terraform-provider-kubeproxy/scripts/add-tfmac.sh ./contrib/scripts/txdecoder.sh

- name: Validate renovate
uses: rinchsan/renovate-config-validator@v0.0.12
Expand Down
9 changes: 0 additions & 9 deletions .github/workflows/scan.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,3 @@ jobs:
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
- name: 'Qodana Scan'
uses: JetBrains/qodana-action@main
env:
QODANA_TOKEN: ${{ secrets.QODANA_TOKEN }}
with:
args: --baseline,qodana.sarif.json
post-pr-comment: false
use-annotations: false
upload-result: true
4 changes: 2 additions & 2 deletions .github/workflows/solidity.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ on:
- 'packages/contracts-core/**'
- 'packages/contracts-rfq/**'
- '.github/workflows/solidity.yml'
- 'packages/contracts-communication'
- 'packages/contracts-communication/**'
- 'packages/solidity-devops/**'
push:
paths:
- 'packages/contracts-core/**'
- 'packages/contracts-rfq/**'
- 'packages/contracts-communication'
- 'packages/contracts-communication/**'
- 'packages/solidity-devops/**'
- '.github/workflows/solidity.yml'

Expand Down
2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v16.14.0
v18.17.0
1 change: 1 addition & 0 deletions agents/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ require (
github.com/status-im/keycard-go v0.2.0 // indirect
github.com/uptrace/opentelemetry-go-extra/otelutil v0.2.3 // indirect
github.com/uptrace/opentelemetry-go-extra/otelzap v0.2.3 // indirect
github.com/valyala/fastjson v1.6.4 // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20240108191215-35c7eff3a6b1 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240108191215-35c7eff3a6b1 // indirect
gopkg.in/natefinch/lumberjack.v2 v2.0.0 // indirect
Expand Down
2 changes: 2 additions & 0 deletions agents/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -1147,6 +1147,8 @@ github.com/valyala/fasthttp v1.6.0/go.mod h1:FstJa9V+Pj9vQ7OJie2qMHdwemEDaDiSdBn
github.com/valyala/fasthttp v1.34.0/go.mod h1:epZA5N+7pY6ZaEKRmstzOuYJx9HI8DI1oaCGZpdH4h0=
github.com/valyala/fasthttp v1.41.0 h1:zeR0Z1my1wDHTRiamBCXVglQdbUwgb9uWG3k1HQz6jY=
github.com/valyala/fasthttp v1.41.0/go.mod h1:f6VbjjoI3z1NDOZOv17o6RvtRSWxC77seBFc2uWtgiY=
github.com/valyala/fastjson v1.6.4 h1:uAUNq9Z6ymTgGhcm0UynUAB6tlbakBrz6CQFax3BXVQ=
github.com/valyala/fastjson v1.6.4/go.mod h1:CLCAqky6SMuOcxStkYQvblddUtoRxhYMGLrsQns1aXY=
github.com/valyala/fastrand v1.0.0/go.mod h1:HWqCzkrkg6QXT8V2EXWvXCoow7vLwOFN002oeRzjapQ=
github.com/valyala/fastrand v1.1.0 h1:f+5HkLW4rsgzdNoleUOB69hyT9IlD2ZQh9GyDMfb5G8=
github.com/valyala/fastrand v1.1.0/go.mod h1:HWqCzkrkg6QXT8V2EXWvXCoow7vLwOFN002oeRzjapQ=
Expand Down
329 changes: 283 additions & 46 deletions committee/contracts/interchaindb/interchaindb.abigen.go

Large diffs are not rendered by default.

Large diffs are not rendered by default.

371 changes: 288 additions & 83 deletions committee/contracts/synapsemodule/synapsemodule.abigen.go

Large diffs are not rendered by default.

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions committee/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,7 @@ require (
github.com/uptrace/opentelemetry-go-extra/otelzap v0.2.3 // indirect
github.com/valyala/bytebufferpool v1.0.0 // indirect
github.com/valyala/fasthttp v1.41.0 // indirect
github.com/valyala/fastjson v1.6.4 // indirect
github.com/valyala/fastrand v1.1.0 // indirect
github.com/whyrusleeping/chunker v0.0.0-20181014151217-fe64bd25879f // indirect
github.com/whyrusleeping/go-keyspace v0.0.0-20160322163242-5b898ac5add1 // indirect
Expand Down
2 changes: 2 additions & 0 deletions committee/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -1296,6 +1296,8 @@ github.com/valyala/fasthttp v1.6.0/go.mod h1:FstJa9V+Pj9vQ7OJie2qMHdwemEDaDiSdBn
github.com/valyala/fasthttp v1.34.0/go.mod h1:epZA5N+7pY6ZaEKRmstzOuYJx9HI8DI1oaCGZpdH4h0=
github.com/valyala/fasthttp v1.41.0 h1:zeR0Z1my1wDHTRiamBCXVglQdbUwgb9uWG3k1HQz6jY=
github.com/valyala/fasthttp v1.41.0/go.mod h1:f6VbjjoI3z1NDOZOv17o6RvtRSWxC77seBFc2uWtgiY=
github.com/valyala/fastjson v1.6.4 h1:uAUNq9Z6ymTgGhcm0UynUAB6tlbakBrz6CQFax3BXVQ=
github.com/valyala/fastjson v1.6.4/go.mod h1:CLCAqky6SMuOcxStkYQvblddUtoRxhYMGLrsQns1aXY=
github.com/valyala/fastrand v1.0.0/go.mod h1:HWqCzkrkg6QXT8V2EXWvXCoow7vLwOFN002oeRzjapQ=
github.com/valyala/fastrand v1.1.0 h1:f+5HkLW4rsgzdNoleUOB69hyT9IlD2ZQh9GyDMfb5G8=
github.com/valyala/fastrand v1.1.0/go.mod h1:HWqCzkrkg6QXT8V2EXWvXCoow7vLwOFN002oeRzjapQ=
Expand Down
93 changes: 52 additions & 41 deletions contrib/git-changes-action/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Git Changes Action

This GitHub Action exports a variable that contains the list of Go modules changed in the current pull request, along with any dependent modules. This can be useful for automating build, test, or deployment workflows that involve Go projects.
This GitHub Action exports a variable that contains the list of Go modules changed in the current pull request, and if desired, along with any dependent modules. This can be useful for automating build, test, or deployment workflows that involve Go projects.

[![Go Reference](https://pkg.go.dev/badge/github.com/synapsecns/sanguine/contrib/git-changes-action.svg)](https://pkg.go.dev/github.com/synapsecns/sanguine/contrib/git-changes-action)
[![Go Report Card](https://goreportcard.com/badge/github.com/synapsecns/sanguine/contrib/git-changes-action)](https://goreportcard.com/report/github.com/synapsecns/sanguine/contrib/git-changes-action)
Expand All @@ -9,16 +9,15 @@ This GitHub Action exports a variable that contains the list of Go modules chang

1. To use this action, add the following steps to your workflow:

Check out the current pull request using the actions/checkout action. It's recommended to set fetch-depth to 0 and submodules to recursive to ensure that all necessary dependencies are fetched.


Check out the current pull request using the actions/checkout action. It's recommended to set fetch-depth to 0 and submodules to 'recursive' to ensure that all necessary dependencies are fetched.

```yaml
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
submodules: 'recursive'
dependencyLevelResolution: "modules"
```
1. Use the synapsecns/sanguine/git-changes-action Docker image to run the git-changes script, which exports a variable that contains the list of changed Go modules.
Expand All @@ -29,55 +28,26 @@ This GitHub Action exports a variable that contains the list of Go modules chang
with:
github_token: ${{ secrets.github_token }}
timeout: "1m" # optional, defaults to 1m
dependencyLevelResolution: "modules"
# For package level resolution, use "packages" instead of "modules"
```

You can customize the behavior of the git-changes script by using the following inputs:

- `github_token`: The token to use for authentication with the GitHub API. This is required to fetch information about the current pull request.
- `timeout`: The maximum time to wait for the GitHub API to respond. Defaults to 1 minute.
- `dependencyLevelResolution`: "modules" or "packages".

The output of the git-changes script is a comma-separated list of Go module paths. You can access this list using the `filter_go` output variable, like so:

```yaml
- run: echo "Changed modules: ${{ steps.filter_go.outputs.changed_modules }}"
- run: echo "Unchanged modules: ${{ steps.filter_go.outputs.unchanged_modules }}"
- run: echo "Changed modules (including dependencies): ${{ steps.filter_go.outputs.changed_modules_deps }}"
- run: echo "Unchanged modules (including dependencies): ${{ steps.filter_go.outputs.unchanged_modules_deps }}"
```

## Example

Here's an example workflow that uses the `git-changes` action to run tests for changed Go modules:


```yaml
name: Test Go Modules
on:
pull_request:
types: [opened, synchronize]
jobs:
test_go_modules:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
submodules: 'recursive'
- run: echo 'Changed modules:' ${{ steps.filter_go.outputs.changed_modules }}
- run: echo 'Unchanged modules:' ${{ steps.filter_go.outputs.unchanged_modules }}
- run: echo 'Changed modules (including dependencies):' ${{ steps.filter_go.outputs.changed_modules_deps }}
- run: echo 'Unchanged modules (including dependencies):' ${{ steps.filter_go.outputs.unchanged_modules_deps }}

- uses: docker://ghcr.io/synapsecns/sanguine/git-changes-action:latest
id: filter_go
with:
github_token: ${{ secrets.github_token }}
timeout: "1m"
- name: Run tests
run: go test -v ${{ steps.filter_go.outputs.changed_modules }}
```

This workflow will run tests for all changed Go modules and their dependencies whenever a pull request is opened or synchronized.

## How It Works

First a change tree is calculated between the ref and the base (as passed in by the user or inferred by the event type) based on the flow described below and [here](https://github.com/dorny/paths-filter/blob/4067d885736b84de7c414f582ac45897079b0a78/README.md#supported-workflows). This is a file tree that contains all the files that have changed between two refs.
Expand All @@ -94,7 +64,9 @@ graph TB
F --> G
```

Each module in the `go.work` is visited. If any changes were detected by the previous step, the module is added to the list of changed modules. If `include_dependencies` is on and the module has a dependency that is also in the `go.work`, the dependency is added to the list of changed modules as well. This process is repeated until all modules in the `go.work` have been visited.
## Module Level Resolution

Each module in the `go.work` is visited. If any changes are detected, the module itself is added to the list of changed modules. By setting `include_dependencies` to `modules`, changes to their direct or indirect module dependencies will flag the module as changed. This process is repeated until all modules in the `go.work` have been visited.

```mermaid
sequenceDiagram
Expand Down Expand Up @@ -126,3 +98,42 @@ sequenceDiagram
end
GW->>GW: Continue Until All Modules Visited
```

## Package Level Resolution

Each module in the `go.work` is visited. If any changes are detected, the module itself is added to the list of changed modules. By setting `include_dependencies` to `packages`, changes to its direct or indirect package dependencies will flag the module as changed. This process is repeated until all package dependencies for the module been visited.

```mermaid
sequenceDiagram
participant GW as go.work
participant M as Module
participant P as Package
participant CML as Changed_Module_List
participant UML as Unchanged_Module_List
participant D as Dependency
GW->>M: Visit Module
M->>P:Extract all packages for each Module
P->>M: Returns [module]: [package1,package2]
M->>M: Changes detected?
M->>P: Loop over packages
P-->>GW: Changes Detected?
alt Changes Detected
GW->>CML: Add Module to Changed_Module_List
M->>D: Has Package Dependency?
alt Has Dependency
GW->>CML: Add Dependency to Changed_Module_List
else No Dependency
M-->>GW: No Dependency to Add
end
else No Changes Detected
GW->>UML: Add Module to Unchanged_Module_List
M->>D: Has Dependency in go.work?
alt Has Dependency
GW->>UML: Add Dependency to Unchanged_Module_List
else No Dependency
M-->>GW: No Dependency to Add
end
end
GW->>GW: Continue Until All Modules Visited
```
2 changes: 0 additions & 2 deletions contrib/git-changes-action/detector/doc.go

This file was deleted.

14 changes: 0 additions & 14 deletions contrib/git-changes-action/detector/export_test.go

This file was deleted.

2 changes: 2 additions & 0 deletions contrib/git-changes-action/detector/git/doc.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
// Package git provides utilities to interact with git.
package git

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -1,72 +1,21 @@
package detector
package git

import (
"encoding/hex"
"encoding/json"
"errors"
"fmt"
"github.com/ethereum/go-ethereum/common"
"github.com/go-git/go-git/v5"
"github.com/go-git/go-git/v5/plumbing"
"github.com/go-git/go-git/v5/plumbing/object"
"github.com/google/go-github/v41/github"
"github.com/synapsecns/sanguine/contrib/git-changes-action/detector/actionscore"
"github.com/synapsecns/sanguine/contrib/git-changes-action/detector/tree"
"github.com/synapsecns/sanguine/core"
"golang.org/x/mod/modfile"
"os"
"path"
"strings"
)

// DetectChangedModules is the change detector client.
// nolint: cyclop
func DetectChangedModules(repoPath string, ct tree.Tree, includeDeps bool) (modules map[string]bool, err error) {
modules = make(map[string]bool)

goWorkPath := path.Join(repoPath, "go.work")

if !common.FileExist(goWorkPath) {
return nil, fmt.Errorf("go.work file not found in %s", repoPath)
}

//nolint: gosec
workFile, err := os.ReadFile(goWorkPath)
if err != nil {
return nil, fmt.Errorf("failed to read go.work file: %w", err)
}

parsedWorkFile, err := modfile.ParseWork(goWorkPath, workFile, nil)
if err != nil {
return nil, fmt.Errorf("failed to parse go.work file: %w", err)
}

depGraph, err := getDependencyGraph(repoPath)
if err != nil {
return nil, fmt.Errorf("could not get dep graph: %w", err)
}

for _, module := range parsedWorkFile.Use {
changed := false
if ct.HasPath(module.Path) {
changed = true
}

if includeDeps {
deps := depGraph[module.Path]
for _, dep := range deps {
if ct.HasPath(dep) {
changed = true
}
}
}

modules[module.Path] = changed
}

return modules, nil
}

// getChangeTreeFromGit returns a tree of all the files that have changed between the current commit and the commit with the given hash.
// nolint: cyclop, gocognit
func getChangeTreeFromGit(repoPath string, ghContext *actionscore.Context, head, base string) (tree.Tree, error) {
Expand All @@ -76,7 +25,7 @@ func getChangeTreeFromGit(repoPath string, ghContext *actionscore.Context, head,
return nil, fmt.Errorf("could not open repository %s: %w", repoPath, err)
}

head, err = getHead(repository, ghContext, head)
head, err = GetHead(repository, ghContext, head)
if err != nil {
return nil, fmt.Errorf("could not get head: %w", err)
}
Expand Down Expand Up @@ -272,9 +221,9 @@ func getHeadBase(repo *git.Repository) (head string, base string, err error) {
return co.Hash().String(), lastCommit.Hash.String(), nil
}

// getHead gets the head of the current branch.
// GetHead gets the head of the current branch.
// it attempts to mirror the logic of https://github.com/dorny/paths-filter/blob/0ef5f0d812dc7b631d69e07d2491d70fcebc25c8/src/main.ts#L104
func getHead(repo *git.Repository, ghContext *actionscore.Context, head string) (string, error) {
func GetHead(repo *git.Repository, ghContext *actionscore.Context, head string) (string, error) {
if head != "" {
return head, nil
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package detector
package git

import (
"context"
Expand Down
Loading

0 comments on commit c5a9c25

Please sign in to comment.