diff --git a/.github/workflows/builder.yaml b/.github/workflows/builder.yaml index 3a5a82fab..edc7a0969 100644 --- a/.github/workflows/builder.yaml +++ b/.github/workflows/builder.yaml @@ -18,6 +18,14 @@ on: platform: required: true type: string + head-sha: + required: false + type: string + default: '' + head-branch: + required: false + type: string + default: '' jobs: build: @@ -29,6 +37,7 @@ jobs: uses: actions/checkout@v6 with: submodules: "true" + ref: ${{ inputs.head-sha || github.sha }} - name: Cache tools uses: ./.github/actions/cache-tools - name: Build ${{ inputs.example-app }} @@ -43,7 +52,7 @@ jobs: build-type: ${{ inputs.build-type }} - name: Create asset files - if: startsWith(github.ref_name, 'release_') + if: startsWith(inputs.head-branch || github.ref_name, 'release_') run: | find out -type f \( -name "*.s37" -o -name "*.rps" \) | while read file; do echo '' > "${file}.asset" diff --git a/.github/workflows/dev-apps-builder.yaml b/.github/workflows/dev-apps-builder.yaml index ca1da8f9e..d3fcf37ea 100644 --- a/.github/workflows/dev-apps-builder.yaml +++ b/.github/workflows/dev-apps-builder.yaml @@ -5,6 +5,7 @@ on: branches: - main - "release_*" + - "**/**" # TODO : remove this after testing schedule: - cron: "5 0 * * 5" # Thursday at 8:05 PM EDT workflow_dispatch: @@ -242,25 +243,9 @@ jobs: delete-merged: true pattern: "*-${{ needs.set-build-type.outputs.build-type }}" - wait-for-test-results: - name: Wait for Test Results - needs: merge-apps - uses: ./.github/workflows/sqa-sanity-tests.yaml - secrets: - SILABSSW_MATTER_CI_BOT_APP_PRIVATE_KEY: ${{ secrets.SILABSSW_MATTER_CI_BOT_APP_PRIVATE_KEY }} - - build-sqa-apps: - name: Build SQA apps - needs: wait-for-test-results - if: ${{ github.ref_name == 'main' || startsWith(github.ref_name, 'release_') }} - permissions: - contents: read - actions: write - uses: ./.github/workflows/sqa-apps-builder.yaml - delete-cache: name: Delete tools cache - needs: [build-sqa-apps, cache-tools] + needs: [merge-apps, cache-tools] if: always() runs-on: ubuntu-latest permissions: diff --git a/.github/workflows/platform-builder.yaml b/.github/workflows/platform-builder.yaml index cbc0fb2fb..21926c435 100644 --- a/.github/workflows/platform-builder.yaml +++ b/.github/workflows/platform-builder.yaml @@ -61,6 +61,14 @@ on: required: false type: boolean default: false + head-sha: + required: false + type: string + default: '' + head-branch: + required: false + type: string + default: '' jobs: mg24-build-job: @@ -72,6 +80,8 @@ jobs: example-app: ${{ inputs.example-app }} build-type: ${{ inputs.build-type }} platform: mg24 + head-sha: ${{ inputs.head-sha }} + head-branch: ${{ inputs.head-branch }} mg24-internal-build-job: if: ${{ inputs.thread-support && inputs.mg24-internal-support }} @@ -82,6 +92,8 @@ jobs: example-app: ${{ inputs.example-app }} build-type: ${{ inputs.build-type }} platform: mg24-internal + head-sha: ${{ inputs.head-sha }} + head-branch: ${{ inputs.head-branch }} mg24-trustzone-build-job: if: ${{ inputs.thread-support && inputs.mg24-support && inputs.trustzone-support }} @@ -92,6 +104,8 @@ jobs: example-app: ${{ inputs.example-app }} build-type: ${{ inputs.build-type }} platform: mg24-trustzone + head-sha: ${{ inputs.head-sha }} + head-branch: ${{ inputs.head-branch }} mgm24-build-job: if: ${{ inputs.thread-support && inputs.mgm24-support }} @@ -102,6 +116,8 @@ jobs: example-app: ${{ inputs.example-app }} build-type: ${{ inputs.build-type }} platform: mgm24 + head-sha: ${{ inputs.head-sha }} + head-branch: ${{ inputs.head-branch }} mgm24-internal-build-job: if: ${{ inputs.thread-support && inputs.mgm24-internal-support }} @@ -112,6 +128,8 @@ jobs: example-app: ${{ inputs.example-app }} build-type: ${{ inputs.build-type }} platform: mgm24-internal + head-sha: ${{ inputs.head-sha }} + head-branch: ${{ inputs.head-branch }} mg26-build-job: if: ${{ inputs.thread-support && inputs.mg26-support }} @@ -122,6 +140,8 @@ jobs: example-app: ${{ inputs.example-app }} build-type: ${{ inputs.build-type }} platform: mg26 + head-sha: ${{ inputs.head-sha }} + head-branch: ${{ inputs.head-branch }} mg26-internal-build-job: if: ${{ inputs.thread-support && inputs.mg26-internal-support }} @@ -132,6 +152,8 @@ jobs: example-app: ${{ inputs.example-app }} build-type: ${{ inputs.build-type }} platform: mg26-internal + head-sha: ${{ inputs.head-sha }} + head-branch: ${{ inputs.head-branch }} mgm26-internal-build-job: if: ${{ inputs.thread-support && inputs.mgm26-internal-support }} @@ -142,6 +164,8 @@ jobs: example-app: ${{ inputs.example-app }} build-type: ${{ inputs.build-type }} platform: mgm26-internal + head-sha: ${{ inputs.head-sha }} + head-branch: ${{ inputs.head-branch }} ncp-917-build-job: if: ${{ inputs.ncp-917-support }} @@ -152,6 +176,8 @@ jobs: example-app: ${{ inputs.example-app }} build-type: ${{ inputs.build-type }} platform: ncp-917 + head-sha: ${{ inputs.head-sha }} + head-branch: ${{ inputs.head-branch }} siwx-soc-build-job: if: ${{ inputs.wifi-soc-support }} @@ -162,6 +188,8 @@ jobs: example-app: ${{ inputs.example-app }} build-type: ${{ inputs.build-type }} platform: siwx-soc + head-sha: ${{ inputs.head-sha }} + head-branch: ${{ inputs.head-branch }} sixg301-build-job: if: ${{ inputs.thread-support && inputs.sixg301-support }} @@ -172,3 +200,5 @@ jobs: example-app: ${{ inputs.example-app }} build-type: ${{ inputs.build-type }} platform: sixg301 + head-sha: ${{ inputs.head-sha }} + head-branch: ${{ inputs.head-branch }} diff --git a/.github/workflows/sqa-apps-builder.yaml b/.github/workflows/sqa-apps-builder.yaml index 8703ff97b..aedb405de 100644 --- a/.github/workflows/sqa-apps-builder.yaml +++ b/.github/workflows/sqa-apps-builder.yaml @@ -2,6 +2,15 @@ name: Build SQA apps on: workflow_call: + inputs: + head-sha: + required: false + type: string + default: '' + head-branch: + required: false + type: string + default: '' jobs: build-lock-app: @@ -15,6 +24,8 @@ jobs: mgm24-internal-support: false mg26-internal-support: false mgm26-internal-support: false + head-sha: ${{ inputs.head-sha }} + head-branch: ${{ inputs.head-branch }} build-lighting-app: name: Build Lighting App @@ -26,6 +37,8 @@ jobs: mgm24-internal-support: false mg26-internal-support: false mgm26-internal-support: false + head-sha: ${{ inputs.head-sha }} + head-branch: ${{ inputs.head-branch }} build-window-app: name: Build Window App @@ -41,6 +54,8 @@ jobs: mgm26-internal-support: false wifi-soc-support: false sixg301-support: false + head-sha: ${{ inputs.head-sha }} + head-branch: ${{ inputs.head-branch }} # build-dishwasher-app: # name: Build Dishwasher App @@ -73,6 +88,8 @@ jobs: mgm26-internal-support: false wifi-soc-support: false sixg301-support: false + head-sha: ${{ inputs.head-sha }} + head-branch: ${{ inputs.head-branch }} build-light-switch-app: name: Build Light Switch App @@ -85,6 +102,8 @@ jobs: mgm24-internal-support: false mg26-internal-support: false mgm26-internal-support: false + head-sha: ${{ inputs.head-sha }} + head-branch: ${{ inputs.head-branch }} build-multi-sensor-app: name: Build Multi Sensor App @@ -99,6 +118,8 @@ jobs: mg26-internal-support: false mgm26-internal-support: false sixg301-support: false + head-sha: ${{ inputs.head-sha }} + head-branch: ${{ inputs.head-branch }} build-zigbee-matter-light: name: Build Zigbee Matter Light @@ -113,6 +134,8 @@ jobs: mg26-internal-support: false mgm26-internal-support: false wifi-soc-support: false + head-sha: ${{ inputs.head-sha }} + head-branch: ${{ inputs.head-branch }} build-closure-app: name: Build Closure App @@ -125,6 +148,8 @@ jobs: mgm24-internal-support: false mg26-internal-support: false mgm26-internal-support: false + head-sha: ${{ inputs.head-sha }} + head-branch: ${{ inputs.head-branch }} build-platform-template: name: Build Platform App @@ -137,6 +162,8 @@ jobs: mgm24-internal-support: false mg26-internal-support: false mgm26-internal-support: false + head-sha: ${{ inputs.head-sha }} + head-branch: ${{ inputs.head-branch }} merge-apps: name: Merge SQA App Artifacts diff --git a/.github/workflows/sqa-sanity-tests.yaml b/.github/workflows/sqa-sanity-tests.yaml index 2954a0d79..3a382a2f1 100644 --- a/.github/workflows/sqa-sanity-tests.yaml +++ b/.github/workflows/sqa-sanity-tests.yaml @@ -1,15 +1,15 @@ name: Wait for Test Results on: - workflow_call: - secrets: - SILABSSW_MATTER_CI_BOT_APP_PRIVATE_KEY: - required: true + workflow_run: + workflows: ['Build Dev apps'] + types: ['completed'] jobs: - wait-for-jenkins-status: + wait-for-jenkins-status: name: Wait for Jenkins Status runs-on: ubuntu-latest + if: github.event.workflow_run.conclusion == 'success' steps: - name: Generate GitHub App Token id: generate_app_token @@ -27,9 +27,11 @@ jobs: with: github-token: ${{ steps.generate_app_token.outputs.token }} script: | - const headSha = (context.eventName === 'pull_request') - ? context.payload.pull_request.head.sha - : context.sha; + const headSha = context.eventName === 'workflow_run' + ? context.payload.workflow_run.head_sha + : context.eventName === 'pull_request' + ? context.payload.pull_request.head.sha + : context.sha; const { data } = await github.rest.checks.create({ owner: context.repo.owner, repo: context.repo.repo, @@ -163,4 +165,64 @@ jobs: core.info('Waiting for check run to complete...'); await new Promise(r => setTimeout(r, pollIntervalSeconds * 1000)); elapsed += pollIntervalSeconds; - } \ No newline at end of file + } + + cache-tools: + name: Cache tools + needs: [wait-for-jenkins-status] + runs-on: ubuntu-latest + if: | + github.event.workflow_run.head_repository.full_name == github.repository && + (github.event.workflow_run.head_branch == 'main' || + startsWith(github.event.workflow_run.head_branch, 'release_')) + permissions: + contents: read + actions: write + outputs: + cache-key: ${{ steps.cache-tools.outputs.cache-key }} + steps: + - name: Checkout + uses: actions/checkout@v6 + with: + ref: ${{ github.event.workflow_run.head_sha }} + - uses: ./.github/actions/cache-tools + id: cache-tools + + build-sqa-apps: + name: Build SQA apps + needs: [cache-tools] + if: | + github.event.workflow_run.head_repository.full_name == github.repository && + (github.event.workflow_run.head_branch == 'main' || + startsWith(github.event.workflow_run.head_branch, 'release_')) + permissions: + contents: read + actions: write + uses: ./.github/workflows/sqa-apps-builder.yaml + with: + head-sha: ${{ github.event.workflow_run.head_sha }} + head-branch: ${{ github.event.workflow_run.head_branch }} + + delete-cache: + name: Delete tools cache + needs: [build-sqa-apps, cache-tools] + if: | + always() && + github.event.workflow_run.head_repository.full_name == github.repository && + (github.event.workflow_run.head_branch == 'main' || + startsWith(github.event.workflow_run.head_branch, 'release_')) + runs-on: ubuntu-latest + permissions: + actions: write + steps: + - name: Delete tools cache + uses: actions/github-script@v8 + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + script: | + await github.rest.actions.deleteActionsCacheByKey({ + owner: context.repo.owner, + repo: context.repo.repo, + key: '${{ needs.cache-tools.outputs.cache-key }}', + }); + \ No newline at end of file diff --git a/README.md b/README.md index 6284ffe27..0793cb28d 100644 --- a/README.md +++ b/README.md @@ -2,6 +2,7 @@ # Silicon Labs Matter +TEST Welcome to the Silicon Labs Matter Extension repo. Matter is an application layer that provides a standardized interface between protocols and devices. With Matter, it is transparent to the underlying device whether the interaction is from a Thread application or a Wi-Fi application. For more information on Matter in general, see the main [Matter Overview](https://www.silabs.com/wireless/matter) page. Silicon Labs supports Matter on both 802.15.4 (Thread) and 802.11 (Wi-Fi) transport protocols. Silicon Labs supports Matter on several different hardware platforms including the EFR32, and the new SiWx917, which is a Wi-Fi System-on-Chip (SoC). diff --git a/jenkins_integration/github/github_workflow.py b/jenkins_integration/github/github_workflow.py index c0343b6e4..e481c4b66 100644 --- a/jenkins_integration/github/github_workflow.py +++ b/jenkins_integration/github/github_workflow.py @@ -50,7 +50,7 @@ def _get_pr_latest_sha(pr_identifier): print(f"Head branch: {head_branch}") print(f"Commit SHA - {commit_sha}") print(f"PR Number: {pr_number}") - return head_branch + return commit_sha, head_branch def get_workflow_info(branch_name): @@ -67,7 +67,7 @@ def get_workflow_info(branch_name): ValueError: If the workflow data is invalid or wrong job type is triggered """ if branch_name.startswith("PR"): - head_branch = _get_pr_latest_sha(branch_name) + commit_sha, head_branch = _get_pr_latest_sha(branch_name) if head_branch: pr_url = f"{config.actions_runs_url_pr}&branch={head_branch}" else: @@ -76,7 +76,7 @@ def get_workflow_info(branch_name): response = _make_github_api_request(pr_url) workflow_runs = response.json().get('workflow_runs', []) pr_number = branch_name.split('-')[1] - return _find_pr_workflow(workflow_runs, pr_number) + return _find_pr_workflow(workflow_runs, pr_number, commit_sha) else: print(f"Fetching workflow runs from actions/runs URL: {config.actions_runs_url}") response = _make_github_api_request(config.actions_runs_url) @@ -189,13 +189,14 @@ def _find_branch_workflow(workflow_runs, branch_name): raise RuntimeError(f"No matching branch workflow {workflow_name} found for branch: {branch_name}.") -def _find_pr_workflow(workflow_runs, pr_number): +def _find_pr_workflow(workflow_runs, pr_number, commit_sha=None): """ Find a PR workflow that matches the given criteria. Args: workflow_runs (list): List of workflow runs from GitHub API pr_number (str): PR number to match + commit_sha (str): Head commit SHA, used as fallback for fork PRs Returns: tuple: (run_number (int), workflow_id (int), commit_sha (str)) @@ -205,7 +206,7 @@ def _find_pr_workflow(workflow_runs, pr_number): """ workflow_name = "Build Dev apps" for workflow in workflow_runs: - if _matches_pr_workflow(workflow, pr_number, workflow_name): + if _matches_pr_workflow(workflow, pr_number, workflow_name, commit_sha): return _extract_workflow_info(workflow) raise RuntimeError(f"No matching PR workflow {workflow_name} found for PR: {pr_number}.") @@ -227,23 +228,33 @@ def _matches_branch_workflow(workflow, branch_name, workflow_name): workflow.get('name') == workflow_name) -def _matches_pr_workflow(workflow, pr_number, workflow_name): +def _matches_pr_workflow(workflow, pr_number, workflow_name, commit_sha=None): """ Check if a workflow matches PR workflow criteria. + For internal PRs, matches by PR number via the pull_requests field. + For fork PRs, GitHub returns an empty pull_requests array, so falls back + to matching by head_sha. + Args: workflow (dict): Workflow data from GitHub API pr_number (str): PR number to match workflow_name (str): Workflow name to match + commit_sha (str): Head commit SHA, used as fallback when pull_requests is empty Returns: bool: True if workflow matches criteria """ pull_requests = workflow.get('pull_requests', []) - return (pull_requests and - pull_requests[0].get("number") == int(pr_number) and - workflow.get('status') == 'in_progress' and - workflow.get('name') == workflow_name) + name_ok = workflow.get('name') == workflow_name + status_ok = workflow.get('status') == 'in_progress' + if pull_requests: + pr_ok = pull_requests[0].get("number") == int(pr_number) + elif commit_sha: + pr_ok = workflow.get('head_sha') == commit_sha + else: + pr_ok = False + return name_ok and status_ok and pr_ok def _validate_branch_workflow(workflow):