|
| 1 | +# ******************************************************************************* |
| 2 | +# Copyright (c) 2026 Contributors to the Eclipse Foundation |
| 3 | +# |
| 4 | +# See the NOTICE file(s) distributed with this work for additional |
| 5 | +# information regarding copyright ownership. |
| 6 | +# |
| 7 | +# This program and the accompanying materials are made available under the |
| 8 | +# terms of the Apache License Version 2.0 which is available at |
| 9 | +# https://www.apache.org/licenses/LICENSE-2.0 |
| 10 | +# |
| 11 | +# SPDX-License-Identifier: Apache-2.0 |
| 12 | +# ******************************************************************************* |
| 13 | + |
| 14 | +name: AutoSD Build |
| 15 | + |
| 16 | +on: |
| 17 | + workflow_call: |
| 18 | + inputs: |
| 19 | + arch: |
| 20 | + description: "Architecture to build" |
| 21 | + required: true |
| 22 | + type: string |
| 23 | + default: "x86_64" |
| 24 | + runner_label: |
| 25 | + description: "Runner label to use" |
| 26 | + required: false |
| 27 | + type: string |
| 28 | + bazel-action: |
| 29 | + description: "Bazel action to run (build, test, etc)" |
| 30 | + required: false |
| 31 | + default: "build" |
| 32 | + type: string |
| 33 | + bazel-target: |
| 34 | + description: "Bazel target to build or test" |
| 35 | + required: false |
| 36 | + default: "//score/..." |
| 37 | + type: string |
| 38 | + bazel-disk-cache: |
| 39 | + description: "Enable Bazel disk cache on GitHub. The value can be a string to use as cache key for separating workflows" |
| 40 | + required: false |
| 41 | + default: "true" |
| 42 | + type: string |
| 43 | + extra-bazel-flags: |
| 44 | + description: "Additional Bazel flags to pass to the build command (whitespace separated)" |
| 45 | + required: false |
| 46 | + default: "" |
| 47 | + type: string |
| 48 | + |
| 49 | +jobs: |
| 50 | + build: |
| 51 | + name: Build Target |
| 52 | + runs-on: ${{ inputs.runner_label || (vars.REPO_RUNNER_LABELS && fromJSON(vars.REPO_RUNNER_LABELS)) || 'ubuntu-latest' }} |
| 53 | + permissions: |
| 54 | + contents: read |
| 55 | + pull-requests: read |
| 56 | + |
| 57 | + steps: |
| 58 | + - name: Checkout Repository (Handle all events) |
| 59 | + uses: actions/checkout@v4.2.2 |
| 60 | + with: |
| 61 | + ref: ${{ github.head_ref || github.event.pull_request.head.ref || github.ref }} |
| 62 | + repository: ${{ github.event.pull_request.head.repo.full_name || github.repository }} |
| 63 | + - name: Checkout repository |
| 64 | + uses: actions/checkout@v4 |
| 65 | + with: |
| 66 | + repository: odra/cicd-workflows |
| 67 | + ref: autosd-bazel-ci |
| 68 | + path: score-ci-cd-workflows |
| 69 | + - name: Setup Bazel (Shared Caching) |
| 70 | + uses: bazel-contrib/setup-bazel@0.18.0 |
| 71 | + with: |
| 72 | + disk-cache: ${{ inputs.bazel-disk-cache }} |
| 73 | + repository-cache: true |
| 74 | + bazelisk-cache: true |
| 75 | + cache-save: ${{ github.event_name == 'push' }} |
| 76 | + |
| 77 | + - name: Look for AutoSD Toolchain |
| 78 | + run: | |
| 79 | + bazel cquery '@score_autosd10_x86_64_toolchain//:x86_64-linux-autosd10' |
| 80 | +
|
| 81 | + - name: Check for toolchain bazelrc file |
| 82 | + run: | |
| 83 | + stat score-ci-cd-workflows/bazelrc.d/autosd.bazelrc |
| 84 | +
|
| 85 | + - name: Run Bazel Action |
| 86 | + if: inputs.bazel-target != '' |
| 87 | + run: | |
| 88 | + set -euo pipefail |
| 89 | +
|
| 90 | + bazel \ |
| 91 | + --bazelrc=score-ci-cd-workflows/bazelrc.d/autosd.bazelrc \ |
| 92 | + --bazelrc=.bazelrc \ |
| 93 | + ${{ inputs.bazel-action }} \ |
| 94 | + --config autosd-${{ inputs.arch }} \ |
| 95 | + ${{ inputs.extra-bazel-flags }} -- ${{ inputs.bazel-target }} |
0 commit comments