Compare commits

...
36 Commits
Author SHA1 Message Date
james.maes 5196609974 Merge pull request #16 from QRun-IO/develop
release: publish npm Trusted Publishing support in orb 0.6.7
2026-09-29 14:18:44 -05:00
james.maes 988401023a Merge pull request #15 from QRun-IO/feature/GH-912-npm-trusted-publishing
fix(ci): support CircleCI npm Trusted Publishing
2026-09-29 14:17:01 -05:00
james.maes e23bd4588d test(ci): preserve stdin for npm subprocesses (#912) 2026-09-29 14:14:32 -05:00
james.maes 51e9bba5b0 fix(ci): support tokenless npm publishing (#912)
Refs QRun-IO/qqq#912. Use CircleCI OIDC with isolated npm configuration and retain legacy authentication by default.
2026-09-29 14:09:04 -05:00
james.maes 49e09a6776 Merge pull request #14 from QRun-IO/develop
release: publish orb log-safety fix as 0.6.6
2026-09-29 13:38:22 -05:00
james.maes dae3f4b677 fix: keep Maven settings out of orb logs (#13)
* fix: keep Maven settings out of orb logs (#12)

* test: enforce Maven log-safety guard in CI (#12)

Run the reviewed output regression before publishing and capture both output streams. Refs QRun-IO/qqq#903.
2026-09-29 13:23:43 -05:00
James MaesandClaude Opus 4.8 20d324957d docs: add CLAUDE.md pointer to QQQ knowledge-base dossier + hub
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-12 05:31:59 -05:00
james.maesandClaude Opus 4.7 bdff16ff95 chore: add CODEOWNERS pointing to sole maintainer
Architecture audit pass 2026-05-21. Minimal CODEOWNERS file
making the implicit ownership explicit.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-21 17:13:51 -05:00
james.maes 748016f105 Merge pull request #10 from QRun-IO/develop
[minor] feat: add node_app_* job family
2026-02-27 12:59:51 -06:00
james.maesandClaude Sonnet 4.6 dbd158e5eb fix(node-app): handle corepack permission error on cimg/node
cimg/node images have pnpm pre-installed; corepack enable fails with
EACCES when trying to replace /usr/local/bin/pnpm (owned by root).
Skip corepack entirely when the package manager is already available.
Fall back to sudo corepack enable or user-local --install-directory
only when the tool is genuinely missing.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-02-27 12:34:41 -06:00
james.maesandClaude Sonnet 4.6 1297ba10f0 fix(node-app): fix helper sourcing and cache key bugs
- Add fallback stubs to all node_app_*.sh scripts — qqq_helpers.sh
  is not present on disk in a packed orb, so the source silently fails
  and banner/require_tool are undefined (exit 127)
- Fix node_app_install cache keys to use per-pkg_manager conditionals —
  checksumming all three lockfiles simultaneously fails hard when the
  non-primary lockfiles (package-lock.json, yarn.lock) don't exist

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-02-27 12:31:35 -06:00
james.maes 62ae2f7d29 Merge pull request #9 from QRun-IO/feature/node-app-jobs
feat: add node_app_* job family for deployed Node.js apps
2026-02-27 12:07:31 -06:00
james.maesandClaude Opus 4.6 99fa73a581 feat: add node_app_* job family for deployed Node.js applications
Add new job family for pnpm/npm/yarn-based Node.js applications that
need CI for build/test/e2e but do NOT publish to npm (e.g., Next.js apps).

New files:
- qqq_helpers.sh: shared helper functions (banner, require_tool, source guard)
- node_app_install.sh/yml: dependency install with corepack + cache
- node_app_test.sh/yml: type-check + lint + unit tests
- node_app_build.sh/yml: production build with timing
- node_app_e2e.sh/yml: Playwright browser install + e2e tests

Jobs:
- node_app_test_only: checkout + install + test (feature branches)
- node_app_build: checkout + install + test + build + persist workspace
- node_app_e2e: attach workspace + Playwright e2e tests

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-27 12:05:30 -06:00
james.maes 6514aaa688 Merge pull request #8 from QRun-IO/develop
fix(ci): remove legacy tag-based publish workflow
2026-01-31 18:46:54 -06:00
james.maes c561e4d290 fix(ci): remove legacy tag-based publish workflow 2026-01-31 18:43:52 -06:00
james.maes 3ac47adc21 Merge pull request #7 from QRun-IO/develop
Release: auto-publish pipelines and security scanning
2026-01-31 18:40:34 -06:00
james.maes 8d7f645c0e fix(ci): pass CIRCLE_TOKEN to orb publish commands 2026-01-31 18:34:39 -06:00
james.maes 9285f2d842 fix(ci): use circleci-cli image for orb publish jobs 2026-01-31 18:33:07 -06:00
james.maes f4e1536d77 Merge pull request #6 from QRun-IO/feature/security-scan-job
ci: auto-publish orb on develop and main pushes
2026-01-31 18:04:35 -06:00
james.maes 8d1b353fe2 docs: update readme and changelog for auto-publish and security scan 2026-01-31 18:01:53 -06:00
james.maes d24b7d131f ci: auto-publish orb on develop and main pushes
develop pushes publish dev:snapshot, main pushes auto-increment
patch version with [minor]/[major] commit keyword support.
2026-01-31 17:55:05 -06:00
james.maes 184b7c54e9 feat(security): add security_scan job with Gitleaks, Semgrep, OWASP, and CycloneDX
Adds a new security_scan job with four tools (all report-only by default),
configurable fail gates, and aggregated artifact collection.
2026-01-31 10:34:16 -06:00
james.maes 2471f5adff docs: update changelog and readme for v0.6.2 2026-01-30 11:14:20 -06:00
james.maes 546bf38a0b Merge branch 'develop' 2026-01-30 11:11:22 -06:00
james.maes ab841b2ddd fix(node): handle empty CIRCLE_BRANCH in version commit
Aligned node_version_commit.sh with Maven equivalent: added feature
branch skip, empty branch fallback, and non-fatal push handling.
2026-01-30 11:10:57 -06:00
james.maes 3b3d80188d docs: update changelog and readme for v0.6.1 2026-01-21 12:17:16 -06:00
james.maes 5271b5bfa5 Merge branch 'develop' 2026-01-18 08:39:43 -06:00
james.maes d3e1891725 fix: skip version commit for feature branches 2026-01-18 08:12:52 -06:00
james.maes 0eab936d85 fix(static_analysis): use mvn install for multi-module dependency resolution
Static analysis needs artifacts in local repo for inter-module deps.
2026-01-14 13:58:26 -06:00
james.maes 04888150fd build: cleaned up linting errors 2026-01-14 13:58:26 -06:00
james.maes 43fcfe1213 feat(orb): added spotbugs and pmd workflows 2026-01-14 13:58:26 -06:00
james.maes fec302d58d fix(static_analysis): use mvn install for multi-module dependency resolution
Static analysis needs artifacts in local repo for inter-module deps.
2026-01-14 13:47:34 -06:00
james.maes dabfcce4ad build: cleaned up linting errors 2026-01-14 13:30:15 -06:00
james.maes 3ffe371af2 feat(orb): added spotbugs and pmd workflows 2026-01-14 13:27:07 -06:00
james.maes 34688a1a53 Merge branch 'develop' 2026-01-10 20:43:05 -06:00
james.maes 6d181f361b fix: npm prerelease tags and skip GitHub release for RCs 2026-01-10 20:41:49 -06:00
51 changed files with 1863 additions and 53 deletions

No files matched your search

+81 -18
View File
@@ -12,23 +12,89 @@ filters: &filters
tags:
only: /.*/
# Filter for release tags.
release-filters: &release-filters
# Auto-publish filters.
develop-filters: &develop-filters
branches:
ignore: /.*/
tags:
only: /^v[0-9]+\.[0-9]+\.[0-9]+$/
only: [develop]
main-filters: &main-filters
branches:
only: [main]
jobs:
# Create jobs to test the commands of your orbs.
# You may want to add additional validation steps to ensure the commands are working as expected.
command-test:
docker:
- image: cimg/base:current
- image: cimg/node:24.21
steps:
- checkout
- run:
name: Verify Maven settings stay out of build logs
command: bash tests/test_maven_settings_output.sh
- run:
name: Verify npm publisher authentication and dist-tags
command: python3 tests/test_node_npm_publish.py
# Run your orb's commands to validate them.
- qqq-orb/install_asciidoctor
publish-dev-snapshot:
docker:
- image: circleci/circleci-cli:latest
steps:
- checkout
- run:
name: Pack and Publish Dev Snapshot
command: |
circleci orb pack src > /tmp/orb.yml
circleci orb validate /tmp/orb.yml
circleci orb publish --token "${CIRCLE_TOKEN}" /tmp/orb.yml kingsrook/qqq-orb@dev:snapshot
echo "Published kingsrook/qqq-orb@dev:snapshot"
publish-production:
docker:
- image: circleci/circleci-cli:latest
steps:
- checkout
- add_ssh_keys
- run:
name: Calculate Next Version and Publish
command: |
git fetch --tags
LATEST=$(git tag -l 'v*' | sort -V | tail -1)
LATEST=${LATEST:-v0.0.0}
LATEST_CLEAN=${LATEST#v}
# Check recent commit messages for bump keywords
BUMP="patch"
COMMITS=$(git log "${LATEST}..HEAD" --pretty=%s 2>/dev/null || git log --pretty=%s -10)
if echo "${COMMITS}" | grep -qi '\[major\]'; then
BUMP="major"
elif echo "${COMMITS}" | grep -qi '\[minor\]'; then
BUMP="minor"
fi
IFS='.' read -r MAJOR MINOR PATCH \<<< "${LATEST_CLEAN}"
case "${BUMP}" in
major) MAJOR=$((MAJOR + 1)); MINOR=0; PATCH=0 ;;
minor) MINOR=$((MINOR + 1)); PATCH=0 ;;
patch) PATCH=$((PATCH + 1)) ;;
esac
VERSION="${MAJOR}.${MINOR}.${PATCH}"
echo "Latest: ${LATEST} | Bump: ${BUMP} | Next: ${VERSION}"
circleci orb pack src > /tmp/orb.yml
circleci orb validate /tmp/orb.yml
circleci orb publish --token "${CIRCLE_TOKEN}" /tmp/orb.yml "kingsrook/qqq-orb@${VERSION}"
git config user.email "ci@qrun.io"
git config user.name "CircleCI"
git tag -a "v${VERSION}" -m "Release v${VERSION}"
git push origin "v${VERSION}"
echo "Published kingsrook/qqq-orb@${VERSION}"
workflows:
test-deploy:
jobs:
@@ -36,16 +102,13 @@ workflows:
# Test your orb's commands in a custom job and test your orb's jobs directly as a part of this workflow.
- command-test:
filters: *filters
# The orb must be re-packed for publishing, and saved to the workspace.
- orb-tools/pack:
filters: *release-filters
- orb-tools/publish:
orb_name: kingsrook/qqq-orb
vcs_type: << pipeline.project.type >>
pub_type: production
# Ensure this job requires all test jobs and the pack job.
requires:
- orb-tools/pack
- command-test
# Auto-publish dev snapshot on develop
- publish-dev-snapshot:
context: orb-publishing
filters: *release-filters
filters: *develop-filters
requires: [command-test]
# Auto-publish production release on main
- publish-production:
context: orb-publishing
filters: *main-filters
requires: [command-test]
+1
View File
@@ -0,0 +1 @@
* @KofTwentyTwo
+39 -2
View File
@@ -5,12 +5,49 @@ All notable changes to QQQ Orb will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## [Unreleased]
### Added
- Auto-publish `dev:snapshot` on develop branch pushes
- Auto-publish production releases on main branch pushes with semantic version bumping
- Support for `[major]` and `[minor]` commit keywords to control version bumps (default: patch)
- Security scanning job with Gitleaks, Semgrep, OWASP Dependency Check, and CycloneDX SBOM
## [0.6.2] - 2026-01-30
### Fixed
- Node.js version commit fails with `invalid refspec 'HEAD:'` when `CIRCLE_BRANCH` is empty (detached HEAD builds)
- Aligned `node_version_commit.sh` with Maven equivalent: added feature branch skip, empty branch fallback, and non-fatal push handling
## [0.6.1] - 2026-01-18
### Fixed
- Skip version commit for feature branches (prevents unnecessary commits)
## [0.6.0] - 2026-01-14
### Added
- SpotBugs and PMD static analysis workflows
### Fixed
- Use `mvn install` for multi-module dependency resolution in static analysis
## [0.5.3] - 2026-01-10
### Fixed
- NPM prerelease tags now correctly formatted
- Skip GitHub release creation for release candidates
## [0.5.2] - 2026-01-09
### Fixed
- Version commit push failures no longer fail the build (moved from 0.5.1 notes)
- Strip `<rerunFailure>` elements from JUnit XML (moved from 0.5.1 notes)
## [0.5.1] - 2026-01-07
### Fixed
- Added `DEBIAN_FRONTEND=noninteractive` to browser dependency installation to prevent interactive prompts from blocking CI
- Strip `<rerunFailure>` elements from JUnit XML before upload to fix CircleCI test result parsing errors
- Version commit push failures no longer fail the build (handles race conditions between concurrent builds)
## [0.5.0] - 2025-12-28
+12
View File
@@ -80,3 +80,15 @@ The orb uses CircleCI's "unpacked" format. YAML files in `src/` are packed into
- `MAVEN_USERNAME`, `MAVEN_PASSWORD` - Sonatype credentials
- `GPG_PRIVATE_KEY_B64`, `GPG_KEYNAME`, `GPG_PASSPHRASE` - GPG signing
- `GITHUB_TOKEN` - GitHub API access
## Knowledge base
Deep-review dossiers for this repo and the wider QQQ platform live in the second-brain
vault (Obsidian, `R:/Git.Local/KofTwentyTwo/second-brain`):
- Platform hub: `knowledge/qqq/qqq-hub.md`
- This repo's dossier: `knowledge/qqq/repos/qqq-orb.md` (reviewed at develop
commit `bdff16ff9582`, 2026-07-04) — covers 0.5.0→0.6.0→HEAD behavior changes,
the npm dist-tag defect verdict, org-wide pin survey, licensing history, and
open bug #5 (release-branch patch loss).
- Release/versioning architecture: `knowledge/qqq/architecture/build-release-versioning.md`
+31 -8
View File
@@ -3,7 +3,7 @@
CircleCI orb for QQQ framework projects.
**For:** Teams using CircleCI to build, test, and publish QQQ applications
**Status:** Stable (v0.5.0)
**Status:** Stable (v0.6.x)
## Why This Exists
@@ -29,7 +29,7 @@ This orb provides pre-built jobs for the complete QQQ development lifecycle. Add
# .circleci/config.yml
version: 2.1
orbs:
qqq-orb: kingsrook/qqq-orb@0.5
qqq-orb: kingsrook/qqq-orb@0.6
workflows:
build_and_test:
@@ -57,6 +57,22 @@ workflows:
| `mvn_frontend_publish` | Build, test, and publish Maven projects with npm frontend |
| `node_test_only` | Build and test Node.js projects |
| `node_publish` | Build, test, and publish Node.js packages |
| `static_analysis` | Run SpotBugs and PMD static analysis |
| `security_scan` | Run Gitleaks, Semgrep, OWASP Dependency Check, and CycloneDX SBOM |
### npm Trusted Publishing
For npm Trusted Publishing, set `npm_trusted_publishing: true` and use a supported
executor such as `node_version: "24.21"` on `node_publish`. Configure the package's
[npm Trusted Publisher](https://docs.npmjs.com/trusted-publishers/) for the exact
CircleCI organization, project, pipeline definition and VCS origin, and allow
direct `npm publish`. The job requires Node >=22.14.0 and npm >=11.5.1, obtains an
OIDC identity at publish time, and does not run `npm whoami` or need `NPM_TOKEN`.
Existing token authentication remains the default. Trusted mode requires no
project `.npmrc` or npm credential/config-path environment settings; it ignores user/global
npm config and clears conventional token variables to prevent token fallback.
CircleCI does not currently provide npm provenance attestations. A successful
real publication, not a dry run, verifies the trust relationship.
### Branch Types
@@ -93,16 +109,23 @@ Maven jobs use machine executors with Docker pre-installed. Tests using Testcont
| `GPG_PASSPHRASE` | GPG passphrase |
| `GITHUB_TOKEN` | GitHub API token |
## Orb Publishing
The orb auto-publishes via CircleCI:
| Branch | Action |
|--------|--------|
| `develop` | Publishes `kingsrook/qqq-orb@dev:snapshot` |
| `main` | Auto-increments version and publishes production release |
| `vX.Y.Z` tag | Manual production release (legacy) |
Version bumps on main default to patch. Include `[minor]` or `[major]` in a commit message to bump accordingly.
## Project Status
**Maturity:** Stable, used across all QQQ repositories
**Breaking changes:** See [CHANGELOG.md](CHANGELOG.md)
**Roadmap:**
- GitHub Actions support
- Parallel test execution
- Container image publishing
## Contributing
```bash
@@ -115,4 +138,4 @@ See [QQQ Contribution Guidelines](https://github.com/Kingsrook/qqq/blob/develop/
## License
AGPL-3.0 - QRun-IO
Apache-2.0
@@ -0,0 +1,9 @@
description: >
Collects all security scan reports into a central location for artifact
storage. Generates a summary.txt with finding counts from each tool.
steps:
- run:
name: Collect Security Reports
command: <<include(scripts/collect_security_reports.sh)>>
when: always
@@ -0,0 +1,9 @@
description: >
Collects SpotBugs and PMD reports from all modules into a central
location for artifact storage. Generates a summary report.
steps:
- run:
name: Collect Static Analysis Reports
command: <<include(scripts/collect_static_analysis_reports.sh)>>
when: always
+10 -1
View File
@@ -2,7 +2,14 @@ description: >
Git operations for version management
- Adds SSH keys for Git operations
- Sets up Git identity for version commits
- Commits version changes if modified
- Commits version changes if modified (skipped for feature branches)
parameters:
branch_type:
type: string
default: "snapshot"
description: "Branch type: snapshot, release_candidate, release, hotfix, or feature"
steps:
- add_ssh_keys # injects the CircleCI User Key (write-capable)
- run:
@@ -10,4 +17,6 @@ steps:
command: <<include(scripts/manage_version_git_config.sh)>>
- run:
name: Commit version change if modified
environment:
BRANCH_TYPE: << parameters.branch_type >>
command: <<include(scripts/manage_version_commit.sh)>>
+17
View File
@@ -0,0 +1,17 @@
description: >
Runs PMD static analysis on Maven project.
Detects code quality issues, potential bugs, and style violations.
Requires maven-pmd-plugin configured in project pom.xml.
parameters:
fail_on_violation:
type: boolean
default: false
description: "Fail the build if PMD finds violations"
steps:
- run:
name: Run PMD Analysis
environment:
PMD_FAIL_ON_VIOLATION: << parameters.fail_on_violation >>
command: <<include(scripts/mvn_pmd.sh)>>
+18
View File
@@ -0,0 +1,18 @@
description: >
Runs SpotBugs static analysis on Maven project.
Reports potential bugs including null pointer issues, resource leaks,
and security vulnerabilities (via FindSecBugs plugin).
Requires spotbugs-maven-plugin configured in project pom.xml.
parameters:
fail_on_error:
type: boolean
default: false
description: "Fail the build if SpotBugs finds bugs"
steps:
- run:
name: Run SpotBugs Analysis
environment:
SPOTBUGS_FAIL_ON_ERROR: << parameters.fail_on_error >>
command: <<include(scripts/mvn_spotbugs.sh)>>
+21
View File
@@ -0,0 +1,21 @@
description: >
Runs the production build for a Node.js application
- Executes the build script with timing output
parameters:
pkg_manager:
type: string
default: "pnpm"
description: "Package manager to use (e.g., 'pnpm', 'npm', 'yarn')."
build_script:
type: string
default: "build"
description: "Name of the build script in package.json."
steps:
- run:
name: "Production build"
environment:
NODE_PKG_MANAGER: << parameters.pkg_manager >>
BUILD_SCRIPT: << parameters.build_script >>
command: <<include(scripts/node_app_build.sh)>>
+31
View File
@@ -0,0 +1,31 @@
description: >
Runs Playwright end-to-end tests for a Node.js application
- Installs Playwright browsers
- Runs e2e test suite producing JUnit output
- Stores test results and Playwright traces as artifacts
parameters:
pkg_manager:
type: string
default: "pnpm"
description: "Package manager to use (e.g., 'pnpm', 'npm', 'yarn')."
e2e_script:
type: string
default: "test:e2e"
description: "Name of the e2e test script in package.json."
steps:
- run:
name: "Run Playwright e2e tests"
environment:
NODE_PKG_MANAGER: << parameters.pkg_manager >>
E2E_SCRIPT: << parameters.e2e_script >>
command: <<include(scripts/node_app_e2e.sh)>>
- store_test_results:
path: test-results/e2e
- store_artifacts:
path: test-results/e2e
destination: e2e-results
- store_artifacts:
path: playwright-report
destination: playwright-report
+72
View File
@@ -0,0 +1,72 @@
description: >
Installs dependencies for a Node.js application
- Restores dependency cache
- Runs install via configured package manager (pnpm, npm, yarn)
- Saves dependency cache
parameters:
pkg_manager:
type: string
default: "pnpm"
description: "Package manager to use (e.g., 'pnpm', 'npm', 'yarn')."
steps:
# Restore cache using only the lockfile for the configured pkg manager.
# All three lockfiles cannot be checksummed simultaneously — CircleCI
# fails hard if any referenced file doesn't exist.
- when:
condition:
equal: [ pnpm, << parameters.pkg_manager >> ]
steps:
- restore_cache:
keys:
- node-app-v1-pnpm-{{ checksum "pnpm-lock.yaml" }}
- node-app-v1-pnpm-
- when:
condition:
equal: [ npm, << parameters.pkg_manager >> ]
steps:
- restore_cache:
keys:
- node-app-v1-npm-{{ checksum "package-lock.json" }}
- node-app-v1-npm-
- when:
condition:
equal: [ yarn, << parameters.pkg_manager >> ]
steps:
- restore_cache:
keys:
- node-app-v1-yarn-{{ checksum "yarn.lock" }}
- node-app-v1-yarn-
- run:
name: "Install dependencies"
environment:
NODE_PKG_MANAGER: << parameters.pkg_manager >>
command: <<include(scripts/node_app_install.sh)>>
- when:
condition:
equal: [ pnpm, << parameters.pkg_manager >> ]
steps:
- save_cache:
key: node-app-v1-pnpm-{{ checksum "pnpm-lock.yaml" }}
paths:
- node_modules
- ~/.cache/pnpm
- when:
condition:
equal: [ npm, << parameters.pkg_manager >> ]
steps:
- save_cache:
key: node-app-v1-npm-{{ checksum "package-lock.json" }}
paths:
- node_modules
- ~/.npm
- when:
condition:
equal: [ yarn, << parameters.pkg_manager >> ]
steps:
- save_cache:
key: node-app-v1-yarn-{{ checksum "yarn.lock" }}
paths:
- node_modules
- ~/.cache/yarn
+37
View File
@@ -0,0 +1,37 @@
description: >
Runs type-check, lint, and unit tests for a Node.js application
- Runs type checking, linting, and tests via package.json scripts
- Stores test results as artifacts
parameters:
pkg_manager:
type: string
default: "pnpm"
description: "Package manager to use (e.g., 'pnpm', 'npm', 'yarn')."
typecheck_script:
type: string
default: "typecheck"
description: "Name of the typecheck script in package.json."
lint_script:
type: string
default: "lint"
description: "Name of the lint script in package.json."
test_script:
type: string
default: "test"
description: "Name of the test script in package.json."
steps:
- run:
name: "Run type-check, lint, and tests"
environment:
NODE_PKG_MANAGER: << parameters.pkg_manager >>
TYPECHECK_SCRIPT: << parameters.typecheck_script >>
LINT_SCRIPT: << parameters.lint_script >>
TEST_SCRIPT: << parameters.test_script >>
command: <<include(scripts/node_app_test.sh)>>
- store_test_results:
path: test-results
- store_artifacts:
path: test-results
destination: test-results
+9 -1
View File
@@ -3,7 +3,13 @@ description: >
- Adds SSH keys for Git operations
- Sets up Git identity for version commits
- Synchronizes NPM version
- Commits version changes if modified
- Commits version changes if modified (skipped for feature branches)
parameters:
branch_type:
type: string
default: "snapshot"
description: "Branch type: snapshot, release_candidate, release, hotfix, or feature"
steps:
- add_ssh_keys # injects the CircleCI User Key (write-capable)
@@ -15,4 +21,6 @@ steps:
command: <<include(scripts/sync-npm-version.sh)>>
- run:
name: Commit version changes if modified
environment:
BRANCH_TYPE: << parameters.branch_type >>
command: <<include(scripts/node_version_commit.sh)>>
+15 -4
View File
@@ -3,10 +3,21 @@ description: >
- Sets up NPM authentication
- Publishes the package to NPM
parameters:
trusted_publishing:
type: boolean
default: false
description: "Authenticate npm publish using the CircleCI job's OIDC identity."
steps:
- run:
name: "Setup NPM authentication"
command: <<include(scripts/node_npm_auth.sh)>>
- unless:
condition: << parameters.trusted_publishing >>
steps:
- run:
name: "Setup NPM authentication"
command: <<include(scripts/node_npm_auth.sh)>>
- run:
name: "Publish to NPM"
command: npm publish --access public
environment:
QQQ_NPM_TRUSTED_PUBLISHING: << parameters.trusted_publishing >>
command: <<include(scripts/node_npm_publish.sh)>>
+9
View File
@@ -0,0 +1,9 @@
description: >
Generates a CycloneDX Software Bill of Materials (SBOM) in JSON format.
Uses the CycloneDX Maven plugin to produce an aggregate BOM across all
modules. No pom.xml changes required -- runs as a CLI Maven goal.
steps:
- run:
name: Generate CycloneDX SBOM
command: <<include(scripts/run_cyclonedx_sbom.sh)>>
+17
View File
@@ -0,0 +1,17 @@
description: >
Runs Gitleaks secret detection scan on the repository.
Detects hardcoded secrets, API keys, passwords, and tokens in source code
and git history. Reports findings in JSON format.
parameters:
fail_on_findings:
type: boolean
default: false
description: "Fail the build if Gitleaks detects secrets"
steps:
- run:
name: Run Gitleaks Secret Detection
environment:
GITLEAKS_FAIL_ON_FINDINGS: << parameters.fail_on_findings >>
command: <<include(scripts/run_gitleaks.sh)>>
@@ -0,0 +1,32 @@
description: >
Runs OWASP Dependency-Check to scan project dependencies for known CVEs.
Uses the dependency-check-maven plugin as a CLI goal (no pom.xml changes needed).
Includes retry logic (3 attempts) for NVD database download reliability.
Supports NVD API key for faster database updates via NVD_API_KEY env var.
parameters:
fail_on_cvss:
type: boolean
default: false
description: "Fail the build if vulnerabilities exceed the CVSS threshold"
cvss_threshold:
type: string
default: "7"
description: "CVSS score threshold (0-10). Vulnerabilities at or above this score are flagged."
steps:
- restore_cache:
keys:
- v1-owasp-nvd-cache-{{ .Branch }}
- v1-owasp-nvd-cache-
- run:
name: Run OWASP Dependency-Check
environment:
OWASP_FAIL_ON_CVSS: << parameters.fail_on_cvss >>
OWASP_CVSS_THRESHOLD: << parameters.cvss_threshold >>
command: <<include(scripts/run_owasp_dependency_check.sh)>>
no_output_timeout: 30m
- save_cache:
paths:
- ~/.m2/repository/org/owasp
key: v1-owasp-nvd-cache-{{ .Branch }}-{{ epoch }}
+22
View File
@@ -0,0 +1,22 @@
description: >
Runs Semgrep SAST (Static Application Security Testing) analysis.
Scans source code for security vulnerabilities, code quality issues,
and OWASP Top 10 patterns. Produces JSON and SARIF reports.
parameters:
fail_on_findings:
type: boolean
default: false
description: "Fail the build if Semgrep finds security issues"
rulesets:
type: string
default: "p/java p/owasp-top-ten p/security-audit"
description: "Space-separated list of Semgrep rulesets to run"
steps:
- run:
name: Run Semgrep SAST Analysis
environment:
SEMGREP_FAIL_ON_FINDINGS: << parameters.fail_on_findings >>
SEMGREP_RULESETS: << parameters.rulesets >>
command: <<include(scripts/run_semgrep.sh)>>
+10 -1
View File
@@ -1,6 +1,7 @@
description: >
Complete CI/CD workflow example for Maven-based projects using GitFlow branching strategy.
This example demonstrates how to use the qqq-orb for automated building, testing, and releasing.
This example demonstrates how to use the qqq-orb for automated building, testing, releasing,
and security scanning.
usage:
version: 2.1
@@ -72,3 +73,11 @@ usage:
branches:
only:
- /hotfix\/.*/
security_scan:
jobs:
- qqq-orb/security_scan:
context: [ qqq-maven-registry-credentials, qqq-security-credentials ]
filters:
branches:
only: [ develop ]
+4 -3
View File
@@ -1,7 +1,7 @@
description: >
Unified publishing job for all branch types with frontend
Handles version management, building, testing, and publishing based on branch type
Supports: snapshot, release_candidate, release, and hotfix workflows
Supports: snapshot, release_candidate, release, hotfix, and feature workflows
executor: java
@@ -17,7 +17,7 @@ parameters:
branch_type:
type: string
default: "snapshot"
description: "Branch type: snapshot, release_candidate, release, or hotfix"
description: "Branch type: snapshot, release_candidate, release, hotfix, or feature"
steps:
- install_java:
@@ -30,4 +30,5 @@ steps:
- frontend_test
- frontend_package
- mvn_jar_deploy
- git_operations
- git_operations:
branch_type: << parameters.branch_type >>
+4 -2
View File
@@ -50,18 +50,20 @@ steps:
not:
equal: [ "<< parameters.branch_type >>", "feature" ]
steps:
- git_operations
- git_operations:
branch_type: << parameters.branch_type >>
- when:
condition: << parameters.publish_asciidoc >>
steps:
- publish_asciidoc
# GitHub releases only for final releases and hotfixes (not RCs)
# RCs just publish artifacts - GitHub release happens when merged to main
- when:
condition:
or:
- equal: [ "<< parameters.branch_type >>", "release" ]
- equal: [ "<< parameters.branch_type >>", "release_candidate" ]
- equal: [ "<< parameters.branch_type >>", "hotfix" ]
steps:
- publish_github_release:
+53
View File
@@ -0,0 +1,53 @@
description: >
Build job for Node.js applications on protected branches
Runs checkout, install, test, and production build
Persists build output to workspace for downstream jobs (e.g., e2e)
executor:
name: default
tag: << parameters.node_version >>
parameters:
node_version:
type: string
default: "lts"
description: "Node.js version tag (e.g., 'lts', '18.0', '20.0')."
pkg_manager:
type: string
default: "pnpm"
description: "Package manager to use (e.g., 'pnpm', 'npm', 'yarn')."
typecheck_script:
type: string
default: "typecheck"
description: "Name of the typecheck script in package.json."
lint_script:
type: string
default: "lint"
description: "Name of the lint script in package.json."
test_script:
type: string
default: "test"
description: "Name of the test script in package.json."
build_script:
type: string
default: "build"
description: "Name of the build script in package.json."
steps:
- checkout
- node_app_install:
pkg_manager: << parameters.pkg_manager >>
- node_app_test:
pkg_manager: << parameters.pkg_manager >>
typecheck_script: << parameters.typecheck_script >>
lint_script: << parameters.lint_script >>
test_script: << parameters.test_script >>
- node_app_build_step:
pkg_manager: << parameters.pkg_manager >>
build_script: << parameters.build_script >>
- persist_to_workspace:
root: .
paths:
- .next/
- node_modules/
- package.json
+29
View File
@@ -0,0 +1,29 @@
description: >
End-to-end test job for Node.js applications using Playwright
Attaches workspace from a prior build job and runs e2e tests
Stores JUnit results and Playwright traces as artifacts
executor:
name: default
tag: << parameters.node_version >>
parameters:
node_version:
type: string
default: "lts"
description: "Node.js version tag (e.g., 'lts', '18.0', '20.0')."
pkg_manager:
type: string
default: "pnpm"
description: "Package manager to use (e.g., 'pnpm', 'npm', 'yarn')."
e2e_script:
type: string
default: "test:e2e"
description: "Name of the e2e test script in package.json."
steps:
- attach_workspace:
at: .
- node_app_e2e:
pkg_manager: << parameters.pkg_manager >>
e2e_script: << parameters.e2e_script >>
+40
View File
@@ -0,0 +1,40 @@
description: >
Test-only job for Node.js application feature branches
Runs checkout, dependency install, and test suite
Supports: pnpm, npm, and yarn package managers
executor:
name: default
tag: << parameters.node_version >>
parameters:
node_version:
type: string
default: "lts"
description: "Node.js version tag (e.g., 'lts', '18.0', '20.0')."
pkg_manager:
type: string
default: "pnpm"
description: "Package manager to use (e.g., 'pnpm', 'npm', 'yarn')."
typecheck_script:
type: string
default: "typecheck"
description: "Name of the typecheck script in package.json."
lint_script:
type: string
default: "lint"
description: "Name of the lint script in package.json."
test_script:
type: string
default: "test"
description: "Name of the test script in package.json."
steps:
- checkout
- node_app_install:
pkg_manager: << parameters.pkg_manager >>
- node_app_test:
pkg_manager: << parameters.pkg_manager >>
typecheck_script: << parameters.typecheck_script >>
lint_script: << parameters.lint_script >>
test_script: << parameters.test_script >>
+10 -3
View File
@@ -16,22 +16,29 @@ parameters:
type: string
default: "snapshot"
description: "Branch type: snapshot, release_candidate, release, or hotfix"
npm_trusted_publishing:
type: boolean
default: false
description: "Use CircleCI OIDC instead of NPM_TOKEN (Node >=22.14, npm >=11.5.1)."
steps:
- git_full_checkout
- node_install_dependencies
- node_run_tests
- node_manage_version
- node_manage_version:
branch_type: << parameters.branch_type >>
- attach_workspace:
at: .
- node_build_package
- node_publish
- node_publish:
trusted_publishing: << parameters.npm_trusted_publishing >>
# GitHub releases only for final releases and hotfixes (not RCs)
# RCs just publish artifacts - GitHub release happens when merged to main
- when:
condition:
or:
- equal: [ "<< parameters.branch_type >>", "release" ]
- equal: [ "<< parameters.branch_type >>", "release_candidate" ]
- equal: [ "<< parameters.branch_type >>", "hotfix" ]
steps:
- publish_github_release:
+101
View File
@@ -0,0 +1,101 @@
description: >
Runs security scanning tools on a Maven project: Gitleaks (secret detection),
Semgrep (SAST), OWASP Dependency-Check (CVE scanning), and CycloneDX (SBOM).
All tools default to report-only mode. Use fail_on_* parameters to enforce gates.
Usage in consuming repo:
workflows:
security_scan:
jobs:
- qqq-orb/security_scan:
context: [qqq-maven-registry-credentials, qqq-security-credentials]
filters:
branches:
only: [develop]
executor: java
parameters:
java_version:
type: string
default: "21"
description: "Java major version to install"
run_gitleaks:
type: boolean
default: true
description: "Run Gitleaks secret detection"
run_semgrep:
type: boolean
default: true
description: "Run Semgrep SAST analysis"
run_owasp:
type: boolean
default: true
description: "Run OWASP Dependency-Check CVE scanning"
run_sbom:
type: boolean
default: true
description: "Run CycloneDX SBOM generation"
fail_on_gitleaks:
type: boolean
default: false
description: "Fail the build if Gitleaks finds secrets"
fail_on_semgrep:
type: boolean
default: false
description: "Fail the build if Semgrep finds security issues"
fail_on_owasp:
type: boolean
default: false
description: "Fail the build if OWASP finds CVEs above threshold"
semgrep_rulesets:
type: string
default: "p/java p/owasp-top-ten p/security-audit"
description: "Space-separated list of Semgrep rulesets"
owasp_cvss_threshold:
type: string
default: "7"
description: "CVSS score threshold for OWASP (0-10)"
steps:
- install_java:
java_version: << parameters.java_version >>
- git_full_checkout
- run:
name: Setup Maven Settings
command: <<include(scripts/setup_maven_settings.sh)>>
- restore_cache:
keys:
- v1-dependencies-{{ checksum "pom.xml" }}
- run:
name: Build and Install for Security Analysis
command: <<include(scripts/mvn_install_for_analysis.sh)>>
- save_cache:
paths:
- ~/.m2
key: v1-dependencies-{{ checksum "pom.xml" }}
- when:
condition: << parameters.run_gitleaks >>
steps:
- run_gitleaks:
fail_on_findings: << parameters.fail_on_gitleaks >>
- when:
condition: << parameters.run_semgrep >>
steps:
- run_semgrep:
fail_on_findings: << parameters.fail_on_semgrep >>
rulesets: << parameters.semgrep_rulesets >>
- when:
condition: << parameters.run_owasp >>
steps:
- run_owasp_dependency_check:
fail_on_cvss: << parameters.fail_on_owasp >>
cvss_threshold: << parameters.owasp_cvss_threshold >>
- when:
condition: << parameters.run_sbom >>
steps:
- run_cyclonedx_sbom
- collect_security_reports
- store_artifacts:
path: /home/circleci/security-reports
destination: security-reports
+72
View File
@@ -0,0 +1,72 @@
description: >
Runs SpotBugs and PMD static analysis on a Maven project.
This job is designed to be used in an optional workflow triggered
by tag (static-analysis/*) or pipeline parameter.
Usage in consuming repo:
workflows:
static_analysis:
when:
or:
- matches:
pattern: "^static-analysis/.*"
value: << pipeline.git.tag >>
- equal: [true, << pipeline.parameters.run_static_analysis >>]
jobs:
- qqq-orb/static_analysis
executor: java
parameters:
java_version:
type: string
default: "21"
description: "Java major version to install"
fail_on_spotbugs:
type: boolean
default: false
description: "Fail the build if SpotBugs finds bugs"
fail_on_pmd:
type: boolean
default: false
description: "Fail the build if PMD finds violations"
run_spotbugs:
type: boolean
default: true
description: "Run SpotBugs analysis"
run_pmd:
type: boolean
default: true
description: "Run PMD analysis"
steps:
- install_java:
java_version: << parameters.java_version >>
- git_full_checkout
- run:
name: Setup Maven Settings
command: <<include(scripts/setup_maven_settings.sh)>>
- restore_cache:
keys:
- v1-dependencies-{{ checksum "pom.xml" }}
- run:
name: Build and Install for Analysis
command: <<include(scripts/mvn_install_for_analysis.sh)>>
- save_cache:
paths:
- ~/.m2
key: v1-dependencies-{{ checksum "pom.xml" }}
- when:
condition: << parameters.run_spotbugs >>
steps:
- mvn_spotbugs:
fail_on_error: << parameters.fail_on_spotbugs >>
- when:
condition: << parameters.run_pmd >>
steps:
- mvn_pmd:
fail_on_violation: << parameters.fail_on_pmd >>
- collect_static_analysis_reports
- store_artifacts:
path: /home/circleci/static-analysis-reports
destination: static-analysis
+88
View File
@@ -0,0 +1,88 @@
#!/bin/bash
# Collect security scan reports to a central location for artifacts
REPORT_DIR="/home/circleci/security-reports"
mkdir -p "$REPORT_DIR/gitleaks" "$REPORT_DIR/semgrep" "$REPORT_DIR/owasp" "$REPORT_DIR/sbom"
echo "Collecting security scan reports..."
# Collect Gitleaks reports
if [ -f /tmp/gitleaks-report.json ]; then
cp /tmp/gitleaks-report.json "$REPORT_DIR/gitleaks/" 2>/dev/null || true
fi
# Collect Semgrep reports
if [ -f /tmp/semgrep-report.json ]; then
cp /tmp/semgrep-report.json "$REPORT_DIR/semgrep/" 2>/dev/null || true
fi
if [ -f /tmp/semgrep-report.sarif ]; then
cp /tmp/semgrep-report.sarif "$REPORT_DIR/semgrep/" 2>/dev/null || true
fi
# Collect OWASP Dependency-Check reports
if [ -f /tmp/owasp-dependency-check.json ]; then
cp /tmp/owasp-dependency-check.json "$REPORT_DIR/owasp/" 2>/dev/null || true
fi
if [ -f /tmp/owasp-dependency-check.html ]; then
cp /tmp/owasp-dependency-check.html "$REPORT_DIR/owasp/" 2>/dev/null || true
fi
# Collect CycloneDX SBOM
if [ -f /tmp/cyclonedx-sbom.json ]; then
cp /tmp/cyclonedx-sbom.json "$REPORT_DIR/sbom/" 2>/dev/null || true
fi
# Generate combined summary
{
echo "=== Security Scan Report Summary ==="
echo "Generated: $(date)"
echo ""
echo "Gitleaks (Secret Detection):"
if [ -f "$REPORT_DIR/gitleaks/gitleaks-report.json" ]; then
COUNT=$(python3 -c "import json; print(len(json.load(open('$REPORT_DIR/gitleaks/gitleaks-report.json'))))" 2>/dev/null || echo "unknown")
echo " Findings: ${COUNT}"
else
echo " Not run or no report"
fi
echo ""
echo "Semgrep (SAST):"
if [ -f "$REPORT_DIR/semgrep/semgrep-report.json" ]; then
COUNT=$(python3 -c "import json; r=json.load(open('$REPORT_DIR/semgrep/semgrep-report.json')); print(len(r.get('results', [])))" 2>/dev/null || echo "unknown")
echo " Findings: ${COUNT}"
else
echo " Not run or no report"
fi
echo ""
echo "OWASP Dependency-Check (CVEs):"
if [ -f "$REPORT_DIR/owasp/owasp-dependency-check.json" ]; then
COUNT=$(python3 -c "
import json
r = json.load(open('$REPORT_DIR/owasp/owasp-dependency-check.json'))
deps = r.get('dependencies', [])
vulns = sum(len(d.get('vulnerabilities', [])) for d in deps)
print(vulns)
" 2>/dev/null || echo "unknown")
echo " Vulnerabilities: ${COUNT}"
else
echo " Not run or no report"
fi
echo ""
echo "CycloneDX SBOM:"
if [ -f "$REPORT_DIR/sbom/cyclonedx-sbom.json" ]; then
COUNT=$(python3 -c "import json; r=json.load(open('$REPORT_DIR/sbom/cyclonedx-sbom.json')); print(len(r.get('components', [])))" 2>/dev/null || echo "unknown")
echo " Components: ${COUNT}"
else
echo " Not run or no report"
fi
echo ""
echo "==================================="
} > "$REPORT_DIR/summary.txt"
cat "$REPORT_DIR/summary.txt"
echo ""
echo "Reports collected to: $REPORT_DIR"
@@ -0,0 +1,46 @@
#!/bin/bash
# Collect SpotBugs and PMD reports to a central location for artifacts
REPORT_DIR="/home/circleci/static-analysis-reports"
mkdir -p "$REPORT_DIR/spotbugs" "$REPORT_DIR/pmd"
echo "Collecting static analysis reports..."
# Collect SpotBugs reports
find . -name "spotbugsXml.xml" -exec sh -c '
MODULE=$(dirname "$1" | sed "s|^\./||;s|/target.*||" | tr "/" "_")
cp "$1" "'"$REPORT_DIR/spotbugs"'/${MODULE}_spotbugs.xml" 2>/dev/null || true
' _ {} \;
# Collect PMD reports
find . -name "pmd.xml" -exec sh -c '
MODULE=$(dirname "$1" | sed "s|^\./||;s|/target.*||" | tr "/" "_")
cp "$1" "'"$REPORT_DIR/pmd"'/${MODULE}_pmd.xml" 2>/dev/null || true
' _ {} \;
# Generate combined summary
{
echo "=== Static Analysis Report Summary ==="
echo "Generated: $(date)"
echo ""
echo "SpotBugs:"
} > "$REPORT_DIR/summary.txt"
find "$REPORT_DIR/spotbugs" -name "*.xml" 2>/dev/null | while read -r f; do
MODULE=$(basename "$f" _spotbugs.xml)
COUNT=$(grep -c "<BugInstance" "$f" 2>/dev/null || echo "0")
echo " $MODULE: $COUNT bugs" >> "$REPORT_DIR/summary.txt"
done
echo "" >> "$REPORT_DIR/summary.txt"
echo "PMD:" >> "$REPORT_DIR/summary.txt"
find "$REPORT_DIR/pmd" -name "*.xml" 2>/dev/null | while read -r f; do
MODULE=$(basename "$f" _pmd.xml)
COUNT=$(grep -c "<violation" "$f" 2>/dev/null || echo "0")
echo " $MODULE: $COUNT violations" >> "$REPORT_DIR/summary.txt"
done
cat "$REPORT_DIR/summary.txt"
echo ""
echo "Reports collected to: $REPORT_DIR"
+10
View File
@@ -20,6 +20,16 @@
set -e
################################################################
## Skip version commit for feature branches ##
## Feature versions are ephemeral (include commit hash) and ##
## don't need to be persisted back to the repository ##
################################################################
if [[ "$BRANCH_TYPE" == "feature" ]]; then
echo "Skipping version commit for feature branch (ephemeral versions)"
exit 0
fi
################################################################
## Check if pom.xml was modified and commit changes if needed ##
################################################################
+6
View File
@@ -0,0 +1,6 @@
#!/bin/bash
set -e
echo "Building and installing project for static analysis..."
mvn install -DskipTests -Dmaven.javadoc.skip=true -Dcheckstyle.skip=true
echo "Build complete - artifacts installed to local repository"
-1
View File
@@ -25,5 +25,4 @@ set -e
##############################################
## Deploy signed artifacts to Maven Central ##
##############################################
cat /tmp/circleci/mvn-settings.xml
mvn -s /tmp/circleci/mvn-settings.xml -P release -B -DskipTests -Dgpg.keyname="$GPG_KEYNAME" -Dgpg.passphrase="$GPG_PASSPHRASE" deploy
+23
View File
@@ -0,0 +1,23 @@
#!/bin/bash
set -e
echo "Running PMD static analysis..."
# Default to report-only mode unless PMD_FAIL_ON_VIOLATION is set
FAIL_FLAG=""
if [ "${PMD_FAIL_ON_VIOLATION}" = "true" ]; then
FAIL_FLAG="-Dpmd.failOnViolation=true"
fi
# Run PMD
mvn pmd:check -DskipTests ${FAIL_FLAG} 2>&1 | tee /tmp/pmd-output.txt
# Summarize results
echo ""
echo "=== PMD Summary ==="
find . -name "pmd.xml" -exec sh -c '
MODULE=$(dirname "$1" | sed "s|^\./||;s|/target.*||")
COUNT=$(grep -c "<violation" "$1" 2>/dev/null || echo "0")
echo " $MODULE: $COUNT violations"
' _ {} \; 2>/dev/null | sort || true
echo "==================="
+23
View File
@@ -0,0 +1,23 @@
#!/bin/bash
set -e
echo "Running SpotBugs static analysis..."
# Default to report-only mode unless SPOTBUGS_FAIL_ON_ERROR is set
FAIL_FLAG=""
if [ "${SPOTBUGS_FAIL_ON_ERROR}" = "true" ]; then
FAIL_FLAG="-Dspotbugs.failOnError=true"
fi
# Run SpotBugs
mvn spotbugs:check -DskipTests ${FAIL_FLAG} 2>&1 | tee /tmp/spotbugs-output.txt
# Summarize results
echo ""
echo "=== SpotBugs Summary ==="
find . -name "spotbugsXml.xml" -exec sh -c '
MODULE=$(dirname "$1" | sed "s|^\./||;s|/target.*||")
COUNT=$(grep -c "<BugInstance" "$1" 2>/dev/null || echo "0")
echo " $MODULE: $COUNT bugs"
' _ {} \; 2>/dev/null | sort || true
echo "========================"
+43
View File
@@ -0,0 +1,43 @@
#!/bin/bash
############################################################################
## node_app_build.sh
## Node Application Production Build
##
## Runs the production build for a Node.js application with timing output.
##
## Environment Variables:
## NODE_PKG_MANAGER - Package manager to use (default: pnpm)
## BUILD_SCRIPT - Script name for the build step (default: build)
##
## Usage: Called by CircleCI orb command node_app_build_step
## Output: Production build artifacts
############################################################################
set -e
# Source shared helpers (no-op in packed orb — file won't exist at runtime)
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]:-$0}")" && pwd)"
# shellcheck disable=SC1091
source "${SCRIPT_DIR}/qqq_helpers.sh" 2>/dev/null || true
# Fallback stubs when helpers couldn't be sourced (packed orb environment)
if ! type banner &>/dev/null; then
banner() { echo ""; echo "========================================"; echo " ${1:-}"; echo "========================================"; echo ""; }
require_tool() { command -v "$1" &>/dev/null || { echo "ERROR: Required tool '$1' is not installed."; exit 1; }; }
fi
NODE_PKG_MANAGER="${NODE_PKG_MANAGER:-pnpm}"
BUILD_SCRIPT="${BUILD_SCRIPT:-build}"
banner "Production Build"
require_tool "${NODE_PKG_MANAGER}"
START_TIME=$(date +%s)
"${NODE_PKG_MANAGER}" run "${BUILD_SCRIPT}"
END_TIME=$(date +%s)
ELAPSED=$((END_TIME - START_TIME))
echo "Build completed in ${ELAPSED}s"
+56
View File
@@ -0,0 +1,56 @@
#!/bin/bash
############################################################################
## node_app_e2e.sh
## Node Application End-to-End Test Runner
##
## Installs Playwright browsers and runs e2e tests producing JUnit output.
##
## Environment Variables:
## NODE_PKG_MANAGER - Package manager to use (default: pnpm)
## E2E_SCRIPT - Script name for e2e tests (default: test:e2e)
##
## Usage: Called by CircleCI orb command node_app_e2e
## Output: JUnit test results in test-results/e2e/ and Playwright traces
############################################################################
set -e
# Source shared helpers (no-op in packed orb — file won't exist at runtime)
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]:-$0}")" && pwd)"
# shellcheck disable=SC1091
source "${SCRIPT_DIR}/qqq_helpers.sh" 2>/dev/null || true
# Fallback stubs when helpers couldn't be sourced (packed orb environment)
if ! type banner &>/dev/null; then
banner() { echo ""; echo "========================================"; echo " ${1:-}"; echo "========================================"; echo ""; }
require_tool() { command -v "$1" &>/dev/null || { echo "ERROR: Required tool '$1' is not installed."; exit 1; }; }
fi
NODE_PKG_MANAGER="${NODE_PKG_MANAGER:-pnpm}"
E2E_SCRIPT="${E2E_SCRIPT:-test:e2e}"
banner "End-to-End Tests (Playwright)"
require_tool "${NODE_PKG_MANAGER}"
###########################
## Install Browsers ##
###########################
echo "Installing Playwright browsers..."
npx playwright install --with-deps chromium
###########################
## Run E2E Tests ##
###########################
mkdir -p test-results/e2e
echo "Running e2e tests..."
"${NODE_PKG_MANAGER}" run "${E2E_SCRIPT}" || E2E_EXIT=$?
if [[ "${E2E_EXIT:-0}" -ne 0 ]]; then
echo "E2E tests failed with exit code ${E2E_EXIT}"
exit "${E2E_EXIT}"
fi
echo "E2E tests completed successfully"
+96
View File
@@ -0,0 +1,96 @@
#!/bin/bash
############################################################################
## node_app_install.sh
## Node Application Dependency Installation
##
## Installs dependencies for a Node.js application project using the
## configured package manager (pnpm, npm, or yarn). Enables corepack
## when using pnpm or yarn.
##
## Environment Variables:
## NODE_PKG_MANAGER - Package manager to use (default: pnpm)
##
## Usage: Called by CircleCI orb command node_app_install
## Output: Installed node_modules and validated lockfile
############################################################################
set -e
# Source shared helpers (no-op in packed orb — file won't exist at runtime)
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]:-$0}")" && pwd)"
# shellcheck disable=SC1091
source "${SCRIPT_DIR}/qqq_helpers.sh" 2>/dev/null || true
# Fallback stubs when helpers couldn't be sourced (packed orb environment)
if ! type banner &>/dev/null; then
banner() { echo ""; echo "========================================"; echo " ${1:-}"; echo "========================================"; echo ""; }
require_tool() { command -v "$1" &>/dev/null || { echo "ERROR: Required tool '$1' is not installed."; exit 1; }; }
fi
NODE_PKG_MANAGER="${NODE_PKG_MANAGER:-pnpm}"
banner "Install Dependencies (${NODE_PKG_MANAGER})"
###########################
## Enable Corepack ##
###########################
if [[ "${NODE_PKG_MANAGER}" == "pnpm" || "${NODE_PKG_MANAGER}" == "yarn" ]]; then
if command -v "${NODE_PKG_MANAGER}" &>/dev/null; then
echo "${NODE_PKG_MANAGER} already available: $(${NODE_PKG_MANAGER} --version)"
else
echo "Installing ${NODE_PKG_MANAGER} via corepack..."
# corepack enable requires write access to /usr/local/bin; use sudo if available
if sudo -n corepack enable 2>/dev/null; then
echo "corepack enable succeeded (sudo)"
else
corepack enable --install-directory "${HOME}/.local/bin"
export PATH="${HOME}/.local/bin:${PATH}"
fi
corepack prepare "${NODE_PKG_MANAGER}@latest" --activate
fi
fi
require_tool "${NODE_PKG_MANAGER}"
###########################
## Lockfile Validation ##
###########################
case "${NODE_PKG_MANAGER}" in
pnpm)
if [[ ! -f pnpm-lock.yaml ]]; then
echo "WARNING: pnpm-lock.yaml not found"
fi
;;
npm)
if [[ ! -f package-lock.json ]]; then
echo "WARNING: package-lock.json not found"
fi
;;
yarn)
if [[ ! -f yarn.lock ]]; then
echo "WARNING: yarn.lock not found"
fi
;;
*)
echo "ERROR: Unsupported package manager '${NODE_PKG_MANAGER}'"
exit 1
;;
esac
###########################
## Install ##
###########################
case "${NODE_PKG_MANAGER}" in
pnpm)
pnpm install --frozen-lockfile
;;
npm)
npm ci
;;
yarn)
yarn install --immutable
;;
esac
echo "Dependencies installed successfully with ${NODE_PKG_MANAGER}"
+73
View File
@@ -0,0 +1,73 @@
#!/bin/bash
############################################################################
## node_app_test.sh
## Node Application Test Runner
##
## Runs type-checking, linting, and unit tests for a Node.js application.
## Each step can be overridden via environment variables to support
## projects with non-standard script names.
##
## Environment Variables:
## NODE_PKG_MANAGER - Package manager to use (default: pnpm)
## TYPECHECK_SCRIPT - Script name for type checking (default: typecheck)
## LINT_SCRIPT - Script name for linting (default: lint)
## TEST_SCRIPT - Script name for unit tests (default: test)
##
## Usage: Called by CircleCI orb command node_app_test
## Output: Test results and lint/typecheck status
############################################################################
set -e
# Source shared helpers (no-op in packed orb — file won't exist at runtime)
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]:-$0}")" && pwd)"
# shellcheck disable=SC1091
source "${SCRIPT_DIR}/qqq_helpers.sh" 2>/dev/null || true
# Fallback stubs when helpers couldn't be sourced (packed orb environment)
if ! type banner &>/dev/null; then
banner() { echo ""; echo "========================================"; echo " ${1:-}"; echo "========================================"; echo ""; }
require_tool() { command -v "$1" &>/dev/null || { echo "ERROR: Required tool '$1' is not installed."; exit 1; }; }
fi
NODE_PKG_MANAGER="${NODE_PKG_MANAGER:-pnpm}"
TYPECHECK_SCRIPT="${TYPECHECK_SCRIPT:-typecheck}"
LINT_SCRIPT="${LINT_SCRIPT:-lint}"
TEST_SCRIPT="${TEST_SCRIPT:-test}"
############################################################################
## has_script - check if a script exists in package.json
############################################################################
has_script() {
local name="$1"
node -e "
const pkg = require('./package.json');
process.exit(pkg.scripts && pkg.scripts['${name}'] ? 0 : 1);
"
}
############################################################################
## run_step - run a package.json script if it exists
############################################################################
run_step() {
local label="$1"
local script="$2"
banner "${label}"
if has_script "${script}"; then
"${NODE_PKG_MANAGER}" run "${script}"
else
echo "SKIP: No '${script}' script found in package.json"
fi
}
###########################
## Run Steps ##
###########################
run_step "Type Check" "${TYPECHECK_SCRIPT}"
run_step "Lint" "${LINT_SCRIPT}"
run_step "Unit Tests" "${TEST_SCRIPT}"
echo "All test steps completed successfully"
+82
View File
@@ -0,0 +1,82 @@
#!/usr/bin/env bash
############################################################################
## node_npm_publish.sh
## NPM Publishing Script with Prerelease Tag Support
##
## This script publishes npm packages with proper handling of prerelease
## versions. NPM requires a --tag flag for prerelease versions.
##
## Prerelease detection:
## - RC versions (e.g., 1.0.0-RC.1) -> --tag rc
## - SNAPSHOT versions (e.g., 1.0.0-SNAPSHOT) -> --tag snapshot
## - Alpha/Beta versions -> --tag next
## - Stable versions (e.g., 1.0.0) -> --tag latest (default)
##
## Usage: Called by CircleCI orb command node_publish
############################################################################
set +x
set -euo pipefail
if [[ "${QQQ_NPM_TRUSTED_PUBLISHING:-false}" == "true" ]]; then
NPM_CLI_VERSION=$(npm --version)
node - "$NPM_CLI_VERSION" <<'NODE'
const atLeast = (actual, minimum) => {
const parts = actual.split('.').map(Number);
return minimum.every((part, index) => parts[index] === part)
|| minimum.some((part, index) => parts[index] > part
&& minimum.slice(0, index).every((value, previous) => parts[previous] === value));
};
if (!atLeast(process.versions.node, [22, 14, 0]) || !atLeast(process.argv[2], [11, 5, 1])) {
console.error('Trusted publishing requires Node >=22.14.0 and npm >=11.5.1.');
process.exit(1);
}
if (Object.keys(process.env).some(name => /^npm_config_.*(auth|password|username|userconfig|globalconfig)/i.test(name))) {
console.error('Remove npm credential/config-path environment settings before using trusted publishing.');
process.exit(1);
}
NODE
# Do not inherit a project/user token or write the short-lived identity to disk.
if [[ -f .npmrc ]]; then
echo "Trusted publishing requires a publish directory without .npmrc." >&2
exit 1
fi
unset NPM_TOKEN NODE_AUTH_TOKEN NPM_AUTH_TOKEN
PUBLISH_CONFIG_DIR=$(mktemp -d)
trap 'rm -rf "$PUBLISH_CONFIG_DIR"' EXIT
export NPM_CONFIG_USERCONFIG="$PUBLISH_CONFIG_DIR/user.npmrc"
export NPM_CONFIG_GLOBALCONFIG="$PUBLISH_CONFIG_DIR/global.npmrc"
NPM_ID_TOKEN=$(circleci run oidc get --claims '{"aud":"npm:registry.npmjs.org"}')
if [[ -z "$NPM_ID_TOKEN" ]]; then
echo "CircleCI did not provide an npm OIDC token." >&2
exit 1
fi
export NPM_ID_TOKEN
fi
# Extract version from package.json
VERSION=$(grep '"version"' package.json | sed 's/.*"version": "//;s/".*//')
echo "Publishing version: $VERSION"
# Determine the appropriate npm tag based on version
if [[ "$VERSION" =~ -RC\.[0-9]+$ ]]; then
NPM_TAG="rc"
echo "Detected RC version - using tag: $NPM_TAG"
elif [[ "$VERSION" =~ -SNAPSHOT$ ]]; then
NPM_TAG="snapshot"
echo "Detected SNAPSHOT version - using tag: $NPM_TAG"
elif [[ "$VERSION" =~ -(alpha|beta) ]]; then
NPM_TAG="next"
echo "Detected alpha/beta version - using tag: $NPM_TAG"
else
NPM_TAG="latest"
echo "Detected stable version - using tag: $NPM_TAG"
fi
# Publish with the appropriate tag
echo "Running: npm publish --access public --tag $NPM_TAG"
npm publish --access public --tag "$NPM_TAG"
echo "Successfully published $VERSION with tag $NPM_TAG"
+36 -7
View File
@@ -3,16 +3,17 @@
############################################################################
## node_version_commit.sh
## Node.js Version Commit Management Script
##
##
## This script handles committing version changes to Git for Node.js projects.
## It checks if the package.json file has been modified and commits the changes if needed.
## It also pushes the changes back to the current branch.
##
## Process:
## 1. Checks if package.json has been modified
## 2. Extracts the new version from package.json
## 3. Commits the changes with skip ci flag
## 4. Pushes changes to the current branch
## 1. Skips for feature branches (ephemeral versions)
## 2. Checks if package.json has been modified
## 3. Extracts the new version from package.json
## 4. Commits the changes with skip ci flag
## 5. Pushes changes to the current branch (non-fatal on failure)
##
## Usage: Called by node_manage_version command
## Output: Commits and pushes version changes if package.json was modified
@@ -20,13 +21,41 @@
set -e
################################################################
## Skip version commit for feature branches ##
## Feature versions are ephemeral and don't need to be ##
## persisted back to the repository ##
################################################################
if [[ "$BRANCH_TYPE" == "feature" ]]; then
echo "Skipping version commit for feature branch (ephemeral versions)"
exit 0
fi
################################################################
## Check if package.json was modified and commit if needed ##
################################################################
echo "Checking for package.json version changes"
if [[ -n "$(git status --porcelain package.json)" ]]; then
NEW_VERSION=$(grep '"version"' package.json | sed 's/.*"version": "//;s/".*//')
git add package.json
git commit -m "Bump version to $NEW_VERSION [skip ci]"
git push origin "HEAD:${CIRCLE_BRANCH}"
echo "Version updated to: $NEW_VERSION and pushed"
# Determine target branch
if [ -n "$CIRCLE_BRANCH" ]; then
TARGET_BRANCH="$CIRCLE_BRANCH"
else
TARGET_BRANCH="main"
fi
# Try to push, but don't fail the build if push fails
# This can happen if another build pushed first (race condition)
if git push origin "HEAD:${TARGET_BRANCH}"; then
echo "Version updated to: $NEW_VERSION and pushed to ${TARGET_BRANCH}"
else
echo "WARNING: Failed to push version commit to ${TARGET_BRANCH}"
echo "This is not fatal - version will be updated on next build"
echo "Common causes: concurrent builds, branch protection rules"
fi
else
echo "No version change needed"
fi
+50
View File
@@ -0,0 +1,50 @@
#!/bin/bash
############################################################################
## qqq_helpers.sh
## QQQ Orb Shared Helper Functions
##
## Provides common utilities used across node_app_* scripts:
## - Double-source guard to prevent re-initialization
## - Banner display for step identification
## - Tool existence checking
##
## Usage: source qqq_helpers.sh (from other scripts)
## Output: Exports helper functions into the calling script
############################################################################
# Double-source guard
if [[ -n "${_QQQ_HELPERS_LOADED:-}" ]]; then
# shellcheck disable=SC2317
return 0 2>/dev/null || true
fi
_QQQ_HELPERS_LOADED=1
############################################################################
## banner
## Print a visible section header
##
## Usage: banner "Step Name"
############################################################################
banner() {
local msg="$1"
echo ""
echo "========================================"
echo " ${msg}"
echo "========================================"
echo ""
}
############################################################################
## require_tool
## Verify a CLI tool is available, exit 1 if missing
##
## Usage: require_tool "pnpm"
############################################################################
require_tool() {
local tool="$1"
if ! command -v "${tool}" &>/dev/null; then
echo "ERROR: Required tool '${tool}' is not installed."
exit 1
fi
}
+38
View File
@@ -0,0 +1,38 @@
#!/bin/bash
set -e
echo "Generating CycloneDX SBOM..."
##################################
## Run CycloneDX Maven plugin ##
##################################
mvn -s /tmp/circleci/mvn-settings.xml \
--no-transfer-progress \
org.cyclonedx:cyclonedx-maven-plugin:2.9.1:makeAggregateBom \
-DskipTests \
-DoutputFormat=json \
-DoutputName=bom
##################################
## Collect SBOM output ##
##################################
echo ""
echo "=== CycloneDX SBOM Summary ==="
if [ -f target/bom.json ]; then
COMPONENTS=$(python3 -c "import json; r=json.load(open('target/bom.json')); print(len(r.get('components', [])))" 2>/dev/null || echo "unknown")
echo " Components: ${COMPONENTS}"
cp target/bom.json /tmp/cyclonedx-sbom.json
else
# Multi-module projects may output to different location
BOM_FILE=$(find . -name "bom.json" -path "*/target/*" | head -1)
if [ -n "${BOM_FILE}" ]; then
COMPONENTS=$(python3 -c "import json; r=json.load(open('${BOM_FILE}')); print(len(r.get('components', [])))" 2>/dev/null || echo "unknown")
echo " Components: ${COMPONENTS}"
cp "${BOM_FILE}" /tmp/cyclonedx-sbom.json
else
echo " No SBOM generated"
fi
fi
echo "==============================="
echo "CycloneDX SBOM generation complete"
+46
View File
@@ -0,0 +1,46 @@
#!/bin/bash
set -e
echo "Running Gitleaks secret detection..."
##################################
## Install Gitleaks binary ##
##################################
GITLEAKS_VERSION="8.21.2"
curl -sSfL "https://github.com/gitleaks/gitleaks/releases/download/v${GITLEAKS_VERSION}/gitleaks_${GITLEAKS_VERSION}_linux_x64.tar.gz" \
| tar -xz -C /tmp
chmod +x /tmp/gitleaks
##################################
## Run Gitleaks scan ##
##################################
EXIT_CODE=0
/tmp/gitleaks detect \
--source=. \
--report-format=json \
--report-path=/tmp/gitleaks-report.json \
--verbose \
|| EXIT_CODE=$?
##################################
## Summarize results ##
##################################
echo ""
echo "=== Gitleaks Summary ==="
if [ -f /tmp/gitleaks-report.json ]; then
COUNT=$(python3 -c "import json; print(len(json.load(open('/tmp/gitleaks-report.json'))))" 2>/dev/null || echo "unknown")
echo " Findings: ${COUNT}"
else
echo " Findings: 0"
fi
echo "========================="
##################################
## Handle fail_on flag ##
##################################
if [ "${GITLEAKS_FAIL_ON_FINDINGS}" = "true" ] && [ "${EXIT_CODE}" -ne 0 ]; then
echo "Gitleaks found secrets and fail_on_gitleaks is enabled. Failing build."
exit 1
fi
echo "Gitleaks scan complete (exit code: ${EXIT_CODE})"
+98
View File
@@ -0,0 +1,98 @@
#!/bin/bash
set -e
echo "Running OWASP Dependency-Check..."
##################################
## Build Maven command ##
##################################
MVN_CMD="mvn -s /tmp/circleci/mvn-settings.xml --no-transfer-progress"
MVN_CMD="${MVN_CMD} org.owasp:dependency-check-maven:12.1.0:aggregate"
MVN_CMD="${MVN_CMD} -DskipTests"
MVN_CMD="${MVN_CMD} -DfailBuildOnCVSS=${OWASP_CVSS_THRESHOLD}"
MVN_CMD="${MVN_CMD} -Dformats=JSON,HTML"
# Use NVD API key if available (speeds up NVD database updates)
if [ -n "${NVD_API_KEY}" ]; then
MVN_CMD="${MVN_CMD} -DnvdApiKey=${NVD_API_KEY}"
echo " NVD API key detected -- using authenticated NVD access"
else
echo " No NVD API key -- using unauthenticated access (slower)"
fi
##################################
## Run with retry logic (3x) ##
##################################
MAX_RETRIES=3
ATTEMPT=1
EXIT_CODE=0
while [ "${ATTEMPT}" -le "${MAX_RETRIES}" ]; do
echo ""
echo "OWASP Dependency-Check attempt ${ATTEMPT}/${MAX_RETRIES}..."
EXIT_CODE=0
eval "${MVN_CMD}" 2>&1 | tee /tmp/owasp-output.txt || EXIT_CODE=$?
# Exit code 1 = vulnerabilities found (expected), anything else = tool error
if [ "${EXIT_CODE}" -eq 0 ] || [ "${EXIT_CODE}" -eq 1 ]; then
break
fi
echo "Attempt ${ATTEMPT} failed with exit code ${EXIT_CODE}"
ATTEMPT=$((ATTEMPT + 1))
if [ "${ATTEMPT}" -le "${MAX_RETRIES}" ]; then
echo "Retrying in 30 seconds..."
sleep 30
fi
done
if [ "${ATTEMPT}" -gt "${MAX_RETRIES}" ] && [ "${EXIT_CODE}" -gt 1 ]; then
echo "OWASP Dependency-Check failed after ${MAX_RETRIES} attempts"
echo "This is typically caused by NVD database download issues"
exit 1
fi
##################################
## Collect reports ##
##################################
REPORT_FILE=$(find . -name "dependency-check-report.json" -path "*/target/*" | head -1)
if [ -n "${REPORT_FILE}" ]; then
cp "${REPORT_FILE}" /tmp/owasp-dependency-check.json
fi
HTML_REPORT=$(find . -name "dependency-check-report.html" -path "*/target/*" | head -1)
if [ -n "${HTML_REPORT}" ]; then
cp "${HTML_REPORT}" /tmp/owasp-dependency-check.html
fi
##################################
## Summarize results ##
##################################
echo ""
echo "=== OWASP Dependency-Check Summary ==="
if [ -f /tmp/owasp-dependency-check.json ]; then
VULN_COUNT=$(python3 -c "
import json
r = json.load(open('/tmp/owasp-dependency-check.json'))
deps = r.get('dependencies', [])
vulns = sum(len(d.get('vulnerabilities', [])) for d in deps)
print(vulns)
" 2>/dev/null || echo "unknown")
echo " Vulnerabilities: ${VULN_COUNT}"
echo " CVSS Threshold: ${OWASP_CVSS_THRESHOLD}"
else
echo " No report generated"
fi
echo "======================================="
##################################
## Handle fail_on flag ##
##################################
if [ "${OWASP_FAIL_ON_CVSS}" = "true" ] && [ "${EXIT_CODE}" -ne 0 ]; then
echo "OWASP found CVEs above threshold and fail_on_owasp is enabled. Failing build."
exit 1
fi
echo "OWASP Dependency-Check complete"
+44
View File
@@ -0,0 +1,44 @@
#!/bin/bash
set -e
echo "Running Semgrep SAST analysis..."
##################################
## Install Semgrep ##
##################################
pip3 install --quiet semgrep
##################################
## Run Semgrep scan ##
##################################
EXIT_CODE=0
semgrep scan \
--config "${SEMGREP_RULESETS// / --config }" \
--json --output /tmp/semgrep-report.json \
--sarif --sarif-output /tmp/semgrep-report.sarif \
--metrics=off \
. \
|| EXIT_CODE=$?
##################################
## Summarize results ##
##################################
echo ""
echo "=== Semgrep Summary ==="
if [ -f /tmp/semgrep-report.json ]; then
COUNT=$(python3 -c "import json; r=json.load(open('/tmp/semgrep-report.json')); print(len(r.get('results', [])))" 2>/dev/null || echo "unknown")
echo " Findings: ${COUNT}"
else
echo " Findings: 0"
fi
echo "========================"
##################################
## Handle fail_on flag ##
##################################
if [ "${SEMGREP_FAIL_ON_FINDINGS}" = "true" ] && [ "${EXIT_CODE}" -ne 0 ]; then
echo "Semgrep found issues and fail_on_semgrep is enabled. Failing build."
exit 1
fi
echo "Semgrep scan complete (exit code: ${EXIT_CODE})"
-1
View File
@@ -47,4 +47,3 @@ http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.
EOF
echo "✅ Maven settings file created: /tmp/circleci/mvn-settings.xml"
cat /tmp/circleci/mvn-settings.xml
+7 -1
View File
@@ -16,6 +16,7 @@ set -e
###################
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
TEST_SCRIPT="$SCRIPT_DIR/test_calculate_version.sh"
SETTINGS_TEST_SCRIPT="$SCRIPT_DIR/test_maven_settings_output.sh"
VERBOSE=false
CI_MODE=false
@@ -54,6 +55,10 @@ main() {
echo "❌ Test script not found: $TEST_SCRIPT"
exit 1
fi
if [[ ! -f "$SETTINGS_TEST_SCRIPT" ]]; then
echo "❌ Test script not found: $SETTINGS_TEST_SCRIPT"
exit 1
fi
###############
## Run tests ##
@@ -68,7 +73,7 @@ main() {
## CI mode: minimal output, focus on results ##
###############################################
echo "Running tests in CI mode..."
if "$TEST_SCRIPT" $test_args > /tmp/test_output.log 2>&1; then
if { "$TEST_SCRIPT" $test_args && bash "$SETTINGS_TEST_SCRIPT"; } > /tmp/test_output.log 2>&1; then
echo "✅ All tests passed!"
exit 0
else
@@ -82,6 +87,7 @@ main() {
## Interactive mode: full output ##
###################################
"$TEST_SCRIPT" $test_args
bash "$SETTINGS_TEST_SCRIPT"
fi
}
+55
View File
@@ -0,0 +1,55 @@
#!/bin/bash
set -euo pipefail
script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
source_dir="$(dirname "$script_dir")/src/scripts"
test_dir="$(mktemp -d)"
trap 'rm -rf "$test_dir"' EXIT
mkdir -p "$test_dir/bin"
# Keep the production scripts' fixed CircleCI path away from any shared /tmp file.
sed "s|/tmp/circleci|$test_dir/circleci|g" \
"$source_dir/setup_maven_settings.sh" > "$test_dir/setup.sh"
sed "s|/tmp/circleci|$test_dir/circleci|g" \
"$source_dir/mvn_jar_deploy.sh" > "$test_dir/deploy.sh"
bash "$test_dir/setup.sh" > "$test_dir/setup-output" 2>&1
settings="$test_dir/circleci/mvn-settings.xml"
test -f "$settings"
grep -Fq "\${env.CENTRAL_USERNAME}" "$settings"
grep -Fq "\${env.CENTRAL_PASSWORD}" "$settings"
if grep -Fq '<settings' "$test_dir/setup-output" ||
grep -Fq "\${env.CENTRAL_USERNAME}" "$test_dir/setup-output"; then
echo 'Setup printed Maven settings content' >&2
exit 1
fi
# A distinctive future secret must never be echoed by the deploy wrapper.
printf '\n<!-- settings-output-sentinel -->\n' >> "$settings"
cat > "$test_dir/bin/mvn" <<'EOF'
#!/bin/bash
printf '%s\n' "$@" > "$TEST_MVN_ARGS"
EOF
chmod +x "$test_dir/bin/mvn"
PATH="$test_dir/bin:$PATH" TEST_MVN_ARGS="$test_dir/mvn-args" \
GPG_KEYNAME=test-key GPG_PASSPHRASE=test-passphrase \
bash "$test_dir/deploy.sh" > "$test_dir/deploy-output" 2>&1
if grep -Fq 'settings-output-sentinel' "$test_dir/deploy-output"; then
echo 'Deploy printed Maven settings content' >&2
exit 1
fi
cat > "$test_dir/expected-args" <<EOF
-s
$settings
-P
release
-B
-DskipTests
-Dgpg.keyname=test-key
-Dgpg.passphrase=test-passphrase
deploy
EOF
diff -u "$test_dir/expected-args" "$test_dir/mvn-args"
echo 'Maven settings setup and deploy output are safe; deploy arguments preserved'
+128
View File
@@ -0,0 +1,128 @@
#!/usr/bin/env python3
"""Exercise publisher boundaries without network access or real credentials."""
import json
import os
from pathlib import Path
import shutil
import subprocess
import tempfile
import unittest
SCRIPT = Path(__file__).resolve().parents[1] / 'src/scripts/node_npm_publish.sh'
NODE = shutil.which('node')
NPM = shutil.which('npm')
class PublishTests(unittest.TestCase):
def run_publish(self, version='1.0.0-RC.1', trusted=True, project_config=False, **overrides):
with tempfile.TemporaryDirectory() as directory:
root = Path(directory)
bin_dir = root / 'bin'
bin_dir.mkdir()
(root / 'package.json').write_text(json.dumps({'version': version}) + '\n')
if project_config:
(root / '.npmrc').write_text('//registry.npmjs.org/:_authToken=synthetic-old-token\n')
scripts = {
'npm': '''#!/usr/bin/env python3
import json, os, pathlib, subprocess, sys
if sys.argv[1:] == ['--version']:
print(os.environ.get('TEST_NPM_VERSION', '11.19.0'))
else:
assert sys.argv[1] == 'publish', 'Unexpected npm command'
if os.environ['QQQ_NPM_TRUSTED_PUBLISHING'] == 'true':
assert os.environ.get('NPM_ID_TOKEN') == 'synthetic-oidc-token'
assert all(not os.environ.get(name) for name in ['NPM_TOKEN', 'NODE_AUTH_TOKEN', 'NPM_AUTH_TOKEN'])
assert os.environ['NPM_CONFIG_USERCONFIG'] != os.environ['NPM_CONFIG_GLOBALCONFIG']
assert not pathlib.Path(os.environ['NPM_CONFIG_USERCONFIG']).exists()
assert not pathlib.Path(os.environ['NPM_CONFIG_GLOBALCONFIG']).exists()
registry = subprocess.check_output([os.environ['TEST_REAL_NPM'], 'config', 'get', 'registry'], text=True)
assert registry.strip() == 'https://registry.npmjs.org/'
pathlib.Path('published.json').write_text(json.dumps(sys.argv[1:]))
sys.exit(int(os.environ.get('TEST_PUBLISH_STATUS', '0')))
''',
'circleci': '''#!/usr/bin/env python3
import os, pathlib, sys
assert sys.argv[1:] == ['run', 'oidc', 'get', '--claims', '{"aud":"npm:registry.npmjs.org"}']
pathlib.Path('oidc-called').touch()
print(os.environ.get('TEST_OIDC_VALUE', 'synthetic-oidc-token'))
sys.exit(int(os.environ.get('TEST_OIDC_STATUS', '0')))
''',
'node': '''#!/usr/bin/env python3
import os, subprocess, sys
if sys.argv[1] != '-':
os.execv(os.environ['TEST_REAL_NODE'], [os.environ['TEST_REAL_NODE'], *sys.argv[1:]])
source = sys.stdin.read()
if 'TEST_NODE_VERSION' in os.environ:
source = source.replace('process.versions.node', repr(os.environ['TEST_NODE_VERSION']))
sys.exit(subprocess.run([os.environ['TEST_REAL_NODE'], *sys.argv[1:]], input=source, text=True).returncode)
'''
}
for name, contents in scripts.items():
executable = bin_dir / name
executable.write_text(contents)
executable.chmod(0o755)
env = dict(os.environ, PATH=str(bin_dir) + os.pathsep + os.environ['PATH'],
QQQ_NPM_TRUSTED_PUBLISHING=str(trusted).lower(), TEST_REAL_NODE=NODE, TEST_REAL_NPM=NPM,
NPM_TOKEN='synthetic-old-token', NODE_AUTH_TOKEN='synthetic-old-token',
NPM_AUTH_TOKEN='synthetic-old-token', **overrides)
result = subprocess.run(['bash', '-x', str(SCRIPT)], cwd=root, env=env,
text=True, capture_output=True)
self.assertNotIn('synthetic-oidc-token', result.stdout + result.stderr)
self.assertNotIn('synthetic-old-token', result.stdout + result.stderr)
published = root / 'published.json'
return result, json.loads(published.read_text()) if published.exists() else None, (root / 'oidc-called').exists()
def test_tags_and_legacy_authentication(self):
for trusted in [True, False]:
for version, tag in [('1.0.0-RC.1', 'rc'), ('1.0.0-SNAPSHOT', 'snapshot'),
('1.0.0-alpha.1', 'next'), ('1.0.0-beta.1', 'next'), ('1.0.0', 'latest')]:
with self.subTest(trusted=trusted, version=version):
result, args, oidc = self.run_publish(version, trusted)
self.assertEqual(result.returncode, 0, result.stderr)
self.assertEqual(args, ['publish', '--access', 'public', '--tag', tag])
self.assertEqual(oidc, trusted)
def test_oidc_failure_or_empty_token_stops_publication(self):
for overrides in [{'TEST_OIDC_STATUS': '7'}, {'TEST_OIDC_VALUE': ''}]:
with self.subTest(overrides=overrides):
result, args, oidc = self.run_publish(**overrides)
self.assertNotEqual(result.returncode, 0)
self.assertIsNone(args)
self.assertTrue(oidc)
def test_unsupported_toolchains_stop_before_requesting_identity(self):
for overrides in [{'TEST_NPM_VERSION': '11.5.0'}, {'TEST_NPM_VERSION': '10.9.0'},
{'TEST_NODE_VERSION': '22.13.1'}, {'TEST_NODE_VERSION': '20.20.0'}]:
with self.subTest(overrides=overrides):
result, args, oidc = self.run_publish(**overrides)
self.assertNotEqual(result.returncode, 0)
self.assertIsNone(args)
self.assertFalse(oidc)
def test_minimum_toolchain_is_supported(self):
result, args, oidc = self.run_publish(TEST_NPM_VERSION='11.5.1', TEST_NODE_VERSION='22.14.0')
self.assertEqual(result.returncode, 0, result.stderr)
self.assertIsNotNone(args)
self.assertTrue(oidc)
def test_project_or_environment_credentials_are_rejected(self):
for overrides in [{'project_config': True}, {'NPM_CONFIG__AUTH': 'synthetic-old-token'},
{'npm_config_userconfig': '/synthetic/legacy.npmrc'},
{'npm_config_USERCONFIG': '/synthetic/legacy.npmrc'},
{'Npm_Config_Globalconfig': '/synthetic/legacy.npmrc'}]:
with self.subTest(overrides=overrides):
result, args, oidc = self.run_publish(**overrides)
self.assertNotEqual(result.returncode, 0)
self.assertIsNone(args)
self.assertFalse(oidc)
def test_publish_failure_is_not_reported_as_success(self):
result, args, oidc = self.run_publish(TEST_PUBLISH_STATUS='9')
self.assertEqual(result.returncode, 9)
self.assertIsNotNone(args)
self.assertTrue(oidc)
self.assertNotIn('Successfully published', result.stdout)
if __name__ == '__main__':
unittest.main()