@vzn/vx-ci 0.0.644 → 0.0.646
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +1 -1
- package/README.md +13 -20
- package/package.json +2 -2
- package/src/cache-scope.ts +5 -5
- package/src/gitlab.ts +3 -3
- package/src/index.ts +26 -3
- package/src/plugin.ts +5 -5
package/LICENSE
CHANGED
package/README.md
CHANGED
|
@@ -8,7 +8,7 @@ page and names the run's cache scope; `gitlab()` names the run's cache
|
|
|
8
8
|
scope on GitLab CI ([below](#gitlab-ci)).
|
|
9
9
|
|
|
10
10
|
```sh
|
|
11
|
-
|
|
11
|
+
bun add -d @vzn/vx @vzn/vx-ci
|
|
12
12
|
```
|
|
13
13
|
|
|
14
14
|
```ts
|
|
@@ -50,7 +50,7 @@ github({
|
|
|
50
50
|
title: 'build & test', // default: 'vx run'
|
|
51
51
|
checks: true, // default: on with GITHUB_TOKEN; true warns when it is missing, false opts out
|
|
52
52
|
checkName: 'ci', // default: 'vx', the check run's name
|
|
53
|
-
cacheScope: false, // default: on; scope
|
|
53
|
+
cacheScope: false, // default: on; scope plugin cache entries by ref
|
|
54
54
|
})
|
|
55
55
|
```
|
|
56
56
|
|
|
@@ -59,26 +59,19 @@ github({
|
|
|
59
59
|
On Actions (`GITHUB_ACTIONS=true`) the plugin's `config` stage names the
|
|
60
60
|
run's branch through `ctx.setBranch`, from the ref (`GITHUB_REF`,
|
|
61
61
|
`GITHUB_REF_NAME`, `GITHUB_HEAD_REF`, `GITHUB_REPOSITORY`) and the
|
|
62
|
-
`GITHUB_EVENT_PATH` payload. A push to the default branch names no scope
|
|
63
|
-
|
|
62
|
+
`GITHUB_EVENT_PATH` payload. A push to the default branch names no scope.
|
|
63
|
+
A push to, or a pull request from, a branch names
|
|
64
64
|
`<owner>/<repo>:<branch>` of the repository the branch lives in, so a
|
|
65
65
|
fork's pull request names the fork; so does a `pull_request_target` or
|
|
66
66
|
`workflow_run` run on a PR's behalf (by `GITHUB_EVENT_NAME`, though its
|
|
67
67
|
ref is main's), and an `issue_comment` on a PR, which names no branch,
|
|
68
68
|
`pr-<n>`. A merge queue's run (`merge_group`) is trusted: no scope,
|
|
69
|
-
whatever its `gh-readonly-queue/...` branch,
|
|
70
|
-
the default keys (`x-vx-cache-scope: trusted`), compared with
|
|
69
|
+
whatever its `gh-readonly-queue/...` branch, compared with
|
|
71
70
|
`merge_group.base_sha`. A pull request also names its base commit
|
|
72
|
-
(`pull_request.base.sha`),
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
PR never writes what main reads, and a laptop on the branch derives the
|
|
77
|
-
same scope. Whether a run writes at all is `cache.policy`'s call.
|
|
78
|
-
`VX_CACHE_SCOPE` overrides it. This is a client-side convention: the
|
|
79
|
-
real boundary is a cache token the server limits, so give PR jobs one
|
|
80
|
-
that cannot write the default keys (`docs/security.md` § Cache
|
|
81
|
-
poisoning).
|
|
71
|
+
(`pull_request.base.sha`), the base of a bare `--affected`. The scope
|
|
72
|
+
keys only what plugins store themselves (`ctx.cache`, run records):
|
|
73
|
+
task keys never carry it, and the cache server decides from the CI OIDC
|
|
74
|
+
token where a task's entry lands. `VX_CACHE_SCOPE` overrides it.
|
|
82
75
|
|
|
83
76
|
## GitLab CI
|
|
84
77
|
|
|
@@ -99,10 +92,10 @@ subgroup's project is `group/sub/app:feat-x`, the scope a laptop on
|
|
|
99
92
|
`feat-x` derives. A merge request pipeline names its source branch
|
|
100
93
|
(`CI_MERGE_REQUEST_SOURCE_BRANCH_NAME`) in the project it lives in (a
|
|
101
94
|
fork's `CI_MERGE_REQUEST_SOURCE_PROJECT_PATH`) and its diff base
|
|
102
|
-
(`CI_MERGE_REQUEST_DIFF_BASE_SHA`),
|
|
103
|
-
|
|
104
|
-
builds what lands on the target, so it is trusted: no scope
|
|
105
|
-
|
|
95
|
+
(`CI_MERGE_REQUEST_DIFF_BASE_SHA`), the base of a bare `--affected`.
|
|
96
|
+
A merge train's pipeline (`CI_MERGE_REQUEST_EVENT_TYPE=merge_train`)
|
|
97
|
+
builds what lands on the target, so it is trusted: no scope. As on
|
|
98
|
+
Actions, the scope keys only plugin entries. `gitlab({ cacheScope: false })` (`GitlabPluginOptions`) turns it off;
|
|
106
99
|
`VX_CACHE_SCOPE` overrides it. Anywhere else `gitlab()` returns
|
|
107
100
|
`undefined`, so declaring both plugins is safe. Merge request comments
|
|
108
101
|
and reports are not part of it yet.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vzn/vx-ci",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.646",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "GitHub Actions and GitLab CI integration for vx — a job summary on Actions and the branch cache scope on both.",
|
|
6
6
|
"keywords": [
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
"access": "public"
|
|
35
35
|
},
|
|
36
36
|
"peerDependencies": {
|
|
37
|
-
"@vzn/vx": "^0.0.
|
|
37
|
+
"@vzn/vx": "^0.0.646"
|
|
38
38
|
},
|
|
39
39
|
"repository": {
|
|
40
40
|
"type": "git",
|
package/src/cache-scope.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// The cache scope and base commit a GitHub Actions run names through
|
|
2
|
-
// `setBranch`:
|
|
3
|
-
//
|
|
2
|
+
// `setBranch`: none on the default branch, a branch its own scope, the one
|
|
3
|
+
// a laptop on that branch derives (owner, 2026-10-17).
|
|
4
4
|
import { readFile } from 'node:fs/promises'
|
|
5
5
|
import { type BranchFacts, branchCacheScope } from '@vzn/vx'
|
|
6
6
|
|
|
@@ -13,10 +13,10 @@ import { type BranchFacts, branchCacheScope } from '@vzn/vx'
|
|
|
13
13
|
* derives. An event that runs in the default branch's context on a pull
|
|
14
14
|
* request's behalf (`pull_request_target`, `issue_comment` on a PR, a
|
|
15
15
|
* `workflow_run` a PR started) is the PR's, whatever `GITHUB_REF` says: a
|
|
16
|
-
* workflow that checks out the PR's head there would otherwise
|
|
17
|
-
*
|
|
16
|
+
* workflow that checks out the PR's head there would otherwise share main's
|
|
17
|
+
* scope. `issue_comment` names no branch, so it writes `pr-<n>`.
|
|
18
18
|
* A merge queue's run (`merge_group`) is trusted (owner, 2026-10-18): no
|
|
19
|
-
* scope,
|
|
19
|
+
* scope, compared with `merge_group.base_sha`.
|
|
20
20
|
* `base`: a pull request's base commit (`pull_request.base.sha`), what its
|
|
21
21
|
* merge checkout is compared with, no git call needed.
|
|
22
22
|
*/
|
package/src/gitlab.ts
CHANGED
|
@@ -14,9 +14,9 @@ import {
|
|
|
14
14
|
export interface GitlabPluginOptions {
|
|
15
15
|
/**
|
|
16
16
|
* Name the run's cache scope and base commit from GitLab's predefined
|
|
17
|
-
* variables: the default branch
|
|
18
|
-
*
|
|
19
|
-
*
|
|
17
|
+
* variables: none on the default branch or a merge train, else
|
|
18
|
+
* `<project path>:<branch>`; a merge request is compared with its diff
|
|
19
|
+
* base. The scope keys plugin entries only. `VX_CACHE_SCOPE` beats it.
|
|
20
20
|
* Default: on; `false` opts out.
|
|
21
21
|
*/
|
|
22
22
|
cacheScope?: boolean
|
package/src/index.ts
CHANGED
|
@@ -8,9 +8,32 @@
|
|
|
8
8
|
// On a GitHub Actions runner (GITHUB_STEP_SUMMARY set) every `vx run`
|
|
9
9
|
// appends a job summary: verdict, stats, failures, and the per-task table.
|
|
10
10
|
// Anywhere else the plugin declines and costs nothing.
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
11
|
+
import { createRequire } from 'node:module'
|
|
12
|
+
import type { RunSummaryRecord, VxPlugin } from '@vzn/vx'
|
|
13
|
+
import type { GithubPluginOptions } from './plugin.js'
|
|
14
|
+
import type { GitlabPluginOptions } from './gitlab.js'
|
|
15
|
+
|
|
16
|
+
export type { GithubPluginOptions, GitlabPluginOptions }
|
|
17
|
+
|
|
18
|
+
// Every run evaluates `.vx/workspace.ts`, and off CI both factories
|
|
19
|
+
// decline: this file is all a laptop loads (five files were ~1.1 ms of
|
|
20
|
+
// every run). Each module loads on its own CI, by `require` as the
|
|
21
|
+
// factories are synchronous.
|
|
22
|
+
const load = createRequire(import.meta.url)
|
|
23
|
+
|
|
24
|
+
export function github(options?: GithubPluginOptions): VxPlugin | undefined {
|
|
25
|
+
if (process.env['GITHUB_ACTIONS'] !== 'true') return undefined
|
|
26
|
+
return (load('./plugin.js') as typeof import('./plugin.js')).github(options)
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export function gitlab(options?: GitlabPluginOptions): VxPlugin | undefined {
|
|
30
|
+
if (process.env['GITLAB_CI'] !== 'true') return undefined
|
|
31
|
+
return (load('./gitlab.js') as typeof import('./gitlab.js')).gitlab(options)
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export function renderJobSummary(summary: RunSummaryRecord, title?: string): string {
|
|
35
|
+
return (load('./summary.js') as typeof import('./summary.js')).renderJobSummary(summary, title)
|
|
36
|
+
}
|
|
14
37
|
|
|
15
38
|
// The Checks API helpers are the plugin's own; only the transport type
|
|
16
39
|
// the options name is public (1.0 freezes what this file exports).
|
package/src/plugin.ts
CHANGED
|
@@ -40,11 +40,11 @@ export interface GithubPluginOptions {
|
|
|
40
40
|
/** Check-run name. Default: `'vx'`. */
|
|
41
41
|
checkName?: string
|
|
42
42
|
/**
|
|
43
|
-
* Name the run's cache scope and base commit from the Actions event:
|
|
44
|
-
*
|
|
45
|
-
* request
|
|
46
|
-
*
|
|
47
|
-
*
|
|
43
|
+
* Name the run's cache scope and base commit from the Actions event: none
|
|
44
|
+
* on the default branch, else `<owner>/<repo>:<branch>` (a fork's names
|
|
45
|
+
* the fork); a pull request is compared with its base commit. The scope
|
|
46
|
+
* keys plugin entries only. `VX_CACHE_SCOPE` beats it. Default: on;
|
|
47
|
+
* `false` opts out.
|
|
48
48
|
*/
|
|
49
49
|
cacheScope?: boolean
|
|
50
50
|
/** Test seam — inject the append. Defaults to fs appendFile. */
|