Skip to content

Auto detect OS platform#35

Merged
bodrovis merged 3 commits intomainfrom
auto_detect_platform
Feb 24, 2026
Merged

Auto detect OS platform#35
bodrovis merged 3 commits intomainfrom
auto_detect_platform

Conversation

@bodrovis
Copy link
Copy Markdown
Collaborator

@bodrovis bodrovis commented Feb 24, 2026

Summary by CodeRabbit

  • New Features

    • Automatic platform detection with input validation for supported platforms.
  • Documentation

    • Added CI status badge to README.
    • Clarified platform configuration and auto-detection guidance.
  • Chores

    • Upgraded Go toolchain to 1.26 and bumped CI tooling versions.
    • Updated workflow tooling and a project dependency.
  • Tests

    • Simplified a unit test to use standard library membership check.

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Feb 24, 2026

Warning

Rate limit exceeded

@bodrovis has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 12 minutes and 44 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

📥 Commits

Reviewing files that changed from the base of the PR and between 15f26bd and f930d11.

📒 Files selected for processing (1)
  • action.yml

Note

.coderabbit.yaml has unrecognized properties

CodeRabbit is using all valid settings from your configuration. Unrecognized properties (listed below) have been ignored and may indicate typos or deprecated fields that can be removed.

⚠️ Parsing warnings (1)
Validation error: Unrecognized key(s) in object: 'tools'
⚙️ Configuration instructions
  • Please see the configuration documentation for more information.
  • You can also validate your configuration using the online YAML validator.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Walkthrough

Bumps Go toolchain to 1.26 across CI and modules, adds platform auto-detection and validation to the composite action, updates several GitHub Action versions, adjusts README/CI badges, removes a .gitignore entry, and simplifies a test using slices.Contains.

Changes

Cohort / File(s) Summary
Go version & toolchain
\.github/workflows/build-to-bin.yml, \.github/workflows/ci.yml, src/find_all_files/go.mod, src/lokalise_upload/go.mod, src/store_translation_paths/go.mod
Updated Go language/toolchain from 1.25 / go1.25.6 → 1.26 / go1.26.0.
Composite action (platform detection)
action.yml
Added Detect platform step, changed os_platform default to empty, added auto-detection and validation mapping from RUNNER_OS/RUNNER_ARCH, and propagated PLATFORM output to subsequent steps; updated validation error behavior.
CI workflows & actions
\.github/workflows/codeql.yml, \.github/workflows/ci.yml
Upgraded checkout/action versions (checkout@v6) and bumped Go setup versions in CI workflows; removed header comments in CodeQL workflow.
Documentation
README.md
Added CI badge, updated Push action reference version, and clarified os_platform auto-detection and platform description.
.gitignore
.gitignore
Removed go.work.sum entry; adjusted placement of cosign.exe entry.
Tests
src/store_translation_paths/main_test.go
Replaced manual membership loop with slices.Contains import and call.
Dependency update
src/lokalise_upload/go.mod
Bumped github.com/bodrovis/lokex/v2 from v2.0.0 → v2.0.1.

Sequence Diagram(s)

sequenceDiagram
    participant User as User / Workflow
    participant Action as Composite Action
    participant Validator as Validation Logic
    participant Steps as Subsequent Steps

    rect rgba(200,200,255,0.5)
    User->>Action: Trigger action (with or without os_platform)
    end

    rect rgba(200,255,200,0.5)
    Action->>Validator: If os_platform set -> validate value
    alt valid
        Validator-->>Action: PLATFORM value
    else invalid
        Validator-->>Action: error (unsupported os_platform)
        Action-->>User: fail with guidance
    end
    end

    rect rgba(255,200,200,0.5)
    Action->>Validator: If os_platform empty -> auto-detect from RUNNER_OS/RUNNER_ARCH
    alt supported runner
        Validator-->>Action: PLATFORM detected
    else unsupported runner
        Validator-->>Action: error (unsupported runner)
        Action-->>User: fail with guidance
    end
    end

    rect rgba(200,200,255,0.5)
    Action-->>Steps: Pass PLATFORM output
    Steps->>Steps: Run platform-specific steps
    end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The PR title 'Auto detect OS platform' accurately reflects the primary objective of the changeset, which adds platform auto-detection logic to the action.yml file and updates Go versions across the project.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch auto_detect_platform

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

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 the current code and only fix it if needed.

Inline comments:
In `@action.yml`:
- Around line 118-150: The auto-detect branch should normalize RUNNER_OS and
RUNNER_ARCH before matching: create lowercased variables (e.g. RUNNER_OS_LC and
RUNNER_ARCH_LC using printf/... | tr '[:upper:]' '[:lower:]'), normalize common
variants (map "macos" -> "mac", "darwin" -> "mac" if needed, and map arch "x64"
-> "amd64", leave "arm64"), then switch on
"${RUNNER_OS_LC}/${RUNNER_ARCH_MAPPED}" instead of raw RUNNER_OS/RUNNER_ARCH and
set PLATFORM accordingly; update the case patterns used in the auto-detect block
and keep validate_platform, OS_PLATFORM and PLATFORM logic unchanged.

ℹ️ Review info

Configuration used: Repository: lokalise/coderabbit/.coderabbit.yaml

Review profile: CHILL

Plan: Pro

Disabled knowledge base sources:

  • Jira integration is disabled

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 9085e9b and b9e1182.

⛔ Files ignored due to path filters (1)
  • src/lokalise_upload/go.sum is excluded by !**/*.sum
📒 Files selected for processing (10)
  • .github/workflows/build-to-bin.yml
  • .github/workflows/ci.yml
  • .github/workflows/codeql.yml
  • .gitignore
  • README.md
  • action.yml
  • src/find_all_files/go.mod
  • src/lokalise_upload/go.mod
  • src/store_translation_paths/go.mod
  • src/store_translation_paths/main_test.go

Comment on lines +118 to +150
OS_PLATFORM="$(printf '%s' "${OS_PLATFORM:-}" \
| sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//' -e 's/[[:space:]]//g' \
| tr '[:upper:]' '[:lower:]')"

validate_platform() {
case "$1" in
linux_amd64|linux_arm64|mac_amd64|mac_arm64) return 0 ;;
*) return 1 ;;
esac
}

if [[ -n "$OS_PLATFORM" ]]; then
if ! validate_platform "$OS_PLATFORM"; then
echo "Error: unsupported 'os_platform' input: '$OS_PLATFORM'"
echo "Supported values: linux_amd64, linux_arm64, mac_amd64, mac_arm64"
exit 1
fi
echo "Using user-provided platform: $OS_PLATFORM"
PLATFORM="$OS_PLATFORM"
else
echo "Auto-detecting platform from runner: OS=${RUNNER_OS:-} ARCH=${RUNNER_ARCH:-}"

case "${RUNNER_OS:-}/${RUNNER_ARCH:-}" in
Linux/X64) PLATFORM="linux_amd64" ;;
Linux/ARM64) PLATFORM="linux_arm64" ;;
macOS/X64) PLATFORM="mac_amd64" ;;
macOS/ARM64) PLATFORM="mac_arm64" ;;
*)
echo "Error: unsupported runner platform: ${RUNNER_OS:-}/${RUNNER_ARCH:-}"
echo "Please set 'os_platform' input explicitly to one of: linux_amd64, linux_arm64, mac_amd64, mac_arm64"
exit 1
;;
esac
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Normalize RUNNER_OS/RUNNER_ARCH before matching.
On some self‑hosted runners (or future GitHub changes), casing can be linux/x64 or macos/arm64, which would currently fall into the “unsupported” branch even though the platform is valid.

🔧 Suggested hardening
-          echo "Auto-detecting platform from runner: OS=${RUNNER_OS:-} ARCH=${RUNNER_ARCH:-}"
-
-          case "${RUNNER_OS:-}/${RUNNER_ARCH:-}" in
-            Linux/X64)   PLATFORM="linux_amd64" ;;
-            Linux/ARM64) PLATFORM="linux_arm64" ;;
-            macOS/X64)   PLATFORM="mac_amd64" ;;
-            macOS/ARM64) PLATFORM="mac_arm64" ;;
+          runner_os="$(printf '%s' "${RUNNER_OS:-}" | tr '[:upper:]' '[:lower:]')"
+          runner_arch="$(printf '%s' "${RUNNER_ARCH:-}" | tr '[:upper:]' '[:lower:]')"
+          echo "Auto-detecting platform from runner: OS=${runner_os} ARCH=${runner_arch}"
+
+          case "${runner_os}/${runner_arch}" in
+            linux/x64|linux/amd64) PLATFORM="linux_amd64" ;;
+            linux/arm64)           PLATFORM="linux_arm64" ;;
+            macos/x64|macos/amd64) PLATFORM="mac_amd64" ;;
+            macos/arm64)           PLATFORM="mac_arm64" ;;
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
OS_PLATFORM="$(printf '%s' "${OS_PLATFORM:-}" \
| sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//' -e 's/[[:space:]]//g' \
| tr '[:upper:]' '[:lower:]')"
validate_platform() {
case "$1" in
linux_amd64|linux_arm64|mac_amd64|mac_arm64) return 0 ;;
*) return 1 ;;
esac
}
if [[ -n "$OS_PLATFORM" ]]; then
if ! validate_platform "$OS_PLATFORM"; then
echo "Error: unsupported 'os_platform' input: '$OS_PLATFORM'"
echo "Supported values: linux_amd64, linux_arm64, mac_amd64, mac_arm64"
exit 1
fi
echo "Using user-provided platform: $OS_PLATFORM"
PLATFORM="$OS_PLATFORM"
else
echo "Auto-detecting platform from runner: OS=${RUNNER_OS:-} ARCH=${RUNNER_ARCH:-}"
case "${RUNNER_OS:-}/${RUNNER_ARCH:-}" in
Linux/X64) PLATFORM="linux_amd64" ;;
Linux/ARM64) PLATFORM="linux_arm64" ;;
macOS/X64) PLATFORM="mac_amd64" ;;
macOS/ARM64) PLATFORM="mac_arm64" ;;
*)
echo "Error: unsupported runner platform: ${RUNNER_OS:-}/${RUNNER_ARCH:-}"
echo "Please set 'os_platform' input explicitly to one of: linux_amd64, linux_arm64, mac_amd64, mac_arm64"
exit 1
;;
esac
OS_PLATFORM="$(printf '%s' "${OS_PLATFORM:-}" \
| sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//' -e 's/[[:space:]]//g' \
| tr '[:upper:]' '[:lower:]')"
validate_platform() {
case "$1" in
linux_amd64|linux_arm64|mac_amd64|mac_arm64) return 0 ;;
*) return 1 ;;
esac
}
if [[ -n "$OS_PLATFORM" ]]; then
if ! validate_platform "$OS_PLATFORM"; then
echo "Error: unsupported 'os_platform' input: '$OS_PLATFORM'"
echo "Supported values: linux_amd64, linux_arm64, mac_amd64, mac_arm64"
exit 1
fi
echo "Using user-provided platform: $OS_PLATFORM"
PLATFORM="$OS_PLATFORM"
else
runner_os="$(printf '%s' "${RUNNER_OS:-}" | tr '[:upper:]' '[:lower:]')"
runner_arch="$(printf '%s' "${RUNNER_ARCH:-}" | tr '[:upper:]' '[:lower:]')"
echo "Auto-detecting platform from runner: OS=${runner_os} ARCH=${runner_arch}"
case "${runner_os}/${runner_arch}" in
linux/x64|linux/amd64) PLATFORM="linux_amd64" ;;
linux/arm64) PLATFORM="linux_arm64" ;;
macos/x64|macos/amd64) PLATFORM="mac_amd64" ;;
macos/arm64) PLATFORM="mac_arm64" ;;
*)
echo "Error: unsupported runner platform: ${RUNNER_OS:-}/${RUNNER_ARCH:-}"
echo "Please set 'os_platform' input explicitly to one of: linux_amd64, linux_arm64, mac_amd64, mac_arm64"
exit 1
;;
esac
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@action.yml` around lines 118 - 150, The auto-detect branch should normalize
RUNNER_OS and RUNNER_ARCH before matching: create lowercased variables (e.g.
RUNNER_OS_LC and RUNNER_ARCH_LC using printf/... | tr '[:upper:]' '[:lower:]'),
normalize common variants (map "macos" -> "mac", "darwin" -> "mac" if needed,
and map arch "x64" -> "amd64", leave "arm64"), then switch on
"${RUNNER_OS_LC}/${RUNNER_ARCH_MAPPED}" instead of raw RUNNER_OS/RUNNER_ARCH and
set PLATFORM accordingly; update the case patterns used in the auto-detect block
and keep validate_platform, OS_PLATFORM and PLATFORM logic unchanged.

Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
action.yml (1)

171-171: Nit: double space in expression reference.

Lines 171, 302, and 356 all have ${{ steps.detect-platform.outputs.platform }} with two spaces before }}. GitHub Actions ignores the extra whitespace, so there's no functional impact, but it's inconsistent with every other expression in the file.

✏️ Suggested cleanup (apply at all three occurrences)
-        PLATFORM: "${{ steps.detect-platform.outputs.platform  }}"
+        PLATFORM: "${{ steps.detect-platform.outputs.platform }}"
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@action.yml` at line 171, Update the PLATFORM environment mapping that uses
the expression steps.detect-platform.outputs.platform to remove the stray extra
space before the closing braces; replace occurrences of "${{
steps.detect-platform.outputs.platform  }}" with "${{
steps.detect-platform.outputs.platform }}" (apply the same fix for all three
occurrences) so the expression formatting matches the other entries and remains
consistent.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@action.yml`:
- Line 171: Update the PLATFORM environment mapping that uses the expression
steps.detect-platform.outputs.platform to remove the stray extra space before
the closing braces; replace occurrences of "${{
steps.detect-platform.outputs.platform  }}" with "${{
steps.detect-platform.outputs.platform }}" (apply the same fix for all three
occurrences) so the expression formatting matches the other entries and remains
consistent.

ℹ️ Review info

Configuration used: Repository: lokalise/coderabbit/.coderabbit.yaml

Review profile: CHILL

Plan: Pro

Disabled knowledge base sources:

  • Jira integration is disabled

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between b9e1182 and 15f26bd.

📒 Files selected for processing (2)
  • README.md
  • action.yml
🚧 Files skipped from review as they are similar to previous changes (1)
  • README.md

@bodrovis bodrovis merged commit 10b685f into main Feb 24, 2026
@bodrovis bodrovis deleted the auto_detect_platform branch February 24, 2026 17:40
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.

1 participant