@@ -29,37 +29,46 @@ var (
29
29
errNotEnoughArg = errors .New ("path argument required" )
30
30
)
31
31
32
- // configuredUpdates returns the set of Go modules and Dockerfiles dependabot
33
- // is configured to check updates for.
34
- func configuredUpdates (path string ) (mods map [string ]struct {}, docker map [string ]struct {}, err error ) {
32
+ type updates struct {
33
+ mods map [string ]struct {}
34
+ docker map [string ]struct {}
35
+ pip map [string ]struct {}
36
+ }
37
+
38
+ // configuredUpdates returns updates configured in the dependabot configuration
39
+ func configuredUpdates (path string ) (u updates , err error ) {
35
40
f , err := os .Open (filepath .Clean (path ))
36
41
if errors .Is (err , os .ErrNotExist ) {
37
- return nil , nil , fmt .Errorf ("dependabot configuration file does not exist: %s" , path )
42
+ return updates {} , fmt .Errorf ("dependabot configuration file does not exist: %s" , path )
38
43
}
39
44
if err != nil {
40
- return nil , nil , fmt .Errorf ("failed to read dependabot configuration file: %s" , path )
45
+ return updates {} , fmt .Errorf ("failed to read dependabot configuration file: %s" , path )
41
46
}
42
47
43
48
var c dependabotConfig
44
49
if err := yaml .NewDecoder (f ).Decode (& c ); err != nil {
45
- return nil , nil , fmt .Errorf ("invalid dependabot configuration: %w" , err )
50
+ return updates {} , fmt .Errorf ("invalid dependabot configuration: %w" , err )
46
51
}
47
52
48
- mods = make (map [string ]struct {})
49
- docker = make (map [string ]struct {})
53
+ mods := make (map [string ]struct {})
54
+ docker := make (map [string ]struct {})
55
+ pip := make (map [string ]struct {})
50
56
for _ , u := range c .Updates {
51
57
if u .PackageEcosystem == dockerPkgEco {
52
58
docker [u .Directory ] = struct {}{}
53
59
}
54
60
if u .PackageEcosystem == gomodPkgEco {
55
61
mods [u .Directory ] = struct {}{}
56
62
}
63
+ if u .PackageEcosystem == pipPkgEco {
64
+ pip [u .Directory ] = struct {}{}
65
+ }
57
66
}
58
- return mods , docker , nil
67
+ return updates { mods , docker , pip } , nil
59
68
}
60
69
61
- // verify ensures dependabot configuration contains a check for all modules and
62
- // Dockerfiles.
70
+ // verify ensures dependabot configuration contains a check for all modules,
71
+ // Dockerfiles, and requirements.txt files .
63
72
func verify (args []string ) error {
64
73
switch len (args ) {
65
74
case 0 :
@@ -80,7 +89,13 @@ func verify(args []string) error {
80
89
return err
81
90
}
82
91
83
- modUp , dockerUp , err := configuredUpdatesFunc (args [0 ])
92
+ pipFiles , err := allPipFunc (root )
93
+ if err != nil {
94
+ return err
95
+ }
96
+
97
+ u , err := configuredUpdatesFunc (args [0 ])
98
+
84
99
if err != nil {
85
100
return err
86
101
}
@@ -92,7 +107,7 @@ func verify(args []string) error {
92
107
return err
93
108
}
94
109
95
- if _ , ok := modUp [local ]; ! ok {
110
+ if _ , ok := u . mods [local ]; ! ok {
96
111
missingMod = append (missingMod , local )
97
112
}
98
113
}
@@ -103,19 +118,33 @@ func verify(args []string) error {
103
118
return err
104
119
}
105
120
106
- if _ , ok := dockerUp [local ]; ! ok {
121
+ if _ , ok := u . docker [local ]; ! ok {
107
122
missingDocker = append (missingDocker , local )
108
123
}
109
124
}
125
+ var missingPip []string
126
+ for _ , p := range pipFiles {
127
+ local , err := localPath (root , p )
128
+ if err != nil {
129
+ return err
130
+ }
110
131
111
- if len (missingMod ) > 0 || len (missingDocker ) > 0 {
132
+ if _ , ok := u .pip [local ]; ! ok {
133
+ missingPip = append (missingPip , local )
134
+ }
135
+ }
136
+
137
+ if len (missingMod ) > 0 || len (missingDocker ) > 0 || len (missingPip ) > 0 {
112
138
msg := "missing update check(s):"
113
139
if len (missingMod ) > 0 {
114
140
msg = fmt .Sprintf ("%s\n - Go mod files: %s" , msg , strings .Join (missingMod , ", " ))
115
141
}
116
142
if len (missingDocker ) > 0 {
117
143
msg = fmt .Sprintf ("%s\n - Dockerfiles: %s" , msg , strings .Join (missingDocker , ", " ))
118
144
}
145
+ if len (missingPip ) > 0 {
146
+ msg = fmt .Sprintf ("%s\n - Pip files: %s" , msg , strings .Join (missingPip , ", " ))
147
+ }
119
148
msg += "\n "
120
149
return errors .New (msg )
121
150
}
0 commit comments