Skip to main content

Gerrit to GitHub / GitLab

Project description

Build Status Coveralls Project generated with PyScaffold

gerrit-to-platform

Gerrit to GitHub / GitLab (not yet available)

Gerrit hooks to allow using GitHub and GitLab as CI platforms.

To use, install the Gerrit hooks plugin and then symlink the hooks from the virtualenv that has the package installed.

A Python 3.8 or greater environment

Repositories that use the CI platform must have full mirroring replication configured. In specific refs/* must be in the replication set and not refs/heads/*

To activate a given hook, symlink the installed hook in the gerrit hooks directory.

Two configuration files needed. These files are:

  • ~gerrituser/.config/gerrit_to_platform/gerrit_to_platform.ini

  • ~gerrituser/.config/gerrit_to_platform/replication.config

The replication.config file should be a symlink to the standard Gerrit replication.config file

The gerrit_to_platform.ini file has the following format:

[mapping "content-added"]
recheck = verify
remerge = merge

[github.com]
token = <a_token_that_allows_triggering_actions>

[gitlab.com]
token = <a_token_that_allows_triggering_workflows>

The content-added mapping section is a key value pair for comment triggers to the corresponding workflow name or filename

GitHub Workflow Configuration

There are three hooks that gerrit-to-platform handles:

  • patchset-created (search filter: verify)

  • change-merged (search filter: merge)

  • comment-added (comment mapping for keyword to search filter)

Configuration for triggered workflows must meet the following requirements:

  • The workflow filename must contain ‘gerrit’

  • The workflow filename must contain the search filter

Required workflows must be part of the ORGANIZATION/.github magic repository. These workflow filenames must also contain ‘required’

ex: .github/workflows/gerrit-verify.yaml or .github/workflows/gerrit-required-verify.yaml

Standard workflows (non-required ones) must have the following primary configuration:

---
name: Gerrit Verify

# yamllint disable-line rule:truthy
on:
  workflow_dispatch:
    inputs:
      GERRIT_BRANCH:
        description: 'Branch that change is against'
        required: true
        type: string
      GERRIT_CHANGE_ID:
        description: 'The ID for the change'
        required: true
        type: string
      GERRIT_CHANGE_NUMBER:
        description: 'The Gerrit number'
        required: true
        type: string
      GERRIT_CHANGE_URL:
        description: 'URL to the change'
        required: true
        type: string
      GERRIT_EVENT_TYPE:
        description: 'Gerrit event type'
        required: true
        type: string
      GERRIT_PATCHSET_NUMBER:
        description: 'The patch number for the change'
        required: true
        type: string
      GERRIT_PATCHSET_REVISION:
        description: 'The revision sha'
        required: true
        type: string
      GERRIT_PROJECT:
        description: 'Project in Gerrit'
        required: true
        type: string
      GERRIT_REFSPEC:
        description: 'Gerrit refspec of change'
        required: true
        type: string


concurrency:
  group: ${{ github.event.inputs.GERRIT_CHANGE_ID || github.run_id }}
  cancel-in-progress: true

jobs:
  <your_job_configurations>

Required workflows must have the following extra input:

TARGET_REPO:
  description: 'The target GitHub repository needing the required workflow'
  required: true
  type: string

Making Changes & Contributing

This project uses pre-commit, please make sure to install it before making any changes:

pip install pre-commit
cd gerrit_to_platform
pre-commit install
pre-commit install -t commit-msg

Don’t forget to tell your contributors to also install and use pre-commit.

Note

PyScaffold 4.4 provided the initial project setup. For details and usage information on PyScaffold see https://pyscaffold.org/.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

gerrit-to-platform-0.2.1.tar.gz (47.8 kB view details)

Uploaded Source

Built Distribution

gerrit_to_platform-0.2.1-py3-none-any.whl (22.3 kB view details)

Uploaded Python 3

File details

Details for the file gerrit-to-platform-0.2.1.tar.gz.

File metadata

  • Download URL: gerrit-to-platform-0.2.1.tar.gz
  • Upload date:
  • Size: 47.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/4.0.1 CPython/3.11.4

File hashes

Hashes for gerrit-to-platform-0.2.1.tar.gz
Algorithm Hash digest
SHA256 c750cfc66677ea5d0d2c190143bc41551571318d0d67fd1a6f11746543328655
MD5 c2b9dfd14a085a498711e40a959813bf
BLAKE2b-256 d63b47ce29d43f06ba519844c3ac7971bf8e4a4583e35a07397507c2e83d4d2e

See more details on using hashes here.

File details

Details for the file gerrit_to_platform-0.2.1-py3-none-any.whl.

File metadata

File hashes

Hashes for gerrit_to_platform-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 cdaec1d1cef37e01042dd8a1fd86a5fa17cf0452adcc12e7a3e738c794bc13ab
MD5 a2312ca08eeacdba8f175fdc87f9f0e0
BLAKE2b-256 2768b27062ea29188fd19d0dafc636d3836630b308ecb99698f13242c7d2dac3

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page