-
Notifications
You must be signed in to change notification settings - Fork 676
/
testvectors.go
51 lines (37 loc) · 1012 Bytes
/
testvectors.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
package dependencies
import (
"os"
"github.com/0xPolygonHermez/zkevm-node/log"
"github.com/spf13/afero"
)
// TVConfig is the configuration for the test vector updater.
type TVConfig struct {
TargetDirPath string
SourceRepo string
}
type testVectorUpdater struct {
fs afero.Fs
gm *githubManager
sourceRepo string
targetDirPath string
}
func newTestVectorUpdater(sourceRepo, targetDirPath string) *testVectorUpdater {
aferoFs := afero.NewOsFs()
gm := newGithubManager(aferoFs, os.Getenv("UPDATE_DEPS_SSH_PK"), os.Getenv("GITHUB_TOKEN"))
return &testVectorUpdater{
fs: aferoFs,
gm: gm,
sourceRepo: sourceRepo,
targetDirPath: targetDirPath,
}
}
func (tu *testVectorUpdater) update() error {
log.Infof("Cloning %q...", tu.sourceRepo)
tmpdir, err := tu.gm.cloneTargetRepo(tu.sourceRepo)
if err != nil {
return err
}
targetDirPath := getTargetPath(tu.targetDirPath)
log.Infof("Updating files %q...", tu.sourceRepo)
return updateFiles(tu.fs, tmpdir, targetDirPath)
}