@tahminator/pipeline 1.0.105 → 1.0.106-beta.gb5ff7d24
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/README.md +19 -0
- package/dist/gh/client.d.ts +20 -0
- package/dist/gh/client.js +7 -0
- package/dist/gh/pr/index.d.ts +23 -0
- package/dist/gh/pr/index.js +38 -15
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -357,6 +357,14 @@ await client.sendPrMessage({
|
|
|
357
357
|
message: "Deployed and healthy.",
|
|
358
358
|
});
|
|
359
359
|
|
|
360
|
+
// returns the comment previously sent with `key` on this PR, or null if there is none
|
|
361
|
+
const existing = await client.getPrMessage({
|
|
362
|
+
owner: "tahminator",
|
|
363
|
+
repository: "pipeline",
|
|
364
|
+
prId: 123,
|
|
365
|
+
key: "deploy-status",
|
|
366
|
+
});
|
|
367
|
+
|
|
360
368
|
// uploads files as an artifact of the current workflow run; returns { id, url }
|
|
361
369
|
// requires the Actions runtime token, which the setup action exposes
|
|
362
370
|
await client.uploadArtifact({
|
|
@@ -538,6 +546,17 @@ Language toolchains are installed and cached by the setup action, so jobs don't
|
|
|
538
546
|
RUST_COMPONENTS: "clippy, rustfmt"
|
|
539
547
|
```
|
|
540
548
|
|
|
549
|
+
Go modules and the build cache are cached by setup-go under one key per Go version and `go.sum`, so every job shares one entry and only the first job to save it wins. Jobs that build differently, such as `-race` tests, can set `GO_CACHE_KEY` to save their own `GOMODCACHE` and `GOCACHE` entry with `actions/cache`. Setting it disables setup-go's built-in caching. `GO_CACHE_RESTORE_KEYS` optionally supplies newline-separated fallback prefixes.
|
|
550
|
+
|
|
551
|
+
```yaml
|
|
552
|
+
- uses: tahminator/pipeline/actions/setup@<version>
|
|
553
|
+
with:
|
|
554
|
+
INSTALL_GO: "true"
|
|
555
|
+
GO_CACHE_KEY: ${{ runner.os }}-${{ runner.arch }}-go-test-${{ hashFiles('**/go.sum') }}
|
|
556
|
+
GO_CACHE_RESTORE_KEYS: |
|
|
557
|
+
${{ runner.os }}-${{ runner.arch }}-go-test-
|
|
558
|
+
```
|
|
559
|
+
|
|
541
560
|
Java version and distribution are configurable with `JAVA_VERSION` and `JAVA_DISTRIBUTION`. For built-in dependency caching, `JAVA_CACHE` selects `maven` (default), `gradle`, or `sbt`; set it to `""` to disable built-in caching. `JAVA_CACHE_DEPENDENCY_PATH` accepts newline-separated dependency files/globs for the generated key, and `JAVA_CACHE_PATH` overrides the cached directories. Empty paths keep setup-java's defaults.
|
|
542
561
|
|
|
543
562
|
For an explicit cache key, set both `JAVA_CACHE_KEY` and `JAVA_CACHE_PATH`. This uses `actions/cache` and disables setup-java's built-in caching to avoid duplicate restore/save operations. `JAVA_CACHE_RESTORE_KEYS` optionally supplies newline-separated fallback prefixes. `JAVA_CACHE_DEPENDENCY_PATH` is ignored in this mode; compute dependency hashes in `JAVA_CACHE_KEY` yourself. Both cache modes require `INSTALL_JAVA: "true"`.
|
package/dist/gh/client.d.ts
CHANGED
|
@@ -107,6 +107,26 @@ export declare class GitHubClient {
|
|
|
107
107
|
performed_via_github_app?: import("@octokit/openapi-types").components["schemas"]["nullable-integration"];
|
|
108
108
|
reactions?: import("@octokit/openapi-types").components["schemas"]["reaction-rollup"];
|
|
109
109
|
}>;
|
|
110
|
+
/**
|
|
111
|
+
* Returns the comment previously posted by `sendPrMessage` with the same `key` on this PR, or
|
|
112
|
+
* `null` if there is none. The returned `body` still starts with the hidden key marker.
|
|
113
|
+
*/
|
|
114
|
+
getPrMessage(...args: Parameters<GitHubPRManager["getPrMessage"]>): Promise<{
|
|
115
|
+
id: number;
|
|
116
|
+
node_id: string;
|
|
117
|
+
url: string;
|
|
118
|
+
body?: string;
|
|
119
|
+
body_text?: string;
|
|
120
|
+
body_html?: string;
|
|
121
|
+
html_url: string;
|
|
122
|
+
user: import("@octokit/openapi-types").components["schemas"]["nullable-simple-user"];
|
|
123
|
+
created_at: string;
|
|
124
|
+
updated_at: string;
|
|
125
|
+
issue_url: string;
|
|
126
|
+
author_association: import("@octokit/openapi-types").components["schemas"]["author-association"];
|
|
127
|
+
performed_via_github_app?: import("@octokit/openapi-types").components["schemas"]["nullable-integration"];
|
|
128
|
+
reactions?: import("@octokit/openapi-types").components["schemas"]["reaction-rollup"];
|
|
129
|
+
} | null>;
|
|
110
130
|
/**
|
|
111
131
|
* Replaces the body of an existing PR comment, e.g. one returned by `sendPrMessage`.
|
|
112
132
|
*
|
package/dist/gh/client.js
CHANGED
|
@@ -123,6 +123,13 @@ export class GitHubClient {
|
|
|
123
123
|
sendPrMessage(...args) {
|
|
124
124
|
return this.prManager.sendPrMessage(...args);
|
|
125
125
|
}
|
|
126
|
+
/**
|
|
127
|
+
* Returns the comment previously posted by `sendPrMessage` with the same `key` on this PR, or
|
|
128
|
+
* `null` if there is none. The returned `body` still starts with the hidden key marker.
|
|
129
|
+
*/
|
|
130
|
+
getPrMessage(...args) {
|
|
131
|
+
return this.prManager.getPrMessage(...args);
|
|
132
|
+
}
|
|
126
133
|
/**
|
|
127
134
|
* Replaces the body of an existing PR comment, e.g. one returned by `sendPrMessage`.
|
|
128
135
|
*
|
package/dist/gh/pr/index.d.ts
CHANGED
|
@@ -124,6 +124,29 @@ export declare class GitHubPRManager {
|
|
|
124
124
|
performed_via_github_app?: import("@octokit/openapi-types").components["schemas"]["nullable-integration"];
|
|
125
125
|
reactions?: import("@octokit/openapi-types").components["schemas"]["reaction-rollup"];
|
|
126
126
|
}>;
|
|
127
|
+
getPrMessage({ prId, owner, repository, key, }: {
|
|
128
|
+
prId: number;
|
|
129
|
+
owner: string;
|
|
130
|
+
repository: string;
|
|
131
|
+
key: string;
|
|
132
|
+
}): Promise<{
|
|
133
|
+
id: number;
|
|
134
|
+
node_id: string;
|
|
135
|
+
url: string;
|
|
136
|
+
body?: string;
|
|
137
|
+
body_text?: string;
|
|
138
|
+
body_html?: string;
|
|
139
|
+
html_url: string;
|
|
140
|
+
user: import("@octokit/openapi-types").components["schemas"]["nullable-simple-user"];
|
|
141
|
+
created_at: string;
|
|
142
|
+
updated_at: string;
|
|
143
|
+
issue_url: string;
|
|
144
|
+
author_association: import("@octokit/openapi-types").components["schemas"]["author-association"];
|
|
145
|
+
performed_via_github_app?: import("@octokit/openapi-types").components["schemas"]["nullable-integration"];
|
|
146
|
+
reactions?: import("@octokit/openapi-types").components["schemas"]["reaction-rollup"];
|
|
147
|
+
} | null>;
|
|
148
|
+
private getPrMessageMarker;
|
|
149
|
+
private findPrMessage;
|
|
127
150
|
editPrMessage({ commentId, owner, repository, message, }: {
|
|
128
151
|
commentId: number;
|
|
129
152
|
owner: string;
|
package/dist/gh/pr/index.js
CHANGED
|
@@ -194,22 +194,21 @@ export class GitHubPRManager {
|
|
|
194
194
|
});
|
|
195
195
|
return data;
|
|
196
196
|
}
|
|
197
|
-
|
|
198
|
-
throw new Error("key must start with a letter or digit and contain only letters, digits, '_', '.', ':' or '-'");
|
|
199
|
-
}
|
|
200
|
-
const marker = `<!-- pipeline-pr-message:${key} -->`;
|
|
197
|
+
const marker = this.getPrMessageMarker(key);
|
|
201
198
|
const body = `${marker}\n${message}`;
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
199
|
+
const existing = await this.findPrMessage({
|
|
200
|
+
prId,
|
|
201
|
+
owner,
|
|
202
|
+
repository,
|
|
203
|
+
marker,
|
|
204
|
+
});
|
|
205
|
+
if (existing) {
|
|
206
|
+
return this.editPrMessage({
|
|
207
|
+
commentId: existing.id,
|
|
208
|
+
owner,
|
|
209
|
+
repository,
|
|
210
|
+
message: body,
|
|
211
|
+
});
|
|
213
212
|
}
|
|
214
213
|
const { data } = await this.client.rest.issues.createComment({
|
|
215
214
|
issue_number: prId,
|
|
@@ -219,6 +218,30 @@ export class GitHubPRManager {
|
|
|
219
218
|
});
|
|
220
219
|
return data;
|
|
221
220
|
}
|
|
221
|
+
async getPrMessage({ prId, owner, repository, key, }) {
|
|
222
|
+
return this.findPrMessage({
|
|
223
|
+
prId,
|
|
224
|
+
owner,
|
|
225
|
+
repository,
|
|
226
|
+
marker: this.getPrMessageMarker(key),
|
|
227
|
+
});
|
|
228
|
+
}
|
|
229
|
+
getPrMessageMarker(key) {
|
|
230
|
+
if (!/^[a-zA-Z0-9][a-zA-Z0-9_.:-]*$/.test(key)) {
|
|
231
|
+
throw new Error("key must start with a letter or digit and contain only letters, digits, '_', '.', ':' or '-'");
|
|
232
|
+
}
|
|
233
|
+
return `<!-- pipeline-pr-message:${key} -->`;
|
|
234
|
+
}
|
|
235
|
+
async findPrMessage({ prId, owner, repository, marker, }) {
|
|
236
|
+
for await (const { data: comments } of this.client.paginate.iterator(this.client.rest.issues.listComments, { owner, repo: repository, issue_number: prId, per_page: 100 })) {
|
|
237
|
+
const existing = comments.find((comment) => comment.user?.type === "Bot" &&
|
|
238
|
+
comment.body?.startsWith(`${marker}\n`));
|
|
239
|
+
if (existing) {
|
|
240
|
+
return existing;
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
return null;
|
|
244
|
+
}
|
|
222
245
|
async editPrMessage({ commentId, owner, repository, message, }) {
|
|
223
246
|
const { data } = await this.client.rest.issues.updateComment({
|
|
224
247
|
comment_id: commentId,
|
package/package.json
CHANGED