generated from actions/typescript-action
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use
pkl-gha
for GitHub Action Workflows (#47)
* Add pkl GitHub Action Workflows * Add pre-commit git hook * Fix setup-node actions * Fix lint * Add check-action * Extract steps to pkl module * Use pkl properties over functions * Rename generated yml files * Fix check-dist diff * Remove GitHub Actions from dependabot * Move pkl workflows to pkl-workflows dir * Inline checkoutAndInstallPkl in action * Remove bash script and inlineas npm script * Fix missing quotes * Update check-actions workflow * Remove old ci job * Fix gen:action script * Fix ci again * Fix trigger for check actions
- Loading branch information
Showing
15 changed files
with
438 additions
and
200 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
amends "package://pkg.pkl-lang.org/github.com/stefma/pkl-gha/[email protected]#/GitHubAction.pkl" | ||
import "modules/Steps.pkl" | ||
|
||
name = "Check Pkl Actions Converted" | ||
|
||
on { | ||
pull_request {} | ||
push { | ||
branches { | ||
"main" | ||
} | ||
} | ||
} | ||
|
||
permissions { | ||
contents = "read" | ||
} | ||
|
||
jobs { | ||
["check-actions"] { | ||
name = "Check Actions converted" | ||
`runs-on` = "ubuntu-latest" | ||
steps { | ||
...Steps.checkoutAndSetupNode | ||
new { | ||
name = "Install pkl" | ||
uses = "pkl-community/setup-pkl@v0" | ||
with { | ||
["pkl-version"] = "0.26.3" | ||
} | ||
} | ||
new { | ||
name = "Convert pkl actions to yaml" | ||
run = "npm run gen:actions" | ||
} | ||
new { | ||
name = "Verify if pkl actions are converted" | ||
run = "git diff --exit-code" | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
amends "package://pkg.pkl-lang.org/github.com/stefma/pkl-gha/[email protected]#/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 | ||
// run. For this project, the `dist/index.js` file is transpiled from other | ||
// source files. This workflow ensures the `dist/` directory contains the | ||
// expected transpiled code. | ||
// | ||
// If this workflow is run from a feature branch, it will act as an additional CI | ||
// check and fail if the checked-in `dist/` directory does not match what is | ||
// expected from the build. | ||
name = "Check Transpiled JavaScript" | ||
|
||
on { | ||
pull_request {} | ||
push { | ||
branches { | ||
"main" | ||
} | ||
} | ||
} | ||
|
||
permissions { | ||
contents = "read" | ||
} | ||
|
||
jobs { | ||
["check-dist"] { | ||
name = "Check Dist" | ||
`runs-on` = "ubuntu-latest" | ||
steps { | ||
...Steps.checkoutAndSetupNode | ||
new { | ||
name = "Install pkl" | ||
uses = "pkl-community/setup-pkl@v0" | ||
with { | ||
["pkl-version"] = "0.26.3" | ||
} | ||
} | ||
new { | ||
name = "Build dist/ Directory" | ||
run = "npm run bundle" | ||
} | ||
// This will fail the workflow if the PR wasn't created by Dependabot. | ||
new { | ||
name = "Compare Directories" | ||
id = "diff" | ||
run = """ | ||
if [ "$(git diff --ignore-space-at-eol --text dist/ | wc -l)" -gt "0" ]; then | ||
echo "Detected uncommitted changes after build. See status below:" | ||
git diff --ignore-space-at-eol --text dist/ | ||
exit 1 | ||
fi | ||
""" | ||
} | ||
new { | ||
name = "Upload Artifact" | ||
`if` = "${{ failure() && steps.diff.outcome == 'failure' }}" | ||
uses = "actions/upload-artifact@v4" | ||
with { | ||
["name"] = "dist" | ||
["path"] = "dist" | ||
} | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
amends "package://pkg.pkl-lang.org/github.com/stefma/pkl-gha/[email protected]#/GitHubAction.pkl" | ||
import "modules/Steps.pkl" | ||
|
||
name = "Continuous Integration" | ||
|
||
env { | ||
["CHECK_VERSION"] = "0.26.0" | ||
} | ||
|
||
on { | ||
pull_request {} | ||
push { | ||
branches { | ||
"main" | ||
} | ||
} | ||
} | ||
|
||
permissions { | ||
contents = "read" | ||
} | ||
|
||
jobs { | ||
["test-typescript"] { | ||
name = "TypeScript Tests" | ||
`runs-on` = "ubuntu-latest" | ||
steps { | ||
...Steps.checkoutAndSetupNode | ||
new { | ||
name = "Check Format" | ||
run = "npm run format:check" | ||
} | ||
new { | ||
name = "Lint" | ||
run = "npm run lint" | ||
} | ||
new { | ||
name = "Test" | ||
run = "npm run ci-test" | ||
} | ||
} | ||
} | ||
["test-action"] { | ||
strategy { | ||
matrix { | ||
["os"] = new { | ||
"ubuntu-latest" | ||
"macos-13" // macos-13 is amd64 | ||
"macos-14" // macos-14 is aarch64 (M1) | ||
"windows-latest" | ||
} | ||
} | ||
} | ||
`runs-on` = "${{ matrix.os }}" | ||
steps { | ||
Steps.checkout | ||
new { | ||
name = "Test Local Action" | ||
uses = "./" | ||
with { | ||
["pkl-version"] = "${{ env.CHECK_VERSION }}" | ||
} | ||
} | ||
new { | ||
name = "Confirm download (unix)" | ||
`if` = "matrix.os != 'windows-latest'" | ||
run = """ | ||
pkl --version | grep "Pkl ${{ env.CHECK_VERSION }}" | ||
""" | ||
} | ||
new { | ||
name = "Confirm download (windows)" | ||
`if` = "matrix.os == 'windows-latest'" | ||
run = """ | ||
.github/pkl-workflows/Check-Version.ps1 "Pkl ${{ env.CHECK_VERSION }}" | ||
""" | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
amends "package://pkg.pkl-lang.org/github.com/stefma/pkl-gha/[email protected]#/GitHubAction.pkl" | ||
import "modules/Steps.pkl" | ||
|
||
name = "Lint Codebase" | ||
|
||
on { | ||
pull_request {} | ||
push { | ||
branches { | ||
"main" | ||
} | ||
} | ||
} | ||
|
||
permissions { | ||
contents = "read" | ||
packages = "read" | ||
statuses = "write" | ||
} | ||
|
||
jobs { | ||
["test-typescript"] { | ||
name = "Lint Codebase" | ||
`runs-on` = "ubuntu-latest" | ||
steps { | ||
(Steps.checkout) { | ||
with { | ||
["fetch-depth"] = 0 | ||
} | ||
} | ||
Steps.installNode | ||
Steps.installNodeDeps | ||
new { | ||
name = "Lint Codebase" | ||
uses = "super-linter/super-linter/slim@v6" | ||
env { | ||
["DEFAULT_BRANCH"] = "main" | ||
["FILTER_REGEX_EXCLUDE"] = "dist/**/*" | ||
["GITHUB_TOKEN"] = "${{ secrets.GITHUB_TOKEN }}" | ||
["VALIDATE_ALL_CODEBASE"] = "true" | ||
["VALIDATE_JAVASCRIPT_STANDARD"] = "false" | ||
["VALIDATE_JSCPD"] = "false" | ||
["VALIDATE_TYPESCRIPT_STANDARD"] = "false" | ||
} | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import "package://pkg.pkl-lang.org/github.com/stefma/pkl-gha/[email protected]#/GitHubAction.pkl" | ||
|
||
checkout: GitHubAction.Step = new { | ||
name = "Checkout" | ||
uses = "actions/checkout@v4" | ||
} | ||
|
||
installNode: GitHubAction.Step = new { | ||
name = "Install node" | ||
uses = "actions/setup-node@v4" | ||
with { | ||
["node-version-file"] = ".nvmrc" | ||
["cache"] = "npm" | ||
} | ||
} | ||
|
||
installNodeDeps: GitHubAction.Step = new { | ||
name = "Install Dependencies" | ||
run = "npm ci" | ||
} | ||
|
||
checkoutAndSetupNode: Listing<GitHubAction.Step> = new { | ||
checkout | ||
installNode | ||
installNodeDeps | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
# Do not modify! | ||
# This file was generated from a template using https://github.com/StefMa/pkl-gha | ||
|
||
name: Check Pkl Actions Converted | ||
'on': | ||
pull_request: {} | ||
push: | ||
branches: | ||
- main | ||
permissions: | ||
contents: read | ||
jobs: | ||
check-actions: | ||
name: Check Actions converted | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
- name: Install node | ||
uses: actions/setup-node@v4 | ||
with: | ||
node-version-file: .nvmrc | ||
cache: npm | ||
- name: Install Dependencies | ||
run: npm ci | ||
- name: Install pkl | ||
uses: pkl-community/setup-pkl@v0 | ||
with: | ||
pkl-version: 0.26.3 | ||
- name: Convert pkl actions to yaml | ||
run: npm run gen:actions | ||
- name: Verify if pkl actions are converted | ||
run: git diff --exit-code |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
# Do not modify! | ||
# This file was generated from a template using https://github.com/StefMa/pkl-gha | ||
|
||
name: Check Transpiled JavaScript | ||
'on': | ||
pull_request: {} | ||
push: | ||
branches: | ||
- main | ||
permissions: | ||
contents: read | ||
jobs: | ||
check-dist: | ||
name: Check Dist | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
- name: Install node | ||
uses: actions/setup-node@v4 | ||
with: | ||
node-version-file: .nvmrc | ||
cache: npm | ||
- name: Install Dependencies | ||
run: npm ci | ||
- name: Install pkl | ||
uses: pkl-community/setup-pkl@v0 | ||
with: | ||
pkl-version: 0.26.3 | ||
- name: Build dist/ Directory | ||
run: npm run bundle | ||
- name: Compare Directories | ||
id: diff | ||
run: |- | ||
if [ "$(git diff --ignore-space-at-eol --text dist/ | wc -l)" -gt "0" ]; then | ||
echo "Detected uncommitted changes after build. See status below:" | ||
git diff --ignore-space-at-eol --text dist/ | ||
exit 1 | ||
fi | ||
- name: Upload Artifact | ||
if: ${{ failure() && steps.diff.outcome == 'failure' }} | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: dist | ||
path: dist |
Oops, something went wrong.