# This file holds all gerrit lint verifications https://jenkins.osmocom.org/jenkins/view/Jenkins-Gerrit/.
# Add project's repositories to jobs/gerrit-verifications.yml. When
# pipeline_lint is set for that project, the pipeline will call the gerrit-lint
# job for it.

- project:
    name: gerrit-lint
    jobs:
      - 'gerrit-lint'

- job:
    name: 'gerrit-lint'
    project-type: freestyle
    node: osmocom-gerrit
    retry-count: 3 # scm checkout
    properties:
      - build-discarder:
          days-to-keep: 30
          num-to-keep: 1000
    description: |
      Lint job of CI for patches sent to <a href="https://gerrit.osmocom.org">gerrit</a>.
      </br></br>
      Related issue: <a href="https://osmocom.org/issues/5087">OS#5087</a>

    parameters:
      !include: gerrit-verifications-parameters.yaml.inc

    scm:
      - git:
         basedir: 'code-from-gerrit'
         url: '$GERRIT_REPO_URL'
         credentials-id: d5eda5e9-b59d-44ba-88d2-43473cb6e42d
         branches:
           - $GERRIT_BRANCH
         refspec: $GERRIT_REFSPEC
         choosing-strategy: gerrit
         skip-tag: true
         submodule:
           recursive: false

    builders:
      - shell: |
          rm -rf osmo-ci
          git clone \
            --depth=1 \
            --branch="$BRANCH_CI" \
            https://gerrit.osmocom.org/osmo-ci \
            osmo-ci
          git -C osmo-ci log --oneline

          docker run \
            --rm \
            -e GERRIT_HOST=$GERRIT_HOST \
            -e GERRIT_PORT=$GERRIT_PORT \
            -e GERRIT_PROJECT=$GERRIT_PROJECT \
            -e GERRIT_CHANGE_NUMBER=$GERRIT_CHANGE_NUMBER \
            -e GERRIT_PATCHSET_NUMBER=$GERRIT_PATCHSET_NUMBER \
            -e JENKINS_HOME=1 \
            -e SSH_AUTH_SOCK=/ssh-agent \
            -u build \
            -v $(readlink -f $SSH_AUTH_SOCK):/ssh-agent \
            -v ./code-from-gerrit:/build/code-from-gerrit \
            -v ./osmo-ci:/build/osmo-ci \
            -w /build/code-from-gerrit \
            "$USER/debian-bookworm-build" \
            /build/osmo-ci/lint/lint_diff.sh HEAD~1

    wrappers:
    - ansicolor:
        colormap: xterm
    - ssh-agent-credentials:
        users:
        - d5eda5e9-b59d-44ba-88d2-43473cb6e42d

# vim: expandtab tabstop=2 shiftwidth=2