Skip to content

Commit 23771ca

Browse files
committed
Updated post-merge logic to fix sync and permission issues
Adjusted workflow to ensure post-merge cron runs on schedule. This PR resolves problems in post-merge sync and permission handling. Signed-off-by: Mani Deepak Gurram <manigurr@qti.qualcomm.com>
1 parent 631c564 commit 23771ca

6 files changed

Lines changed: 84 additions & 24 deletions

File tree

.github/actions/loading/action.yml

Lines changed: 37 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,8 @@ outputs:
66
build_matrix:
77
description: Build matrix
88
value: ${{ steps.set-matrix.outputs.build_matrix }}
9-
109
full_matrix:
11-
description: full matrix containing lava devails
10+
description: Full matrix containing lava details
1211
value: ${{ steps.set-matrix.outputs.full_matrix }}
1312

1413
runs:
@@ -21,24 +20,49 @@ runs:
2120
script: |
2221
const fs = require('fs');
2322
const path = require('path');
24-
const targetsPath = path.join(process.env.GITHUB_WORKSPACE, 'video-driver', 'ci', 'MACHINES.json');
23+
24+
// 1. Define possible paths for MACHINES.json
25+
// Path A: Workspace/video-driver/ci/MACHINES.json (Nested)
26+
const pathNested = path.join(process.env.GITHUB_WORKSPACE, 'video-driver', 'ci', 'MACHINES.json');
27+
// Path B: Workspace/ci/MACHINES.json (Root)
28+
const pathRoot = path.join(process.env.GITHUB_WORKSPACE, 'ci', 'MACHINES.json');
29+
30+
let targetsPath = '';
31+
32+
// 2. Check which path exists
33+
if (fs.existsSync(pathNested)) {
34+
console.log(`Found config at nested path: ${pathNested}`);
35+
targetsPath = pathNested;
36+
} else if (fs.existsSync(pathRoot)) {
37+
console.log(`Found config at root path: ${pathRoot}`);
38+
targetsPath = pathRoot;
39+
} else {
40+
// 3. Debugging: If neither exists, list files to help us see what is happening
41+
console.log('!!! Error: MACHINES.json not found in expected locations.');
42+
console.log(`Checked: ${pathNested}`);
43+
console.log(`Checked: ${pathRoot}`);
44+
45+
console.log('--- Workspace Root Contents ---');
46+
try {
47+
console.log(fs.readdirSync(process.env.GITHUB_WORKSPACE));
48+
} catch (e) { console.log(e.message); }
49+
50+
core.setFailed(`MACHINES.json not found.`);
51+
return;
52+
}
53+
54+
// 4. Parse the file
2555
let targets;
2656
try {
27-
if (!fs.existsSync(targetsPath)) {
28-
core.setFailed(`MACHINES.json not found at ${targetsPath}`);
29-
return;
30-
}
3157
targets = JSON.parse(fs.readFileSync(targetsPath, 'utf-8'));
3258
} catch (err) {
33-
core.setFailed(`Failed to load or parse MACHINES.json: ${err.message}`);
59+
core.setFailed(`Failed to parse MACHINES.json: ${err.message}`);
3460
return;
3561
}
36-
// Build matrix: machine, firmware
62+
63+
// 5. Generate Outputs
3764
const build_matrix = Object.values(targets).map(({ machine, firmware }) => ({ machine, firmware }));
3865
core.setOutput('build_matrix', JSON.stringify(build_matrix));
39-
console.log("Build Matrix:", build_matrix);
4066
41-
// Full matrix: machine, firmware, lavaname
4267
const full_matrix = Object.values(targets).map(({ machine, firmware, lavaname }) => ({ machine, firmware, lavaname }));
43-
core.setOutput('full_matrix', JSON.stringify(full_matrix));
44-
console.log("Full Matrix:", full_matrix);
68+
core.setOutput('full_matrix', JSON.stringify(full_matrix));

.github/workflows/loading.yml

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,16 @@ description: Load required parameters for the subsequent jobs
44

55
on:
66
workflow_call:
7+
inputs:
8+
target_branch:
9+
description: "Branch to checkout (optional)"
10+
required: false
11+
type: string
12+
default: ""
713
outputs:
814
build_matrix:
915
description: Build matrix
1016
value: ${{ jobs.loading.outputs.build_matrix }}
11-
1217
full_matrix:
1318
description: Full Matrix containing lava description
1419
value: ${{ jobs.loading.outputs.full_matrix }}
@@ -20,14 +25,28 @@ jobs:
2025
build_matrix: ${{ steps.loading.outputs.build_matrix }}
2126
full_matrix: ${{ steps.loading.outputs.full_matrix }}
2227
steps:
23-
- name: Sync codebase
28+
# SCENARIO 1: Pull Request (Pre-Merge)
29+
# Uses your custom sync action to merge PR code with base
30+
- name: Sync codebase (PR)
31+
if: github.event_name == 'pull_request'
2432
uses: qualcomm-linux/video-driver/.github/actions/sync@video.qclinux.0.0
2533
with:
2634
event_name: ${{ github.event_name }}
2735
pr_ref: ${{ github.event.pull_request.head.ref }}
2836
pr_repo: ${{ github.event.pull_request.head.repo.full_name }}
2937
base_ref: ${{ github.ref_name }}
3038

39+
# SCENARIO 2: Schedule or Manual (Post-Merge)
40+
# Uses standard checkout because there is no PR to sync
41+
- name: Checkout Code (Schedule)
42+
if: github.event_name != 'pull_request'
43+
uses: actions/checkout@v4
44+
with:
45+
# Use the input branch if provided, otherwise default to current ref
46+
ref: ${{ inputs.target_branch || github.ref_name }}
47+
# Check out into 'video-driver' folder so the script finds the nested path
48+
path: video-driver
49+
3150
- name: Load Parameters
3251
id: loading
33-
uses: qualcomm-linux/video-driver/.github/actions/loading@video.qclinux.0.0
52+
uses: qualcomm-linux/video-driver/.github/actions/loading@video.qclinux.0.0

.github/workflows/post_merge.yml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
1-
name: post_merge_weekly
1+
name: Post Merge Weekly
22
description: |
33
Runs post-merge CI for the video-driver repository on a weekly schedule.
44
Reuses loading, build and test workflows.
55
66
on:
77
schedule:
8-
# Every Monday and Thursday at 02:30 UTC (8:00 AM IST)
9-
- cron: "30 2 * * 1,4"
8+
- cron: '0 0 * * *'
109
workflow_dispatch:
1110

1211
jobs:

.github/workflows/qcom-preflight-checks.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
name: Qualcomm Preflight Checks
22
on:
33
pull_request_target:
4-
branches: [ development ]
4+
branches: [ video.qclinux.0.0 ]
55
push:
6-
branches: [ development ]
6+
branches: [ video.qclinux.0.0 ]
77
workflow_dispatch:
88

99
permissions:

.github/workflows/sync-and-build.yml

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,17 @@ jobs:
2828
uses: qualcomm-linux/kernel-config/.github/actions/pull_docker_image@main
2929
with:
3030
image: ${{ inputs.docker_image }}
31-
31+
32+
# ------------------------------------------------------------------------
33+
# ✅ CRITICAL FIX: Explicitly checkout the driver code.
34+
# This ensures the source code exists for Post-Merge/Scheduled runs.
35+
# ------------------------------------------------------------------------
36+
- name: Checkout Video Driver
37+
uses: actions/checkout@v4
38+
with:
39+
path: video-driver
40+
fetch-depth: 0
41+
3242
- name: Sync codebase
3343
uses: qualcomm-linux/video-driver/.github/actions/sync@video.qclinux.0.0
3444
with:
@@ -38,11 +48,19 @@ jobs:
3848
base_ref: ${{ github.ref_name }}
3949
caller_workflow: build
4050

51+
4152
- name: Build workspace
4253
uses: qualcomm-linux/video-driver/.github/actions/build@video.qclinux.0.0
4354
with:
4455
docker_image: kmake-image:ver.1.0
4556
workspace_path: ${{ github.workspace }}
57+
58+
- name: Fix Workspace Ownership
59+
if: always()
60+
shell: bash
61+
run: |
62+
echo "🔧 Fixing file ownership (root -> runner user)..."
63+
sudo chown -R $(id -u):$(id -g) ${{ github.workspace }}
4664
4765
- name: Download iris_test_app from the s3
4866
shell: bash
@@ -287,4 +305,4 @@ jobs:
287305
done < "$file_list"
288306
fi
289307
echo "</details>"
290-
} >> "$GITHUB_STEP_SUMMARY"
308+
} >> "$GITHUB_STEP_SUMMARY"

ci/MACHINES.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"qcs6490-rb3gen2": {
33
"machine": "qcs6490-rb3gen2",
44
"firmware": "rb3gen2",
5-
"lavaname": "qcs6490",
5+
"lavaname": "qcs6490-rb3gen2",
66
"target": "qcs6490-rb3gen2",
77
"buildid": "QCM6490.LE.1.0-00376-STD.PROD-1",
88
"firmwareid": "rb3gen2"

0 commit comments

Comments
 (0)