-
Notifications
You must be signed in to change notification settings - Fork 0
148 lines (148 loc) · 7.17 KB
/
review-deno-code.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
# yaml-language-server: $schema=https://json.schemastore.org/github-workflow.json
name: "Review Deno Code"
on:
push:
branches:
- "**"
pull_request:
branches:
- "**"
types:
- "edited"
- "opened"
- "reopened"
- "synchronize"
workflow_dispatch:
jobs:
main:
name: "${{matrix.runon}}"
permissions:
contents: "read"
strategy:
matrix:
runon:
- "macos-latest"
- "ubuntu-latest"
- "windows-latest"
fail-fast: false
runs-on: "${{matrix.runon}}"
env:
CDV_RUN_LITE: "${{matrix.runon != 'ubuntu-latest'}}"
steps:
- name: "Checkout Repository"
uses: "actions/checkout@v4.2.1"
- name: "Setup Deno"
uses: "denoland/setup-deno@v2.0.1"
with:
deno-version: "^2.0.0"
- name: "Get Deno Cache Path"
id: "deno-cache-path"
shell: "pwsh"
run: |-
[PSCustomObject]$DenoInfo = deno info --json |
ConvertFrom-Json -Depth 100
Add-Content -LiteralPath $Env:GITHUB_OUTPUT -Value "value=$($DenoInfo.denoDir)" -Confirm:$False -Encoding 'UTF8NoBOM'
- name: "Restore Deno Cache"
id: "deno-cache-restore"
uses: "actions/cache/restore@v4.1.2"
with:
key: "Deno/${{runner.os}}-${{github.run_id}}-${{github.run_attempt}}-${{github.job}}"
restore-keys: |-
Deno/${{runner.os}}-${{github.run_id}}-${{github.run_attempt}}-
Deno/${{runner.os}}-${{github.run_id}}-${{github.run_attempt}}
Deno/${{runner.os}}-${{github.run_id}}-
Deno/${{runner.os}}-${{github.run_id}}
Deno/${{runner.os}}-
Deno/${{runner.os}}
Deno/
path: "${{steps.deno-cache-path.outputs.value}}"
- name: "Analyze Repository"
id: "analyze"
shell: "pwsh"
run: |-
[PSCustomObject]$Config = Get-Content -LiteralPath '.\deno.jsonc' -Encoding 'UTF8NoBOM' |
ConvertFrom-Json -Depth 100
[String[]]$FilesTest = Get-ChildItem -LiteralPath '.\' -Include @('*.test.ts', '*.test.tsx', '*_test.ts', '*_test.tsx', 'test.ts', 'test.tsx') -File -Recurse -Name
[String[]]$FilesBenchmark = Get-ChildItem -LiteralPath '.\' -Include @('*.bench.ts', '*.bench.tsx', '*_bench.ts', '*_bench.tsx', 'bench.ts', 'bench.tsx') -File -Recurse -Name
Add-Content -LiteralPath $Env:GITHUB_OUTPUT -Value "test=$(($FilesTest.Count -gt 0).ToString().ToLower())"
Add-Content -LiteralPath $Env:GITHUB_OUTPUT -Value "benchmark=$(($FilesBenchmark.Count -gt 0).ToString().ToLower())"
Add-Content -LiteralPath $Env:GITHUB_OUTPUT -Value "build=$(($Null -ine $Config.tasks.build).ToString().ToLower())"
Add-Content -LiteralPath $Env:GITHUB_OUTPUT -Value "jsr-check=$(($Null -ine $Config.tasks.('jsr-check')).ToString().ToLower())"
Add-Content -LiteralPath $Env:GITHUB_OUTPUT -Value "npm-build=$(($Null -ine $Config.tasks.('npm-build')).ToString().ToLower())"
Add-Content -LiteralPath $Env:GITHUB_OUTPUT -Value "npm-root=$(Join-Path -Path $Env:GITHUB_WORKSPACE -ChildPath ($Config._behaviour.npm.root ?? './npm'))"
- 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: "Verify Code"
if: "${{!cancelled() && steps.analyze.outcome == 'success'}}"
shell: "pwsh"
run: |-
[String[]]$Files = Get-ChildItem -LiteralPath '.\' -Include @('*.ts', '*.tsx') -File -Recurse -Name
[Boolean]$ShouldReload = $Env:GITHUB_EVENT_NAME -iin @('schedule', 'workflow_dispatch')
ForEach ($File In $Files) {
$ShouldReload ? (deno cache --reload $File) : (deno cache $File)
}
- name: "Lint Code"
if: "${{!cancelled() && steps.analyze.outcome == 'success'}}"
run: |-
deno lint
- name: "Build Repository"
if: "${{!cancelled() && steps.analyze.outcome == 'success' && steps.analyze.outputs.build == 'true'}}"
run: |-
deno task build
- name: "Test Code"
id: "test"
if: "${{!cancelled() && steps.analyze.outcome == 'success' && steps.analyze.outputs.test == 'true'}}"
run: |-
deno test --allow-all --coverage --no-prompt
- name: "List Test Code Coverage"
if: "${{!cancelled() && steps.analyze.outcome == 'success' && steps.analyze.outputs.test == 'true' && (steps.test.outcome == 'failure' || steps.test.outcome == 'success')}}"
run: |-
deno coverage
- name: "Benchmark Code"
if: "${{!cancelled() && steps.analyze.outcome == 'success' && steps.analyze.outputs.benchmark == 'true'}}"
run: |-
deno bench --allow-all --no-prompt
# - name: "Check Dependencies Update"
# if: "${{!cancelled() && steps.analyze.outcome == 'success' && env.CDV_RUN_LITE == 'false' && (github.event_name == 'schedule' || github.event_name == 'workflow_dispatch')}}"
# shell: "pwsh"
# run: |-
# [String]$Output = deno run --allow-net "--allow-read=$($Env:GITHUB_WORKSPACE)" --no-prompt https://deno.land/x/udd@0.8.2/main.ts --dry-run **/*.ts **/*.tsx deno.jsonc *>&1 |
# Join-String -Separator "`n"
# $LASTEXITCODE = 0
# Write-Host -Object $Output
# If ($Output -imatch 'able to update') {
# Write-Warning -Message 'Found dependencies that need to update!'
# }
- name: "Check Deployment For Remote Import"
if: "${{!cancelled() && steps.analyze.outcome == 'success' && env.CDV_RUN_LITE == 'false'}}"
shell: "pwsh"
run: |-
Get-ChildItem -LiteralPath '.\' -File -Recurse -Name
- name: "Check Deployment For JSR"
if: "${{!cancelled() && steps.analyze.outcome == 'success' && env.CDV_RUN_LITE == 'false' && steps.analyze.outputs.jsr-check == 'true'}}"
run: |-
deno task jsr-check
- name: "Build Package For NPM"
if: "${{!cancelled() && steps.analyze.outcome == 'success' && env.CDV_RUN_LITE == 'false' && steps.analyze.outputs.npm-build == 'true'}}"
run: |-
deno task npm-build
- name: "Check Deployment For NPM"
if: "${{!cancelled() && steps.analyze.outcome == 'success' && env.CDV_RUN_LITE == 'false' && steps.analyze.outputs.npm-build == 'true'}}"
working-directory: "${{steps.analyze.outputs.npm-root}}"
run: |-
npm publish --dry-run
- name: "Save Deno Cache"
if: "${{!cancelled() && steps.deno-cache-restore.outcome == 'success'}}"
uses: "actions/cache/save@v4.1.2"
with:
key: "Deno/${{runner.os}}-${{github.run_id}}-${{github.run_attempt}}-${{github.job}}"
path: "${{steps.deno-cache-path.outputs.value}}"