File tree Expand file tree Collapse file tree 5 files changed +36
-10
lines changed Expand file tree Collapse file tree 5 files changed +36
-10
lines changed Original file line number Diff line number Diff line change @@ -149,7 +149,7 @@ export async function containerBuild(
149
149
dockerArgs . push ( '-t' , tag )
150
150
dockerArgs . push ( '-f' , args . dockerfile )
151
151
dockerArgs . push ( getBuildContext ( args . dockerfile ) )
152
- // TODO: figure out build working directory
152
+
153
153
await runDockerCommand ( dockerArgs , {
154
154
workingDir : getWorkingDir ( args . dockerfile )
155
155
} )
Original file line number Diff line number Diff line change @@ -94,7 +94,10 @@ export async function prepareJob(
94
94
)
95
95
}
96
96
97
- const isAlpine = await isContainerAlpine ( containerMetadata ! . id )
97
+ let isAlpine = false
98
+ if ( containerMetadata ?. id ) {
99
+ isAlpine = await isContainerAlpine ( containerMetadata . id )
100
+ }
98
101
99
102
if ( containerMetadata ?. id ) {
100
103
containerMetadata . ports = await containerPorts ( containerMetadata . id )
@@ -105,7 +108,10 @@ export async function prepareJob(
105
108
}
106
109
}
107
110
108
- const healthChecks : Promise < void > [ ] = [ healthCheck ( containerMetadata ! ) ]
111
+ const healthChecks : Promise < void > [ ] = [ ]
112
+ if ( containerMetadata ) {
113
+ healthChecks . push ( healthCheck ( containerMetadata ) )
114
+ }
109
115
for ( const service of servicesMetadata ) {
110
116
healthChecks . push ( healthCheck ( service ) )
111
117
}
@@ -133,7 +139,6 @@ function generateResponseFile(
133
139
servicesMetadata ?: ContainerMetadata [ ] ,
134
140
isAlpine = false
135
141
) : void {
136
- // todo figure out if we are alpine
137
142
const response = {
138
143
state : { network : networkName } ,
139
144
context : { } ,
Original file line number Diff line number Diff line change @@ -118,4 +118,14 @@ describe('prepare job', () => {
118
118
expect ( redisServicePorts [ '80' ] ) . toBe ( '8080' )
119
119
expect ( redisServicePorts [ '8080' ] ) . toBe ( '8088' )
120
120
} )
121
+
122
+ it ( 'should run prepare job without job container without exception' , async ( ) => {
123
+ prepareJobDefinition . args . container = null
124
+ const prepareJobOutput = testSetup . createOutputFile (
125
+ 'prepare-job-output.json'
126
+ )
127
+ await expect (
128
+ prepareJob ( prepareJobDefinition . args , prepareJobOutput )
129
+ ) . resolves . not . toThrow ( )
130
+ } )
121
131
} )
Original file line number Diff line number Diff line change 1
1
import * as core from '@actions/core'
2
2
import * as io from '@actions/io'
3
3
import * as k8s from '@kubernetes/client-node'
4
- import {
5
- PodPhase ,
6
- containerVolumes ,
7
- DEFAULT_CONTAINER_ENTRY_POINT ,
8
- DEFAULT_CONTAINER_ENTRY_POINT_ARGS
9
- } from '../k8s/utils'
10
4
import { ContextPorts , prepareJobArgs , writeToResponseFile } from 'hooklib'
11
5
import path from 'path'
12
6
import {
@@ -19,12 +13,22 @@ import {
19
13
requiredPermissions ,
20
14
waitForPodPhases
21
15
} from '../k8s'
16
+ import {
17
+ containerVolumes ,
18
+ DEFAULT_CONTAINER_ENTRY_POINT ,
19
+ DEFAULT_CONTAINER_ENTRY_POINT_ARGS ,
20
+ PodPhase
21
+ } from '../k8s/utils'
22
22
import { JOB_CONTAINER_NAME } from './constants'
23
23
24
24
export async function prepareJob (
25
25
args : prepareJobArgs ,
26
26
responseFile
27
27
) : Promise < void > {
28
+ if ( ! args . container ) {
29
+ throw new Error ( 'Job Container is required.' )
30
+ }
31
+
28
32
await prunePods ( )
29
33
if ( ! ( await isAuthPermissionsOK ( ) ) ) {
30
34
throw new Error (
Original file line number Diff line number Diff line change @@ -68,4 +68,11 @@ describe('Prepare job', () => {
68
68
prepareJob ( prepareJobData . args , prepareJobOutputFilePath )
69
69
) . rejects . toThrow ( )
70
70
} )
71
+
72
+ it ( 'should not run prepare job without the job container' , async ( ) => {
73
+ prepareJobData . args . container = undefined
74
+ await expect (
75
+ prepareJob ( prepareJobData . args , prepareJobOutputFilePath )
76
+ ) . rejects . toThrow ( )
77
+ } )
71
78
} )
You can’t perform that action at this time.
0 commit comments