FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
setup-vp/src/portable-bundles.test.ts at github-task-cache · KTrain5169/setup-vp · GitHub
KTrain5169
setup-vp
Repository navigation
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
setup-vp
/
src
/
portable-bundles.test.ts
Copy path
More file actions
More file actions
Latest commit
History
History
History
105 lines (100 loc) · 3.77 KB
Breadcrumbs
setup-vp
/
src
/
portable-bundles.test.ts
Copy path
File metadata and controls
105 lines (100 loc) · 3.77 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
import
{
describe
,
it
,
expect
}
from
"vite-plus/test"
;
import
{
readFileSync
,
existsSync
,
mkdtempSync
,
mkdirSync
,
writeFileSync
,
rmSync
}
from
"node:fs"
;
import
{
tmpdir
}
from
"node:os"
;
import
path
from
"node:path"
;
import
{
fileURLToPath
}
from
"node:url"
;
import
{
spawnSync
}
from
"node:child_process"
;
const
distRoot
=
fileURLToPath
(
new
URL
(
"../dist"
,
import
.
meta
.
url
)
)
;
const
azureDist
=
`
${
distRoot
}
/azure/index.mjs`
;
const
gitlabDist
=
`
${
distRoot
}
/gitlab/index.mjs`
;
const
actionDist
=
`
${
distRoot
}
/index.mjs`
;
describe
(
"portable CI bundles"
,
(
)
=>
{
it
(
"fails invalid GitLab phases without attempting installation"
,
(
)
=>
{
const
result
=
spawnSync
(
process
.
execPath
,
[
gitlabDist
,
"invalid-phase"
]
,
{
encoding
:
"utf8"
,
timeout
:
10_000
,
}
)
;
expect
(
result
.
error
)
.
toBeUndefined
(
)
;
expect
(
result
.
status
)
.
not
.
toBe
(
0
)
;
expect
(
result
.
stderr
)
.
toContain
(
"Invalid GitLab phase: invalid-phase"
)
;
}
)
;
it
(
"runs the GitLab post-job cache phase from the standalone bundle"
,
(
)
=>
{
const
root
=
mkdtempSync
(
path
.
join
(
tmpdir
(
)
,
"setup-vp-bundle-cache-"
)
)
;
const
store
=
path
.
join
(
root
,
"store"
)
;
const
lockFile
=
path
.
join
(
root
,
"package-lock.json"
)
;
mkdirSync
(
store
)
;
writeFileSync
(
path
.
join
(
store
,
"package"
)
,
"post-job package"
)
;
writeFileSync
(
lockFile
,
"{}"
)
;
writeFileSync
(
path
.
join
(
root
,
".setup-vp-cache-state.json"
)
,
JSON
.
stringify
(
{
ready
:
true
,
cachePath
:
store
,
lockFile
,
lockType
:
"npm"
,
}
)
,
)
;
try
{
const
result
=
spawnSync
(
process
.
execPath
,
[
gitlabDist
,
"save-cache"
]
,
{
env
:
{
...
process
.
env
,
CI_PROJECT_DIR
:
root
}
,
encoding
:
"utf8"
,
timeout
:
10_000
,
}
)
;
expect
(
result
.
status
,
result
.
stderr
)
.
toBe
(
0
)
;
expect
(
readFileSync
(
path
.
join
(
root
,
".setup-vp-cache"
,
process
.
platform
,
process
.
arch
,
"npm"
,
"packages"
,
"package"
,
)
,
"utf8"
,
)
,
)
.
toBe
(
"post-job package"
)
;
}
finally
{
rmSync
(
root
,
{
recursive
:
true
,
force
:
true
}
)
;
}
}
)
;
it
(
"builds azure and gitlab bundles without @actions imports"
,
(
)
=>
{
expect
(
existsSync
(
azureDist
)
)
.
toBe
(
true
)
;
expect
(
existsSync
(
gitlabDist
)
)
.
toBe
(
true
)
;
const
azure
=
readFileSync
(
azureDist
,
"utf8"
)
;
const
gitlab
=
readFileSync
(
gitlabDist
,
"utf8"
)
;
expect
(
azure
)
.
not
.
toContain
(
"@actions/"
)
;
expect
(
gitlab
)
.
not
.
toContain
(
"@actions/"
)
;
expect
(
azure
)
.
not
.
toMatch
(
/
\b
f
r
o
m
[
"
'
]
\.
\.
\/
/
)
;
expect
(
gitlab
)
.
not
.
toMatch
(
/
\b
f
r
o
m
[
"
'
]
\.
\.
\/
/
)
;
expect
(
readFileSync
(
actionDist
,
"utf8"
)
)
.
toContain
(
"@actions/"
)
;
}
)
;
it
(
"fails invalid azure phase with a controlled message"
,
(
)
=>
{
const
result
=
spawnSync
(
process
.
execPath
,
[
azureDist
,
"invalid-phase"
]
,
{
encoding
:
"utf8"
,
timeout
:
10_000
,
}
)
;
expect
(
result
.
error
)
.
toBeUndefined
(
)
;
expect
(
result
.
status
)
.
not
.
toBe
(
0
)
;
expect
(
result
.
stderr
)
.
toContain
(
'invalid phase "invalid-phase"'
)
;
}
,
15_000
)
;
it
(
"fails standalone Azure finalize when vp is unavailable"
,
(
)
=>
{
const
root
=
mkdtempSync
(
path
.
join
(
tmpdir
(
)
,
"setup-vp-missing-command-"
)
)
;
try
{
const
result
=
spawnSync
(
process
.
execPath
,
[
azureDist
,
"finalize"
]
,
{
cwd
:
root
,
env
:
{
PATH
:
root
,
SYSTEM_DEFAULTWORKINGDIRECTORY
:
root
,
SETUP_VP_RUN_INSTALL
:
"false"
}
,
encoding
:
"utf8"
,
timeout
:
10_000
,
}
)
;
expect
(
result
.
error
)
.
toBeUndefined
(
)
;
expect
(
result
.
status
)
.
not
.
toBe
(
0
)
;
expect
(
result
.
stderr
)
.
toContain
(
"Failed to verify Vite+ installation"
)
;
expect
(
result
.
stdout
)
.
not
.
toContain
(
"variable=version"
)
;
expect
(
result
.
stdout
)
.
not
.
toContain
(
"unknown"
)
;
}
finally
{
rmSync
(
root
,
{
recursive
:
true
,
force
:
true
}
)
;
}
}
)
;
}
)
;
Back
|
FazBrowse Home
|
New Git URL