1- import { FeatureFlags } from "@actions/expressions" ;
21import { registerLogger } from "./log.js" ;
32import { createDocument } from "./test-utils/document.js" ;
43import { TestLogger } from "./test-utils/logger.js" ;
54import { clearCache } from "./utils/workflow-cache.js" ;
6- import { validate , ValidationConfig } from "./validate.js" ;
5+ import { validate } from "./validate.js" ;
76
87registerLogger ( new TestLogger ( ) ) ;
98
10- const configWithFlag : ValidationConfig = {
11- featureFlags : new FeatureFlags ( { allowServiceContainerCommand : true } )
12- } ;
13-
149beforeEach ( ( ) => {
1510 clearCache ( ) ;
1611} ) ;
1712
1813describe ( "service container command/entrypoint" , ( ) => {
19- describe ( "with feature flag enabled" , ( ) => {
20- it ( "allows command in service container" , async ( ) => {
21- const input = `
14+ it ( "allows command in service container" , async ( ) => {
15+ const input = `
2216on: push
2317jobs:
2418 build:
@@ -30,13 +24,13 @@ jobs:
3024 steps:
3125 - run: echo hi
3226` ;
33- const result = await validate ( createDocument ( "wf.yaml" , input ) , configWithFlag ) ;
34- const commandErrors = result . filter ( d => d . message . includes ( "command" ) ) ;
35- expect ( commandErrors ) . toEqual ( [ ] ) ;
36- } ) ;
27+ const result = await validate ( createDocument ( "wf.yaml" , input ) ) ;
28+ const commandErrors = result . filter ( d => d . message . includes ( "command" ) ) ;
29+ expect ( commandErrors ) . toEqual ( [ ] ) ;
30+ } ) ;
3731
38- it ( "allows entrypoint in service container" , async ( ) => {
39- const input = `
32+ it ( "allows entrypoint in service container" , async ( ) => {
33+ const input = `
4034on: push
4135jobs:
4236 build:
@@ -48,13 +42,13 @@ jobs:
4842 steps:
4943 - run: echo hi
5044` ;
51- const result = await validate ( createDocument ( "wf.yaml" , input ) , configWithFlag ) ;
52- const entrypointErrors = result . filter ( d => d . message . includes ( "entrypoint" ) ) ;
53- expect ( entrypointErrors ) . toEqual ( [ ] ) ;
54- } ) ;
45+ const result = await validate ( createDocument ( "wf.yaml" , input ) ) ;
46+ const entrypointErrors = result . filter ( d => d . message . includes ( "entrypoint" ) ) ;
47+ expect ( entrypointErrors ) . toEqual ( [ ] ) ;
48+ } ) ;
5549
56- it ( "allows both command and entrypoint in service container" , async ( ) => {
57- const input = `
50+ it ( "allows both command and entrypoint in service container" , async ( ) => {
51+ const input = `
5852on: push
5953jobs:
6054 build:
@@ -67,13 +61,13 @@ jobs:
6761 steps:
6862 - run: echo hi
6963` ;
70- const result = await validate ( createDocument ( "wf.yaml" , input ) , configWithFlag ) ;
71- const relevantErrors = result . filter ( d => d . message . includes ( "command" ) || d . message . includes ( "entrypoint" ) ) ;
72- expect ( relevantErrors ) . toEqual ( [ ] ) ;
73- } ) ;
64+ const result = await validate ( createDocument ( "wf.yaml" , input ) ) ;
65+ const relevantErrors = result . filter ( d => d . message . includes ( "command" ) || d . message . includes ( "entrypoint" ) ) ;
66+ expect ( relevantErrors ) . toEqual ( [ ] ) ;
67+ } ) ;
7468
75- it ( "rejects command in job container even with flag enabled " , async ( ) => {
76- const input = `
69+ it ( "rejects command in job container" , async ( ) => {
70+ const input = `
7771on: push
7872jobs:
7973 build:
@@ -84,13 +78,13 @@ jobs:
8478 steps:
8579 - run: echo hi
8680` ;
87- const result = await validate ( createDocument ( "wf.yaml" , input ) , configWithFlag ) ;
88- const commandErrors = result . filter ( d => d . message . includes ( "command" ) ) ;
89- expect ( commandErrors . length ) . toBeGreaterThan ( 0 ) ;
90- } ) ;
81+ const result = await validate ( createDocument ( "wf.yaml" , input ) ) ;
82+ const commandErrors = result . filter ( d => d . message . includes ( "command" ) ) ;
83+ expect ( commandErrors . length ) . toBeGreaterThan ( 0 ) ;
84+ } ) ;
9185
92- it ( "rejects entrypoint in job container even with flag enabled " , async ( ) => {
93- const input = `
86+ it ( "rejects entrypoint in job container" , async ( ) => {
87+ const input = `
9488on: push
9589jobs:
9690 build:
@@ -101,47 +95,8 @@ jobs:
10195 steps:
10296 - run: echo hi
10397` ;
104- const result = await validate ( createDocument ( "wf.yaml" , input ) , configWithFlag ) ;
105- const entrypointErrors = result . filter ( d => d . message . includes ( "entrypoint" ) ) ;
106- expect ( entrypointErrors . length ) . toBeGreaterThan ( 0 ) ;
107- } ) ;
108- } ) ;
109-
110- describe ( "with feature flag disabled" , ( ) => {
111- it ( "rejects command in service container" , async ( ) => {
112- const input = `
113- on: push
114- jobs:
115- build:
116- runs-on: ubuntu-latest
117- services:
118- redis:
119- image: redis
120- command: --port 6380
121- steps:
122- - run: echo hi
123- ` ;
124- const result = await validate ( createDocument ( "wf.yaml" , input ) ) ;
125- const commandErrors = result . filter ( d => d . message . includes ( "command" ) ) ;
126- expect ( commandErrors . length ) . toBeGreaterThan ( 0 ) ;
127- } ) ;
128-
129- it ( "rejects entrypoint in service container" , async ( ) => {
130- const input = `
131- on: push
132- jobs:
133- build:
134- runs-on: ubuntu-latest
135- services:
136- redis:
137- image: redis
138- entrypoint: /usr/local/bin/redis-server
139- steps:
140- - run: echo hi
141- ` ;
142- const result = await validate ( createDocument ( "wf.yaml" , input ) ) ;
143- const entrypointErrors = result . filter ( d => d . message . includes ( "entrypoint" ) ) ;
144- expect ( entrypointErrors . length ) . toBeGreaterThan ( 0 ) ;
145- } ) ;
98+ const result = await validate ( createDocument ( "wf.yaml" , input ) ) ;
99+ const entrypointErrors = result . filter ( d => d . message . includes ( "entrypoint" ) ) ;
100+ expect ( entrypointErrors . length ) . toBeGreaterThan ( 0 ) ;
146101 } ) ;
147102} ) ;
0 commit comments