Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dependabot cron job feature #11422

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 43 additions & 0 deletions common/spec/dependabot/config/file_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,49 @@
end
end

describe "#parse" do
let(:config) { described_class.parse(fixture("configfile", "ignore-conditions.yml")) }
let(:update_config) { config.update_config("npm_and_yarn") }

it "loads ignore conditions" do
expect(update_config.ignore_conditions.length).to eq(3)
end

it "passes update-types" do
types_ignore = update_config.ignore_conditions.find { |ic| ic.dependency_name == "@types/node" }
expect(types_ignore.update_types).to eq(["version-update:semver-patch"])
end
end
end
describe "File for cron" do
let(:config) { described_class.parse(fixture("configfile", "npm-cron.yml")) }

describe "#update_config" do
it "maps package_manager to package-ecosystem" do
update_config = config.update_config("npm_and_yarn")
expect(update_config).to be_a(Dependabot::Config::UpdateConfig)
expect(update_config.commit_message_options.prefix).to eq("no directory")
end

it "matches directory" do
update_config = config.update_config("npm_and_yarn", directory: "/target")
expect(update_config).to be_a(Dependabot::Config::UpdateConfig)
expect(update_config.commit_message_options.prefix).to eq("with directory")
end

it "matches target-branch" do
update_config = config.update_config("npm_and_yarn", directory: "/target", target_branch: "the-awesome-branch")
expect(update_config).to be_a(Dependabot::Config::UpdateConfig)
expect(update_config.commit_message_options.prefix).to eq("with directory and branch")
end

it "returns empty when not found" do
update_config = config.update_config("bundler")
expect(update_config).to be_a(Dependabot::Config::UpdateConfig)
expect(update_config.commit_message_options.prefix).to be_nil
end
end

describe "#parse" do
let(:config) { described_class.parse(fixture("configfile", "ignore-conditions.yml")) }
let(:update_config) { config.update_config("npm_and_yarn") }
Expand Down
25 changes: 25 additions & 0 deletions common/spec/fixtures/configfile/npm-cron.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# NOTE: prefix: values are used by common/spec/dependabot/config/file_spec.rb
version: 2
updates:
- package-ecosystem: "npm"
directory: "/"
schedule:
interval: "cron"
cron-expression: "0 8 * * *"
commit-message:
prefix: "no directory"
- package-ecosystem: "npm"
directory: "/target"
schedule:
interval: "cron"
cron-expression: "0 8 * * *"
commit-message:
prefix: "with directory"
- package-ecosystem: "npm"
directory: "/target"
schedule:
interval: "cron"
cron-expression: "0 8 * * *"
target-branch: "the-awesome-branch"
commit-message:
prefix: "with directory and branch"
Loading