Merge branch 'main' into dependabot/bundler/activesupport-7.0.7.1

This commit is contained in:
Begona Guereca
2024-02-15 14:38:22 -08:00
committed by GitHub
10 changed files with 179 additions and 4 deletions
+21
View File
@@ -0,0 +1,21 @@
---
name: Bitbucket
about: Migrate Bitbucket pipelines to GitHub Actions
title: "[Bitbucket]:"
labels: bitbucket
assignees: ""
---
## Inputs
Provide the following required inputs:
Workspace: _Replace this text with the Bitbucket Workspace to migrate pipelines from._
## Available commands
The following commands can be executed by adding a comment to this issue:
- `/audit`
- `/dry-run --repository :repository-name`
- `/migrate --repository :repository-name --target-url :github-repository-url`
+2 -1
View File
@@ -13,7 +13,7 @@ defaults:
shell: bash
env:
GITHUB_INSTANCE_URL: ${{ secrets.GITHUB_INSTANCE_URL || 'https://github.com' }}
GITHUB_INSTANCE_URL: ${{ secrets.GH_INSTANCE_URL || 'https://github.com' }}
GITHUB_ACCESS_TOKEN: ${{ secrets.GH_ACCESS_TOKEN }}
JENKINS_INSTANCE_URL: ${{ secrets.JENKINS_INSTANCE_URL }}
JENKINS_USERNAME: ${{ secrets.jenkins_username }}
@@ -28,6 +28,7 @@ env:
CIRCLE_CI_SOURCE_GITHUB_ACCESS_TOKEN: ${{ secrets.circle_ci_source_github_access_token }}
BAMBOO_ACCESS_TOKEN: ${{ secrets.bamboo_access_token }}
BAMBOO_INSTANCE_URL: ${{ secrets.bamboo_instance_url }}
BITBUCKET_ACCESS_TOKEN: ${{ secrets.bitbucket_access_token }}
jobs:
execute-actions-importer:
+6 -1
View File
@@ -35,7 +35,7 @@ The following secrets are required:
Optionally, the following secrets can be set:
- `GITHUB_INSTANCE_URL`: The base URL of your GitHub instance (only required if it is **not** <https://github.com>).
- `GH_INSTANCE_URL`: The base URL of your GitHub instance (only required if it is **not** <https://github.com>).
### Azure DevOps
@@ -101,6 +101,11 @@ The following secrets are required:
- `BAMBOO_ACCESS_TOKEN`: The personal access token to access the Bamboo instance.
- `BAMBOO_INSTANCE_URL`: The base URL of your Bamboo instance.
### Bitbucket
The following secrets are required:
- `BITBUCKET_ACCESS_TOKEN`: The personal access token to access the BitBucket instance.
## Pipeline migration
+21
View File
@@ -0,0 +1,21 @@
# frozen_string_literal: true
module Bitbucket
class Audit
include IssueParser
def initialize(issue_content, command)
@workspace = parameter_from_issue("Workspace", issue_content)
@project_key = command.options["project-key"]
end
def to_a
args = []
args.push(["--workspace", @workspace]) unless @workspace.nil?
args.push(["--project-key", @project_key]) unless @project_key.nil?
return args unless args.empty?
end
end
end
+20
View File
@@ -0,0 +1,20 @@
# frozen_string_literal: true
module Bitbucket
class DryRun
include IssueParser
def initialize(issue_content, command)
@workspace = parameter_from_issue("Workspace", issue_content)
@repository = command.options["repository"]
end
def to_a
args = []
args.push(["--workspace", @workspace]) unless @workspace.nil?
args.push(["--repository", @repository]) unless @repository.nil?
return args unless args.empty?
end
end
end
+22
View File
@@ -0,0 +1,22 @@
# frozen_string_literal: true
module Bitbucket
class Migrate
include IssueParser
def initialize(issue_content, command)
@workspace = parameter_from_issue("Workspace", issue_content)
@repository = command.options["repository"]
@target_url = command.options["target-url"]
end
def to_a
args = []
args.push(["--workspace", @workspace]) unless @workspace.nil?
args.push(["--repository", @repository]) unless @repository.nil?
args.push(["--target-url", @target_url]) unless @target_url.nil?
return args unless args.empty?
end
end
end
+3 -2
View File
@@ -11,11 +11,12 @@ class Provider
PROVIDER_MAP = {
"azure-devops" => ::AzureDevops,
"bamboo" => ::Bamboo,
"bitbucket" => ::Bitbucket,
"circle-ci" => ::CircleCI,
"gitlab" => ::GitlabCI,
"jenkins" => ::Jenkins,
"travis-ci" => ::TravisCI,
"bamboo" => ::Bamboo
"travis-ci" => ::TravisCI
}.freeze
def initialize(labels)
+42
View File
@@ -0,0 +1,42 @@
# frozen_string_literal: true
RSpec.describe Bitbucket::Audit do
describe "#to_a" do
let(:audit) { described_class.new(issue_content, command) }
let(:command) { Command.new(comment_body) }
let(:comment_body) { "/audit" }
subject { audit.to_a }
context "when issue_content contains no args" do
let(:issue_content) do
<<~ISSUE
Workspace:
ISSUE
end
it { is_expected.to be_nil }
end
context "when issue_content contains a workspace" do
let(:issue_content) do
<<~ISSUE
Workspace: testing
ISSUE
end
it { is_expected.to eq([["--workspace", "testing"]]) }
end
context "when the comment body contains a project key" do
let(:issue_content) do
<<~ISSUE
Workspace: testing
ISSUE
end
let(:comment_body) { "/audit --project-key SW" }
it { is_expected.to eq([["--workspace", "testing"], ["--project-key", "SW"]]) }
end
end
end
+21
View File
@@ -0,0 +1,21 @@
# frozen_string_literal: true
RSpec.describe Bitbucket::DryRun do
let(:dry_run) { described_class.new(issue_content, command) }
let(:command) { Command.new(comment_body) }
describe "#to_a" do
subject { dry_run.to_a }
let(:issue_content) do
<<~ISSUE
Workspace: testing
ISSUE
end
context "when the comment body contains a repository" do
let(:comment_body) { "/dry-run --repository repo" }
it { is_expected.to eq([["--workspace", "testing"], ["--repository", "repo"]]) }
end
end
end
+21
View File
@@ -0,0 +1,21 @@
# frozen_string_literal: true
RSpec.describe Bitbucket::Migrate do
let(:dry_run) { described_class.new(issue_content, command) }
let(:command) { Command.new(comment_body) }
describe "#to_a" do
subject { dry_run.to_a }
let(:issue_content) do
<<~ISSUE
Workspace: testing
ISSUE
end
context "when the comment body contains a repository" do
let(:comment_body) { "/migrate --repository repo --target-url https://github.com/org/repo" }
it { is_expected.to eq([["--workspace", "testing"], ["--repository", "repo"], ["--target-url", "https://github.com/org/repo"]]) }
end
end
end