Initial commit, verify maven and unit tests, self
This commit adds initial versions of verify-unit-tests and
verify-maven shared workflows, as well as actionlint check for the
shared workflows themselves.
Signed-off-by: Eric Ball <eball@linuxfoundation.org>
Change-Id: Ib9d47b7fa62eee48e213a14484e9ff33d6967551
diff --git a/.github/workflows/verify-workflows.yaml b/.github/workflows/verify-workflows.yaml
new file mode 100644
index 0000000..601cfc7
--- /dev/null
+++ b/.github/workflows/verify-workflows.yaml
@@ -0,0 +1,72 @@
+---
+# SPDX-License-Identifier: Apache-2.0
+# SPDX-FileCopyrightText: 2026 The Linux Foundation
+
+name: Lint GitHub Actions workflows
+
+# yamllint disable-line rule:truthy
+on:
+ workflow_dispatch:
+ inputs:
+ # Gerrit-to-Github defaults
+ 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
+
+concurrency:
+ # yamllint disable-line rule:line-length
+ group: verify-workflows-${{ github.workflow }}-${{ github.event.inputs.GERRIT_CHANGE_ID || github.run_id }}
+ cancel-in-progress: true
+
+jobs:
+ actionlint:
+ runs-on: ubuntu-latest
+ steps:
+ # yamllint disable-line rule:line-length
+ - uses: lfreleng-actions/checkout-gerrit-change-action@54d751e8bd167bc91f7d665dabe33fae87aaaa63 # v0.9
+ with:
+ gerrit-refspec: ${{ inputs.GERRIT_REFSPEC }}
+ gerrit-project: ${{ inputs.GERRIT_PROJECT }}
+ gerrit-url: ${{ vars.GERRIT_URL }}
+ delay: "0s"
+ - name: Download actionlint
+ id: get_actionlint
+ # yamllint disable-line rule:line-length
+ run: bash <(curl https://raw.githubusercontent.com/rhysd/actionlint/main/scripts/download-actionlint.bash)
+ shell: bash
+ - name: Check workflow files
+ run: ${{ steps.get_actionlint.outputs.executable }} -color
+ shell: bash
diff --git a/.gitreview b/.gitreview
new file mode 100644
index 0000000..d6ed312
--- /dev/null
+++ b/.gitreview
@@ -0,0 +1,5 @@
+[gerrit]
+host=gerrit.lfbroadband.org
+port=29418
+project=shared-workflows.git
+defaultbranch=main
diff --git a/workflows/verify-maven.yaml b/workflows/verify-maven.yaml
new file mode 100644
index 0000000..b24e95a
--- /dev/null
+++ b/workflows/verify-maven.yaml
@@ -0,0 +1,135 @@
+---
+# SPDX-License-Identifier: Apache-2.0
+# SPDX-FileCopyrightText: 2026 The Linux Foundation
+name: Gerrit Verify - Maven
+
+# yamllint disable-line rule:truthy
+on:
+ workflow_dispatch:
+ inputs:
+ # Gerrit-to-Github defaults
+ 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
+ # Needed for maven-build-action
+ JDK_VERSION:
+ description: "OpenJDK version"
+ required: false
+ default: "17"
+ type: string
+ MVN_VERSION:
+ description: "Maven version"
+ required: false
+ default: "3.8.2"
+ type: stringssh://eball@gerrit.lfbroadband.org:29418/shared-workflows
+ MVN_PARAMS:
+ description: "Maven parameters to pass to the mvn command"
+ required: false
+ default: ""
+ type: string
+ MVN_PHASES:
+ description: "Comma separated list of phases to execute"
+ required: false
+ default: "clean deploy"
+ type: string
+ MVN_OPTS:
+ description: "Maven options"
+ required: false
+ # yamllint disable rule:line-length
+ default: >-
+ -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn
+ -Dmaven.repo.local=/tmp/r -Dorg.ops4j.pax.url.mvn.localRepository=/tmp/r
+ -DaltDeploymentRepository=staging::default::file:"${GITHUB_WORKSPACE}"/m2repo
+ # yamllint enable rule:line-length
+ type: string
+ MVN_POM_FILE:
+ description: "Path to pom.xml file."
+ required: false
+ default: "pom.xml"
+ type: string
+ MVN_PROFILES:
+ description: "Comma-delimited list of profiles to activate"
+ required: false
+ default: ""
+ type: string
+ MVN_GLOBAL_SETTINGS:
+ description: "Maven global settings configuration."
+ required: false
+ default: ${{ vars.GLOBAL_SETTINGS }}
+ type: string
+ ENV_VARS:
+ # yamllint disable-line rule:line-length
+ description: "Pass GitHub variables to be exported as environment variables via `toJSON(vars)` or specific variables encoded in JSON format"
+ required: false
+ default: "{}"
+ type: string
+ ENV_SECRETS:
+ # yamllint disable-line rule:line-length
+ description: "Pass GitHub secrets to be exported as environment variables via `toJSON(secrets)` or specific secrets encoded in JSON format"
+ required: false
+ default: "{}"
+ type: string
+
+concurrency:
+ # yamllint disable-line rule:line-length
+ group: verify-maven-${{ github.workflow }}-${{ github.event.inputs.GERRIT_CHANGE_ID || github.run_id }}
+ cancel-in-progress: true
+
+jobs:
+ maven-verify:
+ runs-on: ubuntu-latest
+ steps:
+ # yamllint disable-line rule:line-length
+ - uses: lfreleng-actions/checkout-gerrit-change-action@54d751e8bd167bc91f7d665dabe33fae87aaaa63 # v0.9
+ with:
+ gerrit-refspec: ${{ inputs.GERRIT_REFSPEC }}
+ gerrit-project: ${{ inputs.GERRIT_PROJECT }}
+ gerrit-url: ${{ vars.GERRIT_URL }}
+ delay: "0s"
+ - name: Run Maven
+ # yamllint disable-line rule:line-length
+ uses: lfreleng-actions/maven-build-action@5be56aed8bed4f0bf9d699f2817eaef37c94ac02 # v0.2.0
+ with:
+ java-version: ${{ inputs.JDK_VERSION }}
+ mvn-version: ${{ inputs.MVN_VERSION }}
+ mvn-params: ${{ inputs.MVN_PARAMS }}
+ mvn-phases: ${{ inputs.MVN_PHASES }}
+ mvn-opts: ${{ inputs.MVN_OPTS }}
+ mvn-pom-file: ${{ inputs.MVN_POM_FILE }}
+ mvn-profiles: ${{ inputs.MVN_PROFILES }}
+ env-vars: ${{ inputs.ENV_VARS }}
+ env-secrets: ${{ inputs.ENV_SECRETS }}
+ global-settings: ${{ inputs.MVN_GLOBAL_SETTINGS }}
diff --git a/workflows/verify-unit-tests.yaml b/workflows/verify-unit-tests.yaml
new file mode 100644
index 0000000..f944f42
--- /dev/null
+++ b/workflows/verify-unit-tests.yaml
@@ -0,0 +1,105 @@
+---
+# SPDX-License-Identifier: Apache-2.0
+# SPDX-FileCopyrightText: 2026 The Linux Foundation
+name: Gerrit Verify - Unit Tests
+
+# yamllint disable-line rule:truthy
+on:
+ workflow_dispatch:
+ inputs:
+ # Gerrit-to-Github defaults
+ 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
+ # Workflow-specific inputs
+ UNIT_TEST_TARGETS:
+ description: "List of targets in json-formatted string"
+ required: false
+ type: string
+ default: '["lint", "sca", "test"]'
+ DEST_GOPATH:
+ description: "Specifies part of the GOPATH. Usually set to Github org."
+ required: false
+ type: string
+ default: "github.com/opencord"
+ GOPROXY:
+ description: "Url for Go proxy"
+ required: false
+ type: string
+ default: "https://proxy.golang.org"
+
+concurrency:
+ # yamllint disable-line rule:line-length
+ group: verify-unit-tests-${{ github.workflow }}-${{ github.event.inputs.GERRIT_CHANGE_ID || github.run_id }}
+ cancel-in-progress: true
+
+jobs:
+ unit-tests:
+ runs-on: ubuntu-latest
+ strategy:
+ matrix:
+ target: ${{ fromJSON(inputs.UNIT_TEST_TARGETS) }}
+ steps:
+ - name: Gerrit Checkout
+ # yamllint disable-line rule:line-length
+ uses: lfit/checkout-gerrit-change-action@54d751e8bd167bc91f7d665dabe33fae87aaaa63 # v0.9
+ with:
+ gerrit-refspec: ${{ inputs.GERRIT_REFSPEC }}
+ gerrit-project: ${{ inputs.GERRIT_PROJECT }}
+ gerrit-url: ${{ vars.GERRIT_URL }}
+ delay: "0s"
+ submodules: "true"
+ fetch-depth: 0
+ # yamllint disable-line rule:line-length
+ - name: Install python
+ uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6.0
+ with:
+ python-version: "3.10"
+ - name: Install virtualenv
+ run: pip install virtualenv
+ - name: Install Go
+ uses: actions/setup-go@v5
+ with:
+ go-version-file: go.mod
+ - name: Run unit tests
+ env:
+ DEST_GOPATH: ${{ inputs.DEST_GOPATH }}
+ UNIT_TEST_TARGETS: ${{ matrix.target }}
+ GOPROXY: ${{ inputs.GOPROXY }}
+ TEST_PROJECT: ${{ github.repository }}
+ WORKSPACE: ${{ github.workspace }}
+ run: |
+ make SHELL="/bin/bash" ${{ matrix.target }}