@akanjs/devkit 3.3.1-rc.0 → 3.4.0-rc.1
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/codeAgent/skills/akan-runtime/SKILL.md +1 -1
- package/executors/executors.test.ts +51 -44
- package/executors/pkgExecutor.ts +13 -10
- package/mobile/nativeApi.test.ts +2 -2
- package/mobile/nativeApi.ts +4 -3
- package/mobile/nativeApp.test.ts +105 -0
- package/mobile/nativeApp.ts +120 -3
- package/mobile/updatePackFolder.test.ts +5 -0
- package/mobile/updatePackFolder.ts +40 -4
- package/mobile/updateUploader.test.ts +41 -3
- package/mobile/updateUploader.ts +12 -4
- package/package.json +3 -4
- package/pipeline/PipelineCompiler.test.ts +270 -0
- package/pipeline/PipelineCompiler.ts +61 -20
- package/pipeline/PipelineDefinition.test.ts +25 -0
- package/pipeline/PipelineDefinition.ts +2 -1
- package/pipeline/PipelineDryRun.test.ts +54 -0
- package/pipeline/PipelineDryRun.ts +11 -4
- package/pipeline/PipelineInputReader.ts +42 -2
- package/pipeline/PipelineRules.ts +5 -1
- package/quality/runtimeImports.test.ts +1 -1
- package/workspace/dependencyScanner.test.ts +10 -0
- package/workspace/dependencyScanner.ts +1 -1
package/mobile/updateUploader.ts
CHANGED
|
@@ -29,6 +29,10 @@ export interface PublishedUpdate {
|
|
|
29
29
|
//* hash), so one the bucket holds is skipped; a manifest is always written.
|
|
30
30
|
export class UpdateUploader {
|
|
31
31
|
static readonly #manifest = /\.json(?:\.sig)?$/;
|
|
32
|
+
//? `<os>-<arch>/<channel>/releases/<bundle>.json`: a desktop release's envelope as it was signed, which `--republish`
|
|
33
|
+
//? reads back from the feed on a computer that never published it. Named by its bundle, it never changes either. Held
|
|
34
|
+
//? to that depth: a channel may itself be named `releases`, and its live envelope must still be written every time.
|
|
35
|
+
static readonly #kept = /^[^/]+\/[^/]+\/releases\/[^/]+\.json$/;
|
|
32
36
|
|
|
33
37
|
/** `s3://bucket/prefix`: the credentials and endpoint come from S3_* (or AWS_*) in the environment. */
|
|
34
38
|
static parseTarget(target: string): { bucket: string; prefix: string } {
|
|
@@ -38,9 +42,10 @@ export class UpdateUploader {
|
|
|
38
42
|
}
|
|
39
43
|
|
|
40
44
|
static order(files: string[]): { releases: string[]; manifests: string[] } {
|
|
41
|
-
const
|
|
45
|
+
const live = (file: string) => UpdateUploader.#manifest.test(file) && !UpdateUploader.#kept.test(file);
|
|
46
|
+
const manifests = files.filter(live);
|
|
42
47
|
return {
|
|
43
|
-
releases: files.filter((file) => !
|
|
48
|
+
releases: files.filter((file) => !live(file)).sort((a, b) => a.localeCompare(b)),
|
|
44
49
|
manifests: manifests.sort(
|
|
45
50
|
(a, b) => Number(a.endsWith(".json")) - Number(b.endsWith(".json")) || a.localeCompare(b),
|
|
46
51
|
),
|
|
@@ -61,8 +66,11 @@ export class UpdateUploader {
|
|
|
61
66
|
? UpdateUploader.#parse<UpdateManifest>(Buffer.from(envelope.manifest, "base64").toString("utf8"))
|
|
62
67
|
: null;
|
|
63
68
|
if (manifest?.bundle !== bundle) continue;
|
|
64
|
-
if (manifest.kind === "app")
|
|
65
|
-
|
|
69
|
+
if (manifest.kind === "app") {
|
|
70
|
+
const kept = `${channel}/releases/${bundle}.json`;
|
|
71
|
+
const history = (await Bun.file(path.join(dir, kept)).exists()) ? [kept] : [];
|
|
72
|
+
return [...UpdateUploader.#appFiles(manifest), ...history, ...pair, `${channel}/${name}`].map(keyOf);
|
|
73
|
+
}
|
|
66
74
|
const hashes = [...new Set(UpdateUploader.#field(manifest.files, "sha256"))];
|
|
67
75
|
if (!hashes.every((hash): hash is string => typeof hash === "string" && /^[0-9a-f]{64}$/.test(hash)))
|
|
68
76
|
throw new Error(
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@akanjs/devkit",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.4.0-rc.1",
|
|
4
4
|
"sourceType": "module",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"publishConfig": {
|
|
@@ -52,10 +52,10 @@
|
|
|
52
52
|
"./workspace/getRelatedCnsts": "./workspace/getRelatedCnsts.ts"
|
|
53
53
|
},
|
|
54
54
|
"dependencies": {
|
|
55
|
-
"@akanjs/language": "3.
|
|
55
|
+
"@akanjs/language": "3.4.0-rc.1",
|
|
56
56
|
"@inquirer/prompts": "^8.7.3",
|
|
57
57
|
"@tailwindcss/node": "^4.3.3",
|
|
58
|
-
"akanjs": "3.
|
|
58
|
+
"akanjs": "3.4.0-rc.1",
|
|
59
59
|
"chalk": "^6.0.1",
|
|
60
60
|
"commander": "^15.0.0",
|
|
61
61
|
"dayjs": "^1.11.23",
|
|
@@ -63,7 +63,6 @@
|
|
|
63
63
|
"fonteditor-core": "^2.6.3",
|
|
64
64
|
"ignore": "^7.0.12",
|
|
65
65
|
"ora": "^9.4.1",
|
|
66
|
-
"react-server-dom-webpack": "^19.3.1",
|
|
67
66
|
"subset-font": "^2.9.0",
|
|
68
67
|
"tailwind-scrollbar": "^4.0.2",
|
|
69
68
|
"tailwindcss": "^4.3.3",
|
|
@@ -550,6 +550,276 @@ describe("PipelineCompiler", () => {
|
|
|
550
550
|
});
|
|
551
551
|
});
|
|
552
552
|
|
|
553
|
+
describe("desktop-ota", () => {
|
|
554
|
+
const webTargets: Record<string, PipelineNativeTargets> = {
|
|
555
|
+
web: {
|
|
556
|
+
targets: [
|
|
557
|
+
{ name: "default", updates: true },
|
|
558
|
+
{ name: "pilot", updates: true },
|
|
559
|
+
{ name: "kiosk", updates: false },
|
|
560
|
+
],
|
|
561
|
+
},
|
|
562
|
+
};
|
|
563
|
+
const mac = { os: "macos", arch: "arm64" } as const;
|
|
564
|
+
const windows = { os: "windows", arch: "x64" } as const;
|
|
565
|
+
const desktopPhase = (plan: PipelinePlan) => plan.phases.find((phase) => phase.action === "desktop-ota");
|
|
566
|
+
|
|
567
|
+
test("is opt-in: zero-config and an app that takes only ota never pack a desktop update", () => {
|
|
568
|
+
expect(desktopPhase(planOf(compile({ nativeTargets: webTargets })))).toBeUndefined();
|
|
569
|
+
const phones = planOf(compile({ nativeTargets: webTargets, apps: { web: { stages: [{ use: "ota" }] } } }));
|
|
570
|
+
expect(desktopPhase(phones)).toBeUndefined();
|
|
571
|
+
});
|
|
572
|
+
|
|
573
|
+
test("runs after ota, one pack per target with updates and platform entry, with its own slot behind it", () => {
|
|
574
|
+
const plan = planOf(
|
|
575
|
+
compile({
|
|
576
|
+
nativeTargets: webTargets,
|
|
577
|
+
apps: {
|
|
578
|
+
web: {
|
|
579
|
+
stages: [
|
|
580
|
+
{ use: "build" },
|
|
581
|
+
{ use: "docker" },
|
|
582
|
+
{ use: "deploy" },
|
|
583
|
+
{ use: "ota" },
|
|
584
|
+
{ name: "Notify phones", sh: "echo phones" },
|
|
585
|
+
{ use: "desktop-ota", platforms: [mac, windows, { os: "linux", arch: "arm64" }] },
|
|
586
|
+
{ name: "Notify desktops", sh: "echo desktops" },
|
|
587
|
+
{ name: "Announce", sh: "echo released" },
|
|
588
|
+
],
|
|
589
|
+
},
|
|
590
|
+
},
|
|
591
|
+
}),
|
|
592
|
+
);
|
|
593
|
+
expect(phaseIds(plan)).toEqual([
|
|
594
|
+
"build",
|
|
595
|
+
"docker",
|
|
596
|
+
"deploy",
|
|
597
|
+
"ota",
|
|
598
|
+
"after-ota",
|
|
599
|
+
"desktop-ota",
|
|
600
|
+
"after-desktop-ota",
|
|
601
|
+
"after-desktop-ota-2",
|
|
602
|
+
]);
|
|
603
|
+
expect(desktopPhase(plan)).toMatchObject({
|
|
604
|
+
slot: "desktop-ota",
|
|
605
|
+
milestone: "deploy",
|
|
606
|
+
name: "Desktop OTA",
|
|
607
|
+
order: "parallel",
|
|
608
|
+
});
|
|
609
|
+
expect(desktopPhase(plan)?.stages).toEqual([
|
|
610
|
+
{
|
|
611
|
+
id: "web:desktop-ota",
|
|
612
|
+
name: "web",
|
|
613
|
+
description: null,
|
|
614
|
+
app: "web",
|
|
615
|
+
milestone: "deploy",
|
|
616
|
+
skip: null,
|
|
617
|
+
runtimeWhen: null,
|
|
618
|
+
allowFailure: false,
|
|
619
|
+
timeoutSeconds: null,
|
|
620
|
+
steps: [
|
|
621
|
+
{
|
|
622
|
+
id: "web:desktop-ota/desktop-ota",
|
|
623
|
+
name: "desktop ota web",
|
|
624
|
+
timeoutSeconds: null,
|
|
625
|
+
retry: null,
|
|
626
|
+
allowFailure: false,
|
|
627
|
+
kind: "action",
|
|
628
|
+
actionVersion: 1,
|
|
629
|
+
action: "desktop-ota",
|
|
630
|
+
with: {
|
|
631
|
+
app: "web",
|
|
632
|
+
targets: ["default", "pilot"],
|
|
633
|
+
platforms: [mac, windows, { os: "linux", arch: "arm64" }],
|
|
634
|
+
},
|
|
635
|
+
},
|
|
636
|
+
],
|
|
637
|
+
},
|
|
638
|
+
]);
|
|
639
|
+
const stagesOf = (id: string) => plan.phases.find((phase) => phase.id === id)?.stages.map((stage) => stage.id);
|
|
640
|
+
expect(stagesOf("after-ota")).toEqual(["web:notify-phones"]);
|
|
641
|
+
expect(stagesOf("after-desktop-ota")).toEqual(["web:notify-desktops"]);
|
|
642
|
+
expect(stagesOf("after-desktop-ota-2")).toEqual(["web:announce"]);
|
|
643
|
+
expect(plan.phases.find((phase) => phase.id === "after-desktop-ota")).toMatchObject({
|
|
644
|
+
slot: "after-desktop-ota",
|
|
645
|
+
name: "After desktop OTA",
|
|
646
|
+
milestone: "deploy",
|
|
647
|
+
action: null,
|
|
648
|
+
});
|
|
649
|
+
});
|
|
650
|
+
|
|
651
|
+
test("an app with no other action packs on its own, and named targets, retry and timeout are kept", () => {
|
|
652
|
+
const plan = planOf(
|
|
653
|
+
compile({
|
|
654
|
+
ctx: context({ apps: ["web"] }),
|
|
655
|
+
nativeTargets: webTargets,
|
|
656
|
+
apps: {
|
|
657
|
+
web: {
|
|
658
|
+
stages: [{ use: "desktop-ota", targets: ["pilot"], platforms: [windows], timeout: "30m", retry: 2 }],
|
|
659
|
+
},
|
|
660
|
+
},
|
|
661
|
+
}),
|
|
662
|
+
);
|
|
663
|
+
expect(phaseIds(plan)).toEqual(["desktop-ota"]);
|
|
664
|
+
expect(desktopPhase(plan)?.stages[0]).toMatchObject({ skip: null, timeoutSeconds: 1800 });
|
|
665
|
+
expect(desktopPhase(plan)?.stages[0]?.steps[0]).toMatchObject({
|
|
666
|
+
retry: { attempts: 2, delaySeconds: 0 },
|
|
667
|
+
with: { app: "web", targets: ["pilot"], platforms: [windows] },
|
|
668
|
+
});
|
|
669
|
+
});
|
|
670
|
+
|
|
671
|
+
test("is skipped with the app's earlier action, and takes when.changed like any action", () => {
|
|
672
|
+
const plan = planOf(
|
|
673
|
+
compile({
|
|
674
|
+
ctx: context({ branch: "develop", env: "develop", apps: ["web"] }),
|
|
675
|
+
nativeTargets: webTargets,
|
|
676
|
+
apps: {
|
|
677
|
+
web: {
|
|
678
|
+
stages: [
|
|
679
|
+
{ use: "build" },
|
|
680
|
+
{ use: "deploy", when: { branch: "main" } },
|
|
681
|
+
{ use: "desktop-ota", platforms: [mac], when: { changed: ["apps/web/**"] } },
|
|
682
|
+
],
|
|
683
|
+
},
|
|
684
|
+
},
|
|
685
|
+
}),
|
|
686
|
+
);
|
|
687
|
+
expect(desktopPhase(plan)?.stages[0]).toMatchObject({
|
|
688
|
+
skip: { reason: "deploy of web is skipped" },
|
|
689
|
+
runtimeWhen: { changed: ["apps/web/**"] },
|
|
690
|
+
});
|
|
691
|
+
});
|
|
692
|
+
|
|
693
|
+
test("never takes on the skip of ota, a separate release, but takes the one of the action before it", () => {
|
|
694
|
+
const lanes = (deploy: { branch: string } | undefined) =>
|
|
695
|
+
planOf(
|
|
696
|
+
compile({
|
|
697
|
+
ctx: context({ branch: "develop", env: "develop", apps: ["web"] }),
|
|
698
|
+
nativeTargets: webTargets,
|
|
699
|
+
apps: {
|
|
700
|
+
web: {
|
|
701
|
+
stages: [
|
|
702
|
+
{ use: "build" },
|
|
703
|
+
{ use: "deploy", ...(deploy ? { when: deploy } : {}) },
|
|
704
|
+
{ use: "ota", when: { branch: "release" } },
|
|
705
|
+
{ use: "desktop-ota", platforms: [mac] },
|
|
706
|
+
],
|
|
707
|
+
},
|
|
708
|
+
},
|
|
709
|
+
}),
|
|
710
|
+
);
|
|
711
|
+
const released = lanes(undefined);
|
|
712
|
+
expect(released.phases.find((phase) => phase.action === "ota")?.stages[0]?.skip).toEqual({
|
|
713
|
+
reason: 'branch "develop" does not match "release"',
|
|
714
|
+
});
|
|
715
|
+
expect(desktopPhase(released)?.stages[0]?.skip).toBeNull();
|
|
716
|
+
const undeployed = lanes({ branch: "main" });
|
|
717
|
+
expect(undeployed.phases.find((phase) => phase.action === "ota")?.stages[0]?.skip).toEqual({
|
|
718
|
+
reason: 'branch "develop" does not match "release"',
|
|
719
|
+
});
|
|
720
|
+
expect(desktopPhase(undeployed)?.stages[0]?.skip).toEqual({ reason: "deploy of web is skipped" });
|
|
721
|
+
const alone = planOf(
|
|
722
|
+
compile({
|
|
723
|
+
ctx: context({ branch: "develop", env: "develop", apps: ["web"] }),
|
|
724
|
+
nativeTargets: webTargets,
|
|
725
|
+
apps: {
|
|
726
|
+
web: {
|
|
727
|
+
stages: [
|
|
728
|
+
{ use: "ota", when: { branch: "release" } },
|
|
729
|
+
{ use: "desktop-ota", platforms: [mac] },
|
|
730
|
+
],
|
|
731
|
+
},
|
|
732
|
+
},
|
|
733
|
+
}),
|
|
734
|
+
);
|
|
735
|
+
expect(desktopPhase(alone)?.stages[0]?.skip).toBeNull();
|
|
736
|
+
});
|
|
737
|
+
|
|
738
|
+
test("a workspace stage may not take the id of its phase or of the slot behind it", () => {
|
|
739
|
+
for (const name of ["Desktop OTA", "After desktop OTA", "After desktop OTA 2"])
|
|
740
|
+
expect(codes(compile({ workspace: { before: [{ name, sh: "x" }] } }))).toEqual(["pipeline.id.reserved"]);
|
|
741
|
+
});
|
|
742
|
+
|
|
743
|
+
const desktopOta = (
|
|
744
|
+
stage: Record<string, unknown>,
|
|
745
|
+
nativeTargets: Record<string, PipelineNativeTargets> = webTargets,
|
|
746
|
+
) =>
|
|
747
|
+
compile({
|
|
748
|
+
ctx: context({ apps: ["web"] }),
|
|
749
|
+
nativeTargets,
|
|
750
|
+
apps: { web: { stages: [{ use: "desktop-ota", platforms: [mac], ...stage } as never] } },
|
|
751
|
+
});
|
|
752
|
+
|
|
753
|
+
test("refuses targets without native.updates, unknown targets, and apps whose targets could not be read", () => {
|
|
754
|
+
const without = desktopOta({ targets: ["default", "kiosk"] });
|
|
755
|
+
expect(without.ok).toBe(false);
|
|
756
|
+
expect(without.diagnostics).toEqual([
|
|
757
|
+
expect.objectContaining({ code: "pipeline.desktopOta.noUpdates", path: "pipeline.stages[0].targets" }),
|
|
758
|
+
]);
|
|
759
|
+
expect(without.diagnostics[0]?.message).toContain("`desktop-ota` packs updates");
|
|
760
|
+
expect(without.diagnostics[0]?.message).toContain('"kiosk"');
|
|
761
|
+
expect(codes(desktopOta({ targets: ["ghost"] }))).toEqual(["pipeline.desktopOta.unknownTarget"]);
|
|
762
|
+
expect(codes(desktopOta({}, { web: { targets: [{ name: "default", updates: false }] } }))).toEqual([
|
|
763
|
+
"pipeline.desktopOta.noUpdates",
|
|
764
|
+
]);
|
|
765
|
+
expect(codes(desktopOta({}, { web: { error: "boom" } }))).toEqual(["pipeline.desktopOta.targets"]);
|
|
766
|
+
expect(codes(desktopOta({}, {}))).toEqual(["pipeline.desktopOta.targets"]);
|
|
767
|
+
expect(codes(desktopOta({ targets: [] }))).toEqual(["pipeline.schema.invalid"]);
|
|
768
|
+
});
|
|
769
|
+
|
|
770
|
+
test("refuses a stage with no platforms, a platform listed twice, and a macOS x64 build", () => {
|
|
771
|
+
const refused = (platforms: unknown, code: string, path: string) => {
|
|
772
|
+
const result = desktopOta({ platforms });
|
|
773
|
+
expect(result.ok).toBe(false);
|
|
774
|
+
expect(result.diagnostics).toEqual([expect.objectContaining({ severity: "error", code, path })]);
|
|
775
|
+
return result.diagnostics[0]?.message;
|
|
776
|
+
};
|
|
777
|
+
const at = "pipeline.stages[0].platforms";
|
|
778
|
+
expect(refused(undefined, "pipeline.desktopOta.noPlatforms", at)).toContain("no default");
|
|
779
|
+
const untyped: AppPipelineConfig = {
|
|
780
|
+
// @ts-expect-error `platforms` is required: `desktop-ota` has no default
|
|
781
|
+
stages: [{ use: "desktop-ota" }],
|
|
782
|
+
};
|
|
783
|
+
expect(codes(compile({ nativeTargets: webTargets, apps: { web: untyped } }))).toEqual([
|
|
784
|
+
"pipeline.desktopOta.noPlatforms",
|
|
785
|
+
]);
|
|
786
|
+
refused([], "pipeline.desktopOta.noPlatforms", at);
|
|
787
|
+
expect(refused([mac, windows, { ...mac }], "pipeline.desktopOta.duplicatePlatform", `${at}[2]`)).toBe(
|
|
788
|
+
'{ os: "macos", arch: "arm64" } is listed twice',
|
|
789
|
+
);
|
|
790
|
+
expect(
|
|
791
|
+
refused([windows, { os: "macos", arch: "x64" }], "pipeline.desktopOta.unsupportedPlatform", `${at}[1]`),
|
|
792
|
+
).toContain("a macOS app is built for arm64 only");
|
|
793
|
+
expect(refused([{ os: "ios", arch: "arm64" }], "pipeline.schema.invalid", `${at}[0].os`)).toBe(
|
|
794
|
+
'"ios" is not one of macos, windows, linux',
|
|
795
|
+
);
|
|
796
|
+
expect(refused([mac, { os: "linux", arch: "ia32" }], "pipeline.schema.invalid", `${at}[1].arch`)).toBe(
|
|
797
|
+
'"ia32" is not one of arm64, x64',
|
|
798
|
+
);
|
|
799
|
+
refused(["macos"], "pipeline.schema.invalid", `${at}[0]`);
|
|
800
|
+
refused("macos", "pipeline.schema.invalid", at);
|
|
801
|
+
refused([{ ...mac, sign: true }], "pipeline.schema.unknownKey", `${at}[0].sign`);
|
|
802
|
+
});
|
|
803
|
+
|
|
804
|
+
test("keeps its own place and keys: once, after ota, and no platform objects on ota", () => {
|
|
805
|
+
const stages = (...list: Record<string, unknown>[]) =>
|
|
806
|
+
codes(
|
|
807
|
+
compile({
|
|
808
|
+
ctx: context({ apps: ["web"] }),
|
|
809
|
+
nativeTargets: webTargets,
|
|
810
|
+
apps: { web: { stages: list as never } },
|
|
811
|
+
}),
|
|
812
|
+
);
|
|
813
|
+
expect(stages({ use: "desktop-ota", platforms: [mac] }, { use: "ota" })).toEqual(["pipeline.action.order"]);
|
|
814
|
+
expect(stages({ use: "desktop-ota", platforms: [mac] }, { use: "desktop-ota", platforms: [windows] })).toContain(
|
|
815
|
+
"pipeline.action.duplicate",
|
|
816
|
+
);
|
|
817
|
+
expect(stages({ use: "ota", platforms: [mac] })).toContain("pipeline.schema.invalid");
|
|
818
|
+
expect(stages({ use: "desktop-ota", platforms: ["ios"] })).toEqual(["pipeline.schema.invalid"]);
|
|
819
|
+
expect(stages({ use: "desktop-ota", platforms: [mac], arch: "arm64" })).toContain("pipeline.schema.unknownKey");
|
|
820
|
+
});
|
|
821
|
+
});
|
|
822
|
+
|
|
553
823
|
test("the context is echoed, and an unknown or doubled app is refused rather than corrected", () => {
|
|
554
824
|
expect(planOf(compile({ ctx: context({ apps: ["web", "api"] }) })).context.apps).toEqual(["web", "api"]);
|
|
555
825
|
expect(codes(compile({ ctx: context({ apps: ["web", "web"] }) }))).toContain("pipeline.context.duplicateApp");
|
|
@@ -7,6 +7,7 @@ import {
|
|
|
7
7
|
} from "akanjs";
|
|
8
8
|
import {
|
|
9
9
|
type PipelineActionName,
|
|
10
|
+
type PipelineDesktopOtaPlatform,
|
|
10
11
|
type PipelineDiagnostic,
|
|
11
12
|
type PipelineMilestone,
|
|
12
13
|
type PipelineOtaPlatform,
|
|
@@ -56,7 +57,7 @@ export interface PipelineCompileInput {
|
|
|
56
57
|
workspaceApps: readonly string[];
|
|
57
58
|
workspace: PipelineSourceFile<WorkspacePipelineConfig> | null;
|
|
58
59
|
apps: ReadonlyMap<string, PipelineSourceFile<AppPipelineConfig>>;
|
|
59
|
-
/** Read only for an app whose pipeline takes `ota`. */
|
|
60
|
+
/** Read only for an app whose pipeline takes `ota` or `desktop-ota`. */
|
|
60
61
|
nativeTargets?: ReadonlyMap<string, PipelineNativeTargets>;
|
|
61
62
|
akanVersion: string;
|
|
62
63
|
/** Function forms run against a sample context (`validate`), which is said once per file. */
|
|
@@ -64,7 +65,9 @@ export interface PipelineCompileInput {
|
|
|
64
65
|
diagnostics?: readonly PipelineDiagnostic[];
|
|
65
66
|
}
|
|
66
67
|
|
|
67
|
-
type CustomSlot = "before-build" | "after-build" | "after-docker" | "after-deploy" | "after-ota";
|
|
68
|
+
type CustomSlot = "before-build" | "after-build" | "after-docker" | "after-deploy" | "after-ota" | "after-desktop-ota";
|
|
69
|
+
|
|
70
|
+
type OtaAction = Extract<PipelineActionName, "ota" | "desktop-ota">;
|
|
68
71
|
|
|
69
72
|
interface AppLane {
|
|
70
73
|
file: string;
|
|
@@ -74,6 +77,7 @@ interface AppLane {
|
|
|
74
77
|
skips: Map<PipelineActionName, PipelineSkip | null>;
|
|
75
78
|
slots: Record<CustomSlot, PipelineShellStageRule[]>;
|
|
76
79
|
ota: { targets: string[]; platforms: PipelineOtaPlatform[] } | null;
|
|
80
|
+
desktopOta: { targets: string[]; platforms: PipelineDesktopOtaPlatform[] } | null;
|
|
77
81
|
}
|
|
78
82
|
|
|
79
83
|
interface StageOptions {
|
|
@@ -94,6 +98,7 @@ export class PipelineCompiler {
|
|
|
94
98
|
docker: "after-docker",
|
|
95
99
|
deploy: "after-deploy",
|
|
96
100
|
ota: "after-ota",
|
|
101
|
+
"desktop-ota": "after-desktop-ota",
|
|
97
102
|
} as const;
|
|
98
103
|
static readonly #slotMilestones = {
|
|
99
104
|
"before-build": "prepare",
|
|
@@ -101,6 +106,7 @@ export class PipelineCompiler {
|
|
|
101
106
|
"after-docker": "package",
|
|
102
107
|
"after-deploy": "deploy",
|
|
103
108
|
"after-ota": "deploy",
|
|
109
|
+
"after-desktop-ota": "deploy",
|
|
104
110
|
} as const;
|
|
105
111
|
static readonly #slotNames = {
|
|
106
112
|
"before-build": "Before build",
|
|
@@ -108,10 +114,18 @@ export class PipelineCompiler {
|
|
|
108
114
|
"after-docker": "After docker",
|
|
109
115
|
"after-deploy": "After deploy",
|
|
110
116
|
"after-ota": "After OTA",
|
|
117
|
+
"after-desktop-ota": "After desktop OTA",
|
|
111
118
|
} as const;
|
|
112
119
|
static readonly #reservedPhaseId =
|
|
113
|
-
/^(?:build|docker|deploy|ota|(?:before-build|after-build|
|
|
114
|
-
static readonly #actionStepNames = {
|
|
120
|
+
/^(?:build|docker|deploy|ota|desktop-ota|(?:before-build|after-(?:build|docker|deploy|ota|desktop-ota))(?:-\d+)?)$/;
|
|
121
|
+
static readonly #actionStepNames = {
|
|
122
|
+
build: "akan build",
|
|
123
|
+
docker: "image",
|
|
124
|
+
deploy: "deploy",
|
|
125
|
+
ota: "ota",
|
|
126
|
+
"desktop-ota": "desktop ota",
|
|
127
|
+
} as const;
|
|
128
|
+
static readonly #otaCodes = { ota: "pipeline.ota", "desktop-ota": "pipeline.desktopOta" } as const;
|
|
115
129
|
//? PipelinePlanSchema reads at most 1024 characters of a skip reason.
|
|
116
130
|
static readonly #reasonChars = 1024;
|
|
117
131
|
|
|
@@ -265,8 +279,16 @@ export class PipelineCompiler {
|
|
|
265
279
|
after: rule.after,
|
|
266
280
|
actions: new Map(),
|
|
267
281
|
skips: new Map(),
|
|
268
|
-
slots: {
|
|
282
|
+
slots: {
|
|
283
|
+
"before-build": [],
|
|
284
|
+
"after-build": [],
|
|
285
|
+
"after-docker": [],
|
|
286
|
+
"after-deploy": [],
|
|
287
|
+
"after-ota": [],
|
|
288
|
+
"after-desktop-ota": [],
|
|
289
|
+
},
|
|
269
290
|
ota: null,
|
|
291
|
+
desktopOta: null,
|
|
270
292
|
};
|
|
271
293
|
let last: PipelineActionName | null = null;
|
|
272
294
|
let lastMilestone = -1;
|
|
@@ -320,7 +342,10 @@ export class PipelineCompiler {
|
|
|
320
342
|
deploy.path,
|
|
321
343
|
);
|
|
322
344
|
const ota = lane.actions.get("ota");
|
|
323
|
-
if (ota) lane.ota = this.#otaTargets(app, ota, file);
|
|
345
|
+
if (ota) lane.ota = this.#otaTargets(app, "ota", ota, file, ota.platforms ?? [...pipelineOtaPlatforms]);
|
|
346
|
+
const desktopOta = lane.actions.get("desktop-ota");
|
|
347
|
+
if (desktopOta)
|
|
348
|
+
lane.desktopOta = this.#otaTargets(app, "desktop-ota", desktopOta, file, desktopOta.desktopPlatforms);
|
|
324
349
|
if (!lane.actions.size)
|
|
325
350
|
this.#warning(
|
|
326
351
|
"pipeline.app.noActions",
|
|
@@ -334,19 +359,26 @@ export class PipelineCompiler {
|
|
|
334
359
|
if (!stage) continue;
|
|
335
360
|
const inherited = previous && lane.skips.get(previous) ? { reason: `${previous} of ${app} is skipped` } : null;
|
|
336
361
|
lane.skips.set(action, this.#skipOf(stage.when) ?? inherited);
|
|
337
|
-
|
|
362
|
+
//? A phone bundle and a desktop app are separate releases: `desktop-ota` never takes on `ota`'s skip.
|
|
363
|
+
if (action !== "ota") previous = action;
|
|
338
364
|
}
|
|
339
365
|
return lane;
|
|
340
366
|
}
|
|
341
367
|
|
|
342
|
-
//? Checked here, not by the executor: a pack for a target without updates fails
|
|
343
|
-
#otaTargets(
|
|
344
|
-
|
|
368
|
+
//? Checked here, not by the executor: a pack for a target without updates fails only where it runs, after its build.
|
|
369
|
+
#otaTargets<Platform>(
|
|
370
|
+
app: string,
|
|
371
|
+
action: OtaAction,
|
|
372
|
+
stage: PipelineActionStageRule,
|
|
373
|
+
file: string,
|
|
374
|
+
platforms: Platform[] | null,
|
|
375
|
+
): { targets: string[]; platforms: Platform[] } | null {
|
|
376
|
+
const code = PipelineCompiler.#otaCodes[action];
|
|
345
377
|
const native = this.#input.nativeTargets?.get(app);
|
|
346
378
|
if (!native || "error" in native) {
|
|
347
379
|
this.#error(
|
|
348
|
-
|
|
349
|
-
|
|
380
|
+
`${code}.targets`,
|
|
381
|
+
`\`${action}\` needs the native targets of ${app}, which could not be read${native ? `: ${native.error}` : ""}`,
|
|
350
382
|
file,
|
|
351
383
|
stage.path,
|
|
352
384
|
);
|
|
@@ -355,10 +387,10 @@ export class PipelineCompiler {
|
|
|
355
387
|
const known = new Map(native.targets.map((target) => [target.name, target.updates]));
|
|
356
388
|
if (!stage.targets) {
|
|
357
389
|
const targets = native.targets.filter((target) => target.updates).map((target) => target.name);
|
|
358
|
-
if (targets.length) return { targets, platforms };
|
|
390
|
+
if (targets.length) return platforms && { targets, platforms };
|
|
359
391
|
this.#error(
|
|
360
|
-
|
|
361
|
-
|
|
392
|
+
`${code}.noUpdates`,
|
|
393
|
+
`\`${action}\` packs updates for targets that declare native.updates, and no native target of ${app} does`,
|
|
362
394
|
file,
|
|
363
395
|
stage.path,
|
|
364
396
|
);
|
|
@@ -368,19 +400,19 @@ export class PipelineCompiler {
|
|
|
368
400
|
const withoutUpdates = stage.targets.filter((name) => known.get(name) === false);
|
|
369
401
|
if (unknown.length)
|
|
370
402
|
this.#error(
|
|
371
|
-
|
|
403
|
+
`${code}.unknownTarget`,
|
|
372
404
|
`${unknown.map((name) => `"${name}"`).join(", ")} ${unknown.length > 1 ? "are not native targets" : "is not a native target"} of ${app}: ${[...known.keys()].join(", ")}`,
|
|
373
405
|
file,
|
|
374
406
|
`${stage.path}.targets`,
|
|
375
407
|
);
|
|
376
408
|
if (withoutUpdates.length)
|
|
377
409
|
this.#error(
|
|
378
|
-
|
|
379
|
-
|
|
410
|
+
`${code}.noUpdates`,
|
|
411
|
+
`\`${action}\` packs updates for targets that declare native.updates, and ${withoutUpdates.map((name) => `"${name}"`).join(", ")} of ${app} ${withoutUpdates.length > 1 ? "do" : "does"} not`,
|
|
380
412
|
file,
|
|
381
413
|
`${stage.path}.targets`,
|
|
382
414
|
);
|
|
383
|
-
return unknown.length || withoutUpdates.length ? null : { targets: stage.targets, platforms };
|
|
415
|
+
return unknown.length || withoutUpdates.length || !platforms ? null : { targets: stage.targets, platforms };
|
|
384
416
|
}
|
|
385
417
|
|
|
386
418
|
#appOrder(lanes: ReadonlyMap<string, AppLane>): string[] {
|
|
@@ -461,7 +493,16 @@ export class PipelineCompiler {
|
|
|
461
493
|
actionVersion: pipelineActions[action].version,
|
|
462
494
|
...(action === "ota"
|
|
463
495
|
? { action, with: { app, targets: lane.ota?.targets ?? [], platforms: lane.ota?.platforms ?? [] } }
|
|
464
|
-
:
|
|
496
|
+
: action === "desktop-ota"
|
|
497
|
+
? {
|
|
498
|
+
action,
|
|
499
|
+
with: {
|
|
500
|
+
app,
|
|
501
|
+
targets: lane.desktopOta?.targets ?? [],
|
|
502
|
+
platforms: lane.desktopOta?.platforms ?? [],
|
|
503
|
+
},
|
|
504
|
+
}
|
|
505
|
+
: { action, with: { app } }),
|
|
465
506
|
},
|
|
466
507
|
],
|
|
467
508
|
},
|
|
@@ -79,6 +79,31 @@ describe("PipelineDefinition", () => {
|
|
|
79
79
|
);
|
|
80
80
|
});
|
|
81
81
|
|
|
82
|
+
test("an app's native targets are read when its pipeline takes ota or desktop-ota, and only then", async () => {
|
|
83
|
+
const updates = `{ url: "https://cdn.example.com/ota", publicKey: "${Buffer.alloc(32, 7).toString("base64")}" }`;
|
|
84
|
+
const native = `native: { targets: { store: { updates: ${updates} }, kiosk: {} } }`;
|
|
85
|
+
const appConfig = (stage: string) => `export default { ${native}, pipeline: { stages: [${stage}] } };\n`;
|
|
86
|
+
await withWorkspace(
|
|
87
|
+
{
|
|
88
|
+
"package.json": '{ "name": "repo", "version": "1.0.0" }\n',
|
|
89
|
+
"apps/desk/akan.config.ts": appConfig('{ use: "desktop-ota", platforms: [{ os: "linux", arch: "x64" }] }'),
|
|
90
|
+
"apps/phone/akan.config.ts": appConfig('{ use: "ota" }'),
|
|
91
|
+
"apps/web/akan.config.ts": appConfig('{ use: "build" }'),
|
|
92
|
+
},
|
|
93
|
+
async (workspace) => {
|
|
94
|
+
const definition = await PipelineDefinition.load(workspace, ["desk", "phone", "web"]);
|
|
95
|
+
const targets = [
|
|
96
|
+
{ name: "store", updates: true },
|
|
97
|
+
{ name: "kiosk", updates: false },
|
|
98
|
+
];
|
|
99
|
+
expect([...definition.nativeTargets]).toEqual([
|
|
100
|
+
["desk", { targets }],
|
|
101
|
+
["phone", { targets }],
|
|
102
|
+
]);
|
|
103
|
+
},
|
|
104
|
+
);
|
|
105
|
+
});
|
|
106
|
+
|
|
82
107
|
test("a config that cannot load is an error naming the file, never a silent default", async () => {
|
|
83
108
|
await withWorkspace(
|
|
84
109
|
{
|
|
@@ -60,7 +60,8 @@ export class PipelineDefinition {
|
|
|
60
60
|
static #mayTakeOta(pipeline: AppPipelineConfig | null) {
|
|
61
61
|
if (typeof pipeline === "function") return true;
|
|
62
62
|
const stages: unknown = pipeline?.stages;
|
|
63
|
-
|
|
63
|
+
const uses = Array.isArray(stages) ? stages.map((stage) => (stage as { use?: unknown } | null)?.use) : [];
|
|
64
|
+
return uses.includes("ota") || uses.includes("desktop-ota");
|
|
64
65
|
}
|
|
65
66
|
|
|
66
67
|
//? The whole app config, libs included: a target's `updates` may come from `native.updates` or its own section.
|
|
@@ -103,6 +103,60 @@ describe("PipelineDryRun", () => {
|
|
|
103
103
|
);
|
|
104
104
|
});
|
|
105
105
|
|
|
106
|
+
test("an ota and a desktop-ota stage say what they pack, a desktop build as os-arch", () => {
|
|
107
|
+
const result = PipelineCompiler.compile({
|
|
108
|
+
context: { ...context, apps: ["web"] },
|
|
109
|
+
workspaceApps: ["web"],
|
|
110
|
+
workspace: null,
|
|
111
|
+
apps: new Map([
|
|
112
|
+
[
|
|
113
|
+
"web",
|
|
114
|
+
{
|
|
115
|
+
file: "apps/web/akan.config.ts",
|
|
116
|
+
sha256: sha,
|
|
117
|
+
pipeline: {
|
|
118
|
+
stages: [
|
|
119
|
+
{ use: "ota", platforms: ["android"] },
|
|
120
|
+
{
|
|
121
|
+
use: "desktop-ota",
|
|
122
|
+
targets: ["store"],
|
|
123
|
+
platforms: [
|
|
124
|
+
{ os: "macos", arch: "arm64" },
|
|
125
|
+
{ os: "windows", arch: "x64" },
|
|
126
|
+
],
|
|
127
|
+
when: { branch: "main" },
|
|
128
|
+
},
|
|
129
|
+
],
|
|
130
|
+
},
|
|
131
|
+
},
|
|
132
|
+
],
|
|
133
|
+
]),
|
|
134
|
+
nativeTargets: new Map([
|
|
135
|
+
[
|
|
136
|
+
"web",
|
|
137
|
+
{
|
|
138
|
+
targets: [
|
|
139
|
+
{ name: "store", updates: true },
|
|
140
|
+
{ name: "pilot", updates: true },
|
|
141
|
+
],
|
|
142
|
+
},
|
|
143
|
+
],
|
|
144
|
+
]),
|
|
145
|
+
akanVersion: "3.0.3",
|
|
146
|
+
});
|
|
147
|
+
expect(PipelineDryRun.render(result)).toBe(
|
|
148
|
+
[
|
|
149
|
+
"plan v1 · branch develop · env develop · trigger push · apps web",
|
|
150
|
+
"from apps/web/akan.config.ts",
|
|
151
|
+
"",
|
|
152
|
+
"prepare (executor) checkout · env · install · plan",
|
|
153
|
+
"deploy ota OTA web (store, pilot × android) action ota",
|
|
154
|
+
'deploy desktop-ota Desktop OTA web (store × macos-arm64, windows-x64; skipped: branch "develop" does not match "main") action desktop-ota',
|
|
155
|
+
"finish (executor) cleanup",
|
|
156
|
+
].join("\n"),
|
|
157
|
+
);
|
|
158
|
+
});
|
|
159
|
+
|
|
106
160
|
test("a failed plan prints its diagnostics", () => {
|
|
107
161
|
const rendered = PipelineDryRun.render({
|
|
108
162
|
ok: false,
|
|
@@ -68,11 +68,8 @@ export class PipelineDryRun {
|
|
|
68
68
|
|
|
69
69
|
static #stage(phase: PipelinePlanPhase, stage: PipelinePlanStage) {
|
|
70
70
|
const label = stage.app && !phase.action && stage.name !== stage.app ? `${stage.app}:${stage.name}` : stage.name;
|
|
71
|
-
const ota = stage.steps.find((step) => step.kind === "action" && step.action === "ota");
|
|
72
71
|
const notes = [
|
|
73
|
-
|
|
74
|
-
? `${ota.with.targets.join(", ")} × ${ota.with.platforms.join(", ")}`
|
|
75
|
-
: null,
|
|
72
|
+
PipelineDryRun.#packs(stage),
|
|
76
73
|
stage.skip ? `skipped: ${stage.skip.reason}` : null,
|
|
77
74
|
stage.allowFailure ? "may fail" : null,
|
|
78
75
|
stage.runtimeWhen ? `if changed: ${stage.runtimeWhen.changed.join(", ")}` : null,
|
|
@@ -80,6 +77,16 @@ export class PipelineDryRun {
|
|
|
80
77
|
return notes.length ? `${label} (${notes.join("; ")})` : label;
|
|
81
78
|
}
|
|
82
79
|
|
|
80
|
+
static #packs(stage: PipelinePlanStage) {
|
|
81
|
+
for (const step of stage.steps) {
|
|
82
|
+
if (step.kind !== "action" || (step.action !== "ota" && step.action !== "desktop-ota")) continue;
|
|
83
|
+
const platforms =
|
|
84
|
+
step.action === "ota" ? step.with.platforms : step.with.platforms.map(({ os, arch }) => `${os}-${arch}`);
|
|
85
|
+
return `${step.with.targets.join(", ")} × ${platforms.join(", ")}`;
|
|
86
|
+
}
|
|
87
|
+
return null;
|
|
88
|
+
}
|
|
89
|
+
|
|
83
90
|
static diagnostics(diagnostics: readonly PipelineDiagnostic[]) {
|
|
84
91
|
return diagnostics.map((diagnostic) => {
|
|
85
92
|
const where = [diagnostic.file, diagnostic.path].filter(Boolean).join(" · ");
|