npm package: @seventhlab/sonarqube-cloud
Description: - [Pulumi SonarQube Cloud Provider](#pulumi-sonarqube-cloud-provider)   - [Features](#features)   - [Provider Configuration](#provider-configuration)   - [Quick Start (Local Development)](#quick-start-local-development)     - [1. Install tooling](#1-insta
Latest version: 1.0.1

# Pulumi SonarQube Cloud Provider

- [Pulumi SonarQube Cloud Provider](#pulumi-sonarqube-cloud-provider)
  - [Features](#features)
  - [Provider Configuration](#provider-configuration)
  - [Quick Start (Local Development)](#quick-start-local-development)
    - [1. Install tooling](#1-install-tooling)
    - [2. Build and install SDKs](#2-build-and-install-sdks)
    - [2. Start the mock SonarQube Cloud server](#2-start-the-mock-sonarqube-cloud-server)
    - [3. Export provider environment variables](#3-export-provider-environment-variables)
    - [4. Run an example](#4-run-an-example)
  - [Building SDKs and Provider Locally](#building-sdks-and-provider-locally)
  - [Automated SDK Releases](#automated-sdk-releases)
  - [Development Commands](#development-commands)
  - [Example Resource (YAML)](#example-resource-yaml)
  - [Repository Layout](#repository-layout)
  - [Notes](#notes)

[![Build](https://github.com/seventhlab/pulumi-sonarqube-cloud/actions/workflows/build.yml/badge.svg)](https://github.com/seventhlab/pulumi-sonarqube-cloud/actions/workflows/build.yml)
[![Tests](https://github.com/seventhlab/pulumi-sonarqube-cloud/actions/workflows/tests.yml/badge.svg)](https://github.com/seventhlab/pulumi-sonarqube-cloud/actions/workflows/tests.yml)
[![Lint](https://github.com/seventhlab/pulumi-sonarqube-cloud/actions/workflows/lint.yml/badge.svg)](https://github.com/seventhlab/pulumi-sonarqube-cloud/actions/workflows/lint.yml)

Native Pulumi provider for SonarQube Cloud.

The provider currently exposes a `Project` resource for managing SonarQube Cloud
projects, including optional GitHub repository linking to the SonarQube project.

## Features

- Create, read, update, and delete SonarQube Cloud projects
- Set project visibility (`public` / `private`)
- Optionally link a GitHub repository during project creation via
  `githubRepositoryId`
- Multi-language SDKs: YAML, Go, Node.js, Python, .NET, Java

## Provider Configuration

Provider configuration supports:

- `token` (required): SonarQube Cloud token, or `SONAR_TOKEN`
- `host` (optional): SonarQube/SonarCloud host, or `SONAR_HOST`
  - Defaults to `https://sonarcloud.io`

`organization` is now a required input on the `Project` resource itself (there
is no provider-level default organization setting).

## Quick Start (Local Development)

### 1. Install tooling

This repository uses `mise` to manage the development toolchain. You can setup all requirements with a simple setup pnpm target:

```bash
pnpm setup
```

Or if you don't have pnpm installed in your system you can manually run the setup script:

```bash
./scripts/dev/setup.sh
```

### 2. Build and install SDKs

In order to use the provider in the example projects you have to freshly generate and install locally the provider SDK for at least the language you are going to use:

```bash
pnpm sdks:build && pnpm sdks:install
```

### 2. Start the mock SonarQube Cloud server

```bash
pnpm serve:dev
```

In another terminal, get the generated token:

```bash
curl http://localhost:8080/api/token
```

### 3. Export provider environment variables

```bash
export SONAR_HOST="http://localhost:8080"
export SONAR_TOKEN="<token from /api/token>"
```

### 4. Run an example

Pick any example under `examples/` (Go, Node.js, Python, .NET, Java, YAML).
For example, Node.js:

```bash
cd examples/nodejs
pulumi stack init local
pulumi config set sonarHost "$SONAR_HOST"
pulumi config set --secret sonarToken "$SONAR_TOKEN"
pulumi up
```

## Building SDKs and Provider Locally

Build the provider binary, generate the schema, and build all SDKs:

```bash
pnpm sdks:build
```

Install the locally built plugin and SDK packages into the example projects:

```bash
pnpm sdks:install
```

## Automated SDK Releases

Node.js SDK release is automated with semantic-release in
`.github/workflows/release-sdk.yml`.

- Push to `main` runs the publish flow for the `nodejs` SDK target.
- Manual dispatch supports dry-run validation without publishing.
- semantic-release and required plugins are pinned in root `devDependencies`
  for reproducible runs.

Required repository secrets:

- `NPM_TOKEN`: npm automation token with publish access for
  `@seventhlab/sonarqube-cloud`

Manual dry-run:

1. Open GitHub Actions and run `Release SDKs`.
2. Set `sdk=nodejs`.
3. Set `dry_run=true`.

Local dry-run:

```bash
./scripts/release/run-semantic-release.sh -s nodejs -d
```

Note: local dry-run defaults to a local `file://` repository URL to avoid
network dependency. If you want canonical GitHub links in generated notes, set
`SEMANTIC_RELEASE_REPOSITORY_URL=https://github.com/seventhlab/pulumi-sonarqube-cloud.git`.

When dry-run is executed in CI, the release script also performs live GitHub API
permission probes (using intentionally invalid write requests that should return
`422` when permissions are correct). This catches token permission gaps (for
`contents`, `issues`, and `pull-requests`) before a real publish run.

The workflow is intentionally matrix-based (`matrix.sdk`) and the release runner
script (`scripts/release/run-semantic-release.sh`) is target-aware, so adding
other SDK release targets only requires:

1. Adding new entries to the workflow matrix.
2. Adding a semantic-release config file for that target.
3. Extending the release runner case statement.

## Development Commands

```bash
# Lint all code and config
pnpm lint

# Run unit tests
pnpm test:unit

# Run integration tests (builds SDKs, installs plugin, runs examples)
pnpm test:integration
```

## Example Resource (YAML)

```yaml
resources:
  example:
    type: pulumi:providers:sonarqube-cloud
    properties:
      token: ${sonarToken}
      host: ${sonarHost}

  exampleProject:
    type: sonarqube-cloud:index:Project
    properties:
      name: Example Project
      organization: seventhlab
      projectKey: example-project
      visibility: public
      githubRepositoryId: "123456789" # optional
    options:
      provider: ${example}
```

You can find more examples in all available supported languages in [`examples/`](examples/) folder.

## Repository Layout

- `provider/`: Pulumi provider implementation
- `internal/`: SonarQube API client, config, and domain logic
- `sdk/`: Generated language SDKs
- `examples/`: Example Pulumi programs used for local/manual testing
- `tests/`: Integration tests and mock SonarQube Cloud server
- `scripts/`: Build, install, lint, and formatter scripts

## Notes

- The mock server under `tests/mock-server/` is intended for local development
  and integration testing. It does not implement the full SonarQube Cloud API.
- Generated SDK files are rebuilt by `./scripts/build.sh`.