Skip to content

Commit 0d836a5

Browse files
mattnitetact1m4n3
andauthored
Co-authored-by: tact1m4n3 <[email protected]>
1 parent 386babb commit 0d836a5

134 files changed

Lines changed: 2084 additions & 1355 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/ci.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ on:
77
workflow_dispatch:
88

99
env:
10-
ZIG_VERSION: 0.14.1
10+
ZIG_VERSION: 0.15.1
1111

1212
jobs:
1313
formatting-check:
@@ -221,7 +221,7 @@ jobs:
221221
- name: Setup Zig
222222
uses: mlugg/setup-zig@v2
223223
with:
224-
version: 0.14.1
224+
version: 0.15.1
225225
- name: Build Website
226226
run: zig build
227227
working-directory: website

.github/workflows/deploy.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ jobs:
2323
- name: Setup Zig
2424
uses: mlugg/setup-zig@v2
2525
with:
26-
version: 0.14.1
26+
version: 0.15.1
2727

2828
- name: Extract version
2929
run: echo "MICROZIG_VERSION=$(zig build package -- get-version)" >> $GITHUB_ENV

.github/workflows/drivers.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ jobs:
2020
- name: Setup Zig
2121
uses: mlugg/setup-zig@v2
2222
with:
23-
version: 0.14.1
23+
version: 0.15.1
2424

2525
- name: Run Test Suite
2626
working-directory: drivers

.github/workflows/lint.yml

Lines changed: 99 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ jobs:
2020
- name: Setup Zig
2121
uses: mlugg/setup-zig@v2
2222
with:
23-
version: 0.14.1
23+
version: 0.15.1
2424

2525
- name: Build linter
2626
working-directory: tools/linter
@@ -45,8 +45,7 @@ jobs:
4545
echo "Lint results:"
4646
cat lint_results.json
4747
48-
49-
- name: Post comments with metadata
48+
- name: Post review with grouped comments
5049
uses: actions/github-script@v7
5150
with:
5251
github-token: ${{ secrets.GITHUB_TOKEN }}
@@ -62,58 +61,126 @@ jobs:
6261
const content = fs.readFileSync('lint_results.json', 'utf8').trim();
6362
if (!content || content === '[]') {
6463
console.log('No lint issues found');
64+
65+
// Check if there's an existing review to dismiss
66+
const existingReviews = await github.rest.pulls.listReviews({
67+
owner: context.repo.owner,
68+
repo: context.repo.repo,
69+
pull_number: context.issue.number
70+
});
71+
72+
const botReview = existingReviews.data.find(review =>
73+
review.user.login === 'github-actions[bot]' &&
74+
review.body && review.body.includes('<!-- lint-review -->')
75+
);
76+
77+
if (botReview) {
78+
await github.rest.pulls.dismissReview({
79+
owner: context.repo.owner,
80+
repo: context.repo.repo,
81+
pull_number: context.issue.number,
82+
review_id: botReview.id,
83+
message: 'All lint issues have been resolved'
84+
});
85+
console.log('Dismissed previous lint review - no issues found');
86+
}
6587
return;
6688
}
6789
6890
const issues = JSON.parse(content);
6991
70-
const existingComments = await github.rest.pulls.listReviewComments({
92+
// Check for existing bot review
93+
const existingReviews = await github.rest.pulls.listReviews({
7194
owner: context.repo.owner,
7295
repo: context.repo.repo,
7396
pull_number: context.issue.number
7497
});
7598
76-
const botComments = existingComments.data.filter(comment =>
77-
comment.user.login === 'github-actions[bot]' &&
78-
comment.body.includes('<!-- lint-comment')
99+
const botReview = existingReviews.data.find(review =>
100+
review.user.login === 'github-actions[bot]' &&
101+
review.body && review.body.includes('<!-- lint-review -->')
79102
);
80103
81-
const existingHashes = new Set();
82-
botComments.forEach(comment => {
83-
const match = comment.body.match(/<!-- lint-comment:(\w+) -->/);
84-
if (match) existingHashes.add(match[1]);
85-
});
104+
// Create hash of current issues to check if review needs updating
105+
const issuesHash = crypto.createHash('md5')
106+
.update(JSON.stringify(issues.map(i => `${i.file}:${i.line}:${i.message}`)))
107+
.digest('hex')
108+
.substring(0, 8);
86109
87-
let postedCount = 0;
88-
let skippedCount = 0;
110+
// Check if existing review has the same issues
111+
if (botReview && botReview.body.includes(`<!-- lint-hash:${issuesHash} -->`)) {
112+
console.log('Review already exists with same issues, skipping');
113+
return;
114+
}
89115
90-
for (const issue of issues) {
91-
const issueData = `${issue.file}:${issue.line}:${issue.message}`;
92-
const issueHash = crypto.createHash('md5').update(issueData).digest('hex').substring(0, 8);
116+
// Dismiss existing review if it exists
117+
if (botReview) {
118+
await github.rest.pulls.dismissReview({
119+
owner: context.repo.owner,
120+
repo: context.repo.repo,
121+
pull_number: context.issue.number,
122+
review_id: botReview.id,
123+
message: 'Updating with new lint results'
124+
});
125+
}
126+
127+
// Prepare review comments
128+
const reviewComments = [];
129+
const issuesByFile = {};
93130
94-
if (existingHashes.has(issueHash)) {
95-
console.log(`Skipping duplicate issue: ${issueHash}`);
96-
skippedCount++;
97-
continue;
131+
for (const issue of issues) {
132+
if (!issuesByFile[issue.file]) {
133+
issuesByFile[issue.file] = [];
98134
}
135+
issuesByFile[issue.file].push(issue);
136+
137+
reviewComments.push({
138+
path: issue.file,
139+
line: issue.line,
140+
body: issue.message
141+
});
142+
}
143+
144+
// Create review body with summary
145+
const totalIssues = issues.length;
146+
const fileCount = Object.keys(issuesByFile).length;
99147
100-
const commentBody = `${issue.message}\n\n<!-- lint-comment:${issueHash} -->\n`;
101-
console.log(`comment body:`, commentBody);
148+
let reviewBody = `## 🔍 Lint Results\n\n`;
149+
reviewBody += `Found **${totalIssues}** issue${totalIssues !== 1 ? 's' : ''} in **${fileCount}** file${fileCount !== 1 ? 's' : ''}:\n\n`;
102150
151+
for (const [file, fileIssues] of Object.entries(issuesByFile)) {
152+
reviewBody += `- **${file}**: ${fileIssues.length} issue${fileIssues.length !== 1 ? 's' : ''}\n`;
153+
}
154+
155+
reviewBody += `\n<!-- lint-review -->\n<!-- lint-hash:${issuesHash} -->`;
156+
157+
try {
158+
const review = await github.rest.pulls.createReview({
159+
owner: context.repo.owner,
160+
repo: context.repo.repo,
161+
pull_number: context.issue.number,
162+
commit_id: context.payload.pull_request.head.sha,
163+
body: reviewBody,
164+
event: 'REQUEST_CHANGES',
165+
comments: reviewComments
166+
});
167+
168+
console.log(`Created review with ${reviewComments.length} comments`);
169+
} catch (error) {
170+
console.error(`Failed to create review:`, error.message);
171+
172+
// Fallback: try to create review without comments if there's an error
103173
try {
104-
await github.rest.pulls.createReviewComment({
174+
await github.rest.pulls.createReview({
105175
owner: context.repo.owner,
106176
repo: context.repo.repo,
107177
pull_number: context.issue.number,
108178
commit_id: context.payload.pull_request.head.sha,
109-
path: issue.file,
110-
line: issue.line,
111-
body: commentBody
179+
body: reviewBody + '\n\n⚠️ Could not attach inline comments due to an error.',
180+
event: 'REQUEST_CHANGES'
112181
});
113-
postedCount++;
114-
} catch (error) {
115-
console.error(`Failed to post comment:`, error.message);
182+
console.log('Created review without inline comments as fallback');
183+
} catch (fallbackError) {
184+
console.error('Fallback review creation also failed:', fallbackError.message);
116185
}
117186
}
118-
119-
console.log(`Posted ${postedCount} new comments, skipped ${skippedCount} duplicates`);

.github/workflows/publish-github-pages.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ jobs:
1717
- name: Setup Zig
1818
uses: mlugg/setup-zig@v2
1919
with:
20-
version: 0.14.1
20+
version: 0.15.1
2121

2222
- name: Download and install GitHub CLI
2323
run: |

.github/workflows/sim-aviron.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ jobs:
1919
- name: Setup Zig
2020
uses: mlugg/setup-zig@v2
2121
with:
22-
version: 0.14.1
22+
version: 0.15.1
2323

2424
- name: Build
2525
working-directory: sim/aviron

.github/workflows/tools-regz-wizard.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ on:
77

88
jobs:
99
build:
10+
if: false
1011
runs-on: ${{ matrix.os }}
1112

1213
strategy:
@@ -23,7 +24,7 @@ jobs:
2324
- name: Setup Zig
2425
uses: mlugg/setup-zig@v2
2526
with:
26-
version: 0.14.1
27+
version: 0.15.1
2728

2829
- name: Build
2930
working-directory: tools/regz-wizard

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
55
## What version of Zig to use
66

7-
Zig 0.14.1
7+
Zig 0.15.1
88

99
## Getting Started With MicroZig
1010

build.zig

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -45,13 +45,17 @@ const exe_targets: []const std.Target.Query = &.{
4545
pub fn build(b: *Build) void {
4646
const optimize = b.standardOptimizeOption(.{});
4747

48-
const generate_linker_script_exe = b.addExecutable(.{
49-
.name = "generate_linker_script",
48+
const generate_linker_script_mod = b.createModule(.{
5049
.root_source_file = b.path("tools/generate_linker_script.zig"),
5150
.target = b.graph.host,
5251
.optimize = optimize,
5352
});
5453

54+
const generate_linker_script_exe = b.addExecutable(.{
55+
.name = "generate_linker_script",
56+
.root_module = generate_linker_script_mod,
57+
});
58+
5559
generate_linker_script_exe.root_module.addImport(
5660
"build-internals",
5761
b.dependency("build-internals", .{}).module("build-internals"),
@@ -366,11 +370,11 @@ pub fn MicroBuild(port_select: PortSelect) type {
366370
};
367371

368372
fn serialize_patches(b: *Build, patches: []const regz.patch.Patch) []const u8 {
369-
var buf = std.ArrayList(u8).init(b.allocator);
373+
var buf: std.Io.Writer.Allocating = .init(b.allocator);
370374

371375
for (patches) |patch| {
372-
std.json.stringify(patch, .{}, buf.writer()) catch @panic("OOM");
373-
buf.writer().writeByte('\n') catch @panic("OOM");
376+
buf.writer.print("{f}", .{std.json.fmt(patch, .{})}) catch @panic("OOM");
377+
buf.writer.writeByte('\n') catch @panic("OOM");
374378
}
375379

376380
return buf.toOwnedSlice() catch @panic("OOM");
@@ -457,7 +461,7 @@ pub fn MicroBuild(port_select: PortSelect) type {
457461
regz_run.addArg("--output_path"); // Write to a file
458462

459463
const chips_dir = regz_run.addOutputDirectoryArg("chips");
460-
var patches = std.ArrayList(regz.patch.Patch).init(b.allocator);
464+
var patches: std.array_list.Managed(regz.patch.Patch) = .init(b.allocator);
461465

462466
// From chip definition
463467
patches.appendSlice(target.chip.patches) catch @panic("OOM");
@@ -488,7 +492,7 @@ pub fn MicroBuild(port_select: PortSelect) type {
488492
regz_run.addArg("--output_path"); // Write to a file
489493

490494
const chips_dir = regz_run.addOutputDirectoryArg("chips");
491-
var patches = std.ArrayList(regz.patch.Patch).init(b.allocator);
495+
var patches: std.array_list.Managed(regz.patch.Patch) = .init(b.allocator);
492496

493497
// From chip definition
494498
patches.appendSlice(target.chip.patches) catch @panic("OOM");
@@ -597,7 +601,7 @@ pub fn MicroBuild(port_select: PortSelect) type {
597601
.ram_image = target.ram_image,
598602
};
599603

600-
const args_str = std.json.stringifyAlloc(
604+
const args_str = std.json.Stringify.valueAlloc(
601605
b.allocator,
602606
generate_linker_script_args,
603607
.{},

build.zig.zon

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@
3636

3737
// used for creating package tarballs
3838
.boxzer = .{
39-
.url = "git+https://github.com/mattnite/boxzer.git#d50d7916b1f850048b2ad7e63a7abf05bd73c0e6",
40-
.hash = "boxzer-0.1.0--ed-MLzlAADinFJMGZncIcYAE07MoAbAr8a2R7Cr-xln",
39+
.url = "git+https://github.com/mattnite/boxzer#ec8779398dad92f77e4c2786a9c65b2c7ba9070f",
40+
.hash = "boxzer-0.1.0--ed-MPLnAABC1-rHkoz2i7rd6GvfuFBqNMxooT0KsEOv",
4141
},
4242
},
4343
.paths = .{

0 commit comments

Comments
 (0)