Compare commits

...
Author SHA1 Message Date
james.maesandCodex 69b94ecc8f fix: preserve verified source heads during Node snapshots
Co-Authored-By: Codex <noreply@openai.com>
2026-10-22 05:03:20 -05:00
6 changed files with 296 additions and 248 deletions

No files matched your search

+248 -238
View File
@@ -1,238 +1,248 @@
# Standardized QQQ pipelines # Standardized QQQ pipelines
The orb owns workflow selection and job configuration. A consumer declares a The orb owns workflow selection and job configuration. A consumer declares a
small manifest; it does not copy pipeline jobs. The initial supported profile is small manifest; it does not copy pipeline jobs. The initial supported profile is
`qbit`; `core` owns the framework's complete acceptance/release graph. Frontend `qbit`; `core` owns the framework's complete acceptance/release graph. Frontend
and CLI profiles described below retain their own publication contracts. Additional and CLI profiles described below retain their own publication contracts. Additional
profiles belong in reviewed `PROFILE_TEMPLATES` renderers in profiles belong in reviewed `PROFILE_TEMPLATES` renderers in
`src/scripts/generate_pipeline.py`, with profile-specific schema and tests. There `src/scripts/generate_pipeline.py`, with profile-specific schema and tests. There
is no arbitrary script or job-YAML passthrough. is no arbitrary script or job-YAML passthrough.
Use the same **published** orb version in all three positions below. `0.7.0` is Use the same **published** orb version in all three positions below. `0.7.0` is
an illustrative version, not a claim that this change is published. A development an illustrative version, not a claim that this change is published. A development
orb version can be used for a controlled canary. orb version can be used for a controlled canary.
`.circleci/config.yml`: `.circleci/config.yml`:
```yaml ```yaml
version: 2.1 version: 2.1
setup: true setup: true
orbs: orbs:
qqq-orb: kingsrook/qqq-orb@0.7.0 qqq-orb: kingsrook/qqq-orb@0.7.0
workflows: workflows:
setup: setup:
jobs: jobs:
- qqq-orb/generate_pipeline: - qqq-orb/generate_pipeline:
orb_version: "0.7.0" orb_version: "0.7.0"
filters: filters:
branches: branches:
ignore: automation/qbit-rc-pending ignore: automation/qbit-rc-pending
tags: tags:
only: /.*/ only: /.*/
``` ```
`.qqq-ci.yml`: `.qqq-ci.yml`:
```yaml ```yaml
profile: qbit profile: qbit
orb_version: "0.7.0" orb_version: "0.7.0"
default_branch: develop default_branch: develop
java_version: "21" java_version: "21"
browsers: false browsers: false
api_checks: false api_checks: false
docs_only: false docs_only: false
publish: publish:
snapshot: true snapshot: true
release_candidate: true release_candidate: true
release: true release: true
asciidoc: false asciidoc: false
``` ```
Only `profile`, `orb_version` and `default_branch` are required. `default_branch` Only `profile`, `orb_version` and `default_branch` are required. `default_branch`
must be `develop` or `main`; Java must be the string `17` or `21`. Browsers default must be `develop` or `main`; Java must be the string `17` or `21`. Browsers default
to **true** for compatibility: opt out only after verifying that the consumer has to **true** for compatibility: opt out only after verifying that the consumer has
no browser tests. API checks and docs-only default to false. Publication defaults no browser tests. API checks and docs-only default to false. Publication defaults
to true for snapshots, RCs and tagged releases; AsciiDoc publication defaults to to true for snapshots, RCs and tagged releases; AsciiDoc publication defaults to
false. Unknown/duplicate keys, unexpected types, unsupported profiles and a setup false. Unknown/duplicate keys, unexpected types, unsupported profiles and a setup
parameter/manifest version mismatch fail before continuation. The canonical-caller parameter/manifest version mismatch fail before continuation. The canonical-caller
validator also verifies the setup import, filters and profile-specific parameter validator also verifies the setup import, filters and profile-specific parameter
declarations; additional jobs, commands, workflows or orbs fail validation. The declarations; additional jobs, commands, workflows or orbs fail validation. The
parser is pinned to PyYAML 6.0.3 and uses its safe loader. parser is pinned to PyYAML 6.0.3 and uses its safe loader.
| Event | Workflow | Job contract | | Event | Workflow | Job contract |
| --- | --- | --- | | --- | --- | --- |
| develop | verify | existing mvn_publish, snapshot | | develop | verify | existing mvn_publish, snapshot |
| release/* | verify | existing mvn_publish, release_candidate | | release/* | verify | existing mvn_publish, release_candidate |
| vX.Y.Z tag resolving to the checkout | verify | existing mvn_publish, release | | vX.Y.Z tag resolving to the checkout | verify | existing mvn_publish, release |
| main, feature/*, hotfix/*, other/unknown branch | verify | existing mvn_test_only | | main, feature/*, hotfix/*, other/unknown branch | verify | existing mvn_test_only |
| Disabled publication or unrecognized/unproven tag | verify | full verification, no publication | | Disabled publication or unrecognized/unproven tag | verify | full verification, no publication |
Generated `qbit`, `core`, `frontend-core`, and `frontend-material` pipelines use Generated `qbit`, `core`, `frontend-core`, and `frontend-material` pipelines use
the stable workflow name `verify`. All selected jobs, dependencies and filters the stable workflow name `verify`. All selected jobs, dependencies and filters
remain intact; this adds no executor or duplicate build. Other profiles retain remain intact; this adds no executor or duplicate build. Other profiles retain
their existing workflow names and native checks. their existing workflow names and native checks.
When upgrading from legacy workflow names, upgrade the immutable RC worker pin When upgrading from legacy workflow names, upgrade the immutable RC worker pin
alongside the orb so finalization recognizes both names. Confirm the CircleCI alongside the orb so finalization recognizes both names. Confirm the CircleCI
app's successful `verify` check on the exact migration commit before replacing app's successful `verify` check on the exact migration commit before replacing
legacy required contexts. Require `setup` and `verify` on managed branches, legacy required contexts. Require `setup` and `verify` on managed branches,
preserving other required checks and controls. Human approval is not required; preserving other required checks and controls. Human approval is not required;
automated checks authorize the migration. automated checks authorize the migration.
The pipeline SHA must match the checkout when Circle supplies it. A tagged release The pipeline SHA must match the checkout when Circle supplies it. A tagged release
must resolve to that checkout; missing local tags are fetched individually. A main must resolve to that checkout; missing local tags are fetched individually. A main
push does **not** publish a release. Migrating a legacy main-publishing consumer push does **not** publish a release. Migrating a legacy main-publishing consumer
therefore requires explicit review of its release contract. Existing direct orb therefore requires explicit review of its release contract. Existing direct orb
callers remain supported. callers remain supported.
The setup filter and generated jobs exclude `automation/qbit-rc-pending`, the The setup filter and generated jobs exclude `automation/qbit-rc-pending`, the
shared RC orchestrator's persistent release lock. Lock updates must not trigger shared RC orchestrator's persistent release lock. Lock updates must not trigger
Maven test or publication work. Maven test or publication work.
The shared jobs keep the `qqq-maven-registry-credentials` context, complete verify, The shared jobs keep the `qqq-maven-registry-credentials` context, complete verify,
coverage and configured API checks. Publishing retains version management, signed coverage and configured API checks. Publishing retains version management, signed
artifact deployment, Git operations and release handling. Generated calls disable artifact deployment, Git operations and release handling. Generated calls disable
the redundant preliminary compile; they do not skip tests or verification. Existing the redundant preliminary compile; they do not skip tests or verification. Existing
callers retain the compatibility defaults in the jobs. callers retain the compatibility defaults in the jobs.
## Core profile ## Core profile
QBit alone accepts `release_completion: true` (default false). It enables the QBit alone accepts `release_completion: true` (default false). It enables the
shared Maven RC job's `notify_rc_published` only for RC publication, including shared Maven RC job's `notify_rc_published` only for RC publication, including
fail-closed verification that the bumped version was pushed before dispatching fail-closed verification that the bumped version was pushed before dispatching
the completion event. Enable this on a consumer only after its default branch the completion event. Enable this on a consumer only after its default branch
contains the shared completion caller. Snapshot and GA jobs never receive this contains the shared completion caller. Snapshot and GA jobs never receive this
opt-in; other profiles reject the key. opt-in; other profiles reject the key.
Use `profile: core` for the QQQ framework. The orb owns the complete baseline Use `profile: core` for the QQQ framework. The orb owns the complete baseline
acceptance, broker conformance, cold bootstrap, coverage, diagnostics, static acceptance, broker conformance, cold bootstrap, coverage, diagnostics, static
analysis and publication graph. Core scripts remain in the core source repository. analysis and publication graph. Core scripts remain in the core source repository.
The independent baseline fixture pins job sets, dependency edges, contexts, The independent baseline fixture pins job sets, dependency edges, contexts,
coverage requirements and actual verification commands across all six workflows. coverage requirements and actual verification commands across all six workflows.
Core additionally supports `publish.feature` and `publish.hotfix` (both true by Core additionally supports `publish.feature` and `publish.hotfix` (both true by
default), preserving `publish*` tag and hotfix branch publication. QBit supports default), preserving `publish*` tag and hotfix branch publication. QBit supports
both keys as explicit opt-ins (false by default). QBit feature publishing requires both keys as explicit opt-ins (false by default). QBit feature publishing requires
a `publish*` tag resolving to the checked-out commit; feature branch pushes remain a `publish*` tag resolving to the checked-out commit; feature branch pushes remain
test-only. Snapshot, RC and GA behavior remains distinct; RC/GA/hotfix test-only. Snapshot, RC and GA behavior remains distinct; RC/GA/hotfix
publication still requires the complete source coverage gate. Cold bootstrap and publication still requires the complete source coverage gate. Cold bootstrap and
fresh consumer Maven repositories remain uncached. Shared installer policy replaces fresh consumer Maven repositories remain uncached. Shared installer policy replaces
local package preparation; preliminary compilation is disabled before clean local package preparation; preliminary compilation is disabled before clean
lifecycles and the dependency cache is saved after successful verification. lifecycles and the dependency cache is saved after successful verification.
Lambda XML copies remain in sample coverage evidence. The sample JUnit collector Lambda XML copies remain in sample coverage evidence. The sample JUnit collector
excludes those two copied reports because their original module directories are excludes those two copied reports because their original module directories are
already uploaded, avoiding duplicate test identities without dropping evidence. already uploaded, avoiding duplicate test identities without dropping evidence.
External core API triggers require these declarations in the tiny **setup** config: External core API triggers require these declarations in the tiny **setup** config:
```yaml ```yaml
parameters: parameters:
mongo_bind_diagnostics: mongo_bind_diagnostics:
type: boolean type: boolean
default: false default: false
next_acceptance_bundle_url: next_acceptance_bundle_url:
type: string type: string
default: "" default: ""
next_acceptance_bundle_sha256: next_acceptance_bundle_sha256:
type: string type: string
default: "" default: ""
next_acceptance_receipt_sha256: next_acceptance_receipt_sha256:
type: string type: string
default: "" default: ""
``` ```
Forward each value on `qqq-orb/generate_pipeline`, for example Forward each value on `qqq-orb/generate_pipeline`, for example
`mongo_bind_diagnostics: << pipeline.parameters.mongo_bind_diagnostics >>`, and `mongo_bind_diagnostics: << pipeline.parameters.mongo_bind_diagnostics >>`, and
likewise for the three bundle parameters. Requested values become defaults in the likewise for the three bundle parameters. Requested values become defaults in the
continued configuration; the continuation POST deliberately omits `parameters` to continued configuration; the continuation POST deliberately omits `parameters` to
avoid CircleCI's setup/continuation/API parameter conflict. Verify both default and avoid CircleCI's setup/continuation/API parameter conflict. Verify both default and
explicit API-triggered parameter values in the hosted canary before migrating explicit API-triggered parameter values in the hosted canary before migrating
triggering consumers. Other profiles reject non-default core parameters. triggering consumers. Other profiles reject non-default core parameters.
## Frontend profiles ## Frontend profiles
`frontend-material` preserves the Maven frontend build/test/package/publication `frontend-material` preserves the Maven frontend build/test/package/publication
jobs, Java21/Node20 defaults, registry context, feature-tag, RC, GA and hotfix jobs, Java21/Node20 defaults, registry context, feature-tag, RC, GA and hotfix
contracts. Declare setup pipeline parameter `run_playwright` (boolean, default contracts. Declare setup pipeline parameter `run_playwright` (boolean, default
false) and forward `run_playwright: << pipeline.parameters.run_playwright >>` on false) and forward `run_playwright: << pipeline.parameters.run_playwright >>` on
the generator job. Test/snapshot events select exactly one base or Playwright graph, the generator job. Test/snapshot events select exactly one base or Playwright graph,
so enabling visual tests cannot publish twice. Visual testing retains the pinned so enabling visual tests cannot publish twice. Visual testing retains the pinned
Playwright image, npm ci with legacy peer dependencies and report uploads; only Playwright image, npm ci with legacy peer dependencies and report uploads; only
npm downloads (`~/.npm`) are cached, never node_modules. npm downloads (`~/.npm`) are cached, never node_modules.
`frontend-core` preserves Node24.21, npm trusted publishing and both existing `frontend-core` preserves Node24.21, npm trusted publishing and both existing
registry/build-sample contexts. Unlike QBit, its existing main-push **and v-tag** registry/build-sample contexts. Unlike QBit, its existing main-push **and v-tag**
release contract remains intentional. Both frontend profiles support explicit release contract remains intentional. Both frontend profiles support explicit
numeric-string `node_version` and publication toggles including feature/hotfix. numeric-string `node_version` and publication toggles including feature/hotfix.
Material also supports `java_version`. Browser/API/AsciiDoc flags are rejected Material also supports `java_version`. Browser/API/AsciiDoc flags are rejected
rather than silently ignored on these profiles. Existing direct jobs remain usable. rather than silently ignored on these profiles. Existing direct jobs remain usable.
## CLI profile ## CLI profile
`cli` owns npm install, generated-client drift, build, unit tests and the real `cli` owns npm install, generated-client drift, build, unit tests and the real
Prism smoke contract through `cli_verify_publish`. Publication is **disabled by Prism smoke contract through `cli_verify_publish`. Publication is **disabled by
default**. To enable the existing v-tag publication, declare `publish.release: default**. To enable the existing v-tag publication, declare `publish.release:
true` plus `publish_context: VERIFIED_CONTEXT_NAME`, after verifying that an true` plus `publish_context: VERIFIED_CONTEXT_NAME`, after verifying that an
existing trusted CircleCI context grants the required GitHub Packages permission. existing trusted CircleCI context grants the required GitHub Packages permission.
No context name or credential availability is inferred from the former Actions No context name or credential availability is inferred from the former Actions
GITHUB_TOKEN. A tag must resolve to the current checkout; the job additionally GITHUB_TOKEN. A tag must resolve to the current checkout; the job additionally
checks the client version before publishing its three fixed workspaces with the checks the client version before publishing its three fixed workspaces with the
existing rc dist-tag. Main pushes never publish. CLI docs-only is currently existing rc dist-tag. Main pushes never publish. CLI docs-only is currently
rejected because generated-client verification remains mandatory. rejected because generated-client verification remains mandatory.
## Conservative documentation routing ## Conservative documentation routing
With `docs_only: true`, only feature/hotfix and main changes can take the light With `docs_only: true`, only feature/hotfix and main changes can take the light
route. Feature/hotfix branches fetch the declared default branch without tags and route. Feature/hotfix branches fetch the declared default branch without tags and
compare its merge base with HEAD, covering the whole branch. Main compares its first compare its merge base with HEAD, covering the whole branch. Main compares its first
parent. Develop, release branches and all tags remain full. Shallow repositories, parent. Develop, release branches and all tags remain full. Shallow repositories,
missing ancestry, fetch/diff errors, empty diffs and unknown paths remain full. missing ancestry, fetch/diff errors, empty diffs and unknown paths remain full.
Only root README.md, CHANGELOG.md, CONTRIBUTING.md and Markdown files below docs/ Only root README.md, CHANGELOG.md, CONTRIBUTING.md and Markdown files below docs/
are eligible. Renames are treated as deletion plus addition, so moving code into are eligible. Renames are treated as deletion plus addition, so moving code into
docs cannot hide it. The lightweight job checks whitespace over the proven diff; docs cannot hide it. The lightweight job checks whitespace over the proven diff;
manifest validation already ran in setup. It adds no new security scanner and manifest validation already ran in setup. It adds no new security scanner and
makes no security-scanning claim. Keep docs-only disabled if those paths are build makes no security-scanning claim. Keep docs-only disabled if those paths are build
inputs or packaged application content. inputs or packaged application content.
The light route keeps workflow `verify` and names its job The light route keeps workflow `verify` and names its job
`qqq-orb/mvn_test_only`. Verify actual CircleCI/GitHub status contexts on the canary `qqq-orb/mvn_test_only`. Verify actual CircleCI/GitHub status contexts on the canary
before changing any protection rule; workflow/job identity alone is not proof of before changing any protection rule; workflow/job identity alone is not proof of
the hosted context name. Current protections must not be removed speculatively. the hosted context name. Current protections must not be removed speculatively.
## Implementation and verification ## Implementation and verification
The setup job checks out source, installs the pinned parser, runs the embedded The setup job checks out source, installs the pinned parser, runs the embedded
Python resource and invokes CircleCI's native continuation API once. JSON output Python resource and invokes CircleCI's native continuation API once. JSON output
is valid CircleCI configuration YAML; it is saved at is valid CircleCI configuration YAML; it is saved at
`/tmp/qqq-generated-config.json`. No external framework or per-consumer generator `/tmp/qqq-generated-config.json`. No external framework or per-consumer generator
installation is required. Readable templates live in src/scripts/templates. scripts/pack_pipeline.py embeds installation is required. Readable templates live in src/scripts/templates. scripts/pack_pipeline.py embeds
them as base64 into packed_generate_pipeline.py before orb packing, preventing them as base64 into packed_generate_pipeline.py before orb packing, preventing
CircleCI from interpolating template expressions during setup. The orb includes CircleCI from interpolating template expressions during setup. The orb includes
the complete generated resource; no runtime source-tree template access is needed. the complete generated resource; no runtime source-tree template access is needed.
make pack regenerates it and CI rejects a stale generated resource. make pack regenerates it and CI rejects a stale generated resource.
Continuation credentials and response bodies are never printed. Continuation credentials and response bodies are never printed.
Run `make test-pipelines` with CircleCI CLI, Python3/PyYAML and Bash available. Run `make test-pipelines` with CircleCI CLI, Python3/PyYAML and Bash available.
Tests use offline temporary Git repositories and a bare origin to cover selection, Tests use offline temporary Git repositories and a bare origin to cover selection,
whole-branch changes, tags, errors, defaults and source/packed parity. The hosted whole-branch changes, tags, errors, defaults and source/packed parity. The hosted
pipeline-contract-test runs the source suite and shared Maven behavioral tests; pipeline-contract-test runs the source suite and shared Maven behavioral tests;
the full local target additionally extracts and executes the actual packed command. the full local target additionally extracts and executes the actual packed command.
## Android and MCP policy profiles ## Node snapshot versions
`android` and `mcp-policy` accept only profile, orb_version and default_branch. The shared Node publisher calculates develop snapshots as
Android retains the audited Android/GCP orb versions and every active unit, `MAJOR.MINOR.NEXT_PATCH-SNAPSHOT.CIRCLE_BUILD_NUM`. A positive CircleCI job number
emulator and Maven-publication step. The emulator now runs on main as well as is required, so independent publication jobs receive distinct npm coordinates.
feature branches so main publication cannot omit its required instrumentation The package version is changed only in the build workspace and published under
gate. Dormant Firebase benchmark and release-build definitions referencing absent the `snapshot` dist-tag. No snapshot version commit is pushed: the branch remains
app/macrobenchmark modules are not scheduled or copied into the profile. at the source revision whose required checks ran, avoiding unchecked `[skip ci]`
heads and recursive publication. Stable, RC and hotfix version policies are unchanged.
MCP policy validation remains a small Python container validating all visible YAML
and required pattern fields. Its existing PyYAML dependency is pinned to 6.0.3. ## Android and MCP policy profiles
Neither profile introduces Maven/JUnit stand-ins for its actual tests.
`android` and `mcp-policy` accept only profile, orb_version and default_branch.
`tests/test_mobile_policy_profiles.py` protects Android steps and dependency edges Android retains the audited Android/GCP orb versions and every active unit,
and executes the policy validator with valid, incomplete and malformed documents. emulator and Maven-publication step. The emulator now runs on main as well as
The generator suite verifies source/packed parity for both profiles. feature branches so main publication cannot omit its required instrumentation
gate. Dormant Firebase benchmark and release-build definitions referencing absent
app/macrobenchmark modules are not scheduled or copied into the profile.
MCP policy validation remains a small Python container validating all visible YAML
and required pattern fields. Its existing PyYAML dependency is pinned to 6.0.3.
Neither profile introduces Maven/JUnit stand-ins for its actual tests.
`tests/test_mobile_policy_profiles.py` protects Android steps and dependency edges
and executes the policy validator with valid, incomplete and malformed documents.
The generator suite verifies source/packed parity for both profiles.
+1 -1
View File
@@ -3,7 +3,7 @@ description: >
- Adds SSH keys for Git operations - Adds SSH keys for Git operations
- Sets up Git identity for version commits - Sets up Git identity for version commits
- Synchronizes NPM version - Synchronizes NPM version
- Commits version changes if modified (skipped for feature branches) - Commits version changes if modified (skipped for feature and snapshot builds)
parameters: parameters:
branch_type: branch_type:
+1 -1
View File
@@ -64,7 +64,7 @@ echo "Publishing version: $VERSION"
if [[ "$VERSION" =~ -RC\.[0-9]+$ ]]; then if [[ "$VERSION" =~ -RC\.[0-9]+$ ]]; then
NPM_TAG="rc" NPM_TAG="rc"
echo "Detected RC version - using tag: $NPM_TAG" echo "Detected RC version - using tag: $NPM_TAG"
elif [[ "$VERSION" =~ -SNAPSHOT$ ]]; then elif [[ "$VERSION" =~ -SNAPSHOT(\.[1-9][0-9]*)?$ ]]; then
NPM_TAG="snapshot" NPM_TAG="snapshot"
echo "Detected SNAPSHOT version - using tag: $NPM_TAG" echo "Detected SNAPSHOT version - using tag: $NPM_TAG"
elif [[ "$VERSION" =~ -(alpha|beta) ]]; then elif [[ "$VERSION" =~ -(alpha|beta) ]]; then
+5 -5
View File
@@ -9,7 +9,7 @@
## It also pushes the changes back to the current branch. ## It also pushes the changes back to the current branch.
## ##
## Process: ## Process:
## 1. Skips for feature branches (ephemeral versions) ## 1. Skips for feature and snapshot builds (ephemeral versions)
## 2. Checks if package.json has been modified ## 2. Checks if package.json has been modified
## 3. Extracts the new version from package.json ## 3. Extracts the new version from package.json
## 4. Commits the changes with skip ci flag ## 4. Commits the changes with skip ci flag
@@ -22,12 +22,12 @@
set -e set -e
################################################################ ################################################################
## Skip version commit for feature branches ## ## Skip version commit for feature and snapshot builds ##
## Feature versions are ephemeral and don't need to be ## ## These versions are ephemeral and don't need to be ##
## persisted back to the repository ## ## persisted back to the repository ##
################################################################ ################################################################
if [[ "$BRANCH_TYPE" == "feature" ]]; then if [[ "$BRANCH_TYPE" == "feature" || "$BRANCH_TYPE" == "snapshot" ]]; then
echo "Skipping version commit for feature branch (ephemeral versions)" echo "Skipping version commit for $BRANCH_TYPE build (ephemeral version)"
exit 0 exit 0
fi fi
+7 -3
View File
@@ -28,13 +28,17 @@ if [[ "$CURRENT_BRANCH" == "main" ]]; then
TARGET_VERSION="$MAJOR_MINOR.0" TARGET_VERSION="$MAJOR_MINOR.0"
echo "Main branch detected - targeting release version: $TARGET_VERSION" echo "Main branch detected - targeting release version: $TARGET_VERSION"
elif [[ "$CURRENT_BRANCH" == "develop" ]]; then elif [[ "$CURRENT_BRANCH" == "develop" ]]; then
# Develop branch - should be a snapshot version (e.g., 1.0.127-SNAPSHOT) # Snapshot coordinates are unique per CI job without pushing a version commit.
# Increment patch version for develop # The source head stays the head whose required checks are being reported.
if [[ ! "${CIRCLE_BUILD_NUM:-}" =~ ^[1-9][0-9]*$ ]]; then
echo "ERROR: Snapshot publication requires a positive CIRCLE_BUILD_NUM" >&2
exit 1
fi
MAJOR_MINOR_PATCH="${NPM_VERSION%-*}" MAJOR_MINOR_PATCH="${NPM_VERSION%-*}"
MAJOR_MINOR="${MAJOR_MINOR_PATCH%.*}" MAJOR_MINOR="${MAJOR_MINOR_PATCH%.*}"
PATCH="${MAJOR_MINOR_PATCH##*.}" PATCH="${MAJOR_MINOR_PATCH##*.}"
NEW_PATCH=$((PATCH + 1)) NEW_PATCH=$((PATCH + 1))
TARGET_VERSION="$MAJOR_MINOR.$NEW_PATCH-SNAPSHOT" TARGET_VERSION="$MAJOR_MINOR.$NEW_PATCH-SNAPSHOT.$CIRCLE_BUILD_NUM"
echo "Develop branch detected - targeting snapshot version: $TARGET_VERSION" echo "Develop branch detected - targeting snapshot version: $TARGET_VERSION"
elif [[ "$CURRENT_BRANCH" == release/* ]]; then elif [[ "$CURRENT_BRANCH" == release/* ]]; then
# Release branch - should be a release candidate (e.g., 1.0.0-RC.1, 1.0.0-RC.2, etc.) # Release branch - should be a release candidate (e.g., 1.0.0-RC.1, 1.0.0-RC.2, etc.)
+34
View File
@@ -76,6 +76,7 @@ sys.exit(subprocess.run([os.environ['TEST_REAL_NODE'], *sys.argv[1:]], input=sou
def test_tags_and_legacy_authentication(self): def test_tags_and_legacy_authentication(self):
for trusted in [True, False]: for trusted in [True, False]:
for version, tag in [('1.0.0-RC.1', 'rc'), ('1.0.0-SNAPSHOT', 'snapshot'), for version, tag in [('1.0.0-RC.1', 'rc'), ('1.0.0-SNAPSHOT', 'snapshot'),
('1.0.0-SNAPSHOT.101', 'snapshot'),
('1.0.0-alpha.1', 'next'), ('1.0.0-beta.1', 'next'), ('1.0.0', 'latest')]: ('1.0.0-alpha.1', 'next'), ('1.0.0-beta.1', 'next'), ('1.0.0', 'latest')]:
with self.subTest(trusted=trusted, version=version): with self.subTest(trusted=trusted, version=version):
result, args, oidc = self.run_publish(version, trusted) result, args, oidc = self.run_publish(version, trusted)
@@ -133,5 +134,38 @@ sys.exit(subprocess.run([os.environ['TEST_REAL_NODE'], *sys.argv[1:]], input=sou
self.assertNotIn('Successfully published', result.stdout) self.assertNotIn('Successfully published', result.stdout)
class SnapshotVersionTests(unittest.TestCase):
def test_snapshot_jobs_keep_source_head_and_publish_distinct_versions(self):
with tempfile.TemporaryDirectory() as directory:
root = Path(directory)
def git(*args):
return subprocess.check_output(['git', *args], cwd=root, text=True).strip()
git('init', '-q', '-b', 'develop')
source = '{"name": "snapshot-test", "version": "0.40.27-SNAPSHOT"}\n'
package = root / 'package.json'
package.write_text(source)
git('add', 'package.json')
git('-c', 'user.name=Test', '-c', 'user.email=test@example.invalid',
'-c', 'commit.gpgsign=false', 'commit', '-qm', 'initial source')
head = git('rev-parse', 'HEAD')
for number in ('101', '102'):
package.write_text(source)
env = dict(os.environ, CIRCLE_BUILD_NUM=number, BRANCH_TYPE='snapshot')
subprocess.run(['bash', str(SCRIPT.parent / 'sync-npm-version.sh')],
cwd=root, env=env, check=True, capture_output=True)
self.assertEqual(json.loads(package.read_text())['version'], '0.40.28-SNAPSHOT.' + number)
subprocess.run(['bash', str(SCRIPT.parent / 'node_version_commit.sh')],
cwd=root, env=env, check=True, capture_output=True)
self.assertEqual(git('rev-parse', 'HEAD'), head)
self.assertEqual(git('diff', '--cached', '--name-only'), '')
for number in ('', '0', '01', '-1', 'abc'):
package.write_text(source)
result = subprocess.run(['bash', str(SCRIPT.parent / 'sync-npm-version.sh')],
cwd=root, env=dict(os.environ, CIRCLE_BUILD_NUM=number),
capture_output=True)
self.assertNotEqual(result.returncode, 0)
self.assertEqual(package.read_text(), source)
if __name__ == '__main__': if __name__ == '__main__':
unittest.main() unittest.main()