Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CI: Add workflow for Autotools SonarCloud scan #158

Merged
merged 1 commit into from
Apr 12, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
135 changes: 135 additions & 0 deletions .github/workflows/composed-autotools-sonar-cloud.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
---
name: Composed Autotools Sonar Cloud

# yamllint disable-line rule:truthy
on:
workflow_call:
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: "Type of Gerrit event"
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
JDK_VERSION:
description: "OpenJDK version"
required: false
default: "17"
type: string
PRE_BUILD_SCRIPT:
description: "Pre-build script to trigger before verify run"
required: false
default: ""
type: string
PRE_BUILD_SCRIPT_PATH:
description: "Path to pre-build script to trigger before verify run"
required: false
default: ""
type: string
PRE_BUILD_SCRIPT_URL:
description: "URL of pre-build script to trigger before verify run"
required: false
default: ""
type: string
SONAR_ARGS:
description: "Additional arguments to the SonarCloud scanner"
required: false
type: string
default: ""
SONAR_PROJECTBASEDIR:
description: "Set the sonar.projectBaseDir analysis property"
required: false
type: string
default: .
secrets:
SONAR_TOKEN:
description: "Sonar Cloud access token"
required: true

concurrency:
# yamllint disable-line rule:line-length
group: composed-autotools-sonar-cloud-${{ github.workflow }}-${{ github.event.inputs.GERRIT_BRANCH}}-${{ github.event.inputs.GERRIT_CHANGE_ID || github.run_id }}
cancel-in-progress: true

jobs:
run-autotools-sonar-scan:
runs-on: ubuntu-latest
env:
PRE_BUILD: "/dev/null"

steps:
- uses: actions/checkout@v4
with:
ref: ${{ inputs.GERRIT_BRANCH }}
submodules: "true"
# yamllint disable-line rule:line-length
- uses: actions/setup-python@0a5c61591373683505ea898e09a3ea4f39ef2b9c # v5.0.0
id: setup-python
with:
python-version: "3.8"
- name: Setup JDK
id: setup-jdk
uses: actions/setup-java@v3
with:
java-version: ${{ inputs.JDK_VERSION }}
jwagantall marked this conversation as resolved.
Show resolved Hide resolved
distribution: 'temurin'
- name: Pre-build path
if: ${{ inputs.PRE_BUILD_SCRIPT_PATH != '' }}
run: |
echo "PRE_BUILD=${{ inputs.PRE_BUILD_SCRIPT_PATH }}" >> "$GITHUB_ENV"
- name: Pre-build script
if: ${{ inputs.PRE_BUILD_SCRIPT != '' }}
run: |
echo "${{ inputs.PRE_BUILD_SCRIPT }}" > "${{ github.run_id }}.sh"
chmod +x "${{ github.run_id }}.sh"
echo "PRE_BUILD=${{ github.run_id }}.sh" >> "$GITHUB_ENV"
- name: Pre-build URL
if: ${{ inputs.PRE_BUILD_SCRIPT_URL != '' }}
run: |
curl "${{ inputs.PRE_BUILD_SCRIPT_URL }}" > "${{ github.run_id }}.sh"
chmod +x "${{ github.run_id }}.sh"
echo "PRE_BUILD=${{ github.run_id }}.sh" >> "$GITHUB_ENV"
- name: Run pre-build-script
shell: bash
run: sh "$PRE_BUILD"
- name: Run autotools script
# yamllint disable rule:line-length
run: |
curl https://raw.githubusercontent.com/lfit/releng-global-jjb/master/shell/autotools-sonarqube.sh | bash
- name: Run Sonar Cloud scan
uses: sonarsource/sonarcloud-github-action@master
env:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
with:
args: ${{ inputs.SONAR_ARGS }}
projectBaseDir: ${{ inputs.SONAR_PROJECTBASEDIR }}