|
1 |
| -import { testBlock } from "bingo-stratum-testers"; |
2 |
| -import { describe, expect, test } from "vitest"; |
| 1 | +import { testBlock, testIntake } from "bingo-stratum-testers"; |
| 2 | +import jsYaml from "js-yaml"; |
| 3 | +import { describe, expect, it, test } from "vitest"; |
3 | 4 |
|
4 | 5 | import { blockGitHubActionsCI } from "./blockGitHubActionsCI.js";
|
5 | 6 | import { optionsBase } from "./options.fakes.js";
|
@@ -565,4 +566,157 @@ describe("blockGitHubActionsCI", () => {
|
565 | 566 | }
|
566 | 567 | `);
|
567 | 568 | });
|
| 569 | + |
| 570 | + describe("intake", () => { |
| 571 | + it("returns undefined when action.yml does not exist", () => { |
| 572 | + const actual = testIntake(blockGitHubActionsCI, { |
| 573 | + files: {}, |
| 574 | + }); |
| 575 | + |
| 576 | + expect(actual).toBeUndefined(); |
| 577 | + }); |
| 578 | + |
| 579 | + it("returns undefined when action.yml contains invalid yml", () => { |
| 580 | + const actual = testIntake(blockGitHubActionsCI, { |
| 581 | + files: { |
| 582 | + ".github": { |
| 583 | + actions: { |
| 584 | + prepare: { |
| 585 | + "action.yml": ["invalid yml!"], |
| 586 | + }, |
| 587 | + }, |
| 588 | + }, |
| 589 | + }, |
| 590 | + }); |
| 591 | + |
| 592 | + expect(actual).toBeUndefined(); |
| 593 | + }); |
| 594 | + |
| 595 | + it("returns undefined when action.yml does not contain a runs entry", () => { |
| 596 | + const actual = testIntake(blockGitHubActionsCI, { |
| 597 | + files: { |
| 598 | + ".github": { |
| 599 | + actions: { |
| 600 | + prepare: { |
| 601 | + "action.yml": [ |
| 602 | + jsYaml.dump({ |
| 603 | + other: { |
| 604 | + steps: [], |
| 605 | + }, |
| 606 | + }), |
| 607 | + ], |
| 608 | + }, |
| 609 | + }, |
| 610 | + }, |
| 611 | + }, |
| 612 | + }); |
| 613 | + |
| 614 | + expect(actual).toBeUndefined(); |
| 615 | + }); |
| 616 | + |
| 617 | + it("returns undefined when action.yml runs steps is not an array", () => { |
| 618 | + const actual = testIntake(blockGitHubActionsCI, { |
| 619 | + files: { |
| 620 | + ".github": { |
| 621 | + actions: { |
| 622 | + prepare: { |
| 623 | + "action.yml": [ |
| 624 | + jsYaml.dump({ |
| 625 | + runs: { |
| 626 | + steps: true, |
| 627 | + }, |
| 628 | + }), |
| 629 | + ], |
| 630 | + }, |
| 631 | + }, |
| 632 | + }, |
| 633 | + }, |
| 634 | + }); |
| 635 | + |
| 636 | + expect(actual).toBeUndefined(); |
| 637 | + }); |
| 638 | + |
| 639 | + it("returns undefined env when action.yml contains a test action with actions/setup-node step", () => { |
| 640 | + const actual = testIntake(blockGitHubActionsCI, { |
| 641 | + files: { |
| 642 | + ".github": { |
| 643 | + actions: { |
| 644 | + prepare: { |
| 645 | + "action.yml": [ |
| 646 | + jsYaml.dump({ |
| 647 | + runs: { |
| 648 | + steps: [ |
| 649 | + { |
| 650 | + uses: "actions/other@v1", |
| 651 | + }, |
| 652 | + ], |
| 653 | + }, |
| 654 | + }), |
| 655 | + ], |
| 656 | + }, |
| 657 | + }, |
| 658 | + }, |
| 659 | + }, |
| 660 | + }); |
| 661 | + |
| 662 | + expect(actual).toBeUndefined(); |
| 663 | + }); |
| 664 | + |
| 665 | + it("returns undefined env when action.yml contains a test action with no env in its actions/setup-node step", () => { |
| 666 | + const actual = testIntake(blockGitHubActionsCI, { |
| 667 | + files: { |
| 668 | + ".github": { |
| 669 | + actions: { |
| 670 | + prepare: { |
| 671 | + "action.yml": [ |
| 672 | + jsYaml.dump({ |
| 673 | + runs: { |
| 674 | + steps: [ |
| 675 | + { |
| 676 | + uses: "actions/setup-node@v4", |
| 677 | + }, |
| 678 | + ], |
| 679 | + }, |
| 680 | + }), |
| 681 | + ], |
| 682 | + }, |
| 683 | + }, |
| 684 | + }, |
| 685 | + }, |
| 686 | + }); |
| 687 | + |
| 688 | + expect(actual).toBeUndefined(); |
| 689 | + }); |
| 690 | + |
| 691 | + it("returns nodeVersion when action.yml contains a test action with node-version in its actions/setup/node step", () => { |
| 692 | + const nodeVersion = "20.10.0"; |
| 693 | + |
| 694 | + const actual = testIntake(blockGitHubActionsCI, { |
| 695 | + files: { |
| 696 | + ".github": { |
| 697 | + actions: { |
| 698 | + prepare: { |
| 699 | + "action.yml": [ |
| 700 | + jsYaml.dump({ |
| 701 | + runs: { |
| 702 | + steps: [ |
| 703 | + { |
| 704 | + uses: "actions/setup-node@v4", |
| 705 | + with: { |
| 706 | + "node-version": nodeVersion, |
| 707 | + }, |
| 708 | + }, |
| 709 | + ], |
| 710 | + }, |
| 711 | + }), |
| 712 | + ], |
| 713 | + }, |
| 714 | + }, |
| 715 | + }, |
| 716 | + }, |
| 717 | + }); |
| 718 | + |
| 719 | + expect(actual).toEqual({ nodeVersion }); |
| 720 | + }); |
| 721 | + }); |
568 | 722 | });
|
0 commit comments