Fix and cleanup of v2 setup actions

Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
This commit is contained in:
CrazyMax 2020-08-16 04:10:09 +02:00
parent 3f08c86128
commit e9cb922263
No known key found for this signature in database
GPG key ID: 3248E46B6BB8C7F7
19 changed files with 66 additions and 3827 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
-

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:

30
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 {
@ -2499,7 +2500,7 @@ function run() {
yield buildx.install(bxVersion || 'latest', dockerConfigHome);
}
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}`;
core.setOutput('name', builderName);
stateHelper.setBuilderName(builderName);
@ -2511,12 +2512,12 @@ function run() {
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,13 +2531,14 @@ 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);
}
catch (error) {
core.warning(error.message);
if (stateHelper.builderName.length == 0) {
return;
}
yield mexec.exec('docker', ['buildx', 'rm', `${stateHelper.builderName}`], false).then(res => {
if (res.stderr != '' && !res.success) {
core.warning(res.stderr);
}
});
});
}
if (!stateHelper.IsPost) {
@ -6481,7 +6483,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 +6499,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",
@ -32,7 +34,6 @@
"@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",

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 {
@ -25,7 +26,7 @@ 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}`;
core.setOutput('name', builderName);
@ -40,14 +41,14 @@ async function run(): Promise<void> {
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 +61,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

@ -1236,11 +1236,6 @@ domexception@^2.0.1:
dependencies:
webidl-conversions "^5.0.0"
dotenv@^8.2.0:
version "8.2.0"
resolved "https://registry.yarnpkg.com/dotenv/-/dotenv-8.2.0.tgz#97e619259ada750eea3e4ea3e26bceea5424b16a"
integrity sha512-8sJ78ElpbDJBHNeBzUbUVLsqKdccaa/BXF1uPTw3GrvQTBgrQrtObr2mUrE38vzYd8cEv+m/JBfDLioYcfXoaw==
ecc-jsbn@~0.1.1:
version "0.1.2"
resolved "https://registry.yarnpkg.com/ecc-jsbn/-/ecc-jsbn-0.1.2.tgz#3a83a904e54353287874c564b7549386849a98c9"

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