Go to file
Yorick Peterse 4dfe26cd8b
Rewrite the GitHub importer from scratch
Prior to this MR there were two GitHub related importers:

* Github::Import: the main importer used for GitHub projects
* Gitlab::GithubImport: importer that's somewhat confusingly used for
  importing Gitea projects (apparently they have a compatible API)

This MR renames the Gitea importer to Gitlab::LegacyGithubImport and
introduces a new GitHub importer in the Gitlab::GithubImport namespace.
This new GitHub importer uses Sidekiq for importing multiple resources
in parallel, though it also has the ability to import data sequentially
should this be necessary.

The new code is spread across the following directories:

* lib/gitlab/github_import: this directory contains most of the importer
  code such as the classes used for importing resources.
* app/workers/gitlab/github_import: this directory contains the Sidekiq
  workers, most of which simply use the code from the directory above.
* app/workers/concerns/gitlab/github_import: this directory provides a
  few modules that are included in every GitHub importer worker.

== Stages

The import work is divided into separate stages, with each stage
importing a specific set of data. Stages will schedule the work that
needs to be performed, followed by scheduling a job for the
"AdvanceStageWorker" worker. This worker will periodically check if all
work is completed and schedule the next stage if this is the case. If
work is not yet completed this worker will reschedule itself.

Using this approach we don't have to block threads by calling `sleep()`,
as doing so for large projects could block the thread from doing any
work for many hours.

== Retrying Work

Workers will reschedule themselves whenever necessary. For example,
hitting the GitHub API's rate limit will result in jobs rescheduling
themselves. These jobs are not processed until the rate limit has been
reset.

== User Lookups

Part of the importing process involves looking up user details in the
GitHub API so we can map them to GitLab users. The old importer used
an in-memory cache, but this obviously doesn't work when the work is
spread across different threads.

The new importer uses a Redis cache and makes sure we only perform
API/database calls if absolutely necessary.  Frequently used keys are
refreshed, and lookup misses are also cached; removing the need for
performing API/database calls if we know we don't have the data we're
looking for.

== Performance & Models

The new importer in various places uses raw INSERT statements (as
generated by `Gitlab::Database.bulk_insert`) instead of using Rails
models. This allows us to bypass any validations and callbacks,
drastically reducing the number of SQL queries and Gitaly RPC calls
necessary to import projects.

To ensure the code produces valid data the corresponding tests check if
the produced rows are valid according to the model validation rules.
2017-11-07 23:24:59 +01:00
.github
.gitlab Add .gitlab/route-map.yml 2017-10-30 16:13:15 +01:00
app Rewrite the GitHub importer from scratch 2017-11-07 23:24:59 +01:00
bin Add Performance category to the changelog 2017-10-13 12:45:56 +02:00
builds
changelogs Merge branch 'add-ingress-to-cluster-applications' into 'master' 2017-11-07 20:23:21 +00:00
config Rewrite the GitHub importer from scratch 2017-11-07 23:24:59 +01:00
db Fix db/schema.rb 2017-11-07 19:46:45 +01:00
doc Rewrite the GitHub importer from scratch 2017-11-07 23:24:59 +01:00
docker
features enable CHROME_HEADLESS environment variable for Spinach tests similar to RSpec 2017-11-01 11:03:06 -05:00
fixtures/emojis
generator_templates
lib Rewrite the GitHub importer from scratch 2017-11-07 23:24:59 +01:00
locale Resolve "Fix GKE wording" 2017-11-07 11:44:29 +00:00
log
public
qa Fixup rspec tag misuse 2017-11-06 17:54:21 +00:00
rubocop Add a new RSpec::EnvAssignment cop to prevent assigning to ENV in specs 2017-10-18 18:42:09 +02:00
scripts Use the --parallel Rubocop flag in the static-analysis and improve the job 2017-11-03 17:00:49 +01:00
shared
spec Rewrite the GitHub importer from scratch 2017-11-07 23:24:59 +01:00
symbol
tmp
vendor Upgrade vendored templates 2017-11-07 20:07:28 +01:00
.babelrc
.codeclimate.yml
.csscomb.json
.eslintignore
.eslintrc
.flayignore
.foreman
.gitignore
.gitlab-ci.yml Merge branch 'sh-headless-chrome-support' into 'master' 2017-11-03 22:50:55 +00:00
.haml-lint.yml
.mailmap
.nvmrc Update .nvmrc to current stable (v9.0.0) 2017-11-02 13:15:39 +01:00
.pkgr.yml
.rubocop.yml Decrease ABC threshold to 54.28 2017-10-22 17:12:35 +00:00
.rubocop_todo.yml
.ruby-version Upgrade Ruby to 2.3.5 2017-10-31 14:19:14 +01:00
.scss-lint.yml Enable BorderZero rule in scss-lint 2017-11-06 17:51:10 +09:00
CHANGELOG.md Update CHANGELOG.md for 10.0.5 2017-11-03 17:57:17 +01:00
CONTRIBUTING.md Merge branch 'docs-clarify-beginner-issue-weights' into 'master' 2017-11-02 14:25:41 +00:00
GITALY_SERVER_VERSION Migrate Gitlab::Git::Wiki#delete_page to Gitaly 2017-10-31 13:47:34 +02:00
GITLAB_PAGES_VERSION
GITLAB_SHELL_VERSION Pass git object dir attributes as relative paths to Gitaly 2017-10-11 15:46:55 +02:00
GITLAB_WORKHORSE_VERSION Support show-all-refs for git over HTTP 2017-10-30 15:20:36 +00:00
Gemfile Merge branch 'master' into sh-headless-chrome-support 2017-10-31 16:08:11 -05:00
Gemfile.lock Merge branch 'master' into sh-headless-chrome-support 2017-11-02 17:05:06 -05:00
LICENSE
MAINTENANCE.md Change location of the maintenance policy document. Add version support information. [CI skip] 2017-10-11 15:01:55 +02:00
PROCESS.md Refactor the Development documentation, and divide the Testing documentation into multiple pages 2017-10-11 05:59:34 +00:00
Procfile
README.md
Rakefile
VERSION Update VERSION to 10.2.0-pre 2017-10-21 22:54:47 +00:00
config.ru
doc_styleguide.md
docker-compose.yml
package.json Merge branch 'vue-update' into 'master' 2017-11-02 09:29:19 +00:00
yarn.lock Resolve "Editor icons" 2017-11-06 12:04:55 +00:00

README.md

GitLab

Build status Overall test coverage Dependency Status Code Climate Core Infrastructure Initiative Best Practices Gitter

Test coverage

  • Ruby coverage Ruby
  • JavaScript coverage JavaScript

Canonical source

The canonical source of GitLab Community Edition is hosted on GitLab.com.

Open source software to collaborate on code

To see how GitLab looks please see the features page on our website.

  • Manage Git repositories with fine grained access controls that keep your code secure
  • Perform code reviews and enhance collaboration with merge requests
  • Complete continuous integration (CI) and CD pipelines to builds, test, and deploy your applications
  • Each project can also have an issue tracker, issue board, and a wiki
  • Used by more than 100,000 organizations, GitLab is the most popular solution to manage Git repositories on-premises
  • Completely free and open source (MIT Expat license)

Hiring

We're hiring developers, support people, and production engineers all the time, please see our jobs page.

Editions

There are two editions of GitLab:

  • GitLab Community Edition (CE) is available freely under the MIT Expat license.
  • GitLab Enterprise Edition (EE) includes extra features that are more useful for organizations with more than 100 users. To use EE and get official support please become a subscriber.

Website

On about.gitlab.com you can find more information about:

Requirements

Please see the requirements documentation for system requirements and more information about the supported operating systems.

Installation

The recommended way to install GitLab is with the Omnibus packages on our package server. Compared to an installation from source, this is faster and less error prone. Just select your operating system, download the respective package (Debian or RPM) and install it using the system's package manager.

There are various other options to install GitLab, please refer to the installation page on the GitLab website for more information.

You can access a new installation with the login root and password 5iveL!fe, after login you are required to set a unique password.

Contributing

GitLab is an open source project and we are very happy to accept community contributions. Please refer to CONTRIBUTING.md for details.

Install a development environment

To work on GitLab itself, we recommend setting up your development environment with the GitLab Development Kit. If you do not use the GitLab Development Kit you need to install and setup all the dependencies yourself, this is a lot of work and error prone. One small thing you also have to do when installing it yourself is to copy the example development unicorn configuration file:

cp config/unicorn.rb.example.development config/unicorn.rb

Instructions on how to start GitLab and how to run the tests can be found in the getting started section of the GitLab Development Kit.

Software stack

GitLab is a Ruby on Rails application that runs on the following software:

  • Ubuntu/Debian/CentOS/RHEL/OpenSUSE
  • Ruby (MRI) 2.3
  • Git 2.8.4+
  • Redis 2.8+
  • PostgreSQL (preferred) or MySQL

For more information please see the architecture documentation.

UX design

Please adhere to the UX Guide when creating designs and implementing code.

Third-party applications

There are a lot of third-party applications integrating with GitLab. These include GUI Git clients, mobile applications and API wrappers for various languages.

GitLab release cycle

For more information about the release process see the release documentation.

Upgrading

For upgrading information please see our update page.

Documentation

All documentation can be found on docs.gitlab.com/ce/.

Getting help

Please see Getting help for GitLab on our website for the many options to get help.

Is it any good?

Yes

Is it awesome?

Thanks for asking this question Joshua. These people seem to like it.