Merge pull request #93 from docker/v2-fix-setup-actions
Fix and cleanup of v2 setup actions
This commit is contained in:
		
						commit
						068cb8e418
					
				
							
								
								
									
										6
									
								
								.github/workflows/setup-buildx-ci.yml
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										6
									
								
								.github/workflows/setup-buildx-ci.yml
									
									
									
									
										vendored
									
									
								
							| @ -27,12 +27,6 @@ jobs: | |||||||
|           - v0.2.2 |           - v0.2.2 | ||||||
|           - "" |           - "" | ||||||
|     steps: |     steps: | ||||||
|       - |  | ||||||
|         name: Runner info |  | ||||||
|         run: | |  | ||||||
|           sudo apt-get install -y hwinfo |  | ||||||
|           sudo hwinfo --short |  | ||||||
|           sudo mount |  | ||||||
|       - |       - | ||||||
|         name: Checkout |         name: Checkout | ||||||
|         uses: actions/checkout@v2.3.1 |         uses: actions/checkout@v2.3.1 | ||||||
|  | |||||||
							
								
								
									
										38
									
								
								.github/workflows/setup-buildx-precheckin.yml
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										38
									
								
								.github/workflows/setup-buildx-precheckin.yml
									
									
									
									
										vendored
									
									
								
							| @ -1,38 +0,0 @@ | |||||||
| name: setup-buildx-precheckin |  | ||||||
| 
 |  | ||||||
| on: |  | ||||||
|   push: |  | ||||||
|     branches: |  | ||||||
|       - master |  | ||||||
|       - v2-working-branch # remove when merged to master |  | ||||||
|     paths: |  | ||||||
|       - .github/workflows/setup-buildx-precheckin.yml |  | ||||||
|       - setup-buildx/** |  | ||||||
|   pull_request: |  | ||||||
|     branches: |  | ||||||
|       - master |  | ||||||
|       - v2-working-branch # remove when merged to master |  | ||||||
|     paths: |  | ||||||
|       - .github/workflows/setup-buildx-precheckin.yml |  | ||||||
|       - setup-buildx/** |  | ||||||
| 
 |  | ||||||
| jobs: |  | ||||||
|   pre-checkin: |  | ||||||
|     runs-on: ubuntu-latest |  | ||||||
|     steps: |  | ||||||
|       - |  | ||||||
|         name: Checkout |  | ||||||
|         uses: actions/checkout@v2.3.1 |  | ||||||
|       - |  | ||||||
|         name: Install |  | ||||||
|         run: yarn --cwd ./setup-buildx/ install |  | ||||||
|       - |  | ||||||
|         name: Pre-checkin |  | ||||||
|         run: yarn --cwd ./setup-buildx/ run pre-checkin |  | ||||||
|       - |  | ||||||
|         name: Check for uncommitted changes |  | ||||||
|         run: | |  | ||||||
|           if [[ `git status --porcelain` ]]; then |  | ||||||
|             git status --porcelain |  | ||||||
|             echo "::warning::Found changes. Please run 'yarn --cwd ./setup-buildx/ run pre-checkin' and push" |  | ||||||
|           fi |  | ||||||
							
								
								
									
										6
									
								
								.github/workflows/setup-qemu-ci.yml
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										6
									
								
								.github/workflows/setup-qemu-ci.yml
									
									
									
									
										vendored
									
									
								
							| @ -29,12 +29,6 @@ jobs: | |||||||
|           - all |           - all | ||||||
|           - arm64,riscv64,arm |           - arm64,riscv64,arm | ||||||
|     steps: |     steps: | ||||||
|       - |  | ||||||
|         name: Runner info |  | ||||||
|         run: | |  | ||||||
|           sudo apt-get install -y hwinfo |  | ||||||
|           sudo hwinfo --short |  | ||||||
|           sudo mount |  | ||||||
|       - |       - | ||||||
|         name: Checkout |         name: Checkout | ||||||
|         uses: actions/checkout@v2.3.1 |         uses: actions/checkout@v2.3.1 | ||||||
|  | |||||||
							
								
								
									
										38
									
								
								.github/workflows/setup-qemu-precheckin.yml
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										38
									
								
								.github/workflows/setup-qemu-precheckin.yml
									
									
									
									
										vendored
									
									
								
							| @ -1,38 +0,0 @@ | |||||||
| name: setup-qemu-precheckin |  | ||||||
| 
 |  | ||||||
| on: |  | ||||||
|   push: |  | ||||||
|     branches: |  | ||||||
|       - master |  | ||||||
|       - v2-working-branch # remove when merged to master |  | ||||||
|     paths: |  | ||||||
|       - .github/workflows/setup-qemu-precheckin.yml |  | ||||||
|       - setup-qemu/** |  | ||||||
|   pull_request: |  | ||||||
|     branches: |  | ||||||
|       - master |  | ||||||
|       - v2-working-branch # remove when merged to master |  | ||||||
|     paths: |  | ||||||
|       - .github/workflows/setup-qemu-precheckin.yml |  | ||||||
|       - setup-qemu/** |  | ||||||
| 
 |  | ||||||
| jobs: |  | ||||||
|   pre-checkin: |  | ||||||
|     runs-on: ubuntu-latest |  | ||||||
|     steps: |  | ||||||
|       - |  | ||||||
|         name: Checkout |  | ||||||
|         uses: actions/checkout@v2.3.1 |  | ||||||
|       - |  | ||||||
|         name: Install |  | ||||||
|         run: yarn --cwd ./setup-qemu/ install |  | ||||||
|       - |  | ||||||
|         name: Pre-checkin |  | ||||||
|         run: yarn --cwd ./setup-qemu/ run pre-checkin |  | ||||||
|       - |  | ||||||
|         name: Check for uncommitted changes |  | ||||||
|         run: | |  | ||||||
|           if [[ `git status --porcelain` ]]; then |  | ||||||
|             git status --porcelain |  | ||||||
|             echo "::warning::Found changes. Please run 'yarn --cwd ./setup-qemu/ run pre-checkin' and push" |  | ||||||
|           fi |  | ||||||
| @ -37,7 +37,7 @@ jobs: | |||||||
|       - |       - | ||||||
|         name: Set up Docker Buildx |         name: Set up Docker Buildx | ||||||
|         id: buildx |         id: buildx | ||||||
|         uses: docker/actions/setup-buildx@v1 |         uses: docker/setup-buildx-action@v1 | ||||||
|         with: |         with: | ||||||
|           version: latest |           version: latest | ||||||
|       - |       - | ||||||
| @ -71,13 +71,13 @@ jobs: | |||||||
|         uses: actions/checkout@v2 |         uses: actions/checkout@v2 | ||||||
|       - |       - | ||||||
|         name: Set up QEMU |         name: Set up QEMU | ||||||
|         uses: docker/actions/setup-qemu@v1 |         uses: docker/setup-qemu-action@v1 | ||||||
|         with: |         with: | ||||||
|           platforms: all |           platforms: all | ||||||
|       - |       - | ||||||
|         name: Set up Docker Buildx |         name: Set up Docker Buildx | ||||||
|         id: buildx |         id: buildx | ||||||
|         uses: docker/actions/setup-buildx@v1 |         uses: docker/setup-buildx-action@v1 | ||||||
|         with: |         with: | ||||||
|           version: latest |           version: latest | ||||||
|       - |       - | ||||||
| @ -91,13 +91,14 @@ jobs: | |||||||
| 
 | 
 | ||||||
| Following inputs can be used as `step.with` keys | Following inputs can be used as `step.with` keys | ||||||
| 
 | 
 | ||||||
| | Name             | Type    | Default                           | Description                        | | | Name               | Type    | Default                           | Description                        | | ||||||
| |------------------|---------|-----------------------------------|------------------------------------| | |--------------------|---------|-----------------------------------|------------------------------------| | ||||||
| | `version`        | String  | _the one installed on the runner_ | [Buildx](https://github.com/docker/buildx) version. e.g. `v0.3.0`, `latest` | | | `version`          | String  | _the one installed on the runner_ | [Buildx](https://github.com/docker/buildx) version. e.g. `v0.3.0`, `latest` | | ||||||
| | `driver`         | String  | `docker-container`                | Sets the [builder driver](https://github.com/docker/buildx#--driver-driver) to be used. | | | `driver`           | String  | `docker-container`                | Sets the [builder driver](https://github.com/docker/buildx#--driver-driver) to be used. | | ||||||
| | `driver-opt`     | String  |                                   | Passes additional [driver-specific options](https://github.com/docker/buildx#--driver-opt-options). e.g. `image=moby/buildkit:master` | | | `driver-opt`       | String  |                                   | Passes additional [driver-specific options](https://github.com/docker/buildx#--driver-opt-options). e.g. `image=moby/buildkit:master` | | ||||||
| | `install`        | Bool    | `false`                           | Sets up `docker build` command as an alias to `docker buildx` | | | `buildkitd-flags`  | String  |                                   | [Flags for buildkitd](https://github.com/moby/buildkit/blob/master/docs/buildkitd.toml.md) daemon. | | ||||||
| | `use`            | Bool    | `true`                            | Switch to this builder instance | | | `install`          | Bool    | `false`                           | Sets up `docker build` command as an alias to `docker buildx` | | ||||||
|  | | `use`              | Bool    | `true`                            | Switch to this builder instance | | ||||||
| 
 | 
 | ||||||
| ### outputs | ### outputs | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -8,20 +8,20 @@ const tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), 'setup-buildx-')); | |||||||
| describe('buildx', () => { | describe('buildx', () => { | ||||||
|   it('is available', async () => { |   it('is available', async () => { | ||||||
|     expect(await buildx.isAvailable()).toBe(true); |     expect(await buildx.isAvailable()).toBe(true); | ||||||
|   }); |   }, 100000); | ||||||
| 
 | 
 | ||||||
|   it('count builders', async () => { |   it('count builders', async () => { | ||||||
|     const countBuilders = await buildx.countBuilders(); |     const countBuilders = await buildx.countBuilders(); | ||||||
|     console.log(`countBuilders: ${countBuilders}`); |     console.log(`countBuilders: ${countBuilders}`); | ||||||
|     expect(countBuilders).toBeGreaterThan(0); |     expect(countBuilders).toBeGreaterThan(0); | ||||||
|   }); |   }, 100000); | ||||||
| 
 | 
 | ||||||
|   it('platforms', async () => { |   it('platforms', async () => { | ||||||
|     const platforms = await buildx.platforms(); |     const platforms = await buildx.platforms(); | ||||||
|     console.log(`platforms: ${platforms}`); |     console.log(`platforms: ${platforms}`); | ||||||
|     expect(platforms).not.toBeUndefined(); |     expect(platforms).not.toBeUndefined(); | ||||||
|     expect(platforms).not.toEqual(''); |     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); | ||||||
|  | |||||||
| @ -1,10 +1,10 @@ | |||||||
| # https://help.github.com/en/articles/metadata-syntax-for-github-actions | # https://help.github.com/en/articles/metadata-syntax-for-github-actions | ||||||
| name: 'Docker - Setup Buildx' | name: 'Docker Setup Buildx' | ||||||
| description: 'GitHub Action to set up Docker Buildx' | description: 'Set up Docker Buildx' | ||||||
| author: 'crazy-max' | author: 'docker' | ||||||
| branding: | branding: | ||||||
|  |   icon: 'anchor' | ||||||
|   color: 'blue' |   color: 'blue' | ||||||
|   icon: 'truck' |  | ||||||
| 
 | 
 | ||||||
| inputs: | inputs: | ||||||
|   version: |   version: | ||||||
| @ -17,6 +17,9 @@ inputs: | |||||||
|   driver-opt: |   driver-opt: | ||||||
|     description: 'Passes additional driver-specific options. Eg. image=moby/buildkit:master' |     description: 'Passes additional driver-specific options. Eg. image=moby/buildkit:master' | ||||||
|     required: false |     required: false | ||||||
|  |   buildkitd-flags: | ||||||
|  |     description: 'Flags for buildkitd daemon' | ||||||
|  |     required: false | ||||||
|   install: |   install: | ||||||
|     description: 'Sets up docker build command as an alias to docker buildx' |     description: 'Sets up docker build command as an alias to docker buildx' | ||||||
|     default: 'false' |     default: 'false' | ||||||
|  | |||||||
							
								
								
									
										36
									
								
								setup-buildx/dist/index.js
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										36
									
								
								setup-buildx/dist/index.js
									
									
									
										generated
									
									
										vendored
									
									
								
							| @ -2186,7 +2186,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); | |||||||
| exports.setBuilderName = exports.builderName = exports.IsPost = void 0; | exports.setBuilderName = exports.builderName = exports.IsPost = void 0; | ||||||
| const core = __importStar(__webpack_require__(470)); | const core = __importStar(__webpack_require__(470)); | ||||||
| exports.IsPost = !!process.env['STATE_isPost']; | exports.IsPost = !!process.env['STATE_isPost']; | ||||||
| exports.builderName = !!process.env['STATE_builderName']; | exports.builderName = process.env['STATE_builderName'] || ''; | ||||||
| function setBuilderName(builderName) { | function setBuilderName(builderName) { | ||||||
|     core.saveState('builderName', builderName); |     core.saveState('builderName', builderName); | ||||||
| } | } | ||||||
| @ -2479,9 +2479,10 @@ Object.defineProperty(exports, "__esModule", { value: true }); | |||||||
| const os = __importStar(__webpack_require__(87)); | const os = __importStar(__webpack_require__(87)); | ||||||
| const path = __importStar(__webpack_require__(622)); | const path = __importStar(__webpack_require__(622)); | ||||||
| const buildx = __importStar(__webpack_require__(982)); | const buildx = __importStar(__webpack_require__(982)); | ||||||
| const exec = __importStar(__webpack_require__(807)); | const mexec = __importStar(__webpack_require__(807)); | ||||||
| const stateHelper = __importStar(__webpack_require__(153)); | const stateHelper = __importStar(__webpack_require__(153)); | ||||||
| const core = __importStar(__webpack_require__(470)); | const core = __importStar(__webpack_require__(470)); | ||||||
|  | const exec = __importStar(__webpack_require__(986)); | ||||||
| function run() { | function run() { | ||||||
|     return __awaiter(this, void 0, void 0, function* () { |     return __awaiter(this, void 0, void 0, function* () { | ||||||
|         try { |         try { | ||||||
| @ -2492,6 +2493,7 @@ function run() { | |||||||
|             const bxVersion = core.getInput('version'); |             const bxVersion = core.getInput('version'); | ||||||
|             const bxDriver = core.getInput('driver') || 'docker-container'; |             const bxDriver = core.getInput('driver') || 'docker-container'; | ||||||
|             const bxDriverOpt = core.getInput('driver-opt'); |             const bxDriverOpt = core.getInput('driver-opt'); | ||||||
|  |             const bxBuildkitdFlags = core.getInput('buildkitd-flags'); | ||||||
|             const bxInstall = /true/i.test(core.getInput('install')); |             const bxInstall = /true/i.test(core.getInput('install')); | ||||||
|             const bxUse = /true/i.test(core.getInput('use')); |             const bxUse = /true/i.test(core.getInput('use')); | ||||||
|             const dockerConfigHome = process.env.DOCKER_CONFIG || path.join(os.homedir(), '.docker'); |             const dockerConfigHome = process.env.DOCKER_CONFIG || path.join(os.homedir(), '.docker'); | ||||||
| @ -2499,8 +2501,8 @@ function run() { | |||||||
|                 yield buildx.install(bxVersion || 'latest', dockerConfigHome); |                 yield buildx.install(bxVersion || 'latest', dockerConfigHome); | ||||||
|             } |             } | ||||||
|             core.info('📣 Buildx info'); |             core.info('📣 Buildx info'); | ||||||
|             yield exec.exec('docker', ['buildx', 'version'], false); |             yield exec.exec('docker', ['buildx', 'version']); | ||||||
|             const builderName = `builder-${(yield buildx.countBuilders()) + 1}-${process.env.GITHUB_JOB}`; |             const builderName = `builder-${process.env.GITHUB_JOB}-${(yield buildx.countBuilders()) + 1}`; | ||||||
|             core.setOutput('name', builderName); |             core.setOutput('name', builderName); | ||||||
|             stateHelper.setBuilderName(builderName); |             stateHelper.setBuilderName(builderName); | ||||||
|             core.info('🔨 Creating a new builder instance...'); |             core.info('🔨 Creating a new builder instance...'); | ||||||
| @ -2508,15 +2510,18 @@ function run() { | |||||||
|             if (bxDriverOpt) { |             if (bxDriverOpt) { | ||||||
|                 createArgs.push('--driver-opt', bxDriverOpt); |                 createArgs.push('--driver-opt', bxDriverOpt); | ||||||
|             } |             } | ||||||
|  |             if (bxBuildkitdFlags) { | ||||||
|  |                 createArgs.push('--buildkitd-flags', bxBuildkitdFlags); | ||||||
|  |             } | ||||||
|             if (bxUse) { |             if (bxUse) { | ||||||
|                 createArgs.push('--use'); |                 createArgs.push('--use'); | ||||||
|             } |             } | ||||||
|             yield exec.exec('docker', createArgs, false); |             yield exec.exec('docker', createArgs); | ||||||
|             core.info('🏃 Booting builder...'); |             core.info('🏃 Booting builder...'); | ||||||
|             yield exec.exec('docker', ['buildx', 'inspect', '--bootstrap'], false); |             yield exec.exec('docker', ['buildx', 'inspect', '--bootstrap']); | ||||||
|             if (bxInstall) { |             if (bxInstall) { | ||||||
|                 core.info('🤝 Setting buildx as default builder...'); |                 core.info('🤝 Setting buildx as default builder...'); | ||||||
|                 yield exec.exec('docker', ['buildx', 'install'], false); |                 yield exec.exec('docker', ['buildx', 'install']); | ||||||
|             } |             } | ||||||
|             core.info('🛒 Extracting available platforms...'); |             core.info('🛒 Extracting available platforms...'); | ||||||
|             const platforms = yield buildx.platforms(); |             const platforms = yield buildx.platforms(); | ||||||
| @ -2530,13 +2535,14 @@ function run() { | |||||||
| } | } | ||||||
| function cleanup() { | function cleanup() { | ||||||
|     return __awaiter(this, void 0, void 0, function* () { |     return __awaiter(this, void 0, void 0, function* () { | ||||||
|         try { |         if (stateHelper.builderName.length == 0) { | ||||||
|             core.info('🚿 Removing builder instance...'); |             return; | ||||||
|             yield exec.exec('docker', ['buildx', 'rm', `${process.env.STATE_builderName}`], false); |  | ||||||
|         } |  | ||||||
|         catch (error) { |  | ||||||
|             core.warning(error.message); |  | ||||||
|         } |         } | ||||||
|  |         yield mexec.exec('docker', ['buildx', 'rm', `${stateHelper.builderName}`], false).then(res => { | ||||||
|  |             if (res.stderr != '' && !res.success) { | ||||||
|  |                 core.warning(res.stderr); | ||||||
|  |             } | ||||||
|  |         }); | ||||||
|     }); |     }); | ||||||
| } | } | ||||||
| if (!stateHelper.IsPost) { | if (!stateHelper.IsPost) { | ||||||
| @ -6481,7 +6487,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge | |||||||
| }; | }; | ||||||
| Object.defineProperty(exports, "__esModule", { value: true }); | Object.defineProperty(exports, "__esModule", { value: true }); | ||||||
| exports.exec = void 0; | exports.exec = void 0; | ||||||
| const actionsExec = __importStar(__webpack_require__(986)); | const aexec = __importStar(__webpack_require__(986)); | ||||||
| exports.exec = (command, args = [], silent) => __awaiter(void 0, void 0, void 0, function* () { | exports.exec = (command, args = [], silent) => __awaiter(void 0, void 0, void 0, function* () { | ||||||
|     let stdout = ''; |     let stdout = ''; | ||||||
|     let stderr = ''; |     let stderr = ''; | ||||||
| @ -6497,7 +6503,7 @@ exports.exec = (command, args = [], silent) => __awaiter(void 0, void 0, void 0, | |||||||
|             stderr += data.toString(); |             stderr += data.toString(); | ||||||
|         } |         } | ||||||
|     }; |     }; | ||||||
|     const returnCode = yield actionsExec.exec(command, args, options); |     const returnCode = yield aexec.exec(command, args, options); | ||||||
|     return { |     return { | ||||||
|         success: returnCode === 0, |         success: returnCode === 0, | ||||||
|         stdout: stdout.trim(), |         stdout: stdout.trim(), | ||||||
|  | |||||||
| @ -1,6 +1,6 @@ | |||||||
| { | { | ||||||
|   "name": "setup-buildx", |   "name": "setup-buildx", | ||||||
|   "description": "GitHub Action to set up Docker Buildx", |   "description": "Set up Docker Buildx", | ||||||
|   "main": "lib/main.js", |   "main": "lib/main.js", | ||||||
|   "scripts": { |   "scripts": { | ||||||
|     "build": "tsc && ncc build", |     "build": "tsc && ncc build", | ||||||
| @ -11,15 +11,17 @@ | |||||||
|   }, |   }, | ||||||
|   "repository": { |   "repository": { | ||||||
|     "type": "git", |     "type": "git", | ||||||
|     "url": "git+https://github.com/docker/actions.git", |     "url": "git+https://github.com/docker/setup-buildx-action.git" | ||||||
|     "directory": "setup-buildx" |  | ||||||
|   }, |   }, | ||||||
|   "keywords": [ |   "keywords": [ | ||||||
|     "actions", |     "actions", | ||||||
|     "docker", |     "docker", | ||||||
|     "buildx" |     "buildx" | ||||||
|   ], |   ], | ||||||
|   "author": "CrazyMax", |   "author": "Docker", | ||||||
|  |   "contributors": [ | ||||||
|  |     "CrazyMax" | ||||||
|  |   ], | ||||||
|   "license": "Apache-2.0", |   "license": "Apache-2.0", | ||||||
|   "dependencies": { |   "dependencies": { | ||||||
|     "@actions/core": "^1.2.4", |     "@actions/core": "^1.2.4", | ||||||
|  | |||||||
| @ -1,4 +1,4 @@ | |||||||
| import * as actionsExec from '@actions/exec'; | import * as aexec from '@actions/exec'; | ||||||
| import {ExecOptions} from '@actions/exec'; | import {ExecOptions} from '@actions/exec'; | ||||||
| 
 | 
 | ||||||
| export interface ExecResult { | export interface ExecResult { | ||||||
| @ -24,7 +24,7 @@ export const exec = async (command: string, args: string[] = [], silent: boolean | |||||||
|     } |     } | ||||||
|   }; |   }; | ||||||
| 
 | 
 | ||||||
|   const returnCode: number = await actionsExec.exec(command, args, options); |   const returnCode: number = await aexec.exec(command, args, options); | ||||||
| 
 | 
 | ||||||
|   return { |   return { | ||||||
|     success: returnCode === 0, |     success: returnCode === 0, | ||||||
|  | |||||||
| @ -1,9 +1,10 @@ | |||||||
| import * as os from 'os'; | import * as os from 'os'; | ||||||
| import * as path from 'path'; | import * as path from 'path'; | ||||||
| import * as buildx from './buildx'; | import * as buildx from './buildx'; | ||||||
| import * as exec from './exec'; | import * as mexec from './exec'; | ||||||
| import * as stateHelper from './state-helper'; | import * as stateHelper from './state-helper'; | ||||||
| import * as core from '@actions/core'; | import * as core from '@actions/core'; | ||||||
|  | import * as exec from '@actions/exec'; | ||||||
| 
 | 
 | ||||||
| async function run(): Promise<void> { | async function run(): Promise<void> { | ||||||
|   try { |   try { | ||||||
| @ -15,6 +16,7 @@ async function run(): Promise<void> { | |||||||
|     const bxVersion: string = core.getInput('version'); |     const bxVersion: string = core.getInput('version'); | ||||||
|     const bxDriver: string = core.getInput('driver') || 'docker-container'; |     const bxDriver: string = core.getInput('driver') || 'docker-container'; | ||||||
|     const bxDriverOpt: string = core.getInput('driver-opt'); |     const bxDriverOpt: string = core.getInput('driver-opt'); | ||||||
|  |     const bxBuildkitdFlags: string = core.getInput('buildkitd-flags'); | ||||||
|     const bxInstall: boolean = /true/i.test(core.getInput('install')); |     const bxInstall: boolean = /true/i.test(core.getInput('install')); | ||||||
|     const bxUse: boolean = /true/i.test(core.getInput('use')); |     const bxUse: boolean = /true/i.test(core.getInput('use')); | ||||||
| 
 | 
 | ||||||
| @ -25,9 +27,9 @@ async function run(): Promise<void> { | |||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     core.info('📣 Buildx info'); |     core.info('📣 Buildx info'); | ||||||
|     await exec.exec('docker', ['buildx', 'version'], false); |     await exec.exec('docker', ['buildx', 'version']); | ||||||
| 
 | 
 | ||||||
|     const builderName: string = `builder-${(await buildx.countBuilders()) + 1}-${process.env.GITHUB_JOB}`; |     const builderName: string = `builder-${process.env.GITHUB_JOB}-${(await buildx.countBuilders()) + 1}`; | ||||||
|     core.setOutput('name', builderName); |     core.setOutput('name', builderName); | ||||||
|     stateHelper.setBuilderName(builderName); |     stateHelper.setBuilderName(builderName); | ||||||
| 
 | 
 | ||||||
| @ -36,18 +38,21 @@ async function run(): Promise<void> { | |||||||
|     if (bxDriverOpt) { |     if (bxDriverOpt) { | ||||||
|       createArgs.push('--driver-opt', bxDriverOpt); |       createArgs.push('--driver-opt', bxDriverOpt); | ||||||
|     } |     } | ||||||
|  |     if (bxBuildkitdFlags) { | ||||||
|  |       createArgs.push('--buildkitd-flags', bxBuildkitdFlags); | ||||||
|  |     } | ||||||
|     if (bxUse) { |     if (bxUse) { | ||||||
|       createArgs.push('--use'); |       createArgs.push('--use'); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     await exec.exec('docker', createArgs, false); |     await exec.exec('docker', createArgs); | ||||||
| 
 | 
 | ||||||
|     core.info('🏃 Booting builder...'); |     core.info('🏃 Booting builder...'); | ||||||
|     await exec.exec('docker', ['buildx', 'inspect', '--bootstrap'], false); |     await exec.exec('docker', ['buildx', 'inspect', '--bootstrap']); | ||||||
| 
 | 
 | ||||||
|     if (bxInstall) { |     if (bxInstall) { | ||||||
|       core.info('🤝 Setting buildx as default builder...'); |       core.info('🤝 Setting buildx as default builder...'); | ||||||
|       await exec.exec('docker', ['buildx', 'install'], false); |       await exec.exec('docker', ['buildx', 'install']); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     core.info('🛒 Extracting available platforms...'); |     core.info('🛒 Extracting available platforms...'); | ||||||
| @ -60,12 +65,14 @@ async function run(): Promise<void> { | |||||||
| } | } | ||||||
| 
 | 
 | ||||||
| async function cleanup(): Promise<void> { | async function cleanup(): Promise<void> { | ||||||
|   try { |   if (stateHelper.builderName.length == 0) { | ||||||
|     core.info('🚿 Removing builder instance...'); |     return; | ||||||
|     await exec.exec('docker', ['buildx', 'rm', `${process.env.STATE_builderName}`], false); |  | ||||||
|   } catch (error) { |  | ||||||
|     core.warning(error.message); |  | ||||||
|   } |   } | ||||||
|  |   await mexec.exec('docker', ['buildx', 'rm', `${stateHelper.builderName}`], false).then(res => { | ||||||
|  |     if (res.stderr != '' && !res.success) { | ||||||
|  |       core.warning(res.stderr); | ||||||
|  |     } | ||||||
|  |   }); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| if (!stateHelper.IsPost) { | if (!stateHelper.IsPost) { | ||||||
|  | |||||||
| @ -1,7 +1,7 @@ | |||||||
| import * as core from '@actions/core'; | import * as core from '@actions/core'; | ||||||
| 
 | 
 | ||||||
| export const IsPost = !!process.env['STATE_isPost']; | export const IsPost = !!process.env['STATE_isPost']; | ||||||
| export const builderName = !!process.env['STATE_builderName']; | export const builderName = process.env['STATE_builderName'] || ''; | ||||||
| 
 | 
 | ||||||
| export function setBuilderName(builderName: string) { | export function setBuilderName(builderName: string) { | ||||||
|   core.saveState('builderName', builderName); |   core.saveState('builderName', builderName); | ||||||
|  | |||||||
| @ -31,7 +31,7 @@ jobs: | |||||||
|       - |       - | ||||||
|         name: Set up QEMU |         name: Set up QEMU | ||||||
|         id: qemu |         id: qemu | ||||||
|         uses: docker/actions/setup-qemu@v1 |         uses: docker/setup-qemu-action@v1 | ||||||
|         with: |         with: | ||||||
|           image: tonistiigi/binfmt:latest |           image: tonistiigi/binfmt:latest | ||||||
|           platforms: all |           platforms: all | ||||||
|  | |||||||
| @ -1,10 +1,10 @@ | |||||||
| # https://help.github.com/en/articles/metadata-syntax-for-github-actions | # https://help.github.com/en/articles/metadata-syntax-for-github-actions | ||||||
| name: 'Docker - Setup QEMU' | name: 'Docker Setup QEMU' | ||||||
| description: 'GitHub Action to install QEMU static binaries' | description: 'Install QEMU static binaries' | ||||||
| author: 'crazy-max' | author: 'docker' | ||||||
| branding: | branding: | ||||||
|  |   icon: 'anchor' | ||||||
|   color: 'blue' |   color: 'blue' | ||||||
|   icon: 'truck' |  | ||||||
| 
 | 
 | ||||||
| inputs: | inputs: | ||||||
|   image: |   image: | ||||||
|  | |||||||
							
								
								
									
										7
									
								
								setup-qemu/dist/index.js
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										7
									
								
								setup-qemu/dist/index.js
									
									
									
										generated
									
									
										vendored
									
									
								
							| @ -1002,8 +1002,9 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge | |||||||
| }; | }; | ||||||
| Object.defineProperty(exports, "__esModule", { value: true }); | Object.defineProperty(exports, "__esModule", { value: true }); | ||||||
| const os = __importStar(__webpack_require__(87)); | const os = __importStar(__webpack_require__(87)); | ||||||
|  | const mexec = __importStar(__webpack_require__(807)); | ||||||
| const core = __importStar(__webpack_require__(470)); | const core = __importStar(__webpack_require__(470)); | ||||||
| const exec = __importStar(__webpack_require__(807)); | const exec = __importStar(__webpack_require__(986)); | ||||||
| function run() { | function run() { | ||||||
|     return __awaiter(this, void 0, void 0, function* () { |     return __awaiter(this, void 0, void 0, function* () { | ||||||
|         try { |         try { | ||||||
| @ -1014,9 +1015,9 @@ function run() { | |||||||
|             const image = core.getInput('image') || 'tonistiigi/binfmt:latest'; |             const image = core.getInput('image') || 'tonistiigi/binfmt:latest'; | ||||||
|             const platforms = core.getInput('platforms') || 'all'; |             const platforms = core.getInput('platforms') || 'all'; | ||||||
|             core.info(`💎 Installing QEMU static binaries...`); |             core.info(`💎 Installing QEMU static binaries...`); | ||||||
|             yield exec.exec('docker', ['run', '--rm', '--privileged', image, '--install', platforms], false); |             yield exec.exec('docker', ['run', '--rm', '--privileged', image, '--install', platforms]); | ||||||
|             core.info('🛒 Extracting available platforms...'); |             core.info('🛒 Extracting available platforms...'); | ||||||
|             yield exec.exec(`docker`, ['run', '--rm', '--privileged', image], true).then(res => { |             yield mexec.exec(`docker`, ['run', '--rm', '--privileged', image], true).then(res => { | ||||||
|                 if (res.stderr != '' && !res.success) { |                 if (res.stderr != '' && !res.success) { | ||||||
|                     throw new Error(res.stderr); |                     throw new Error(res.stderr); | ||||||
|                 } |                 } | ||||||
|  | |||||||
| @ -1,12 +0,0 @@ | |||||||
| module.exports = { |  | ||||||
|   clearMocks: true, |  | ||||||
|   moduleFileExtensions: ['js', 'ts'], |  | ||||||
|   setupFiles: ["dotenv/config"], |  | ||||||
|   testEnvironment: 'node', |  | ||||||
|   testMatch: ['**/*.test.ts'], |  | ||||||
|   testRunner: 'jest-circus/runner', |  | ||||||
|   transform: { |  | ||||||
|     '^.+\\.ts$': 'ts-jest' |  | ||||||
|   }, |  | ||||||
|   verbose: false |  | ||||||
| } |  | ||||||
| @ -1,40 +1,35 @@ | |||||||
| { | { | ||||||
|   "name": "docker-setup-qemu", |   "name": "docker-setup-qemu", | ||||||
|   "description": "GitHub Action to install QEMU static binaries", |   "description": "Install QEMU static binaries", | ||||||
|   "main": "lib/main.js", |   "main": "lib/main.js", | ||||||
|   "scripts": { |   "scripts": { | ||||||
|     "build": "tsc && ncc build", |     "build": "tsc && ncc build", | ||||||
|     "format": "prettier --write **/*.ts", |     "format": "prettier --write **/*.ts", | ||||||
|     "format-check": "prettier --check **/*.ts", |     "format-check": "prettier --check **/*.ts", | ||||||
|     "test": "jest --coverage", |  | ||||||
|     "pre-checkin": "yarn run format && yarn run build" |     "pre-checkin": "yarn run format && yarn run build" | ||||||
|   }, |   }, | ||||||
|   "repository": { |   "repository": { | ||||||
|     "type": "git", |     "type": "git", | ||||||
|     "url": "git+https://github.com/docker/actions.git", |     "url": "git+https://github.com/docker/setup-qemu-action.git" | ||||||
|     "directory": "setup-qemu" |  | ||||||
|   }, |   }, | ||||||
|   "keywords": [ |   "keywords": [ | ||||||
|     "actions", |     "actions", | ||||||
|     "docker", |     "docker", | ||||||
|     "qemu" |     "qemu" | ||||||
|   ], |   ], | ||||||
|   "author": "CrazyMax", |   "author": "Docker", | ||||||
|  |   "contributors": [ | ||||||
|  |     "CrazyMax" | ||||||
|  |   ], | ||||||
|   "license": "Apache-2.0", |   "license": "Apache-2.0", | ||||||
|   "dependencies": { |   "dependencies": { | ||||||
|     "@actions/core": "^1.2.4", |     "@actions/core": "^1.2.4", | ||||||
|     "@actions/exec": "^1.0.4" |     "@actions/exec": "^1.0.4" | ||||||
|   }, |   }, | ||||||
|   "devDependencies": { |   "devDependencies": { | ||||||
|     "@types/jest": "^26.0.3", |  | ||||||
|     "@types/node": "^14.0.14", |     "@types/node": "^14.0.14", | ||||||
|     "@zeit/ncc": "^0.22.3", |     "@zeit/ncc": "^0.22.3", | ||||||
|     "dotenv": "^8.2.0", |  | ||||||
|     "jest": "^26.1.0", |  | ||||||
|     "jest-circus": "^26.1.0", |  | ||||||
|     "jest-runtime": "^26.1.0", |  | ||||||
|     "prettier": "^2.0.5", |     "prettier": "^2.0.5", | ||||||
|     "ts-jest": "^26.1.1", |  | ||||||
|     "typescript": "^3.9.5", |     "typescript": "^3.9.5", | ||||||
|     "typescript-formatter": "^7.2.2" |     "typescript-formatter": "^7.2.2" | ||||||
|   } |   } | ||||||
|  | |||||||
| @ -1,6 +1,7 @@ | |||||||
| import * as os from 'os'; | import * as os from 'os'; | ||||||
|  | import * as mexec from './exec'; | ||||||
| import * as core from '@actions/core'; | import * as core from '@actions/core'; | ||||||
| import * as exec from './exec'; | import * as exec from '@actions/exec'; | ||||||
| 
 | 
 | ||||||
| interface Platforms { | interface Platforms { | ||||||
|   supported: string[]; |   supported: string[]; | ||||||
| @ -18,10 +19,10 @@ async function run(): Promise<void> { | |||||||
|     const platforms: string = core.getInput('platforms') || 'all'; |     const platforms: string = core.getInput('platforms') || 'all'; | ||||||
| 
 | 
 | ||||||
|     core.info(`💎 Installing QEMU static binaries...`); |     core.info(`💎 Installing QEMU static binaries...`); | ||||||
|     await exec.exec('docker', ['run', '--rm', '--privileged', image, '--install', platforms], false); |     await exec.exec('docker', ['run', '--rm', '--privileged', image, '--install', platforms]); | ||||||
| 
 | 
 | ||||||
|     core.info('🛒 Extracting available platforms...'); |     core.info('🛒 Extracting available platforms...'); | ||||||
|     await exec.exec(`docker`, ['run', '--rm', '--privileged', image], true).then(res => { |     await mexec.exec(`docker`, ['run', '--rm', '--privileged', image], true).then(res => { | ||||||
|       if (res.stderr != '' && !res.success) { |       if (res.stderr != '' && !res.success) { | ||||||
|         throw new Error(res.stderr); |         throw new Error(res.stderr); | ||||||
|       } |       } | ||||||
|  | |||||||
							
								
								
									
										3663
									
								
								setup-qemu/yarn.lock
									
									
									
									
									
								
							
							
						
						
									
										3663
									
								
								setup-qemu/yarn.lock
									
									
									
									
									
								
							
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user