|
| 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 | +# Module Smoke Test Workflow |
| 14 | +# |
| 15 | +# Summary: |
| 16 | +# Orchestrates a fast validation of a single module by producing an |
| 17 | +# updated known_good.json (optionally overriding one module to the current PR) |
| 18 | +# and then invoking the integration build workflow to compile and test. |
| 19 | +# |
| 20 | +# What it does: |
| 21 | +# - Checks out the reference integration repository |
| 22 | +# - Generates known_good.updated.json: |
| 23 | +# * If testing an external module PR: overrides `module_name` to the PR SHA |
| 24 | +# * If testing this repo: updates modules to latest branches |
| 25 | +# - Uploads known_good.updated.json as an artifact |
| 26 | +# - Calls the Module Integration Build workflow with a matrix of configs |
| 27 | +# - Publishes a summary to the GitHub Step Summary |
| 28 | +# |
| 29 | +# Inputs: |
| 30 | +# - repo_runner_labels (string, required, default: ubuntu-latest): Runner label. |
| 31 | +# - module_name (string, required): Module to override (e.g., score_baselibs). |
| 32 | +# - target_branch (string, required, default: main): |
| 33 | +# The ref to checkout via actions/checkout — can be a branch name, tag, or |
| 34 | +# commit SHA. This ensures the workflow uses the exact version of the |
| 35 | +# integration files you intend. |
| 36 | +# |
| 37 | +# Repository Variables: |
| 38 | +# - reference_integration_repo (optional): Repository providing integration |
| 39 | +# workflows and tools (format: owner/repo). Supports private forks. |
| 40 | +# Default: eclipse-score/reference_integration |
| 41 | +# |
| 42 | +# Secrets: |
| 43 | +# - REPO_READ_TOKEN (optional): Token for reading private repos; falls back to |
| 44 | +# github.token when not provided. |
| 45 | +# |
| 46 | +# Usage: |
| 47 | +# This workflow is reusable and triggered via workflow_call from other workflows. |
| 48 | +# Example: |
| 49 | +# jobs: |
| 50 | +# smoke: |
| 51 | +# uses: eclipse-score/reference_integration/.github/workflows/module-smoke-test.yml@main |
| 52 | +# with: |
| 53 | +# repo_runner_labels: ubuntu-latest |
| 54 | +# module_name: score_baselibs |
| 55 | +# target_branch: main |
| 56 | +# secrets: |
| 57 | +# REPO_READ_TOKEN: ${{ secrets.REPO_READ_TOKEN }} |
| 58 | +# |
| 59 | +# Note: Set the 'reference_integration_repo' repository variable to use a |
| 60 | +# private fork (e.g., my-org/reference_integration). |
| 61 | +# |
| 62 | +# Notes: |
| 63 | +# - Extend the matrix in `integration-test` to cover additional configs. |
| 64 | +name: Module Smoke Test |
| 65 | +on: |
| 66 | + workflow_call: |
| 67 | + inputs: |
| 68 | + repo_runner_labels: |
| 69 | + description: 'The runner tag to use for the job' |
| 70 | + required: true |
| 71 | + type: string |
| 72 | + default: 'ubuntu-latest' |
| 73 | + module_name: |
| 74 | + description: 'Name of the module to override (e.g., score_baselibs).' |
| 75 | + required: true |
| 76 | + type: string |
| 77 | + target_branch: |
| 78 | + description: 'Ref to checkout (branch, tag, or commit SHA).' |
| 79 | + required: true |
| 80 | + type: string |
| 81 | + default: 'main' |
| 82 | + secrets: |
| 83 | + REPO_READ_TOKEN: |
| 84 | + description: 'Token for reading repositories' |
| 85 | + required: false |
| 86 | +env: |
| 87 | + REFERENCE_INTEGRATION_REPO: ${{ vars.reference_integration_repo != '' && vars.reference_integration_repo || 'eclipse-score/reference_integration' }} |
| 88 | +jobs: |
| 89 | + preparation: |
| 90 | + name: Preparation |
| 91 | + runs-on: ubuntu-latest |
| 92 | + outputs: |
| 93 | + known_good_updated: ${{ steps.set_known_good.outputs.known_good_updated }} |
| 94 | + steps: |
| 95 | + - name: Checkout repository |
| 96 | + uses: actions/checkout@v4.2.2 |
| 97 | + with: |
| 98 | + repository: ${{ env.REFERENCE_INTEGRATION_REPO }} |
| 99 | + ref: ${{ inputs.target_branch }} |
| 100 | + token: ${{ secrets.REPO_READ_TOKEN != '' && secrets.REPO_READ_TOKEN || github.token }} |
| 101 | + - name: Create updated known_good.json with PR commit |
| 102 | + id: set_known_good |
| 103 | + run: | |
| 104 | + if [ "${{ github.repository }}" != "${{ env.REFERENCE_INTEGRATION_REPO }}" ]; then |
| 105 | + echo "Overriding ${{ inputs.module_name }} with current PR" |
| 106 | + python3 scripts/known_good/override_known_good_repo.py \ |
| 107 | + --known known_good.json \ |
| 108 | + --output known_good.updated.json \ |
| 109 | + --module-override ${{ inputs.module_name }}@${{ github.event.repository.clone_url }}@${{ github.sha }} |
| 110 | + else |
| 111 | + echo "Testing reference integration repository itself - updating to latest commits" |
| 112 | + echo "::group::get latest commits from module branches" |
| 113 | + python3 scripts/known_good/update_module_latest.py --output known_good.updated.json |
| 114 | + cat known_good.updated.json |
| 115 | + echo "::endgroup::" |
| 116 | + fi |
| 117 | +
|
| 118 | + # Output the content as a JSON string |
| 119 | + echo "known_good_updated<<EOF" >> $GITHUB_OUTPUT |
| 120 | + cat known_good.updated.json >> $GITHUB_OUTPUT |
| 121 | + echo "EOF" >> $GITHUB_OUTPUT |
| 122 | + env: |
| 123 | + GITHUB_TOKEN: ${{ secrets.REPO_READ_TOKEN != '' && secrets.REPO_READ_TOKEN || github.token }} |
| 124 | + - name: Show updated known_good.json |
| 125 | + run: | |
| 126 | + echo "Updated known_good.json:" |
| 127 | + cat known_good.updated.json |
| 128 | + - name: Upload updated known_good.json artifact |
| 129 | + uses: actions/upload-artifact@v4 |
| 130 | + with: |
| 131 | + name: known_good.updated.json |
| 132 | + path: known_good.updated.json |
| 133 | + docs: |
| 134 | + name: Generate Documentation |
| 135 | + runs-on: ubuntu-latest |
| 136 | + needs: preparation |
| 137 | + steps: |
| 138 | + - name: not implemented |
| 139 | + run: echo "Documentation generation not yet implemented here." |
| 140 | + integration-test: |
| 141 | + name: Integration Testing (${{ matrix.config }}) |
| 142 | + needs: preparation |
| 143 | + strategy: |
| 144 | + fail-fast: false |
| 145 | + matrix: |
| 146 | + config: |
| 147 | + - x86_64-linux |
| 148 | + # - arm64-linux |
| 149 | + # Add more configs here as needed |
| 150 | + # - arm64-qnx8_0 |
| 151 | + # - x86_64-qnx8_0 |
| 152 | + uses: ./.github/workflows/reusable_integration-build.yml |
| 153 | + secrets: inherit |
| 154 | + with: |
| 155 | + known_good: ${{ needs.preparation.outputs.known_good_updated }} |
| 156 | + config: ${{ matrix.config }} |
| 157 | + repo_runner_labels: ${{ inputs.repo_runner_labels }} |
| 158 | + target_branch: ${{ inputs.target_branch }} |
| 159 | + summary: |
| 160 | + name: Publish Summary |
| 161 | + runs-on: ubuntu-latest |
| 162 | + needs: [integration-test, docs] |
| 163 | + if: always() |
| 164 | + steps: |
| 165 | + - name: Checkout repository |
| 166 | + uses: actions/checkout@v4.2.2 |
| 167 | + with: |
| 168 | + repository: ${{ env.REFERENCE_INTEGRATION_REPO }} |
| 169 | + ref: ${{ inputs.target_branch }} |
| 170 | + token: ${{ secrets.REPO_READ_TOKEN != '' && secrets.REPO_READ_TOKEN || github.token }} |
| 171 | + # get all artefacts from integration-test job with name bazel-build-logs-* |
| 172 | + - name: Download Integration Test Artifacts |
| 173 | + uses: actions/download-artifact@v4 |
| 174 | + with: |
| 175 | + pattern: bazel-build-logs-* |
| 176 | + path: _logs/integration_test_logs |
| 177 | + merge-multiple: true |
| 178 | + - name: Publish Integration Test Summary |
| 179 | + run: | |
| 180 | + ls -l _logs/integration_test_logs || true |
| 181 | + python3 scripts/publish_integration_summary.py \ |
| 182 | + --integration-result "${{ needs.integration-test.result }}" \ |
| 183 | + --docs-result "${{ needs.docs.result }}" \ |
| 184 | + --logs-dir "_logs/integration_test_logs" \ |
| 185 | + >> "$GITHUB_STEP_SUMMARY" |
0 commit comments