Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .changeset/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Changesets

Hello and welcome! This folder has been automatically generated by `@changesets/cli`, a build tool that works
with multi-package repos, or single-package repos to help you version and publish your code. You can
find the full documentation for it [in our repository](https://github.com/changesets/changesets).

We have a quick list of common questions to get you started engaging with this project in
[our documentation](https://github.com/changesets/changesets/blob/main/docs/common-questions.md).
14 changes: 14 additions & 0 deletions .changeset/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"$schema": "https://unpkg.com/@changesets/config@3.1.3/schema.json",
"changelog": [
"@changesets/changelog-github",
{ "repo": "codacy/codacy-cloud-cli" }
],
"commit": false,
"fixed": [],
"linked": [],
"access": "public",
"baseBranch": "main",
"updateInternalDependencies": "patch",
"ignore": []
}
2 changes: 2 additions & 0 deletions .changeset/fresh-spoons-build.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
---
---
22 changes: 22 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,25 @@ jobs:

- name: Test
run: npm test

changeset-check:
if: github.event_name == 'pull_request'
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
with:
fetch-depth: 0

- name: Check for changesets
run: |
# Count .changeset/*.md files added/modified in this PR compared to the base branch
CHANGESETS=$(git diff --name-only origin/${{ github.base_ref }}...HEAD -- '.changeset/*.md' ':!.changeset/README.md' | wc -l)
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟡 MEDIUM RISK

This PR is missing a changeset file. Based on the logic added in this line, the CI job will fail because no file matching '.changeset/*.md' (excluding README.md) was found in the diff. Please add a changeset using 'npx changeset' or 'npx changeset --empty'.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Already addressed — an empty changeset was added in the second commit (fresh-spoons-build.md). The changeset-check job is now passing.

🤖 Generated by /pr-fixup command

if [ "$CHANGESETS" -eq 0 ]; then
echo "::error::No changeset found for this PR. Run 'npx changeset' to describe your changes."
echo ""
echo "If this PR does not require a version bump (e.g., docs-only or CI changes),"
echo "add an empty changeset with: npx changeset --empty"
exit 1
fi
Comment on lines +50 to +60
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Already addressed — an empty changeset was added in the second commit. The changeset-check CI job is passing.

🤖 Generated by /pr-fixup command

echo "Found $CHANGESETS changeset file(s) changed in this PR."
40 changes: 0 additions & 40 deletions .github/workflows/publish.yml

This file was deleted.

50 changes: 50 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
name: Release

on:
push:
branches: [main]

concurrency:
group: release-${{ github.ref }}
cancel-in-progress: false

permissions:
contents: write
pull-requests: write
id-token: write

jobs:
release:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4

- uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4
with:
node-version: 22
cache: npm
registry-url: "https://registry.npmjs.org"

- name: Install dependencies
run: npm ci

- name: Generate API client
run: npm run update-api

- name: Build
run: npm run build

- name: Test
run: npm test

- name: Create Release PR or Publish
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🔴 HIGH RISK

The release workflow currently publishes the package without running tests. Since ci.yml and release.yml run concurrently on pushes to main, a failing build on main could still result in a successful (but broken) package publication. Add a test step before the release action. Try running the following prompt in your coding agent: > Add a 'Test' step running 'npm test' before the 'Create Release PR or Publish' step in .github/workflows/release.yml.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Good catch — adding a test step before publish in release.yml, and setting NPM_CONFIG_PROVENANCE=true to preserve provenance signing.

🤖 Generated by /pr-fixup command

uses: changesets/action@6a0a831ff30acef54f2c6aa1cbbc1096b066edaf # v1
with:
publish: npm run release
Comment on lines +32 to +44
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Good catch — adding a test step before the changesets action in release.yml.

🤖 Generated by /pr-fixup command

title: "chore: version packages"
commit: "chore: version packages"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Good catch — adding NPM_CONFIG_PROVENANCE=true to the changesets action env to preserve provenance signing.

🤖 Generated by /pr-fixup command

NPM_CONFIG_PROVENANCE: true
30 changes: 30 additions & 0 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@

```
codacy-cloud-cli/
├── .changeset/ # Changesets config and pending changeset files
├── src/
│ ├── index.ts # CLI entry point (Commander.js setup)
│ ├── api/
Expand Down Expand Up @@ -173,6 +174,35 @@
4. Update `SPECS/README.md` (mark tasks done, add changelog entry) when completing work
5. Add new tasks to `SPECS/README.md` pending table when discovered during work

## Versioning & Releasing

This project uses [changesets](https://github.com/changesets/changesets) for versioning and npm publishing.

### How it works

1. Every PR must include a changeset file (CI enforces this via the `changeset-check` job)

Check warning on line 183 in AGENTS.md

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

AGENTS.md#L183

Absolute rule without escape hatch: "1. Every PR must include a changeset file (CI enforces this via the `c"
2. Run `npx changeset` to create one — select the bump type (`patch`, `minor`, `major`) and describe the change
3. For PRs that don't need a version bump (docs, CI, refactors), use `npx changeset --empty`
4. On merge to `main`, the `release.yml` workflow creates a "chore: version packages" PR that bumps the version and updates `CHANGELOG.md`
5. Merging that PR triggers the actual npm publish with provenance

### Agent responsibilities for changesets

When completing work that changes user-facing behavior or adds features, agents **must**:

Check warning on line 191 in AGENTS.md

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

AGENTS.md#L191

Absolute rule without escape hatch: "When completing work that changes user-facing behavior or adds feature"
1. Run `npx changeset` and create an appropriate changeset file before committing
2. Use `patch` for bug fixes, `minor` for new features or commands, `major` for breaking changes
3. Write a clear, user-facing summary in the changeset (this becomes the CHANGELOG entry)

For internal-only changes (refactors, docs, CI, test-only changes), use `npx changeset --empty`.

### Agent responsibilities for self-documenting changes

When completing work, agents **must** update relevant documentation:

Check warning on line 200 in AGENTS.md

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

AGENTS.md#L200

Absolute rule without escape hatch: "When completing work, agents **must** update relevant documentation:"

Check warning on line 200 in AGENTS.md

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

AGENTS.md#L200

Vague conditional: "When completing work, agents **must** update relevant documentation:". Specify exact threshold or trigger.
1. **`SPECS/README.md`** — mark tasks as done in the pending table, add a changelog entry
2. **`README.md`** — if a new command was added or renamed, update the commands summary table (one row per command, no detailed args/options)
3. **`AGENTS.md`** — if a new convention, pattern, or workflow was introduced that affects how agents work, add it to the relevant section
4. **`SPECS/deployment.md`** — if CI/CD or publishing workflows changed, update this spec to match

## Environment Variables

| Variable | Required | Description |
Expand Down
15 changes: 9 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,14 +89,17 @@ npm run update-api # Update the auto-generated API client
### CI/CD

- **CI**: Runs on every push to `main` and on PRs. Builds and tests across Node.js 18, 20, and 22.
- **Publish**: Triggered on GitHub release creation. Builds, tests, and publishes to npm with provenance.
- **Release**: Uses [changesets](https://github.com/changesets/changesets) for automated versioning and npm publishing.

To publish a new version:
1. Update the version in `package.json`
2. Create a GitHub release with a tag matching the version (e.g. `v1.1.0`)
3. The publish workflow will automatically build and push to npm
#### Publishing a new version

**Prerequisite**: Add an `NPM_TOKEN` secret to your GitHub repository settings.
1. When making changes, run `npx changeset` and describe your change (select `patch`, `minor`, or `major`)
2. Include the generated `.changeset/*.md` file in your PR
3. CI enforces that every PR includes a changeset (use `npx changeset --empty` for changes that don't need a version bump, like docs or CI)
4. When PRs are merged to `main`, the release workflow automatically creates a **"chore: version packages"** PR that bumps the version and updates `CHANGELOG.md`
5. Merging that PR publishes to npm with provenance

**Prerequisite**: An `NPM_TOKEN` secret must be configured in the GitHub repository settings.

## License

Expand Down
31 changes: 17 additions & 14 deletions SPECS/deployment.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
# Deployment & CI Spec

**Status:** ✅ Done (2026-02-18)
**Status:** ✅ Done (updated 2026-05-08)

## npm Package

- **Binary name:** `codacy` (registered in `package.json` under `bin`)
- **Included files:** `dist/` and `README.md` (via `files` field)
- **Pre-publish:** `prepublishOnly` runs `npm run build` using `tsconfig.build.json`
- **Engines:** requires Node.js >= 18
- **Pre-publish:** `prepublishOnly` runs `npm run update-api && npm run build` as a safety net for local publishes
- **Engines:** requires Node.js >= 20
- **Install globally:** `npm install -g "@codacy/codacy-cloud-cli"`

## GitHub Actions
Expand All @@ -18,23 +18,26 @@ Triggers on: push and pull requests to `main`.

Matrix: Node.js 18, 20, 22.

Steps:
1. Checkout
2. Setup Node
3. `npm ci`
4. `npm run build`
5. `npm test`
Jobs:
- **build-and-test**: checkout → setup node → install → generate API client → type check → build → test
- **changeset-check** (PRs only): verifies at least one `.changeset/*.md` file is present in the PR diff

### Release (`release.yml`)

### Publish to npm (`publish.yml`)
Triggers on: push to `main`.

Triggers on: GitHub release published.
Uses the [changesets/action](https://github.com/changesets/changesets) to automate versioning and publishing.

Steps:
1. Checkout
2. Setup Node with `registry-url: https://registry.npmjs.org`
3. `npm ci`
4. `npm run build`
5. `npm publish` (uses `NODE_AUTH_TOKEN` secret)
4. Generate API client (`npm run update-api`)
5. Build (`npm run build`)
6. Test (`npm test`)
7. `changesets/action` — either:
- Creates/updates a "chore: version packages" PR (bumps version, updates CHANGELOG.md)
- If that PR was just merged, runs `changeset publish` to publish to npm with provenance

## Homebrew Formula

Expand All @@ -44,5 +47,5 @@ Planned for future distribution as a separate brew formula for macOS/Linux/Windo

| Secret | Used by |
|---|---|
| `NODE_AUTH_TOKEN` | npm publish workflow |
| `NPM_TOKEN` | Release workflow (`NODE_AUTH_TOKEN` for npm publish) |
| `CODACY_API_TOKEN` | CLI runtime (env var, not a secret in CI) |
Loading
Loading