Merge branch 'v2-working-branch' into v2-build-push

Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
This commit is contained in:
CrazyMax 2020-08-17 01:06:14 +02:00
commit fbd34eda32
No known key found for this signature in database
GPG Key ID: 3248E46B6BB8C7F7
19 changed files with 90 additions and 3833 deletions

View File

@ -27,12 +27,6 @@ jobs:
- v0.2.2
- ""
steps:
-
name: Runner info
run: |
sudo apt-get install -y hwinfo
sudo hwinfo --short
sudo mount
-
name: Checkout
uses: actions/checkout@v2.3.1

View File

@ -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

View File

@ -29,12 +29,6 @@ jobs:
- all
- arm64,riscv64,arm
steps:
-
name: Runner info
run: |
sudo apt-get install -y hwinfo
sudo hwinfo --short
sudo mount
-
name: Checkout
uses: actions/checkout@v2.3.1

View File

@ -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

View File

@ -37,7 +37,7 @@ jobs:
-
name: Set up Docker Buildx
id: buildx
uses: docker/actions/setup-buildx@v1
uses: docker/setup-buildx-action@v1
with:
version: latest
-
@ -71,13 +71,13 @@ jobs:
uses: actions/checkout@v2
-
name: Set up QEMU
uses: docker/actions/setup-qemu@v1
uses: docker/setup-qemu-action@v1
with:
platforms: all
-
name: Set up Docker Buildx
id: buildx
uses: docker/actions/setup-buildx@v1
uses: docker/setup-buildx-action@v1
with:
version: latest
-
@ -92,10 +92,11 @@ jobs:
Following inputs can be used as `step.with` keys
| 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` |
| `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` |
| `buildkitd-flags` | String | | [Flags for buildkitd](https://github.com/moby/buildkit/blob/master/docs/buildkitd.toml.md) daemon. |
| `install` | Bool | `false` | Sets up `docker build` command as an alias to `docker buildx` |
| `use` | Bool | `true` | Switch to this builder instance |

View File

@ -8,20 +8,20 @@ const tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), 'setup-buildx-'));
describe('buildx', () => {
it('is available', async () => {
expect(await buildx.isAvailable()).toBe(true);
});
}, 100000);
it('count builders', async () => {
const countBuilders = await buildx.countBuilders();
console.log(`countBuilders: ${countBuilders}`);
expect(countBuilders).toBeGreaterThan(0);
});
}, 100000);
it('platforms', async () => {
const platforms = await buildx.platforms();
console.log(`platforms: ${platforms}`);
expect(platforms).not.toBeUndefined();
expect(platforms).not.toEqual('');
});
}, 100000);
it('acquires v0.2.2 version of buildx', async () => {
const buildxBin = await buildx.install('v0.2.2', tmpDir);

View File

@ -1,10 +1,10 @@
# https://help.github.com/en/articles/metadata-syntax-for-github-actions
name: 'Docker - Setup Buildx'
description: 'GitHub Action to set up Docker Buildx'
author: 'crazy-max'
name: 'Docker Setup Buildx'
description: 'Set up Docker Buildx'
author: 'docker'
branding:
icon: 'anchor'
color: 'blue'
icon: 'truck'
inputs:
version:
@ -17,6 +17,9 @@ inputs:
driver-opt:
description: 'Passes additional driver-specific options. Eg. image=moby/buildkit:master'
required: false
buildkitd-flags:
description: 'Flags for buildkitd daemon'
required: false
install:
description: 'Sets up docker build command as an alias to docker buildx'
default: 'false'

34
setup-buildx/dist/index.js generated vendored
View File

@ -2186,7 +2186,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
exports.setBuilderName = exports.builderName = exports.IsPost = void 0;
const core = __importStar(__webpack_require__(470));
exports.IsPost = !!process.env['STATE_isPost'];
exports.builderName = !!process.env['STATE_builderName'];
exports.builderName = process.env['STATE_builderName'] || '';
function setBuilderName(builderName) {
core.saveState('builderName', builderName);
}
@ -2479,9 +2479,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
const os = __importStar(__webpack_require__(87));
const path = __importStar(__webpack_require__(622));
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 core = __importStar(__webpack_require__(470));
const exec = __importStar(__webpack_require__(986));
function run() {
return __awaiter(this, void 0, void 0, function* () {
try {
@ -2492,6 +2493,7 @@ function run() {
const bxVersion = core.getInput('version');
const bxDriver = core.getInput('driver') || 'docker-container';
const bxDriverOpt = core.getInput('driver-opt');
const bxBuildkitdFlags = core.getInput('buildkitd-flags');
const bxInstall = /true/i.test(core.getInput('install'));
const bxUse = /true/i.test(core.getInput('use'));
const dockerConfigHome = process.env.DOCKER_CONFIG || path.join(os.homedir(), '.docker');
@ -2499,8 +2501,8 @@ function run() {
yield buildx.install(bxVersion || 'latest', dockerConfigHome);
}
core.info('📣 Buildx info');
yield exec.exec('docker', ['buildx', 'version'], false);
const builderName = `builder-${(yield buildx.countBuilders()) + 1}-${process.env.GITHUB_JOB}`;
yield exec.exec('docker', ['buildx', 'version']);
const builderName = `builder-${process.env.GITHUB_JOB}-${(yield buildx.countBuilders()) + 1}`;
core.setOutput('name', builderName);
stateHelper.setBuilderName(builderName);
core.info('🔨 Creating a new builder instance...');
@ -2508,15 +2510,18 @@ function run() {
if (bxDriverOpt) {
createArgs.push('--driver-opt', bxDriverOpt);
}
if (bxBuildkitdFlags) {
createArgs.push('--buildkitd-flags', bxBuildkitdFlags);
}
if (bxUse) {
createArgs.push('--use');
}
yield exec.exec('docker', createArgs, false);
yield exec.exec('docker', createArgs);
core.info('🏃 Booting builder...');
yield exec.exec('docker', ['buildx', 'inspect', '--bootstrap'], false);
yield exec.exec('docker', ['buildx', 'inspect', '--bootstrap']);
if (bxInstall) {
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...');
const platforms = yield buildx.platforms();
@ -2530,14 +2535,15 @@ function run() {
}
function cleanup() {
return __awaiter(this, void 0, void 0, function* () {
try {
core.info('🚿 Removing builder instance...');
yield exec.exec('docker', ['buildx', 'rm', `${process.env.STATE_builderName}`], false);
if (stateHelper.builderName.length == 0) {
return;
}
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) {
run();
@ -6481,7 +6487,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
};
Object.defineProperty(exports, "__esModule", { value: true });
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* () {
let stdout = '';
let stderr = '';
@ -6497,7 +6503,7 @@ exports.exec = (command, args = [], silent) => __awaiter(void 0, void 0, void 0,
stderr += data.toString();
}
};
const returnCode = yield actionsExec.exec(command, args, options);
const returnCode = yield aexec.exec(command, args, options);
return {
success: returnCode === 0,
stdout: stdout.trim(),

View File

@ -1,6 +1,6 @@
{
"name": "setup-buildx",
"description": "GitHub Action to set up Docker Buildx",
"description": "Set up Docker Buildx",
"main": "lib/main.js",
"scripts": {
"build": "tsc && ncc build",
@ -11,15 +11,17 @@
},
"repository": {
"type": "git",
"url": "git+https://github.com/docker/actions.git",
"directory": "setup-buildx"
"url": "git+https://github.com/docker/setup-buildx-action.git"
},
"keywords": [
"actions",
"docker",
"buildx"
],
"author": "CrazyMax",
"author": "Docker",
"contributors": [
"CrazyMax"
],
"license": "Apache-2.0",
"dependencies": {
"@actions/core": "^1.2.4",

View File

@ -1,4 +1,4 @@
import * as actionsExec from '@actions/exec';
import * as aexec from '@actions/exec';
import {ExecOptions} from '@actions/exec';
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 {
success: returnCode === 0,

View File

@ -1,9 +1,10 @@
import * as os from 'os';
import * as path from 'path';
import * as buildx from './buildx';
import * as exec from './exec';
import * as mexec from './exec';
import * as stateHelper from './state-helper';
import * as core from '@actions/core';
import * as exec from '@actions/exec';
async function run(): Promise<void> {
try {
@ -15,6 +16,7 @@ async function run(): Promise<void> {
const bxVersion: string = core.getInput('version');
const bxDriver: string = core.getInput('driver') || 'docker-container';
const bxDriverOpt: string = core.getInput('driver-opt');
const bxBuildkitdFlags: string = core.getInput('buildkitd-flags');
const bxInstall: boolean = /true/i.test(core.getInput('install'));
const bxUse: boolean = /true/i.test(core.getInput('use'));
@ -25,9 +27,9 @@ async function run(): Promise<void> {
}
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);
stateHelper.setBuilderName(builderName);
@ -36,18 +38,21 @@ async function run(): Promise<void> {
if (bxDriverOpt) {
createArgs.push('--driver-opt', bxDriverOpt);
}
if (bxBuildkitdFlags) {
createArgs.push('--buildkitd-flags', bxBuildkitdFlags);
}
if (bxUse) {
createArgs.push('--use');
}
await exec.exec('docker', createArgs, false);
await exec.exec('docker', createArgs);
core.info('🏃 Booting builder...');
await exec.exec('docker', ['buildx', 'inspect', '--bootstrap'], false);
await exec.exec('docker', ['buildx', 'inspect', '--bootstrap']);
if (bxInstall) {
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...');
@ -60,12 +65,14 @@ async function run(): Promise<void> {
}
async function cleanup(): Promise<void> {
try {
core.info('🚿 Removing builder instance...');
await exec.exec('docker', ['buildx', 'rm', `${process.env.STATE_builderName}`], false);
} catch (error) {
core.warning(error.message);
if (stateHelper.builderName.length == 0) {
return;
}
await mexec.exec('docker', ['buildx', 'rm', `${stateHelper.builderName}`], false).then(res => {
if (res.stderr != '' && !res.success) {
core.warning(res.stderr);
}
});
}
if (!stateHelper.IsPost) {

View File

@ -1,7 +1,7 @@
import * as core from '@actions/core';
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) {
core.saveState('builderName', builderName);

View File

@ -31,7 +31,7 @@ jobs:
-
name: Set up QEMU
id: qemu
uses: docker/actions/setup-qemu@v1
uses: docker/setup-qemu-action@v1
with:
image: tonistiigi/binfmt:latest
platforms: all

View File

@ -1,10 +1,10 @@
# https://help.github.com/en/articles/metadata-syntax-for-github-actions
name: 'Docker - Setup QEMU'
description: 'GitHub Action to install QEMU static binaries'
author: 'crazy-max'
name: 'Docker Setup QEMU'
description: 'Install QEMU static binaries'
author: 'docker'
branding:
icon: 'anchor'
color: 'blue'
icon: 'truck'
inputs:
image:

7
setup-qemu/dist/index.js generated vendored
View File

@ -1002,8 +1002,9 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
};
Object.defineProperty(exports, "__esModule", { value: true });
const os = __importStar(__webpack_require__(87));
const mexec = __importStar(__webpack_require__(807));
const core = __importStar(__webpack_require__(470));
const exec = __importStar(__webpack_require__(807));
const exec = __importStar(__webpack_require__(986));
function run() {
return __awaiter(this, void 0, void 0, function* () {
try {
@ -1014,9 +1015,9 @@ function run() {
const image = core.getInput('image') || 'tonistiigi/binfmt:latest';
const platforms = core.getInput('platforms') || 'all';
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...');
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) {
throw new Error(res.stderr);
}

View File

@ -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
}

View File

@ -1,40 +1,35 @@
{
"name": "docker-setup-qemu",
"description": "GitHub Action to install QEMU static binaries",
"description": "Install QEMU static binaries",
"main": "lib/main.js",
"scripts": {
"build": "tsc && ncc build",
"format": "prettier --write **/*.ts",
"format-check": "prettier --check **/*.ts",
"test": "jest --coverage",
"pre-checkin": "yarn run format && yarn run build"
},
"repository": {
"type": "git",
"url": "git+https://github.com/docker/actions.git",
"directory": "setup-qemu"
"url": "git+https://github.com/docker/setup-qemu-action.git"
},
"keywords": [
"actions",
"docker",
"qemu"
],
"author": "CrazyMax",
"author": "Docker",
"contributors": [
"CrazyMax"
],
"license": "Apache-2.0",
"dependencies": {
"@actions/core": "^1.2.4",
"@actions/exec": "^1.0.4"
},
"devDependencies": {
"@types/jest": "^26.0.3",
"@types/node": "^14.0.14",
"@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",
"ts-jest": "^26.1.1",
"typescript": "^3.9.5",
"typescript-formatter": "^7.2.2"
}

View File

@ -1,6 +1,7 @@
import * as os from 'os';
import * as mexec from './exec';
import * as core from '@actions/core';
import * as exec from './exec';
import * as exec from '@actions/exec';
interface Platforms {
supported: string[];
@ -18,10 +19,10 @@ async function run(): Promise<void> {
const platforms: string = core.getInput('platforms') || 'all';
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...');
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) {
throw new Error(res.stderr);
}

File diff suppressed because it is too large Load Diff