Fix yarn test for container based dev flow
Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
This commit is contained in:
		
							parent
							
								
									de88f925d4
								
							
						
					
					
						commit
						69173c6cad
					
				| @ -4,7 +4,7 @@ FROM node:14 AS deps | |||||||
| WORKDIR /src | WORKDIR /src | ||||||
| COPY package.json yarn.lock ./ | COPY package.json yarn.lock ./ | ||||||
| RUN --mount=type=cache,target=/usr/local/share/.cache/yarn \ | RUN --mount=type=cache,target=/usr/local/share/.cache/yarn \ | ||||||
|   yarn install  |   yarn install | ||||||
| 
 | 
 | ||||||
| FROM scratch AS update-yarn | FROM scratch AS update-yarn | ||||||
| COPY --from=deps /src/yarn.lock / | COPY --from=deps /src/yarn.lock / | ||||||
| @ -26,9 +26,9 @@ ARG BUILDX_VERSION=v0.4.2 | |||||||
| ENV RUNNER_TEMP=/tmp/github_runner | ENV RUNNER_TEMP=/tmp/github_runner | ||||||
| ENV RUNNER_TOOL_CACHE=/tmp/github_tool_cache | ENV RUNNER_TOOL_CACHE=/tmp/github_tool_cache | ||||||
| RUN mkdir -p /usr/local/lib/docker/cli-plugins && \ | RUN mkdir -p /usr/local/lib/docker/cli-plugins && \ | ||||||
|   curl -fsSL https://github.com/docker/buildx/releases/download/$BUILDX_VERSION/buildx-$BUILDX_VERSION.$TARGETOS-$TARGETARCH > /usr/local/lib/docker/cli-plugins/buildx && \ |   curl -fsSL https://github.com/docker/buildx/releases/download/$BUILDX_VERSION/buildx-$BUILDX_VERSION.$TARGETOS-$TARGETARCH > /usr/local/lib/docker/cli-plugins/docker-buildx && \ | ||||||
|   chmod +x /usr/local/lib/docker/cli-plugins/buildx && \ |   chmod +x /usr/local/lib/docker/cli-plugins/docker-buildx && \ | ||||||
|   docker buildx --version && env |   docker buildx version | ||||||
| COPY . . | COPY . . | ||||||
| RUN yarn run test | RUN yarn run test | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -1,4 +1,5 @@ | |||||||
| import fs = require('fs'); | import fs = require('fs'); | ||||||
|  | import * as docker from '../src/docker'; | ||||||
| import * as buildx from '../src/buildx'; | import * as buildx from '../src/buildx'; | ||||||
| import * as path from 'path'; | import * as path from 'path'; | ||||||
| import * as os from 'os'; | import * as os from 'os'; | ||||||
| @ -6,6 +7,10 @@ import * as os from 'os'; | |||||||
| const tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), 'setup-buildx-')); | const tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), 'setup-buildx-')); | ||||||
| 
 | 
 | ||||||
| describe('buildx', () => { | describe('buildx', () => { | ||||||
|  |   async function isDaemonRunning() { | ||||||
|  |     return await docker.isDaemonRunning(); | ||||||
|  |   } | ||||||
|  | 
 | ||||||
|   it('is available', async () => { |   it('is available', async () => { | ||||||
|     expect(await buildx.isAvailable()).toBe(true); |     expect(await buildx.isAvailable()).toBe(true); | ||||||
|   }, 100000); |   }, 100000); | ||||||
| @ -16,12 +21,16 @@ describe('buildx', () => { | |||||||
|     expect(countBuilders).toBeGreaterThan(0); |     expect(countBuilders).toBeGreaterThan(0); | ||||||
|   }, 100000); |   }, 100000); | ||||||
| 
 | 
 | ||||||
|   it('platforms', async () => { |   (isDaemonRunning() ? it : it.skip)( | ||||||
|     const platforms = await buildx.platforms(); |     'platforms', | ||||||
|     console.log(`platforms: ${platforms}`); |     async () => { | ||||||
|     expect(platforms).not.toBeUndefined(); |       const platforms = buildx.platforms(); | ||||||
|     expect(platforms).not.toEqual(''); |       console.log(`platforms: ${platforms}`); | ||||||
|   }, 100000); |       expect(platforms).not.toBeUndefined(); | ||||||
|  |       expect(platforms).not.toEqual(''); | ||||||
|  |     }, | ||||||
|  |     100000 | ||||||
|  |   ); | ||||||
| 
 | 
 | ||||||
|   it('acquires v0.2.2 version of buildx', async () => { |   it('acquires v0.2.2 version of buildx', async () => { | ||||||
|     const buildxBin = await buildx.install('v0.2.2', tmpDir); |     const buildxBin = await buildx.install('v0.2.2', tmpDir); | ||||||
|  | |||||||
							
								
								
									
										7
									
								
								src/docker.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										7
									
								
								src/docker.ts
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,7 @@ | |||||||
|  | import * as exec from './exec'; | ||||||
|  | 
 | ||||||
|  | export async function isDaemonRunning(): Promise<boolean> { | ||||||
|  |   return await exec.exec(`docker`, ['version', '--format', '{{.Server.Os}}'], true).then(res => { | ||||||
|  |     return !res.stdout.includes(' ') && res.success; | ||||||
|  |   }); | ||||||
|  | } | ||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 CrazyMax
						CrazyMax