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

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

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

View file

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

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; 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 {
@ -2499,7 +2500,7 @@ 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-${(yield buildx.countBuilders()) + 1}-${process.env.GITHUB_JOB}`;
core.setOutput('name', builderName); core.setOutput('name', builderName);
stateHelper.setBuilderName(builderName); stateHelper.setBuilderName(builderName);
@ -2511,12 +2512,12 @@ function run() {
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 +2531,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 +6483,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 +6499,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(),

View file

@ -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",
@ -32,7 +34,6 @@
"@types/jest": "^26.0.3", "@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": "^26.1.0",
"jest-circus": "^26.1.0", "jest-circus": "^26.1.0",
"jest-runtime": "^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'; 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,

View file

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

View file

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

View file

@ -1236,11 +1236,6 @@ domexception@^2.0.1:
dependencies: dependencies:
webidl-conversions "^5.0.0" 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: ecc-jsbn@~0.1.1:
version "0.1.2" version "0.1.2"
resolved "https://registry.yarnpkg.com/ecc-jsbn/-/ecc-jsbn-0.1.2.tgz#3a83a904e54353287874c564b7549386849a98c9" 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 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

View file

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

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

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", "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"
} }

View file

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

File diff suppressed because it is too large Load diff