@tahminator/pipeline 1.0.103 → 1.0.104-beta.ge434d50a
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 +14 -0
- package/dist/docker/client.d.ts +5 -0
- package/dist/docker/client.js +9 -2
- package/dist/postgres/client.d.ts +2 -0
- package/dist/postgres/client.js +14 -1
- package/dist/postgres/types.d.ts +6 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -447,6 +447,8 @@ await client.buildImage({
|
|
|
447
447
|
tags: ["latest", "sha-abc123"], // define as many as you would like
|
|
448
448
|
platforms: ["linux/amd64", "linux/arm64"], // build for multiple platforms
|
|
449
449
|
buildArgs: { NODE_ENV: "production" }, // pass in build args
|
|
450
|
+
// read in the Dockerfile with `RUN --mount=type=secret,id=NPM_TOKEN`
|
|
451
|
+
secrets: { NPM_TOKEN: process.env.NPM_TOKEN! },
|
|
450
452
|
});
|
|
451
453
|
|
|
452
454
|
await client.buildImage({
|
|
@@ -550,6 +552,15 @@ With `INSTALL_PNPM: "true"`, set `PNPM_CACHE: "true"` to cache the pnpm store. `
|
|
|
550
552
|
INSTALL_MIGRATE: "true"
|
|
551
553
|
```
|
|
552
554
|
|
|
555
|
+
`INSTALL_GOLANGCI_LINT: "true"` installs the [golangci-lint](https://golangci-lint.run) linux-amd64 release binary to `/usr/local/bin`. Pin the version with `GOLANGCI_LINT_VERSION` (default `2.15.0`, without the `v` prefix).
|
|
556
|
+
|
|
557
|
+
```yaml
|
|
558
|
+
- uses: tahminator/pipeline/actions/setup@<version>
|
|
559
|
+
with:
|
|
560
|
+
INSTALL_GOLANGCI_LINT: "true"
|
|
561
|
+
GOLANGCI_LINT_VERSION: "2.15.0"
|
|
562
|
+
```
|
|
563
|
+
|
|
553
564
|
### `NPMClient`
|
|
554
565
|
|
|
555
566
|
Interface with NPM registry in order to publish packages to `npmjs.com`
|
|
@@ -763,12 +774,15 @@ Spin up a disposable local Postgres instance via Docker. Useful for running migr
|
|
|
763
774
|
|
|
764
775
|
Each call to `create()` gets a unique container name and a Docker-assigned host port, so multiple instances can coexist without conflict.
|
|
765
776
|
|
|
777
|
+
The container runs `postgres:16-alpine` by default. Pass `version` to choose another image, either a major (`18`) or a major.minor (`"18.1"`); versions below 16 are rejected.
|
|
778
|
+
|
|
766
779
|
```ts
|
|
767
780
|
import { $ } from "bun";
|
|
768
781
|
|
|
769
782
|
async function main() {
|
|
770
783
|
await using pgClient = await LocalPostgresClient.create({
|
|
771
784
|
database: "instalock-server-acceptance",
|
|
785
|
+
version: 18,
|
|
772
786
|
});
|
|
773
787
|
|
|
774
788
|
// get credentials
|
package/dist/docker/client.d.ts
CHANGED
|
@@ -35,6 +35,11 @@ export declare class DockerClient {
|
|
|
35
35
|
shouldUpload?: boolean;
|
|
36
36
|
platforms?: string[];
|
|
37
37
|
buildArgs?: Record<string, string | number | boolean>;
|
|
38
|
+
/**
|
|
39
|
+
* BuildKit secrets keyed by id, readable in the Dockerfile via `RUN --mount=type=secret,id=<id>`.
|
|
40
|
+
* Values are handed to `docker buildx build` through environment variables, so they never reach argv or disk.
|
|
41
|
+
*/
|
|
42
|
+
secrets?: Record<string, string>;
|
|
38
43
|
}): Promise<void>;
|
|
39
44
|
[Symbol.asyncDispose](): Promise<void>;
|
|
40
45
|
cleanup(): Promise<void>;
|
package/dist/docker/client.js
CHANGED
|
@@ -41,7 +41,7 @@ export class DockerClient {
|
|
|
41
41
|
console.log(`Promoted ${originalTag} to: ${newGithubTags.join(", ")}`);
|
|
42
42
|
}
|
|
43
43
|
async buildImage(args) {
|
|
44
|
-
const { dockerFileLocation, tags, dockerRepository, shouldUpload = true, platforms = ["linux/amd64"], buildArgs = {}, } = args;
|
|
44
|
+
const { dockerFileLocation, tags, dockerRepository, shouldUpload = true, platforms = ["linux/amd64"], buildArgs = {}, secrets = {}, } = args;
|
|
45
45
|
if (!tags.length) {
|
|
46
46
|
throw new Error("You must provide atleast one tag.");
|
|
47
47
|
}
|
|
@@ -65,16 +65,23 @@ export class DockerClient {
|
|
|
65
65
|
"--build-arg",
|
|
66
66
|
`${k}=${v.toString()}`,
|
|
67
67
|
]);
|
|
68
|
+
const secretEnv = {};
|
|
69
|
+
const secretFlags = Object.entries(secrets).flatMap(([id, value], i) => {
|
|
70
|
+
const envName = `PIPELINE_DOCKER_BUILD_SECRET_${i}`;
|
|
71
|
+
secretEnv[envName] = value;
|
|
72
|
+
return ["--secret", `id=${id},env=${envName}`];
|
|
73
|
+
});
|
|
68
74
|
await $ `docker buildx build ${buildModeFlag} \
|
|
69
75
|
--platform ${platforms.join(",")} \
|
|
70
76
|
--file ${dockerFileLocation} \
|
|
71
77
|
--cache-from=type=gha \
|
|
72
78
|
--cache-to=type=gha,mode=max \
|
|
73
79
|
${buildArgFlags} \
|
|
80
|
+
${secretFlags} \
|
|
74
81
|
--network host \
|
|
75
82
|
--allow network.host \
|
|
76
83
|
${tagFlags} \
|
|
77
|
-
|
|
84
|
+
.`.env({ ...process.env, ...secretEnv });
|
|
78
85
|
console.log(shouldUpload
|
|
79
86
|
? `Image build & successfully uploaded to ${this.username}/${dockerRepository}`
|
|
80
87
|
: "Image has been built (upload skipped.)");
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { PostgresInternalState, PostgresState } from "./types";
|
|
2
2
|
export declare class LocalPostgresClient {
|
|
3
3
|
private readonly iState;
|
|
4
|
+
private static readonly MIN_VERSION;
|
|
4
5
|
private constructor();
|
|
5
6
|
/**
|
|
6
7
|
* Spin up a local Postgres instance via Docker.
|
|
@@ -29,6 +30,7 @@ export declare class LocalPostgresClient {
|
|
|
29
30
|
* ```
|
|
30
31
|
*/
|
|
31
32
|
static create(state: PostgresState): Promise<LocalPostgresClient>;
|
|
33
|
+
private static resolveVersion;
|
|
32
34
|
private static launch;
|
|
33
35
|
private static waitUntilReady;
|
|
34
36
|
get state(): PostgresInternalState;
|
package/dist/postgres/client.js
CHANGED
|
@@ -2,6 +2,7 @@ import { $, randomUUIDv7 } from "bun";
|
|
|
2
2
|
import { Utils } from "../utils";
|
|
3
3
|
export class LocalPostgresClient {
|
|
4
4
|
iState;
|
|
5
|
+
static MIN_VERSION = 16;
|
|
5
6
|
constructor(iState) {
|
|
6
7
|
this.iState = iState;
|
|
7
8
|
}
|
|
@@ -34,6 +35,7 @@ export class LocalPostgresClient {
|
|
|
34
35
|
static async create(state) {
|
|
35
36
|
const iState = {
|
|
36
37
|
...state,
|
|
38
|
+
version: this.resolveVersion(state.version),
|
|
37
39
|
user: "postgres",
|
|
38
40
|
password: "postgres",
|
|
39
41
|
port: 5432,
|
|
@@ -45,6 +47,17 @@ export class LocalPostgresClient {
|
|
|
45
47
|
await this.waitUntilReady(iState);
|
|
46
48
|
return new this(iState);
|
|
47
49
|
}
|
|
50
|
+
static resolveVersion(version) {
|
|
51
|
+
if (version === undefined) {
|
|
52
|
+
return String(this.MIN_VERSION);
|
|
53
|
+
}
|
|
54
|
+
const resolved = String(version);
|
|
55
|
+
const match = resolved.match(/^(\d+)(\.\d+)?$/);
|
|
56
|
+
if (!match || Number(match[1]) < this.MIN_VERSION) {
|
|
57
|
+
throw new Error(`Unsupported Postgres version "${resolved}": expected a major or major.minor version of ${this.MIN_VERSION} or newer.`);
|
|
58
|
+
}
|
|
59
|
+
return resolved;
|
|
60
|
+
}
|
|
48
61
|
static async launch(iState) {
|
|
49
62
|
await $ `docker run -d \
|
|
50
63
|
--name ${iState.dockerName} \
|
|
@@ -52,7 +65,7 @@ export class LocalPostgresClient {
|
|
|
52
65
|
-e POSTGRES_PASSWORD=${iState.password} \
|
|
53
66
|
-e POSTGRES_DB=${iState.database} \
|
|
54
67
|
-p 5432 \
|
|
55
|
-
mirror.gcr.io/library/postgres
|
|
68
|
+
mirror.gcr.io/library/postgres:${iState.version}-alpine`;
|
|
56
69
|
const raw = (await $ `docker port ${iState.dockerName} 5432/tcp`.text()).trim();
|
|
57
70
|
const match = raw.match(/:(\d+)/);
|
|
58
71
|
if (!match) {
|
package/dist/postgres/types.d.ts
CHANGED
|
@@ -1,7 +1,13 @@
|
|
|
1
1
|
export interface PostgresState {
|
|
2
2
|
database: string;
|
|
3
|
+
/**
|
|
4
|
+
* Postgres image version, either a major (`18`) or a major.minor (`"18.1"`).
|
|
5
|
+
* Must be 16 or newer. Defaults to 16.
|
|
6
|
+
*/
|
|
7
|
+
version?: number | string;
|
|
3
8
|
}
|
|
4
9
|
export interface PostgresInternalState extends PostgresState {
|
|
10
|
+
version: string;
|
|
5
11
|
port: number;
|
|
6
12
|
host: string;
|
|
7
13
|
user: string;
|
package/package.json
CHANGED