-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into azure-devops-support
- Loading branch information
Showing
6 changed files
with
145 additions
and
57 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
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,27 @@ | ||
# Build the dummy Dockerfile | ||
exec docker build -qt dummy-updater . | ||
|
||
# Run the dependabot command | ||
dependabot update go_modules dependabot/cli --updater-image dummy-updater | ||
|
||
# assert the dummy is working | ||
stderr 'bin/run arguments: fetch_files' | ||
stderr 'bin/run arguments: update_files' | ||
|
||
-- Dockerfile -- | ||
FROM ubuntu:22.04 | ||
|
||
RUN useradd dependabot | ||
|
||
COPY --chown=dependabot --chmod=755 update-ca-certificates /usr/bin/update-ca-certificates | ||
COPY --chown=dependabot --chmod=755 run bin/run | ||
|
||
-- update-ca-certificates -- | ||
#!/usr/bin/env bash | ||
|
||
echo "Updated those certificates for ya" | ||
|
||
-- run -- | ||
#!/usr/bin/env bash | ||
|
||
echo "bin/run arguments: $@" |
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,36 @@ | ||
# This test tries to verify that the proper job.json is written based on command line arguments. | ||
|
||
exec docker build -qt input-verify-updater . | ||
|
||
dependabot update go_modules dependabot/cli --updater-image input-verify-updater | ||
stderr '"package-manager":"go_modules"' | ||
stderr '"repo":"dependabot/cli"' | ||
|
||
dependabot update go_modules dependabot/cli --commit 1278c8d7503f9881eb969959446e2c3a5a0cce2d --updater-image input-verify-updater | ||
stderr '"commit":"1278c8d7503f9881eb969959446e2c3a5a0cce2d"' | ||
|
||
! dependabot update go_modules dependabot/cli --commit unknown --updater-image input-verify-updater | ||
stderr 'commit must be a SHA, or not provided' | ||
|
||
dependabot update go_modules dependabot/cli --dep golang.org/x/image --updater-image input-verify-updater | ||
stderr '"allowed-updates":\[\{"dependency-name":"golang.org/x/image"\}\]' | ||
|
||
-- Dockerfile -- | ||
FROM ubuntu:22.04 | ||
|
||
RUN useradd dependabot | ||
|
||
COPY --chown=dependabot --chmod=755 update-ca-certificates /usr/bin/update-ca-certificates | ||
COPY --chown=dependabot --chmod=755 run bin/run | ||
|
||
-- update-ca-certificates -- | ||
#!/usr/bin/env bash | ||
|
||
echo "Updated those certificates for ya" | ||
|
||
-- run -- | ||
#!/usr/bin/env bash | ||
|
||
echo "Not sure why but unless I echo here the json doesn't output" | ||
|
||
cat /home/dependabot/dependabot-updater/job.json |
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,71 @@ | ||
package tests | ||
|
||
import ( | ||
"bytes" | ||
"context" | ||
"fmt" | ||
"os" | ||
"os/exec" | ||
"rsc.io/script" | ||
"rsc.io/script/scripttest" | ||
"testing" | ||
) | ||
|
||
func TestDependabot(t *testing.T) { | ||
ctx := context.Background() | ||
engine := &script.Engine{ | ||
Conds: scripttest.DefaultConds(), | ||
Cmds: Commands(), | ||
Quiet: !testing.Verbose(), | ||
} | ||
env := []string{ | ||
"PATH=" + os.Getenv("PATH"), | ||
} | ||
scripttest.Test(t, ctx, engine, env, "../testdata/scripts/*.txt") | ||
} | ||
|
||
// Commands returns the commands that can be used in the scripts. | ||
// Each line of the scripts are <command> <args...> | ||
// So if you enter "dependabot update go_modules rsc/quote", it will run | ||
// the Dependabot() function with args "update go_modules rsc/quote". | ||
// When you use "echo" in the scripts it's actually running the echo command | ||
// from the scripttest package. | ||
func Commands() map[string]script.Cmd { | ||
commands := scripttest.DefaultCmds() | ||
|
||
// additional Dependabot commands | ||
commands["dependabot"] = Dependabot() | ||
|
||
return commands | ||
} | ||
|
||
// Dependabot runs the Dependabot CLI. TODO Should this build once then execute thereafter? | ||
func Dependabot() script.Cmd { | ||
return script.Command( | ||
script.CmdUsage{ | ||
Summary: "runs the Dependabot CLI", | ||
Args: "[<package_manager> <repo> | -f <input.yml>] [flags]", | ||
}, | ||
func(s *script.State, args ...string) (script.WaitFunc, error) { | ||
if len(args) == 0 { | ||
return nil, script.ErrUsage | ||
} | ||
|
||
args = append([]string{"run", "../cmd/dependabot/dependabot.go"}, args...) | ||
execCmd := exec.Command("go", args...) | ||
|
||
var execOut, execErr bytes.Buffer | ||
execCmd.Stdout = &execOut | ||
execCmd.Stderr = &execErr | ||
|
||
if err := execCmd.Start(); err != nil { | ||
return nil, fmt.Errorf("failed to run dependabot: %w", err) | ||
} | ||
|
||
wait := func(*script.State) (stdout, stderr string, err error) { | ||
err = execCmd.Wait() | ||
return execOut.String(), execErr.String(), err | ||
} | ||
return wait, nil | ||
}) | ||
} |
This file was deleted.
Oops, something went wrong.