Update resources #76
This file contains hidden or 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
# 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: "Get Deno 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' | |
- 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: "Analyze Repository" | |
id: "analyze" | |
shell: "pwsh" | |
run: |- | |
[PSCustomObject]$Config = ConvertFrom-Json -InputObject (Get-Content -LiteralPath '.\deno.jsonc' -Raw -Encoding 'UTF8NoBOM') -Depth 100 | |
[Boolean]$JSRDeploy = $Null -ine $Config.tasks.'jsr-check' -and $Null -ine $Config.tasks.'jsr-path-manifest' -and $Null -ine $Config.tasks.'jsr-publish' | |
[Boolean]$NPMDeploy = $Null -ine $Config.tasks.'npm-build' -and $Null -ine $Config.tasks.'npm-check' -and $Null -ine $Config.tasks.'npm-path-root' -and $Null -ine $Config.tasks.'npm-publish' | |
Add-Content -LiteralPath $Env:GITHUB_ENV -Value "CDV_BUILD=$(($Null -ine $Config.tasks.build).ToString().ToLower())" | |
Add-Content -LiteralPath $Env:GITHUB_ENV -Value "CDV_JSR_DEPLOY=$($JSRDeploy.ToString().ToLower())" | |
Add-Content -LiteralPath $Env:GITHUB_ENV -Value "CDV_NPM_DEPLOY=$($NPMDeploy.ToString().ToLower())" | |
Add-Content -LiteralPath $Env:GITHUB_STEP_SUMMARY -Value @" | |
# Packages Automatic Deployment Dispatch | |
- **JSR:** $($JSRDeploy ? '✔️' : '❌') | |
- **NPM:** $($NPMDeploy ? '✔️' : '❌') | |
"@ | |
- 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_DEPLOY == '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: "Check Package For NPM" | |
if: "${{!cancelled() && steps.analyze.outcome == 'success' && env.CDV_RUN_LITE == 'false' && env.CDV_NPM_DEPLOY == 'true'}}" | |
run: |- | |
deno task npm-build | |
deno task npm-check | |
- name: "Flush Deno 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' | |
} | |
- 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}}" |