-
Notifications
You must be signed in to change notification settings - Fork 461
Better SCM CI Integration Overview
NOTE: For now we only support local packages.
SCM CI Integration helps you to collaborate between OBS and the source code management (SCM) systems like GitHub or GitLab. It helps to handle your package sources with those systems. This section describes the integration between SCMs and OBS.

- SCM triggers a webhook pointing to our
trigger/workflowendpoint (someone opened or updated a PR). - Inside
TriggerWorkflowController:- Extract the event, SCM, and payload from the incoming request.
- Create a
WorkflowRun - Create a
ScmWebhookwhich contains a new payload created after the payload coming from the request. - Call
Token::Workflowmodel passing one instance ofWorkflowRunandScmWebhook.
-
Token::Workflowmodel- Download the
.obs/workflows.ymlfile from the target branch, not from the Pull request, using theWorkflows::YAMLDownloader. - Call the
Workflows::YAMLToWorkflowsServicewhich returns a collection ofWorkflowobjects for each workflow defined in the configuration file. - Send the initial report back to the SCM with "pending" state. Using
ScmInitialStatusReporter. - Call each workflow.
- Send the initial report back to the SCM with "success" state. Using
ScmInitialStatusReporter.
- Download the
-
Workflowmodel- Destroy the existing project in case the SCM closes a PR.
- Restore a previously existing project in case the SCM re-opens a PR.
- Handle the steps in other cases:
- Extract the steps from the workflow (
Workflow::Step::BranchPackageStep,Workflow::Step::LinkPackageStepandWorkflow::Step::ConfigureRepositoriesStepetc.) - Call every step.
- Collects the artifacts of each step with
Workflows::ArtifactsCollector.
- Extract the steps from the workflow (
-
Workflow::Stepmodel (and its inherited Workflow::Step::*)- Perform the step.
- Create two
Event::Subscription(storing the token ID in theevent_subscriptions.token_idcolumn) and in thatEvent::Subscription, we store the required information to be able to report back to the SCM (repository owner, etc... see below in Reporting Back to SCM).
NOTE: To make the service run on a linked package (link_package step) we had to make it a "project service" by adding a package named _project into the target project. The package contains a _service file with a correct definition of a service.
- Whenever a build finishes in the Backend, a new
Event::BuildFailorEvent::BuildSuccessis created and a newReportToScmJobis queued inscmqueue. Follow this link for a better understanding of the Events system.-
ReportToScmJobinherits fromCreateJob. -
CreateJobis only for jobs dealing with events, since itsperformmethod expects anevent_id. - For the jobs to be created, event classes like
Event::BuildFailandEvent::BuildSuccessneed to have the following code:create_jobs :report_to_scm_job. This will then be picked up in theafter_create :perform_create_jobscallback in theEvent::Basemodel. - If the provided symbol in the
create_jobsmethod is a valid job inheriting fromCreateJob, then the corresponding job will be queued. - The
scmqueue service is defined insystemd/obs-delayedjob-queue-scm.service - We pass the
event_idto theReportToScmJob. Using theevent_idwe are fetching the event object, we search for the event subscriptions that match the given event object (eventtypeand package), loop over them and callGitlabStatusReporter/GithubStatusReporter(depending on the SCM) for each one.
-
-
GitlabStatusReporter/GithubStatusReporterservice, called byReportToScmJob,- Report status back to the SCM for the corresponding commit
- Create an instance of
ScmStatusReport, which represents the communication between OBS and the SCM. It stores the status (success or fail) and the error message in case of failure. It's associated with the workflow run.
Whenever a workflow token is triggered by an incoming webhook, a workflow run is created to track what is happening, thus helping users understand how their workflow behaves. In addition to the headers and payload of the incoming webhook, workflow runs store the response we send back to the SCM and to which URL it is sent. Finally, the status is saved, so users know if the workflow run succeeded or potentially failed due to an error.
- Development Environment Overview
- Development Environment Tips & Tricks
- Spec-Tips
- Code Style
- Rubocop
- Testing with VCR
- Test in kanku
- Authentication
- Authorization
- Autocomplete
- BS Requests
- Events
- ProjectLog
- Notifications
- Feature Toggles
- Build Results
- Attrib classes
- Flags
- The BackendPackage Cache
- Maintenance classes
- Cloud uploader
- Delayed Jobs
- Staging Workflow
- StatusHistory
- OBS API
- Owner Search
- Search
- Links
- Distributions
- Repository
- Data Migrations
- Package Versions
- next_rails
- Ruby Update
- Rails Profiling
- Remote Pairing Setup Guide
- Factory Dashboard
- osc
- Setup an OBS Development Environment on macOS
- Run OpenQA smoketest locally
- Responsive Guidelines
- Importing database dumps
- Problem Statement & Solution
- Kickoff New Stuff
- New Swagger API doc
- Documentation and Communication
- GitHub Actions
- Brakeman
- How to Introduce Software Design Patterns
- Query Objects
- Services
- View Components
- RFC: Core Components
- RFC: Decorator Pattern
- RFC: Backend models
- RFC: Hotwire Turbo Frames Pattern