Skip to content

Add ngrok devcontainer feature with amd64 and arm64 support#9

Merged
tokidoki11 merged 9 commits into
mainfrom
copilot/add-ngrok-support-for-arm64
Apr 3, 2026
Merged

Add ngrok devcontainer feature with amd64 and arm64 support#9
tokidoki11 merged 9 commits into
mainfrom
copilot/add-ngrok-support-for-arm64

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 3, 2026

The existing public ngrok devcontainer feature is unmaintained and hardcodes amd64, making it unusable on arm64 hosts. This adds a first-party ngrok feature with proper architecture detection.

Changes

  • Architecture detection — uses uname -m to map x86_64amd64 and aarch64/arm64arm64; exits with a clear error for unsupported architectures
  • Dynamic download URL — selects the correct ngrok v3 binary from equinox.io based on detected arch; latest maps to the stable channel
  • Error handlingcurl --fail and explicit tar error checks surface actionable messages instead of silent failures
  • Teststest/ngrok/test.sh, scenarios.json, and install_latest.sh follow the same pattern as existing features
  • CI integrationngrok added to the feature test jobs in .github/workflows/test.yaml, running against debian:latest and ubuntu:latest
  • Path-based CI filtering — a compute-feature-matrix precursor job uses dorny/paths-filter@v3 to detect which feature directories (src/<feature>/**, test/<feature>/**) were modified and outputs a JSON features array; test-autogenerated and test-scenarios consume it via fromJson(needs.compute-feature-matrix.outputs.features) so only features with actual changes are tested; workflow_dispatch always runs all features
  • Root README — added ngrok to the feature list with architecture notes and a link to its feature README

Usage

{
    "features": {
        "ghcr.io/tokidoki11/devcontainer-feature/ngrok:1": {
            "version": "latest"  // or e.g. "3.5.0"
        }
    }
}

@tokidoki11
Copy link
Copy Markdown
Owner

@copilot add test for ngrok feature in github action

Copy link
Copy Markdown
Contributor Author

Copilot AI commented Apr 3, 2026

@copilot add test for ngrok feature in github action

Added ngrok to the test-autogenerated and test-scenarios job matrices in .github/workflows/test.yaml (commit c259476). It will now run the same CI test jobs as cargo-lambda and lambroll — autogenerated tests against debian:latest and ubuntu:latest, plus the scenario defined in test/ngrok/scenarios.json.

@tokidoki11
Copy link
Copy Markdown
Owner

@copilot fix the test failure

Copy link
Copy Markdown
Contributor Author

Copilot AI commented Apr 3, 2026

@copilot fix the test failure

Fixed in commit 2780cec. The test-scenarios (ngrok) job was failing because the devcontainer CLI expects a test script named after each scenario key — install_latest.sh to match the "install_latest" scenario in scenarios.json. Added that file with the same ngrok version / which ngrok checks.

@tokidoki11
Copy link
Copy Markdown
Owner

@copilot I want to run check of feature only when feature related item is changed

Copy link
Copy Markdown
Contributor Author

Copilot AI commented Apr 3, 2026

@copilot I want to run check of feature only when feature related item is changed

Done in commit 5df5e5d. Added a changes job using dorny/paths-filter@v3 that detects which feature directories were modified. The test-autogenerated and test-scenarios jobs now need: changes and each matrix element has an if condition so only the feature(s) whose src/<feature>/** or test/<feature>/** files actually changed will have their tests run. workflow_dispatch always runs all tests.

@tokidoki11
Copy link
Copy Markdown
Owner

@copilot

[Invalid workflow file: .github/workflows/test.yaml#L1](https://github.com/tokidoki11/devcontainer-feature/actions/runs/23940299311/workflow)
(Line: 49, Col: 9): Unrecognized named-value: 'matrix'. Located at position 46 within expression: github.event_name == 'workflow_dispatch' ||
(matrix.features == 'cargo-lambda' && needs.changes.outputs.cargo-lambda == 'true') ||
(matrix.features == 'lambroll' && needs.changes.outputs.lambroll == 'true') ||
(matrix.features == 'ngrok' && needs.changes.outputs.ngrok == 'true'), (Line: 73, Col: 9): Unrecognized named-value: 'matrix'. Located at position 46 within expression: github.event_name == 'workflow_dispatch' ||
(matrix.features == 'cargo-lambda' && needs.changes.outputs.cargo-lambda == 'true') ||
(matrix.features == 'lambroll' && needs.changes.outputs.lambroll == 'true') ||
(matrix.features == 'ngrok' && needs.changes.outputs.ngrok == 'true')

…valid if conditions

Agent-Logs-Url: https://github.com/tokidoki11/devcontainer-feature/sessions/3f7a0c2b-a1f8-4fb8-b79e-36c1de785a96

Co-authored-by: tokidoki11 <7564844+tokidoki11@users.noreply.github.com>
Copy link
Copy Markdown
Contributor Author

Copilot AI commented Apr 3, 2026

@copilot

...

Fixed in commit 46af616. The root cause was that GitHub Actions' job-level if cannot reference the matrix context — that's only available inside steps. Resolved by splitting the combined feature+baseImage matrix into separate per-feature jobs (test-autogenerated-cargo-lambda, test-autogenerated-lambroll, test-autogenerated-ngrok, test-scenarios-cargo-lambda, etc.), each with a simple if: needs.changes.outputs.<feature> == 'true' condition that is valid at the job level.

@tokidoki11
Copy link
Copy Markdown
Owner

@copilot revert instead
create a precursor job that outputs a JSON string representing the matrix.

also update the readme at the root

Copy link
Copy Markdown
Contributor Author

Copilot AI commented Apr 3, 2026

@copilot revert instead
create a precursor job that outputs a JSON string representing the matrix.

...

Done in commit c487746. Reverted the per-feature job split and replaced it with a compute-feature-matrix precursor job that:

  1. Runs dorny/paths-filter to detect which feature directories changed
  2. Outputs a JSON array string (e.g. ["cargo-lambda","ngrok"]) — or all three features on workflow_dispatch

The test-autogenerated and test-scenarios jobs consume it via fromJson(needs.compute-feature-matrix.outputs.features), which is the correct GitHub Actions pattern for dynamic matrices and avoids the job-level matrix context issue entirely.

Also updated the root README to add ngrok to the feature list.

Copilot AI requested a review from tokidoki11 April 3, 2026 10:12
@tokidoki11
Copy link
Copy Markdown
Owner

@copilot that is an ugly if else
Use shell script, create a map variable

Copy link
Copy Markdown
Contributor Author

Copilot AI commented Apr 3, 2026

@copilot that is an ugly if else
Use shell script, create a map variable

Done in commit c520aee. Replaced the if/else with a declare -A changed=(...) associative array mapping each feature to its filter output, and an all_features ordered array to iterate in stable order. A single for loop now handles both workflow_dispatch and push/PR cases — no outer branch needed.

@tokidoki11
Copy link
Copy Markdown
Owner

@copilot offload that long matrix creation to a shell script inside .github/ and call it inside the action

Copy link
Copy Markdown
Contributor Author

Copilot AI commented Apr 3, 2026

@copilot offload that long matrix creation to a shell script inside .github/ and call it inside the action

Done in commit c8cc5d0. Extracted the matrix logic to .github/compute-feature-matrix.sh. It accepts event_name and the per-feature change flags as positional arguments, and writes features=<json> to $GITHUB_OUTPUT. The workflow step is now just:

run: |
  bash .github/compute-feature-matrix.sh \
    "${{ github.event_name }}" \
    "${{ steps.filter.outputs.cargo-lambda }}" \
    "${{ steps.filter.outputs.lambroll }}" \
    "${{ steps.filter.outputs.ngrok }}"

@tokidoki11 tokidoki11 merged commit 4344ea7 into main Apr 3, 2026
6 checks passed
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