Skip to content

feat: setup-task GitHub Action の初回実装#6

Merged
yk-lab merged 8 commits into
mainfrom
feat/initial-implementation
Jun 15, 2026
Merged

feat: setup-task GitHub Action の初回実装#6
yk-lab merged 8 commits into
mainfrom
feat/initial-implementation

Conversation

@yk-lab

@yk-lab yk-lab commented Jun 15, 2026

Copy link
Copy Markdown
Owner

概要

go-task (task) バイナリをインストールする GitHub Action のプロジェクト基盤・初回実装。
arduino/setup-task のドロップイン代替を目指す(Node 24 / 認証既定 / checksum 検証 / cache)。

含まれるもの

  • 実装 (src/): バージョン解決 (exact/range/latest)、プラットフォーム判定、認証付き DL + 指数バックオフ、SHA256 検証、tool-cache、PATH 追加、outputs — FR-1〜FR-10
  • dist/: ncc バンドル済み(Action は dist/index.js を直接実行するためコミット)
  • CI/self-test: typecheck/lint/test/build + dist/ 鮮度チェック、OS×version マトリクス
  • テスト: version / platform / checksum のユニットテスト(20 件 green)
  • ドキュメント: README.md / CLAUDE.md / TODO.md / 企画書・要求仕様書

テスト

  • npm run all(typecheck + lint + test + build)green
  • CI / self-test(この PR で初回実行)

補足

🤖 Generated with Claude Code


Summary by cubic

Initial implementation of setup-task: a Node 24 GitHub Action that installs the Task (go-task) binary with authenticated downloads, SHA256 verification, caching, and retries. A drop-in alternative to arduino/setup-task with exact/range/latest version support and platform detection.

  • Bug Fixes

    • Platform: map process.arch=riscv64 to the correct go-task asset; tests added.
    • Networking/Checksum: fetchText treats HTML pages as transient and retries; checksum mismatches throw PermanentError.
  • Refactors

    • Consolidated fetch flow into fetchOk + content-type guards; added errorMessage; minor cleanups (cacheHit const, input trim).

Written for commit 9e33762. Summary will update on new commits.

Review in cubic

@coderabbitai

coderabbitai Bot commented Jun 15, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Summary by CodeRabbit

リリースノート

  • New Features

    • 新規GitHub Action「setup-task」を提供。go-taskバイナリの自動取得・検証・インストール機能を実装。バージョン指定(exact/range/latest)、複数プラットフォーム対応、SHA256チェックサム検証、指数バックオフ付きリトライ、ツールキャッシュ統合により高速化。
  • Documentation

    • セットアップガイド、要求仕様書、設計ドキュメントを追加。使用例と対応プラットフォーム、入出力仕様を詳細記載。

Walkthrough

yk-lab/setup-task GitHub Action を新規に全実装。src/ 配下に定数・エラー型・プラットフォーム解決・バージョン解決・GitHub API クライアント・ダウンロード・チェックサム検証・展開・エントリーポイントの各モジュールを追加し、Vitest による単体テスト群、ESLint 設定、.gitignore、LICENSE、README、企画書・要求仕様書も同時追加した。

Changes

setup-task GitHub Action 実装

Layer / File(s) Summary
定数・エラー型・プラットフォーム解決
src/errors.ts, src/constants.ts, src/platform.ts, tests/platform.test.ts
PermanentErrorerrorMessage、ツール名/API URL/リトライ設定定数と releaseDownloadUrl、Node の process.platform/arch から go-task アセット名・拡張子・バイナリ名へ写像する resolveAsset を定義。未対応 OS/arch では例外をスロー。Vitest による正常系・異常系テストを含む。
バージョン解決ロジック
src/version.ts, tests/version.test.ts
ReleaseApi インターフェースを定義し、latest/*・exact バージョン・semver range の各ケースを semver.maxSatisfying で解決する resolveVersion を実装。解決不能時は利用可能バージョンを含むエラーをスロー。fakeApi を用いた全分岐テストを含む。
GitHub API クライアントとリリース取得
src/github.ts, tests/github.test.ts
Bearer 認証ヘッダ生成、404 → PermanentError マッピング、HTML 応答を検知する guardContentTypefetchJson<T>fetchTextcreateReleaseApi(最大 10 ページのページング・安定版フィルタ)を実装。fetchText の正常系・HTML 異常系・404 異常系を Vitest で検証。
ダウンロードとリトライ機構
src/download.ts
PermanentError または HTTP 404 で即時中断する指数バックオフリトライ withRetry と、tc.downloadTool を Bearer 認証で呼び出す downloadAsset を実装。
チェックサム検証
src/checksum.ts, tests/checksum.test.ts
parseChecksums(BSD 形式対応)・fetchChecksumsha256FileverifyChecksum(不一致で PermanentError)を実装。Vitest による SHA256 計算・ミスマッチ検出テストを含む。
エントリーポイントと展開・PATH 設定
src/install.ts, src/main.ts
extract(zip/tar 選択)と、入力読み取り→バージョン解決→キャッシュ照合→ダウンロード→チェックサム検証→展開→キャッシュ登録→chmod→core.addPath→outputs 設定の完全パイプラインを run() として実装。
プロジェクト設定・仕様ドキュメント群
eslint.config.mjs, .gitignore, LICENSE, README.md, TODO.md, CLAUDE.md, 企画書.md, 要求仕様書.md
ESLint flat 設定、.gitignore(dist/ はコミット対象)、MIT LICENSE、README(使用例・移行ガイド・入出力仕様)、TODO.md(マイルストーン管理)、CLAUDE.md(AI エージェント作業指針)、企画書・要求仕様書(FR/NFR・エラーハンドリング・受け入れ基準)を追加。

Sequence Diagram(s)

sequenceDiagram
    actor Runner as GitHub Actions Runner
    participant main as main.ts
    participant github as github.ts (createReleaseApi)
    participant version as version.ts (resolveVersion)
    participant tc as tool-cache
    participant download as download.ts (downloadAsset)
    participant checksum as checksum.ts (verifyChecksum)
    participant install as install.ts (extract)

    Runner->>main: action 起動(inputs: version, repo-token, ...)
    main->>github: createReleaseApi(token)
    main->>version: resolveVersion(api, versionInput) [withRetry]
    version->>github: getLatestVersion() or listStableVersions()
    github-->>version: tag_name / stable list
    version-->>main: resolved version tag
    main->>tc: find(TOOL_NAME, version)
    alt cache hit
        tc-->>main: cached dir path
    else cache miss
        main->>download: downloadAsset(releaseDownloadUrl, token) [withRetry]
        download-->>main: tmpPath
        main->>checksum: fetchChecksum(tag, assetName, token)
        checksum-->>main: expected SHA256
        main->>checksum: verifyChecksum(tmpPath, expected)
        checksum-->>main: ok / PermanentError
        main->>install: extract(tmpPath, ext)
        install-->>main: extracted dir
        main->>tc: cacheDir(dir, TOOL_NAME, version)
    end
    main->>Runner: core.addPath + core.setOutput(version/task-path/cache-hit)
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

Possibly related issues

  • [test] fetchJson の content-type ガードのユニットテストを追加する #3: tests/github.test.ts が追加され、fetchText の正常系・HTML エラーページ(PermanentError ではない一時エラー)・404 (PermanentError) の 3 ケースを検証しており、src/github.ts の content-type ガードとエラーハンドリングのユニットテスト追加を求める Issue の目的と一致する。

Poem

🐰 コードの森を駆け抜けて
withRetry で七転び八起き
チェックサムで安心確認
キャッシュに宝を預けたら
task --version 胸を張って!
dist/ はコミット、忘れずに 🎉

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 78.26% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The PR title clearly describes the main change: initial implementation of the setup-task GitHub Action, accurately reflecting the changeset's primary objective.
Description check ✅ Passed The description is directly related to the changeset, detailing the implemented features, test status, and included deliverables for the setup-task GitHub Action.
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.

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

✨ 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 feat/initial-implementation

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.

@yk-lab yk-lab force-pushed the feat/initial-implementation branch from 7b526ee to 84267ad Compare June 15, 2026 15:59
go-task (task) バイナリを解決→取得→検証→展開→キャッシュ→PATH 追加する Node 24 製 Action。
バージョン解決 (exact/range/latest)、プラットフォーム判定、認証付き DL + 指数バックオフ、
SHA256 チェックサム検証、tool-cache、outputs を実装 (FR-1〜FR-10)。
dist/ はバンドル済みでコミット。CI/self-test ワークフロー、ユニットテスト、ドキュメント同梱。

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@yk-lab yk-lab force-pushed the feat/initial-implementation branch from 84267ad to 6e236a6 Compare June 15, 2026 16:03

@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.

3 issues found across 32 files

Tip: cubic can generate docs of your entire codebase and keep them up to date. Try it here.

Re-trigger cubic

Comment thread src/platform.ts
Comment thread src/checksum.ts Outdated
Comment thread .github/workflows/self-test.yml
yk-lab and others added 4 commits June 15, 2026 16:31
対応表に riscv64 があるのに ARCH_MAP が未対応で、riscv64 Linux ランナーの自動判定が throw していた(Codex/cubic 指摘)。回帰テストを追加。

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
checksums URL が HTML エラーページ(レート制限ページ)を返すと、checksum not found で hard fail しリトライされなかった。content-type に html を含む場合は transient エラーとして throw。tests/github.test.ts を新規追加(Codex 指摘3)。

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
errors.ts の設計(checksum 不一致は恒久エラー)に反し素の Error を投げていた。PermanentError に揃え、回帰テストで型を検証(cubic 指摘)。

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
yk-lab and others added 2 commits June 15, 2026 16:58
- github: fetchJson/fetchText の共通プロローグを fetchOk + guardContentType に集約(各セマンティクスは維持)
- errors: errorMessage(err) を新設し download/main のインライン重複を解消
- main: cacheHit を const 化し no-op 再代入を削除
- platform: trim 後に冗長な length>0 を除去
(/simplify 由来・挙動不変)

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

@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.

🧹 Nitpick comments (1)
要求仕様書.md (1)

162-166: 💤 Low value

コード block に言語指定を追加してください。

markdownlint (MD040) の要件に準拠するため、YAML コード block に言語指定を追加してください。

💚 修正案
-```
+```yaml
 runs:
   using: "node24"      # CON-1
   main: "dist/index.js"
-```
+```
🤖 Prompt for 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.

In `@要求仕様書.md` around lines 162 - 166, The YAML code block in the markdown file
does not have a language identifier specified, which violates the markdownlint
MD040 rule. To fix this, add the language identifier "yaml" immediately after
the opening triple backticks of the code block (the line starting with ``` that
precedes the "runs:" line), changing it from ``` to ```yaml to properly declare
the code block language.
🤖 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.

Nitpick comments:
In `@要求仕様書.md`:
- Around line 162-166: The YAML code block in the markdown file does not have a
language identifier specified, which violates the markdownlint MD040 rule. To
fix this, add the language identifier "yaml" immediately after the opening
triple backticks of the code block (the line starting with ``` that precedes the
"runs:" line), changing it from ``` to ```yaml to properly declare the code
block language.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 759993c0-9f99-4e3d-84bc-b4c555f5eaa0

📥 Commits

Reviewing files that changed from the base of the PR and between 9cbcdf2 and 9e33762.

⛔ Files ignored due to path filters (12)
  • .claude/settings.json is excluded by !**/*.json
  • .github/dependabot.yml is excluded by !**/*.yml
  • .github/workflows/ci.yml is excluded by !**/*.yml
  • .github/workflows/self-test.yml is excluded by !**/*.yml
  • action.yml is excluded by !**/*.yml
  • dist/index.js is excluded by !**/dist/**, !dist/**
  • dist/index.js.map is excluded by !**/dist/**, !**/*.map, !dist/**, !**/*.map
  • dist/licenses.txt is excluded by !**/dist/**, !dist/**
  • dist/sourcemap-register.js is excluded by !**/dist/**, !dist/**
  • package-lock.json is excluded by !**/package-lock.json, !**/*.json
  • package.json is excluded by !**/*.json
  • tsconfig.json is excluded by !**/*.json
📒 Files selected for processing (21)
  • .gitignore
  • CLAUDE.md
  • LICENSE
  • README.md
  • TODO.md
  • eslint.config.mjs
  • src/checksum.ts
  • src/constants.ts
  • src/download.ts
  • src/errors.ts
  • src/github.ts
  • src/install.ts
  • src/main.ts
  • src/platform.ts
  • src/version.ts
  • tests/checksum.test.ts
  • tests/github.test.ts
  • tests/platform.test.ts
  • tests/version.test.ts
  • 企画書.md
  • 要求仕様書.md

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