Skip to content

feat(release): add build-identifier script (epic 005 T006) - #43

Merged
rsenna merged 3 commits into
mainfrom
005-t006-build-identifier
Aug 1, 2026
Merged

feat(release): add build-identifier script (epic 005 T006)#43
rsenna merged 3 commits into
mainfrom
005-t006-build-identifier

Conversation

@owkwo-bot

@owkwo-bot owkwo-bot commented Jul 30, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • .github/scripts/build-identifier.sh: computes GITHUB_RUN_NUMBER.GITHUB_RUN_ATTEMPT (FR-005), validating both are present and base-10 numeric rather than blindly concatenating.
  • Fixture tests written test-first per Constitution I.
  • Marks epic 005's T006 done in tasks.md.

Separate PR from #42 (T005) — different scripts, no shared code, one concern each.

Why

Second Phase 2 "Foundational" task — release.yml (T008, not yet built) and the release-notes script (T014) will both consume this identifier.

Test plan

  • bash .github/scripts/tests/test-build-identifier.sh — 8/8 pass (happy path, missing/non-numeric env vars, negative numbers).
  • cargo build --workspace unaffected (no Rust files touched).

🧙 Built with WOZCODE

Summary by Sourcery

Add a script to compute a deterministic build identifier for CI release runs and mark the corresponding task as completed.

New Features:

  • Introduce build-identifier.sh to compute a numeric GITHUB_RUN_NUMBER.GITHUB_RUN_ATTEMPT build identifier for release workflows.

Documentation:

  • Update the CI release versioning spec to record completion of the build-identifier computation task and document its script and test coverage.

Tests:

  • Add fixture-based bash tests for the build-identifier script covering happy path, missing env vars, non-numeric values, and negative numbers.

Summary by cubic

Adds a script to compute a deterministic build ID GITHUB_RUN_NUMBER.GITHUB_RUN_ATTEMPT with strict numeric validation to support numeric release ordering (FR-005/SC-003). Updates tests and marks epic 005 T006 done; tasks doc synced with main.

  • New Features

    • .github/scripts/build-identifier.sh outputs run_number.attempt and fails if either env var is missing or non-numeric.
    • Fixture tests cover happy path and invalid inputs; specs/005-ci-release-versioning/tasks.md marks T006 done.
  • Bug Fixes

    • Fixed the missing GITHUB_RUN_ATTEMPT test by placing env -u before assignments so the script’s validation runs.
    • Added a numeric ordering assertion (same run-number, attempt breaks ties) instead of suppressing lint.

Written for commit deda4ba. Summary will update on new commits.

Review in cubic

Summary by CodeRabbit

  • New Features

    • Added deterministic build identifiers based on the build run number and attempt number.
    • Invalid or missing build information is now clearly reported.
  • Tests

    • Added coverage for valid identifiers, retries, missing values, invalid input, negative values, and numeric ordering.
  • Documentation

    • Marked deterministic build identifier work as complete in the release versioning task list.

Test-first per Constitution I. GITHUB_RUN_NUMBER.GITHUB_RUN_ATTEMPT,
validated as present and base-10 numeric (not just concatenated blindly)
so SC-003's "strictly increasing" check has a numeric pair to compare,
not two arbitrary strings.
@sourcery-ai

sourcery-ai Bot commented Jul 30, 2026

Copy link
Copy Markdown

Reviewer's Guide

Implements a deterministic build identifier script for GitHub Actions releases, along with fixture-based bash tests, and marks the corresponding task as completed in the CI/release specification.

Sequence diagram for build-identifier.sh execution in GitHub Actions

sequenceDiagram
  actor Workflow
  participant BuildIdentifierScript as build_identifier_sh

  Workflow->>BuildIdentifierScript: execute build-identifier.sh
  BuildIdentifierScript->>BuildIdentifierScript: read GITHUB_RUN_NUMBER
  BuildIdentifierScript->>BuildIdentifierScript: read GITHUB_RUN_ATTEMPT

  alt missing_env_vars
    BuildIdentifierScript->>Workflow: stderr "error: GITHUB_RUN_NUMBER and GITHUB_RUN_ATTEMPT must both be set"
    BuildIdentifierScript->>Workflow: exit 1
  else non_numeric_env_vars
    BuildIdentifierScript->>Workflow: stderr "error: ... must both be base-10 integers"
    BuildIdentifierScript->>Workflow: exit 1
  else valid_env_vars
    BuildIdentifierScript->>Workflow: stdout run_number.run_attempt
  end
Loading

File-Level Changes

Change Details Files
Add a bash script that computes and validates the release build identifier from GitHub Actions environment variables.
  • Introduces build-identifier.sh that reads GITHUB_RUN_NUMBER and GITHUB_RUN_ATTEMPT and constructs a build identifier as run_number.run_attempt.
  • Ensures both environment variables are present, failing with a clear error if either is missing.
  • Validates that both values are base-10 numeric (unsigned integers) using a regex, rejecting non-numeric and negative values.
  • Outputs the computed identifier to stdout for consumption by future release-related automation.
.github/scripts/build-identifier.sh
Add fixture-based bash tests for the build-identifier script to document and enforce its behavior.
  • Creates a small bash test harness with pass/fail counters and helper functions for equality checks and expected-failure checks.
  • Covers happy-path scenarios for basic and retry attempts, checking the exact output string.
  • Covers failure scenarios for missing environment variables, non-numeric values, and negative values to ensure strict validation.
  • Includes a numeric ordering sanity check for run numbers to document the intended numeric-pair comparison contract (SC-003).
.github/scripts/tests/test-build-identifier.sh
Update the CI/release versioning spec to mark the build-identifier task as completed and reference the new script and tests.
  • Marks task T006 as completed in the CI/release versioning tasks list.
  • Documents that the implementation lives in build-identifier.sh and that fixture tests exist under the tests directory.
  • Clarifies that tests cover missing and non-numeric environment variables, not just the happy path.
specs/005-ci-release-versioning/tasks.md

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@greptile-apps greptile-apps Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

owkwo-bot has reached the 50-credit limit for trial accounts. To continue receiving code reviews, upgrade your plan.

@gemini-code-assist

Copy link
Copy Markdown

Caution

The consumer version of Gemini Code Assist on GitHub has been sunset. All code review activity has officially ceased.

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - I've reviewed your changes and they look great!


Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@codacy-production

codacy-production Bot commented Jul 30, 2026

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

AI Reviewer: first review requested successfully. AI can make mistakes. Always validate suggestions.

Run reviewer

TIP This summary will be updated as you push new changes.

@codacy-production codacy-production Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

The PR introduces the build-identifier script and its associated tests. Although the implementation aligns with the requirement to use GITHUB_RUN_NUMBER and GITHUB_RUN_ATTEMPT, the PR is currently not up to standards due to quality and reliability issues in the test suite. A significant logic error was found in the shell script tests where the 'env' command is misconfigured, causing tests to pass for the wrong reasons. Additionally, there are multiple linting violations for unused variables in the test script. These issues must be addressed to ensure the build process remains robust and maintainable.

Test suggestions

  • Valid numeric environment variables result in a concatenated run_number.run_attempt output.\n- [x] Missing GITHUB_RUN_NUMBER or GITHUB_RUN_ATTEMPT environment variables causes the script to exit with an error.\n- [x] Non-numeric strings (e.g., 'abc') provided as environment variables cause the script to exit with an error.\n- [x] Negative numbers provided as environment variables cause the script to exit with an error.

TIP Improve review quality by adding custom instructions
TIP How was this review? Give us feedback

Comment thread .github/scripts/tests/test-build-identifier.sh
Comment thread .github/scripts/tests/test-build-identifier.sh Outdated
@coderabbitai

coderabbitai Bot commented Jul 30, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

The PR adds a Bash script that validates GITHUB_RUN_NUMBER and GITHUB_RUN_ATTEMPT, then prints their dotted build identifier. Fixture tests cover valid and invalid inputs. The task record marks T006 complete.

Changes

Build identifier generation

Layer / File(s) Summary
Identifier validation and output
.github/scripts/build-identifier.sh
The script requires numeric GITHUB_RUN_NUMBER and GITHUB_RUN_ATTEMPT values. It reports invalid input to stderr and prints the dotted identifier for valid input.
Fixture coverage and task tracking
.github/scripts/tests/test-build-identifier.sh, specs/005-ci-release-versioning/tasks.md
The tests cover normal runs, retries, missing and invalid values, negative values, numeric ordering, and failure reporting. T006 is marked complete.

Estimated code review effort: 2 (Simple) | ~10 minutes

Possibly related PRs

  • rsenna/iklo#37: Defines the related build-versioning requirements and task planning implemented by this PR.
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly identifies the main change: adding a build-identifier script for release versioning.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch 005-t006-build-identifier

Comment @coderabbitai help to get the list of available commands.

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All reported issues were addressed across 3 files

Reply with feedback, questions, or to request a fix.

Re-trigger cubic

Comment thread .github/scripts/tests/test-build-identifier.sh Outdated
Comment thread .github/scripts/tests/test-build-identifier.sh
…ppressing lint

- The GITHUB_RUN_ATTEMPT-missing test had `env`'s `-u` option after a
  NAME=VALUE assignment. env stops parsing options at the first
  assignment, so it tried to exec a program literally named "-u" and
  failed with "No such file or directory" -- the test still passed, but
  for the wrong reason (env failing, not the script's own validation).
  Verified: reproduced the bug locally (env: -u: No such file or
  directory), confirmed the fix actually reaches the script's own
  "must both be set" error instead.
- a_attempt/b_attempt were assigned but never used (ShellCheck noise).
  Rather than prefix-and-ignore, added a real second assertion that
  exercises them: same run-number, attempt breaks the tie -- a more
  useful test than a suppressed warning.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@specs/005-ci-release-versioning/tasks.md`:
- Around line 99-105: Add an ADR under specs/decisions/ documenting the
GITHUB_RUN_NUMBER.GITHUB_RUN_ATTEMPT build-identifier contract, including its
numeric ordering semantics, release metadata usage, and artifact naming. Update
T006 in tasks.md to reference the new ADR before merging, while preserving its
existing completion details.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: e4ab5f21-7c38-4860-be25-488a6a286fac

📥 Commits

Reviewing files that changed from the base of the PR and between c37d4a2 and 761a158.

📒 Files selected for processing (3)
  • .github/scripts/build-identifier.sh
  • .github/scripts/tests/test-build-identifier.sh
  • specs/005-ci-release-versioning/tasks.md

Comment thread specs/005-ci-release-versioning/tasks.md
# Conflicts:
#	specs/005-ci-release-versioning/tasks.md
@rsenna
rsenna merged commit ee9dd14 into main Aug 1, 2026
4 checks passed
@rsenna
rsenna deleted the 005-t006-build-identifier branch August 1, 2026 02:10
rsenna added a commit that referenced this pull request Aug 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants