Skip to content
This repository has been archived by the owner on May 10, 2022. It is now read-only.

Bitbucket #22

Merged
merged 75 commits into from
Nov 19, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
75 commits
Select commit Hold shift + click to select a range
e1d780c
Receive and transform bitbucket webhooks
K-Phoen Nov 12, 2017
8a81b9f
Start to work on PR analysis scheduling
K-Phoen Nov 13, 2017
30bf980
Fix redirect route for bitbucket auth
K-Phoen Nov 13, 2017
673b541
Start to work on bitbucket auth
K-Phoen Nov 13, 2017
006ba02
WIP
K-Phoen Nov 14, 2017
6063ff1
Fetch bitbucket repositories
K-Phoen Nov 14, 2017
b7e6db4
Display fetched repositories in the UI
K-Phoen Nov 14, 2017
4d409a1
Register new bitbucket repositories
K-Phoen Nov 14, 2017
60b6203
Fix a few entities definitions
K-Phoen Nov 14, 2017
3da6b37
Display the right url for the webhooks
Nov 15, 2017
eee1430
Fix a few things in analysis scheduling
Nov 15, 2017
001659e
Find repository clone url
Nov 15, 2017
777d3ce
Fix bitbucket analysis
Nov 16, 2017
94d89a8
Add a few notes
Nov 16, 2017
4eef677
Fix AnalysisContext unit tests
K-Phoen Nov 16, 2017
b0c29df
Fix Kernel unit tests
K-Phoen Nov 16, 2017
6e4559e
Update AppContext unit tests
K-Phoen Nov 16, 2017
65d645d
Start to fix more tests
K-Phoen Nov 16, 2017
f2f7b6a
Store warning/error counts instead of computing it each time
K-Phoen Nov 16, 2017
9992966
Clean analysis/report model in the analysis context
K-Phoen Nov 16, 2017
008db4d
Add missing getter
K-Phoen Nov 16, 2017
9b1b8d3
Clean a few things in the analysis context
K-Phoen Nov 16, 2017
90a6310
Write a few tests
K-Phoen Nov 16, 2017
ed309c7
Add a few tests for the BitbucketDetails entity
K-Phoen Nov 16, 2017
39aef9f
Test the model
K-Phoen Nov 16, 2017
a640857
Test bitbucket command handlers
K-Phoen Nov 16, 2017
5ddd151
Test the pull request listener
K-Phoen Nov 16, 2017
bdf1adb
Start to write tests for the bitbucket event transformer
K-Phoen Nov 16, 2017
1a2e9c1
Remove useless code
K-Phoen Nov 16, 2017
0d842ed
CS Fixes
K-Phoen Nov 16, 2017
fdf6188
More bitbucket-related tests
K-Phoen Nov 16, 2017
78947ce
Remove dead code
K-Phoen Nov 16, 2017
b09061b
Add a PR scheduling command for bitbucket
Nov 17, 2017
757c26b
Start to send build statuses to bitbucket
Nov 17, 2017
2bc6e70
Use reports to send build statuses
Nov 17, 2017
d6fe041
Test the build status listener
K-Phoen Nov 18, 2017
35fb09e
Test the analysis-status-runner worker
K-Phoen Nov 18, 2017
741711e
Test the github analysis-status-runner worker
K-Phoen Nov 18, 2017
659815b
Start to test the bitbucket client
K-Phoen Nov 18, 2017
0a3e4af
Simplify bitbucket client getCloneUrl method
K-Phoen Nov 18, 2017
e7da8c9
Add tests for bitbucket getCloneUrl method
K-Phoen Nov 18, 2017
f3760dc
Report violations for bitbucket PRs
K-Phoen Nov 18, 2017
603fc5a
Test the bitbucket ReviewComment class
K-Phoen Nov 18, 2017
4691e8d
Test the bitbucket send violations command handler
K-Phoen Nov 18, 2017
8539319
Test bitbucket reporters
K-Phoen Nov 18, 2017
d9335cf
Test the review comment listener
K-Phoen Nov 18, 2017
dd0a50f
Improve tests for the bitbucket client
K-Phoen Nov 18, 2017
afdbb1d
Improve inspections listing SQL query
K-Phoen Nov 18, 2017
47d78bb
Add a way to register deploy keys in bitbucket
K-Phoen Nov 18, 2017
2d0f7a3
Add a few tests
K-Phoen Nov 18, 2017
b5aadca
Update readme
K-Phoen Nov 18, 2017
e947873
Fix team creation
K-Phoen Nov 18, 2017
4578318
Fix teams interface
K-Phoen Nov 18, 2017
e1a027f
Remove useless code
K-Phoen Nov 18, 2017
333774f
Add a test for the app repository model
K-Phoen Nov 18, 2017
dad2784
Add more tests
K-Phoen Nov 18, 2017
5d669d5
Remove useless code
K-Phoen Nov 18, 2017
de2e7b3
Apply fixes from StyleCI
K-Phoen Nov 18, 2017
9a757c4
Merge pull request #23 from K-Phoen/analysis-8jdMVB
K-Phoen Nov 18, 2017
4ff0dc7
Clear violations cache when a bitbucket PR is merged/rejected
K-Phoen Nov 19, 2017
0455b30
Add a few unit tests
K-Phoen Nov 19, 2017
8e672cb
Add missing test case for the github PR status event listener
K-Phoen Nov 19, 2017
208ff3b
Apply fixes from StyleCI
K-Phoen Nov 19, 2017
2360a26
Merge pull request #24 from K-Phoen/analysis-q10223
K-Phoen Nov 19, 2017
b33687a
Remove useless casts
K-Phoen Nov 19, 2017
864e767
Remove the shared-secret override form
K-Phoen Nov 19, 2017
684e106
Add a command to setup bitbucket webhooks
K-Phoen Nov 19, 2017
63428cc
Move stuff around
K-Phoen Nov 19, 2017
36dbaa2
Allow the UI to trigger actions to several types of remote repositories
K-Phoen Nov 19, 2017
ca19c21
Add a few tests
K-Phoen Nov 19, 2017
89c0e69
Remove the two remote-specific webhook creation commands in favor of …
K-Phoen Nov 19, 2017
dbeb07e
Apply fixes from StyleCI
K-Phoen Nov 19, 2017
2779b4b
Merge pull request #25 from K-Phoen/analysis-z3PE7G
K-Phoen Nov 19, 2017
5fb4d47
Store bitbucket refresh tokens
K-Phoen Nov 19, 2017
3dc65e5
The bitbucket client now know how to refresh access tokens
K-Phoen Nov 19, 2017
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
9 changes: 9 additions & 0 deletions .editorconfig.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
root = true

[*]
charset = utf-8
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true
indent_size = 4
indent_style = space
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ keys. They are usually stored in `./var/ssh`.
You can then declare a key to GitHub using the following command:

```
./bin/console regis:deploy-key:add --owner=K-Phoen --repository=regis-test --public-key=./var/ssh/id_rsa_test_regis.pub
./bin/console regis:github:add-deploy-key --owner=K-Phoen --repository=regis-test --public-key=./var/ssh/id_rsa_test_regis.pub
```

License
Expand Down
3 changes: 1 addition & 2 deletions app/AppKernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,7 @@ public function registerBundles()
new Regis\AnalysisContext\Infrastructure\Symfony\Bundle\AnalysisBundle\RegisAnalysisBundle(),
new Regis\GithubContext\Infrastructure\Symfony\Bundle\GithubBundle\RegisGithubBundle(),
new Regis\BitbucketContext\Infrastructure\Symfony\Bundle\BitbucketBundle\RegisBitbucketBundle(),

new Regis\Kernel\Bundle\AppBundle\RegisAppBundle(),
new Regis\AppContext\Infrastructure\Symfony\Bundle\AppBundle\RegisAppBundle(),
];

if (in_array($this->getEnvironment(), ['dev', 'test'], true)) {
Expand Down
46 changes: 22 additions & 24 deletions app/Resources/db/migrations/20171102220313_create_schema.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,25 +7,7 @@
class CreateSchema extends AbstractMigration
{
/**
* Change Method.
*
* Write your reversible migrations using this method.
*
* More information on writing migrations is available here:
* http://docs.phinx.org/en/latest/migrations.html#the-abstractmigration-class
*
* The following commands can be used in this method and Phinx will
* automatically reverse them when rolling back:
*
* createTable
* renameTable
* addColumn
* renameColumn
* addIndex
* addForeignKey
*
* Remember to call "create()" or "update()" and NOT "save()" when working
* with the Table class.
* {@inheritdoc}
*/
public function change()
{
Expand All @@ -41,11 +23,11 @@ public function change()
$repositoriesTeams = $this->table('team_repository', ['id' => false, 'primary_key' => ['repository_id', 'team_id']]);
$usersGithub = $this->table('user_github', ['id' => false, 'primary_key' => ['id']]);
$usersBitbucket = $this->table('user_bitbucket', ['id' => false, 'primary_key' => ['id']]);
$bitbucketPrInspections = $this->table('bitbucket_pr_inspection', ['id' => false, 'primary_key' => ['id']]);

$users
->addColumn('id', 'uuid')
->addColumn('username', 'string')
->addColumn('roles', 'text')
->addColumn('roles', 'text', ['default' => 'ROLE_USER'])
;

$teams
Expand Down Expand Up @@ -73,20 +55,25 @@ public function change()
->addColumn('id', 'uuid')
->addColumn('user_id', 'uuid')
->addColumn('remote_id', 'integer')
->addColumn('username', 'string')
->addColumn('access_token', 'string')
->addForeignKey('user_id', 'user_account', 'id')
;

$usersBitbucket
->addColumn('id', 'uuid')
->addColumn('user_id', 'uuid')
->addColumn('remote_id', 'integer')
->addColumn('remote_id', 'string')
->addColumn('username', 'string')
->addColumn('access_token', 'string')
->addColumn('refresh_token', 'string')
->addColumn('access_token_expiration', 'datetime', ['timezone' => true])
->addForeignKey('user_id', 'user_account', 'id')
;

$inspections
->addColumn('id', 'uuid')
->addColumn('repository_id', 'uuid')
->addColumn('report_id', 'uuid', ['null' => true])
->addColumn('created_at', 'datetime', ['timezone' => true])
->addColumn('started_at', 'datetime', ['timezone' => true, 'null' => true])
Expand All @@ -97,12 +84,14 @@ public function change()
->addColumn('type', 'string')
->addColumn('failure_trace', 'text')
->addForeignKey('report_id', 'report', 'id')
->addForeignKey('repository_id', 'repository', 'id')
;

$repositories
->addColumn('id', 'uuid')
->addColumn('identifier', 'string')
->addColumn('type', 'string')
->addColumn('name', 'string')
->addColumn('owner_id', 'uuid')
->addColumn('shared_secret', 'text')
->addColumn('is_inspection_enabled', 'boolean')
Expand All @@ -116,21 +105,29 @@ public function change()
$githubPrInspections
->addColumn('id', 'uuid')
->addColumn('pull_request_number', 'integer')
->addColumn('repository_id', 'uuid')
->addForeignKey('id', 'inspection', 'id')
->addForeignKey('repository_id', 'repository', 'id')
;

$bitbucketPrInspections
->addColumn('id', 'uuid')
->addColumn('pull_request_number', 'integer')
->addForeignKey('id', 'inspection', 'id')
;

$reports
->addColumn('id', 'uuid')
->addColumn('status', 'string')
->addColumn('errors_count', 'integer', ['default' => 0])
->addColumn('warnings_count', 'integer', ['default' => 0])
->addColumn('raw_diff', 'text')
;

$analyses
->addColumn('id', 'uuid')
->addColumn('report_id', 'uuid')
->addColumn('type', 'text')
->addColumn('errors_count', 'integer', ['default' => 0])
->addColumn('warnings_count', 'integer', ['default' => 0])
->addForeignKey('report_id', 'report', 'id')
;

Expand All @@ -155,6 +152,7 @@ public function change()
$reports->create();
$inspections->create();
$githubPrInspections->create();
$bitbucketPrInspections->create();
$analyses->create();
$violations->create();
}
Expand Down
2 changes: 1 addition & 1 deletion app/Resources/db/seeds/Seed01User.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ public function run()
$users->insert([
[
'id' => 'd67ff369-704b-4315-a75f-b67f5bc9cc5a',
'username' => 'K-Phoen',
'roles' => 'ROLE_USER',
],
]);
Expand All @@ -23,6 +22,7 @@ public function run()
[
'id' => 'bf323fb5-2661-4bc7-bc32-0385b05017be',
'user_id' => 'd67ff369-704b-4315-a75f-b67f5bc9cc5a',
'username' => 'K-Phoen',
'remote_id' => 42,
'access_token' => 'fake access token',
],
Expand Down
1 change: 1 addition & 0 deletions app/Resources/db/seeds/Seed20Repository.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ public function run()
'id' => 'f733e45a-6fc7-404b-879d-656d68e0498d',
'identifier' => 'K-Phoen/regis',
'type' => 'github',
'name' => 'K-Phoen/regis',
'owner_id' => 'd67ff369-704b-4315-a75f-b67f5bc9cc5a',
'shared_secret' => 'some-shared-secret',
'is_inspection_enabled' => true,
Expand Down
2 changes: 1 addition & 1 deletion app/Resources/db/seeds/Seed30Inspection.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ public function run()
$inspections->insert([
[
'id' => 'fca728fc-9be0-40a1-a7d3-94f3fe4e118a',
'repository_id' => 'f733e45a-6fc7-404b-879d-656d68e0498d',
'report_id' => null,
'created_at' => '2017-11-08 21:36:00',
'started_at' => null,
Expand All @@ -30,7 +31,6 @@ public function run()
[
'id' => 'f733e45a-6fc7-404b-879d-656d68e0498d',
'pull_request_number' => 14,
'repository_id' => '2017-11-08 21:36:00',
],
]);

Expand Down
8 changes: 5 additions & 3 deletions app/Resources/views/utils.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

{% macro inspection_type(inspection) %}
{% spaceless %}
{% if inspection.type == 'github_pr' %}
{% if inspection.type == 'github_pr' or inspection.type == 'bitbucket_pr' %}
PR
{% else %}
Unknown ({{ inspection.type }})
Expand Down Expand Up @@ -65,9 +65,11 @@
{% macro repository_type(repo) %}
{% spaceless %}
{% if repo.type == 'github' %}
GitHub
Github
{% elseif repo.type == 'bitbucket' %}
Bitbucket
{% else %}
Unknown ({{ repo.type }})
{% endif %}
{% endspaceless %}
{% endmacro %}
{% endmacro %}
2 changes: 1 addition & 1 deletion app/config/bundles/knpu_oauth2_client.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ knpu_oauth2_client:
type: bitbucket
client_id: '%bitbucket_client_id%'
client_secret: '%bitbucket_client_secret%'
redirect_route: github_connect_check
redirect_route: bitbucket_connect_check
9 changes: 9 additions & 0 deletions app/config/bundles/old_sound_rabbit_mq.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,12 @@ old_sound_rabbit_mq:
routing_keys: [ analysis.github_pr.status ]
callback: regis.github.worker.analysis_status
enable_logger: true

bitbucket_analysis_status:
connection: default
exchange_options: {name: 'analysis-status', type: direct}
queue_options:
name: 'bitbucket-analysis-status'
routing_keys: [ analysis.bitbucket_pr.status ]
callback: regis.bitbucket.worker.analysis_status
enable_logger: true
2 changes: 1 addition & 1 deletion app/config/bundles/tactician.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ services:
- { name: monolog.logger, channel: command_bus }

regis.tactician.middleware.security:
class: Regis\GithubContext\Application\CommandHandler\Middleware\Security
class: Regis\AppContext\Application\CommandHandler\Middleware\Security
arguments: [ '@rulerz', '@regis.security.context' ]
tags:
- { name: monolog.logger, channel: command_bus }
Expand Down
12 changes: 12 additions & 0 deletions app/config/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,18 @@ doctrine:
dir: '%kernel.root_dir%/../src/AnalysisContext/Domain/Entity/config'
prefix: Regis\AnalysisContext\Domain\Entity
alias: RegisAnalysisContext
Regis\AppContext:
type: yml
is_bundle: false
dir: '%kernel.root_dir%/../src/AppContext/Domain/Entity/config'
prefix: Regis\AppContext\Domain\Entity
alias: RegisAppContext
Regis\BitbucketContext:
type: yml
is_bundle: false
dir: '%kernel.root_dir%/../src/BitbucketContext/Domain/Entity/config'
prefix: Regis\BitbucketContext\Domain\Entity
alias: RegisBitbucketContext
Regis\GithubContext:
type: yml
is_bundle: false
Expand Down
12 changes: 3 additions & 9 deletions app/config/security.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,13 @@ security:

# http://symfony.com/doc/current/book/security.html#where-do-users-come-from-user-providers
providers:
regis_db_provider:
entity:
class: Regis\GithubContext\Domain\Entity\User
property: username
regis_user_provider:
id: regis.app.user_account_provider

role_hierarchy:
ROLE_ADMIN: ROLE_USER
ROLE_SUPER_ADMIN: [ROLE_ADMIN, ROLE_ALLOWED_TO_SWITCH]


encoders:
Regis\Domain\Entity\User: bcrypt

firewalls:
# disables authentication for assets and the profiler, adapt it according to your needs
dev:
Expand All @@ -29,7 +23,7 @@ security:

main:
pattern: ^/
provider: regis_db_provider
provider: regis_user_provider
switch_user: true
anonymous: ~
remember_me:
Expand Down
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@

"php-http/guzzle6-adapter": "^1.1",
"knplabs/github-api": "^2.6",
"gentle/bitbucket-api": "^1.1",
"gitonomy/gitlib": "^1.0",

"php-amqplib/rabbitmq-bundle": "^1.10",
Expand Down
Loading