-
-
Notifications
You must be signed in to change notification settings - Fork 328
build: migrate CI/CD to Nix-based development environment #747
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
bebffd1
151a978
101b7cc
43894d2
c120cba
a49f271
9fea277
f58c8fa
41ac8cd
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| use flake |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| name: Setup Nix | ||
| description: Install Nix and configure Cachix | ||
| inputs: | ||
| cachix-auth-token: | ||
| description: Cachix authentication token | ||
| required: false | ||
| runs: | ||
| using: composite | ||
| steps: | ||
| - name: Install Nix | ||
| uses: cachix/install-nix-action@4e002c8ec80594ecd40e759629461e26c8abed15 # v31.9.0 | ||
| with: | ||
| github_access_token: ${{ github.token }} | ||
|
|
||
| - name: Setup Cachix (numtide) | ||
| uses: cachix/cachix-action@0fc020193b5a1fa3ac4575aa3a7d3aa6a35435ad # v16 | ||
| with: | ||
| name: numtide | ||
| authToken: '' | ||
|
|
||
| - name: Setup Cachix (ryoppippi) | ||
| if: inputs.cachix-auth-token != '' | ||
| uses: cachix/cachix-action@0fc020193b5a1fa3ac4575aa3a7d3aa6a35435ad # v16 | ||
| with: | ||
| name: ryoppippi | ||
| authToken: ${{ inputs.cachix-auth-token }} | ||
|
|
||
| - name: Load Nix development environment | ||
| shell: bash | ||
| run: nix develop --command true |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -34,3 +34,7 @@ report.[0-9]_.[0-9]_.[0-9]_.[0-9]_.json | |
| .DS_Store | ||
|
|
||
| .eslintcache | ||
|
|
||
| # nix | ||
| .direnv | ||
| !.envrc | ||
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,37 @@ | ||||||||||||||||||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||||||||||||||||||
| description = "Usage analysis tool for Claude Code"; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||
| inputs = { | ||||||||||||||||||||||||||||||||||||||||||||||||
| nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable"; | ||||||||||||||||||||||||||||||||||||||||||||||||
| flake-utils.url = "github:numtide/flake-utils"; | ||||||||||||||||||||||||||||||||||||||||||||||||
| }; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||
| outputs = { self, nixpkgs, flake-utils }: | ||||||||||||||||||||||||||||||||||||||||||||||||
| flake-utils.lib.eachDefaultSystem (system: | ||||||||||||||||||||||||||||||||||||||||||||||||
| let | ||||||||||||||||||||||||||||||||||||||||||||||||
| pkgs = nixpkgs.legacyPackages.${system}; | ||||||||||||||||||||||||||||||||||||||||||||||||
| in | ||||||||||||||||||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||||||||||||||||||
| devShells.default = pkgs.mkShell { | ||||||||||||||||||||||||||||||||||||||||||||||||
| buildInputs = with pkgs; [ | ||||||||||||||||||||||||||||||||||||||||||||||||
| # Package manager | ||||||||||||||||||||||||||||||||||||||||||||||||
| pnpm_10 | ||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||
| # Development tools | ||||||||||||||||||||||||||||||||||||||||||||||||
| typos | ||||||||||||||||||||||||||||||||||||||||||||||||
| jq | ||||||||||||||||||||||||||||||||||||||||||||||||
| git | ||||||||||||||||||||||||||||||||||||||||||||||||
| gh | ||||||||||||||||||||||||||||||||||||||||||||||||
| ]; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+16
to
+25
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Critical: Node.js is missing from buildInputs. The flake provides Apply this diff to add Node.js to buildInputs: buildInputs = with pkgs; [
+ # Runtime
+ nodejs_24
+
# Package manager
pnpm_10📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||
| shellHook = '' | ||||||||||||||||||||||||||||||||||||||||||||||||
| # Install dependencies only if node_modules/.pnpm/lock.yaml is older than pnpm-lock.yaml | ||||||||||||||||||||||||||||||||||||||||||||||||
| if [ ! -f node_modules/.pnpm/lock.yaml ] || [ pnpm-lock.yaml -nt node_modules/.pnpm/lock.yaml ]; then | ||||||||||||||||||||||||||||||||||||||||||||||||
| echo "📦 Installing dependencies..." | ||||||||||||||||||||||||||||||||||||||||||||||||
| pnpm install --frozen-lockfile | ||||||||||||||||||||||||||||||||||||||||||||||||
| fi | ||||||||||||||||||||||||||||||||||||||||||||||||
| ''; | ||||||||||||||||||||||||||||||||||||||||||||||||
| }; | ||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||
| ); | ||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
🌐 Web query:
actions/setup-node registry-url NODE_AUTH_TOKEN authentication💡 Result:
Short answer: actions/setup-node writes an .npmrc that reads the auth token from the NODE_AUTH_TOKEN environment variable when you pass registry-url (and optional scope). You must set NODE_AUTH_TOKEN in the workflow’s env (usually from a secret such as NPM_TOKEN or GITHUB_TOKEN). For GitHub Packages you can use GITHUB_TOKEN for packages in the same repo; for other private registries use a personal access token with appropriate scopes. Examples and docs below. [1][2][3]
Example (minimal):
uses: actions/setup-node@v4
with:
node-version: '20.x'
registry-url: 'https://registry.npmjs.org' # or https://npm.pkg.github.com for GPR
run: npm ci
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} # or ${{ secrets.GITHUB_TOKEN }} when allowed
What setup-node creates in .npmrc:
//registry.npmjs.org/:_authToken=${NODE_AUTH_TOKEN}
registry=https://registry.npmjs.org/
always-auth=true
References:
[1] actions/setup-node (GitHub repo/docs).
[2] GitHub Actions docs — Use setup-node + example showing NODE_AUTH_TOKEN usage.
[3] GitHub Packages / npm registry auth guidance (GITHUB_TOKEN vs personal access token).
🌐 Web query:
npm publish OIDC provenance GitHub Actions authentication💡 Result:
Short answer — yes. You can publish npm packages from GitHub Actions using OIDC-based authentication and produce/verifiy provenance. High-level steps and requirements:
Pointers / docs
If you want, I can: (A) generate a ready-to‑use GitHub Actions workflow (with permissions, setup-node, npm publish) for your repo and npm version, or (B) walk through configuring a trusted publisher in the npm web UI — which do you want?
🏁 Script executed:
Repository: ryoppippi/ccusage
Length of output: 1376
🏁 Script executed:
Repository: ryoppippi/ccusage
Length of output: 43
Add explicit NODE_AUTH_TOKEN environment variable for npm publishing.
The workflow configures
setup-nodewithregistry-urlbut does not explicitly setNODE_AUTH_TOKEN. Whilesetup-nodecreates the.npmrcstructure to read authentication from the environment, it requiresNODE_AUTH_TOKENto be explicitly provided in the job'senvblock. AddNODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}(or equivalent) to thenpmjob's environment, or alternatively, ensure the npm version (>=11.5.1) supports OIDC-based trusted publishing and configure it in your npm package settings to publish without storing long-lived tokens.🤖 Prompt for AI Agents