|
| 1 | +name: Vivado Build |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_dispatch: |
| 5 | + inputs: |
| 6 | + boards: |
| 7 | + description: "Boards to build: comma-separated (e.g. RFSoC4x2,ZCU208) or 'all'" |
| 8 | + required: true |
| 9 | + default: "RFSoC4x2,ZCU208,ZCU111,ZCU216,RFSoC2x2" |
| 10 | + vivado_settings: |
| 11 | + description: "OPTIONAL override: full path to settings64.sh on this runner" |
| 12 | + required: false |
| 13 | + default: "" |
| 14 | + |
| 15 | + # Only trigger automatically when bitstream inputs change (NOT docs/README edits) |
| 16 | + pull_request: |
| 17 | + branches: [ main, master ] |
| 18 | + paths: |
| 19 | + - "ip/**" |
| 20 | + - "boards/**/rfsoc_qpsk/rfsoc_qpsk.tcl" |
| 21 | + - "boards/**/rfsoc_qpsk/constraints.xdc" |
| 22 | + |
| 23 | +jobs: |
| 24 | + prep-matrix: |
| 25 | + runs-on: ubuntu-latest |
| 26 | + outputs: |
| 27 | + matrix: ${{ steps.mk.outputs.matrix }} |
| 28 | + should_run: ${{ steps.mk.outputs.should_run }} |
| 29 | + steps: |
| 30 | + - uses: actions/checkout@v4 |
| 31 | + |
| 32 | + - id: mk |
| 33 | + env: |
| 34 | + GH_TOKEN: ${{ github.token }} |
| 35 | + shell: bash |
| 36 | + run: | |
| 37 | + set -euo pipefail |
| 38 | +
|
| 39 | + allowed="ZCU111 ZCU208 ZCU216 RFSoC2x2 RFSoC4x2" |
| 40 | +
|
| 41 | + if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then |
| 42 | + boards_in="${{ github.event.inputs.boards }}" |
| 43 | + if [ -z "$boards_in" ]; then boards_in="RFSoC4x2,ZCU208,ZCU111,ZCU216,RFSoC2x2"; fi |
| 44 | +
|
| 45 | + if [ "$boards_in" = "all" ]; then |
| 46 | + boards="$allowed" |
| 47 | + else |
| 48 | + boards="$(echo "$boards_in" | tr ',' ' ')" |
| 49 | + fi |
| 50 | +
|
| 51 | + else |
| 52 | + pr_number="${{ github.event.pull_request.number }}" |
| 53 | +
|
| 54 | + files="$(gh api "/repos/${{ github.repository }}/pulls/${pr_number}/files" \ |
| 55 | + --paginate --jq '.[].filename')" |
| 56 | +
|
| 57 | + echo "Changed files:" |
| 58 | + echo "$files" |
| 59 | +
|
| 60 | + # If any shared IP changed, rebuild everything |
| 61 | + if echo "$files" | grep -qE '^ip/'; then |
| 62 | + boards="$allowed" |
| 63 | + else |
| 64 | + # Otherwise, rebuild only the boards whose TCL/XDC changed |
| 65 | + boards="$(echo "$files" \ |
| 66 | + | grep -E '^boards/[^/]+/rfsoc_qpsk/(rfsoc_qpsk\.tcl|constraints\.xdc)$' \ |
| 67 | + | sed -E 's|^boards/([^/]+)/.*|\1|' \ |
| 68 | + | sort -u || true)" |
| 69 | + fi |
| 70 | + fi |
| 71 | +
|
| 72 | + # Nothing relevant changed -> skip build job |
| 73 | + if [ -z "${boards:-}" ]; then |
| 74 | + echo "No relevant changes detected; skipping build." |
| 75 | + echo 'matrix={"boards":[]}' >> "$GITHUB_OUTPUT" |
| 76 | + echo "should_run=false" >> "$GITHUB_OUTPUT" |
| 77 | + exit 0 |
| 78 | + fi |
| 79 | +
|
| 80 | + # Validate boards list |
| 81 | + for b in $boards; do |
| 82 | + ok=0 |
| 83 | + for a in $allowed; do |
| 84 | + [ "$b" = "$a" ] && ok=1 |
| 85 | + done |
| 86 | + [ $ok -eq 1 ] || (echo "Invalid board: $b. Allowed: $allowed" && exit 1) |
| 87 | + done |
| 88 | +
|
| 89 | + # Build JSON matrix |
| 90 | + json='{"boards":[' |
| 91 | + first=1 |
| 92 | + for b in $boards; do |
| 93 | + [ $first -eq 1 ] || json+=',' |
| 94 | + json+="\"$b\"" |
| 95 | + first=0 |
| 96 | + done |
| 97 | + json+=']}' |
| 98 | +
|
| 99 | + echo "matrix=$json" >> "$GITHUB_OUTPUT" |
| 100 | + echo "should_run=true" >> "$GITHUB_OUTPUT" |
| 101 | + echo "Matrix: $json" |
| 102 | +
|
| 103 | + build-bitstream: |
| 104 | + needs: prep-matrix |
| 105 | + if: ${{ needs.prep-matrix.outputs.should_run == 'true' }} |
| 106 | + runs-on: [self-hosted, linux, x64] |
| 107 | + strategy: |
| 108 | + fail-fast: false |
| 109 | + matrix: ${{ fromJson(needs.prep-matrix.outputs.matrix) }} |
| 110 | + |
| 111 | + steps: |
| 112 | + - uses: actions/checkout@v4 |
| 113 | + |
| 114 | + - name: Resolve Vivado settings path |
| 115 | + shell: bash |
| 116 | + run: | |
| 117 | + set -euo pipefail |
| 118 | +
|
| 119 | + # Priority: |
| 120 | + # 1) workflow_dispatch input (manual override) |
| 121 | + # 2) runner env var VIVADO_SETTINGS |
| 122 | + V="${{ github.event.inputs.vivado_settings }}" |
| 123 | + if [ -n "${V:-}" ]; then |
| 124 | + SETTINGS="$V" |
| 125 | + elif [ -n "${VIVADO_SETTINGS:-}" ]; then |
| 126 | + SETTINGS="$VIVADO_SETTINGS" |
| 127 | + else |
| 128 | + echo "ERROR: Vivado path not provided." |
| 129 | + echo "Set VIVADO_SETTINGS on this self-hosted runner (recommended)," |
| 130 | + echo "or supply 'vivado_settings' when manually running the workflow." |
| 131 | + exit 1 |
| 132 | + fi |
| 133 | +
|
| 134 | + if [ ! -f "$SETTINGS" ]; then |
| 135 | + echo "ERROR: settings64.sh not found at: $SETTINGS" |
| 136 | + exit 1 |
| 137 | + fi |
| 138 | +
|
| 139 | + echo "Using: $SETTINGS" |
| 140 | + echo "VIVADO_SETTINGS_RESOLVED=$SETTINGS" >> "$GITHUB_ENV" |
| 141 | +
|
| 142 | + - name: Run Vivado Build |
| 143 | + shell: bash |
| 144 | + run: | |
| 145 | + set -euo pipefail |
| 146 | + source "$VIVADO_SETTINGS_RESOLVED" |
| 147 | + cd "boards/${{ matrix.boards }}/rfsoc_qpsk/" |
| 148 | + make all |
| 149 | + cd ../../.. |
| 150 | +
|
| 151 | + - name: Create per-board tarball (in RUNNER_TEMP) |
| 152 | + shell: bash |
| 153 | + run: | |
| 154 | + set -euo pipefail |
| 155 | +
|
| 156 | + TAR="rfsoc_qpsk_${{ matrix.boards }}_${{ github.sha }}.tar.gz" |
| 157 | + TAR_PATH="${RUNNER_TEMP}/${TAR}" |
| 158 | +
|
| 159 | + tar -czf "$TAR_PATH" \ |
| 160 | + --warning=no-file-changed \ |
| 161 | + --exclude=".git" --exclude=".github" --exclude="**/.Xil" \ |
| 162 | + --exclude="**/*.jou" --exclude="**/*.log" \ |
| 163 | + . |
| 164 | +
|
| 165 | + echo "TAR_PATH=$TAR_PATH" >> "$GITHUB_ENV" |
| 166 | + echo "Created: $TAR_PATH" |
| 167 | +
|
| 168 | + - uses: actions/upload-artifact@v4 |
| 169 | + with: |
| 170 | + name: bitstream-archive-${{ matrix.boards }} |
| 171 | + path: ${{ env.TAR_PATH }} |
| 172 | + retention-days: 7 |
| 173 | + |
| 174 | + # Check if it works on hardware |
| 175 | + - name: Create pending HW check (PR only) |
| 176 | + if: ${{ github.event_name == 'pull_request' }} |
| 177 | + env: |
| 178 | + GH_TOKEN: ${{ github.token }} |
| 179 | + OWNER: ${{ github.repository_owner }} |
| 180 | + REPO: ${{ github.event.repository.name }} |
| 181 | + SHA: ${{ github.sha }} |
| 182 | + BOARD: ${{ matrix.boards }} |
| 183 | + shell: bash |
| 184 | + run: | |
| 185 | + set -euo pipefail |
| 186 | + NAME="HW Test (${BOARD})" |
| 187 | +
|
| 188 | + # If it already exists (reruns), don't create duplicates. |
| 189 | + existing_id="$(gh api \ |
| 190 | + -H "Accept: application/vnd.github+json" \ |
| 191 | + "/repos/${OWNER}/${REPO}/commits/${SHA}/check-runs" \ |
| 192 | + --jq ".check_runs[] | select(.name==\"${NAME}\") | .id" | head -n 1 || true)" |
| 193 | +
|
| 194 | + if [ -n "${existing_id:-}" ]; then |
| 195 | + echo "Check already exists: ${NAME} (id=${existing_id}). Skipping create." |
| 196 | + exit 0 |
| 197 | + fi |
| 198 | +
|
| 199 | + gh api \ |
| 200 | + -H "Accept: application/vnd.github+json" \ |
| 201 | + "/repos/${OWNER}/${REPO}/check-runs" \ |
| 202 | + -f name="${NAME}" \ |
| 203 | + -f head_sha="${SHA}" \ |
| 204 | + -f status="in_progress" \ |
| 205 | + -f "output[title]=Manual hardware test required" \ |
| 206 | + -f "output[summary]=Download artifact bitstream-archive-${BOARD} from this workflow run, test on ${BOARD}, then comment on the PR:\n\n- /hw-pass ${BOARD}\n- /hw-fail ${BOARD} <reason>\n- /hw-skip ${BOARD} <reason>" |
0 commit comments