diff --git a/.github/workflows/check-dist.pkl b/.github/workflows/check-dist.pkl index 01cc554..b3a88a5 100644 --- a/.github/workflows/check-dist.pkl +++ b/.github/workflows/check-dist.pkl @@ -1,4 +1,5 @@ amends "package://pkg.pkl-lang.org/github.com/stefma/pkl-gha/com.github.action@0.0.3#/GitHubAction.pkl" +import "modules/Steps.pkl" // In TypeScript actions, `dist/` is a special directory. When you reference // an action with the `uses:` property, `dist/index.js` is the code that will be @@ -29,22 +30,7 @@ jobs { name = "Check Dist" `runs-on` = "ubuntu-latest" steps { - new { - name = "Checkout" - uses = "actions/checkout@v4" - } - new { - name = "Setup Node.js" - uses = "actions/setup-node@v4" - with { - ["node-version-file"] = ".nvmrc" - ["cache"] = "npm" - } - } - new { - name = "Install Dependencies" - run = "npm ci" - } + ...Steps.checkoutAndSetupNode(null) new { name = "Build dist/ Directory" run = "npm run bundle" diff --git a/.github/workflows/check-dist.yml b/.github/workflows/check-dist.yml index d9b0df1..c5ea2f3 100644 --- a/.github/workflows/check-dist.yml +++ b/.github/workflows/check-dist.yml @@ -16,7 +16,7 @@ jobs: steps: - name: Checkout uses: actions/checkout@v4 - - name: Setup Node.js + - name: Install node uses: actions/setup-node@v4 with: node-version-file: .nvmrc diff --git a/.github/workflows/ci.pkl b/.github/workflows/ci.pkl index 1ebc4c5..952e1de 100644 --- a/.github/workflows/ci.pkl +++ b/.github/workflows/ci.pkl @@ -1,4 +1,5 @@ amends "package://pkg.pkl-lang.org/github.com/stefma/pkl-gha/com.github.action@0.0.3#/GitHubAction.pkl" +import "modules/Steps.pkl" name = "Continuous Integration" @@ -20,22 +21,7 @@ jobs { name = "TypeScript Tests" `runs-on` = "ubuntu-latest" steps { - new { - name = "Checkout" - uses = "actions/checkout@v4" - } - new { - name = "Setup Node.js" - uses = "actions/setup-node@v4" - with { - ["node-version-file"] = ".nvmrc" - ["cache"] = "npm" - } - } - new { - name = "Install Dependencies" - run = "npm ci" - } + ...Steps.checkoutAndSetupNode(null) new { name = "Check Format" run = "npm run format:check" @@ -63,15 +49,12 @@ jobs { } `runs-on` = "${{ matrix.os }}" steps { - new { - name = "Checkout" - uses = "actions/checkout@v4" - } + Steps.checkout(null) new { name = "Test Local Action" uses = "./" with { - ["pkl-version"] = "0.26.0" + ["pkl-version"] = "0.26.3" } } new { diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 1512ed8..61273dc 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -16,7 +16,7 @@ jobs: steps: - name: Checkout uses: actions/checkout@v4 - - name: Setup Node.js + - name: Install node uses: actions/setup-node@v4 with: node-version-file: .nvmrc @@ -44,6 +44,6 @@ jobs: - name: Test Local Action uses: ./ with: - pkl-version: 0.26.0 + pkl-version: 0.26.3 - name: Confirm download run: pkl --version diff --git a/.github/workflows/linter.pkl b/.github/workflows/linter.pkl index 95bd7ae..115a343 100644 --- a/.github/workflows/linter.pkl +++ b/.github/workflows/linter.pkl @@ -1,4 +1,5 @@ amends "package://pkg.pkl-lang.org/github.com/stefma/pkl-gha/com.github.action@0.0.3#/GitHubAction.pkl" +import "modules/Steps.pkl" name = "Lint Codebase" @@ -22,25 +23,11 @@ jobs { name = "Lint Codebase" `runs-on` = "ubuntu-latest" steps { - new { - name = "Checkout" - uses = "actions/checkout@v4" - with { + ...Steps.checkoutAndSetupNode( + new Mapping { ["fetch-depth"] = 0 } - } - new { - name = "Setup Node.js" - uses = "actions/setup-node@v4" - with { - ["node-version-file"] = ".nvmrc" - ["cache"] = "npm" - } - } - new { - name = "Install Dependencies" - run = "npm ci" - } + ) new { name = "Lint Codebase" uses = "super-linter/super-linter/slim@v6" diff --git a/.github/workflows/linter.yml b/.github/workflows/linter.yml index 16a01b2..b66fac5 100644 --- a/.github/workflows/linter.yml +++ b/.github/workflows/linter.yml @@ -20,7 +20,7 @@ jobs: uses: actions/checkout@v4 with: fetch-depth: 0 - - name: Setup Node.js + - name: Install node uses: actions/setup-node@v4 with: node-version-file: .nvmrc diff --git a/.github/workflows/modules/Steps.pkl b/.github/workflows/modules/Steps.pkl index 279fe74..252c0db 100644 --- a/.github/workflows/modules/Steps.pkl +++ b/.github/workflows/modules/Steps.pkl @@ -1,8 +1,9 @@ import "package://pkg.pkl-lang.org/github.com/stefma/pkl-gha/com.github.action@0.0.3#/GitHubAction.pkl" -function checkout(): GitHubAction.Step = new { - name = "checkout" +function checkout(customWith: Mapping?): GitHubAction.Step = new { + name = "Checkout" uses = "actions/checkout@v4" + with = customWith } function installPkl(): GitHubAction.Step = new { @@ -13,7 +14,27 @@ function installPkl(): GitHubAction.Step = new { } } +function installNode(): GitHubAction.Step = new { + name = "Install node" + uses = "actions/setup-node@v4" + with { + ["node-version-file"] = ".nvmrc" + ["cache"] = "npm" + } +} + +function installNodeDeps(): GitHubAction.Step = new { + name = "Install Dependencies" + run = "npm ci" +} + function checkoutAndInstallPkl(): Listing = new { - checkout() + checkout(null) installPkl() +} + +function checkoutAndSetupNode(customCheckoutWith: Mapping?): Listing = new { + checkout(customCheckoutWith) + installNode() + installNodeDeps() } \ No newline at end of file