Skip to content

Fmt

Fmt #79

# yaml-language-server: $schema=https://json.schemastore.org/github-workflow.json
name: "Review Deno Code"
on:
pull_request:
branches:
- "**"
types:
- "edited"
- "opened"
- "reopened"
- "synchronize"
push:
branches:
- "**"
workflow_dispatch:
jobs:
main:
name: "${{matrix.run_on}}"
if: "${{!(github.event_name == 'pull_request' && github.event.pull_request.head.repo.id == github.event.pull_request.base.repo.id)}}"
permissions:
contents: "read"
strategy:
matrix:
run_on:
- "macos-latest"
- "ubuntu-latest"
- "windows-latest"
fail-fast: false
runs-on: "${{matrix.run_on}}"
env:
CDV_RUN_LITE: "${{matrix.run_on != 'ubuntu-latest'}}"
steps:
- name: "Checkout Repository"
uses: "actions/checkout@v5"
- name: "Setup Deno"
uses: "denoland/setup-deno@v2"
with:
deno-version: "^2.4.5"
- name: "Setup NodeJS"
uses: "actions/setup-node@v4"
with:
node-version: "lts/*"
check-latest: true
- name: "Get Cache Path"
shell: "pwsh"
run: |-
[PSCustomObject]$DenoInfo = ConvertFrom-Json -InputObject (
deno info --json |
Join-String -Separator "`n"
) -Depth 100
Add-Content -LiteralPath $Env:GITHUB_ENV -Value "CDV_DENO_CACHE_PATH_ROOT=$($DenoInfo.denoDir)" -Confirm:$False -Encoding 'UTF8NoBOM'
Add-Content -LiteralPath $Env:GITHUB_ENV -Value "CDV_DENO_CACHE_PATH_FLUSHES=$(ConvertTo-Json -InputObject @(
$DenoInfo.typescriptCache
) -Depth 100 -Compress)" -Confirm:$False -Encoding 'UTF8NoBOM'
[String]$NpmCachePath = (
npm config get cache |
Join-String -Separator "`n"
).Trim()
Add-Content -LiteralPath $Env:GITHUB_ENV -Value "CDV_NPM_CACHE_PATH_ROOT=$($NpmCachePath)" -Confirm:$False -Encoding 'UTF8NoBOM'
Add-Content -LiteralPath $Env:GITHUB_ENV -Value "CDV_NPM_CACHE_PATH_FLUSHES=$(ConvertTo-Json -InputObject @(
(Join-Path -Path $NpmCachePath -ChildPath '_logs')
) -Depth 100 -Compress)" -Confirm:$False -Encoding 'UTF8NoBOM'
- name: "Load Deno Cache"
uses: "actions/cache/restore@v4"
with:
key: "${{runner.os}}/Deno/${{github.run_id}}/${{github.run_attempt}}/${{github.job}}"
restore-keys: |-
${{runner.os}}/Deno/${{github.run_id}}/${{github.run_attempt}}/
${{runner.os}}/Deno/${{github.run_id}}/
${{runner.os}}/Deno/
path: "${{env.CDV_DENO_CACHE_PATH_ROOT}}"
- name: "Load NPM Cache"
uses: "actions/cache/restore@v4"
with:
key: "${{runner.os}}/NPM/${{github.run_id}}/${{github.run_attempt}}/${{github.job}}"
restore-keys: |-
${{runner.os}}/NPM/${{github.run_id}}/${{github.run_attempt}}/
${{runner.os}}/NPM/${{github.run_id}}/
${{runner.os}}/NPM/
path: "${{env.CDV_NPM_CACHE_PATH_ROOT}}"
- name: "Analyze Repository"
id: "analyze"
shell: "pwsh"
run: |-
[PSCustomObject]$Config = ConvertFrom-Json -InputObject (Get-Content -LiteralPath '.\deno.jsonc' -Raw -Encoding 'UTF8NoBOM') -Depth 100
[Boolean]$Build = $Null -ine $Config.tasks.build
[Boolean]$JSRCheck = $Null -ine $Config.tasks.'jsr-check'
[Boolean]$JSRPublish = $Null -ine $Config.tasks.'jsr-publish'
[Boolean]$NPMBuild = $Null -ine $Config.tasks.'npm-build'
[Boolean]$NPMCheck = $Null -ine $Config.tasks.'npm-check'
[Boolean]$NPMDistributionRelative = $Null -ine $Config.tasks.'npm-var-distribution-relative'
[Boolean]$NPMPublish = $Null -ine $Config.tasks.'npm-publish'
If ($Env:CDV_RUN_LITE -ieq 'false') {
Add-Content -LiteralPath $Env:GITHUB_STEP_SUMMARY -Value @"
# Dispatch
- **Build:** $($Build ? '✔️' : '❌')
- **JSR:**
- **Check:** $($JSRCheck ? '✔️' : '❌')
- **Publish:** $($JSRPublish ? '✔️' : '❌')
- **NPM:**
- **Build:** $($NPMBuild ? '✔️' : '❌')
- **Check:** $($NPMCheck ? '✔️' : '❌')
- **DistributionRelative:** $($NPMDistributionRelative ? '✔️' : '❌')
- **Publish:** $($NPMPublish ? '✔️' : '❌')
"@
}
Add-Content -LiteralPath $Env:GITHUB_ENV -Value "CDV_BUILD=$($Build.ToString().ToLower())"
Add-Content -LiteralPath $Env:GITHUB_ENV -Value "CDV_JSR_CHECK=$($JSRCheck.ToString().ToLower())"
Add-Content -LiteralPath $Env:GITHUB_ENV -Value "CDV_NPM_BUILD=$($NPMBuild.ToString().ToLower())"
Add-Content -LiteralPath $Env:GITHUB_ENV -Value "CDV_NPM_CHECK=$($NPMCheck.ToString().ToLower())"
- name: "Check Repository"
if: "${{!cancelled() && steps.analyze.outcome == 'success' && env.CDV_RUN_LITE == 'false'}}"
shell: "pwsh"
run: |-
[String[]]$FilesForbid = Get-ChildItem -LiteralPath '.\' -Include @('*.js', '*.jsx', '*.mjs', '*.mts') -File -Recurse -Name
If ($FilesForbid.Count -gt 0) {
Write-Error -Message "Repository contains forbid file formats (``.js``, ``.jsx``, ``.mjs``, ``.mts``): $(
$FilesForbid |
Join-String -Separator ', '
)" -ErrorAction 'Stop'
}
- name: "Lint Code"
if: "${{!cancelled() && steps.analyze.outcome == 'success' && env.CDV_RUN_LITE == 'false'}}"
run: |-
deno lint --permit-no-files
- name: "Check Dependencies Update"
if: "${{!cancelled() && steps.analyze.outcome == 'success' && env.CDV_RUN_LITE == 'false'}}"
run: |-
deno outdated
- name: "Build Repository"
if: "${{!cancelled() && steps.analyze.outcome == 'success' && env.CDV_BUILD == 'true'}}"
run: |-
deno task build
- name: "Check Package For Remote"
if: "${{!cancelled() && steps.analyze.outcome == 'success' && env.CDV_RUN_LITE == 'false'}}"
shell: "pwsh"
run: |-
Get-ChildItem -LiteralPath '.\' -File -Recurse -Name
- name: "Check Package For JSR"
if: "${{!cancelled() && steps.analyze.outcome == 'success' && env.CDV_RUN_LITE == 'false' && env.CDV_JSR_CHECK == 'true'}}"
run: |-
deno task jsr-check
- name: "Test Code"
if: "${{!cancelled() && steps.analyze.outcome == 'success'}}"
run: |-
deno test --allow-all --coverage --coverage-raw-data-only --no-prompt --permit-no-files --trace-leaks
- name: "List Test Code Coverage"
if: "${{!cancelled() && steps.analyze.outcome == 'success'}}"
shell: "pwsh"
run: |-
If ((Test-Path -LiteralPath '.\coverage' -PathType 'Container') -and (Get-ChildItem -LiteralPath '.\coverage' -File).Count -gt 0) {
deno coverage
}
- name: "Benchmark Code"
if: "${{!cancelled() && steps.analyze.outcome == 'success'}}"
run: |-
deno bench --allow-all --no-prompt --permit-no-files
- name: "Build Package For NPM"
if: "${{!cancelled() && steps.analyze.outcome == 'success' && env.CDV_RUN_LITE == 'false' && env.CDV_NPM_BUILD == 'true'}}"
run: |-
deno task npm-build
- name: "Check Package For NPM"
if: "${{!cancelled() && steps.analyze.outcome == 'success' && env.CDV_RUN_LITE == 'false' && env.CDV_NPM_CHECK == 'true'}}"
run: |-
deno task npm-check
- name: "Flush Cache"
if: "${{!cancelled()}}"
shell: "pwsh"
run: |-
ConvertFrom-Json -InputObject ($Env:CDV_DENO_CACHE_PATH_FLUSHES ?? '[]') -Depth 100 |
ForEach-Object -Process {
Remove-Item -LiteralPath $_ -Recurse -Confirm:$False -ErrorAction 'SilentlyContinue'
}
ConvertFrom-Json -InputObject ($Env:CDV_NPM_CACHE_PATH_FLUSHES ?? '[]') -Depth 100 |
ForEach-Object -Process {
Remove-Item -LiteralPath $_ -Recurse -Confirm:$False -ErrorAction 'SilentlyContinue'
}
- name: "Save Deno Cache"
if: "${{!cancelled()}}"
uses: "actions/cache/save@v4"
with:
key: "${{runner.os}}/Deno/${{github.run_id}}/${{github.run_attempt}}/${{github.job}}"
path: "${{env.CDV_DENO_CACHE_PATH_ROOT}}"
- name: "Save NPM Cache"
if: "${{!cancelled()}}"
uses: "actions/cache/save@v4"
with:
key: "${{runner.os}}/NPM/${{github.run_id}}/${{github.run_attempt}}/${{github.job}}"
path: "${{env.CDV_NPM_CACHE_PATH_ROOT}}"