Eric Ball | 17cfd6d | 2025-07-18 13:51:55 -0700 | [diff] [blame] | 1 | --- |
| 2 | name: Gerrit Composed Maven Verify |
| 3 | |
| 4 | # yamllint disable-line rule:truthy |
| 5 | on: |
| 6 | workflow_dispatch: |
| 7 | inputs: |
| 8 | GERRIT_BRANCH: |
| 9 | description: "Branch that change is against" |
| 10 | required: true |
| 11 | type: string |
| 12 | GERRIT_CHANGE_ID: |
| 13 | description: "The ID for the change" |
| 14 | required: true |
| 15 | type: string |
| 16 | GERRIT_CHANGE_NUMBER: |
| 17 | description: "The Gerrit number" |
| 18 | required: true |
| 19 | type: string |
| 20 | GERRIT_CHANGE_URL: |
| 21 | description: "URL to the change" |
| 22 | required: true |
| 23 | type: string |
| 24 | GERRIT_EVENT_TYPE: |
| 25 | description: "Type of Gerrit event" |
| 26 | required: true |
| 27 | type: string |
| 28 | GERRIT_PATCHSET_NUMBER: |
| 29 | description: "The patch number for the change" |
| 30 | required: true |
| 31 | type: string |
| 32 | GERRIT_PATCHSET_REVISION: |
| 33 | description: "The revision sha" |
| 34 | required: true |
| 35 | type: string |
| 36 | GERRIT_PROJECT: |
| 37 | description: "Project in Gerrit" |
| 38 | required: true |
| 39 | type: string |
| 40 | GERRIT_REFSPEC: |
| 41 | description: "Gerrit refspec of change" |
| 42 | required: true |
| 43 | type: string |
| 44 | |
| 45 | concurrency: |
| 46 | # yamllint disable-line rule:line-length |
| 47 | group: compose-maven-verify-${{ github.workflow }}-${{ github.event.inputs.GERRIT_CHANGE_ID || github.run_id }} |
| 48 | cancel-in-progress: true |
| 49 | |
| 50 | jobs: |
| 51 | license-check: |
| 52 | uses: onosproject/.github/.github/workflows/license-check.yml@main |
| 53 | |
| 54 | unit-tests: |
| 55 | runs-on: ubuntu-latest |
| 56 | strategy: |
| 57 | matrix: |
| 58 | target: [lint, sca, test] |
| 59 | steps: |
| 60 | - name: Gerrit Checkout |
| 61 | # yamllint disable-line rule:line-length |
| 62 | uses: lfit/checkout-gerrit-change-action@54d751e8bd167bc91f7d665dabe33fae87aaaa63 # v0.9 |
| 63 | with: |
| 64 | gerrit-refspec: ${{ inputs.GERRIT_REFSPEC }} |
| 65 | gerrit-project: ${{ inputs.GERRIT_PROJECT }} |
| 66 | gerrit-url: ${{ vars.GERRIT_URL }} |
| 67 | delay: "0s" |
| 68 | submodules: "true" |
| 69 | - name: Run unit tests |
| 70 | env: |
| 71 | # TODO: This is a test. Once in production, these should be inputs |
| 72 | # supplied by the calling job to the reusable workflow. |
| 73 | DEST_GOPATH: github.com/opencord |
| 74 | UNIT_TEST_TARGETS: ${{ matrix.target }} |
| 75 | UNIT_TEST_KEEP_GOING: false |
| 76 | GOPROXY: https://proxy.golang.org |
| 77 | TEST_PROJECT: ${{ github.repository }} |
| 78 | WORKSPACE: ${{ github.workspace }} |
| 79 | #ONF_MAKE_SUBDIR: "lf/onf-make" |
| 80 | #PROJECT: "${TEST_PROJECT:-}" |
| 81 | #REPO: "https://gerrit.opencord.org/$PROJECT" |
| 82 | run: | |
| 83 | export GOPATH=${GOPATH:-$WORKSPACE/go} |
| 84 | mkdir -p "$GOPATH/src/$DEST_GOPATH" |
| 85 | export PATH=$PATH:/usr/lib/go-1.12/bin:/usr/local/go/bin:$GOPATH/bin |
| 86 | test_path="$GOPATH/src/$DEST_GOPATH/$TEST_PROJECT" |
| 87 | mv "$WORKSPACE/$TEST_PROJECT" "$test_path" |
| 88 | |
| 89 | if [ ! -f "$test_path/Makefile" ]; then |
| 90 | echo "Makefile not found at ${test_path}/Makefile" |
| 91 | exit 1 |
| 92 | else |
| 93 | pushd "$test_path" |
| 94 | |
| 95 | # we want to split the make targets apart on spaces, so: |
| 96 | # shellcheck disable=SC2086 |
| 97 | if [ "$UNIT_TEST_KEEP_GOING" = "true" ]; then |
| 98 | make -k $UNIT_TEST_TARGETS |
| 99 | else |
| 100 | make $UNIT_TEST_TARGETS |
| 101 | fi |
| 102 | |
| 103 | popd |
| 104 | fi |