Compare commits

..

1 Commits

Author SHA1 Message Date
5abd98b9f8 替换源镜像 2023-12-02 13:54:36 +08:00
21 changed files with 4030 additions and 10963 deletions

View File

@ -1,12 +1,2 @@
/coverage /coverage
/node_modules
# Dependency directories
node_modules/
jspm_packages/
# yarn v2
.yarn/cache
.yarn/unplugged
.yarn/build-state.yml
.yarn/install-state.gz
.pnp.*

2
.gitattributes vendored
View File

@ -1,4 +1,2 @@
/.yarn/releases/** binary
/.yarn/plugins/** binary
/dist/** linguist-generated=true /dist/** linguist-generated=true
/lib/** linguist-generated=true /lib/** linguist-generated=true

View File

@ -16,28 +16,14 @@ on:
pull_request: pull_request:
jobs: jobs:
default:
runs-on: ubuntu-latest
steps:
-
name: Checkout
uses: actions/checkout@v4
-
name: Set up QEMU
id: qemu
uses: ./
-
name: Available platforms
run: echo ${{ steps.qemu.outputs.platforms }}
main: main:
runs-on: ubuntu-latest runs-on: ubuntu-latest
strategy: strategy:
fail-fast: false fail-fast: false
matrix: matrix:
image: image:
- tonistiigi/binfmt:latest - gitea.icodef.com/codfrm/binfmt:latest
- tonistiigi/binfmt:master - gitea.icodef.com/codfrm/binfmt:master
platforms: platforms:
- all - all
- arm64,riscv64,arm - arm64,riscv64,arm

View File

@ -20,12 +20,11 @@ jobs:
uses: actions/checkout@v4 uses: actions/checkout@v4
- -
name: Test name: Test
uses: docker/bake-action@v5 uses: docker/bake-action@v4
with: with:
targets: test targets: test
- -
name: Upload coverage name: Upload coverage
uses: codecov/codecov-action@v4 uses: codecov/codecov-action@v3
with: with:
file: ./coverage/clover.xml file: ./coverage/clover.xml
token: ${{ secrets.CODECOV_TOKEN }}

View File

@ -40,6 +40,6 @@ jobs:
uses: actions/checkout@v4 uses: actions/checkout@v4
- -
name: Validate name: Validate
uses: docker/bake-action@v5 uses: docker/bake-action@v4
with: with:
targets: ${{ matrix.target }} targets: ${{ matrix.target }}

66
.gitignore vendored
View File

@ -1,5 +1,7 @@
# https://raw.githubusercontent.com/github/gitignore/main/Node.gitignore node_modules
lib
# Rest of the file pulled from https://github.com/github/gitignore/blob/master/Node.gitignore
# Logs # Logs
logs logs
*.log *.log
@ -7,7 +9,6 @@ npm-debug.log*
yarn-debug.log* yarn-debug.log*
yarn-error.log* yarn-error.log*
lerna-debug.log* lerna-debug.log*
.pnpm-debug.log*
# Diagnostic reports (https://nodejs.org/api/report.html) # Diagnostic reports (https://nodejs.org/api/report.html)
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
@ -18,14 +19,34 @@ pids
*.seed *.seed
*.pid.lock *.pid.lock
# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov
# Coverage directory used by tools like istanbul # Coverage directory used by tools like istanbul
coverage coverage
*.lcov *.lcov
# nyc test coverage
.nyc_output
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
.grunt
# Bower dependency directory (https://bower.io/)
bower_components
# node-waf configuration
.lock-wscript
# Compiled binary addons (https://nodejs.org/api/addons.html)
build/Release
# Dependency directories # Dependency directories
node_modules/
jspm_packages/ jspm_packages/
# TypeScript v1 declaration files
typings/
# TypeScript cache # TypeScript cache
*.tsbuildinfo *.tsbuildinfo
@ -35,19 +56,36 @@ jspm_packages/
# Optional eslint cache # Optional eslint cache
.eslintcache .eslintcache
# Optional REPL history
.node_repl_history
# Output of 'npm pack'
*.tgz
# Yarn Integrity file # Yarn Integrity file
.yarn-integrity .yarn-integrity
# dotenv environment variable files # dotenv environment variables file
.env .env
.env.development.local .env.test
.env.test.local
.env.production.local
.env.local
# yarn v2 # parcel-bundler cache (https://parceljs.org/)
.yarn/cache .cache
.yarn/unplugged
.yarn/build-state.yml # next.js build output
.yarn/install-state.gz .next
.pnp.*
# nuxt.js build output
.nuxt
# vuepress build output
.vuepress/dist
# Serverless directories
.serverless/
# FuseBox cache
.fusebox/
# DynamoDB Local files
.dynamodb/

View File

@ -1,6 +0,0 @@
# Dependency directories
node_modules/
jspm_packages/
# yarn v2
.yarn/

File diff suppressed because one or more lines are too long

View File

@ -1,13 +0,0 @@
logFilters:
- code: YN0013
level: discard
- code: YN0019
level: discard
- code: YN0076
level: discard
nodeLinker: node-modules
plugins:
- path: .yarn/plugins/@yarnpkg/plugin-interactive-tools.cjs
spec: "@yarnpkg/plugin-interactive-tools"

View File

@ -43,7 +43,7 @@ The following inputs can be used as `step.with` keys:
| Name | Type | Default | Description | | Name | Type | Default | Description |
|-------------|--------|-------------------------------------------------------------------------------|--------------------------------------------------| |-------------|--------|-------------------------------------------------------------------------------|--------------------------------------------------|
| `image` | String | [`tonistiigi/binfmt:latest`](https://hub.docker.com/r/tonistiigi/binfmt/tags) | QEMU static binaries Docker image | | `image` | String | [`gitea.icodef.com/codfrm/binfmt:latest`](https://hub.docker.com/r/gitea.icodef.com/codfrm/binfmt/tags) | QEMU static binaries Docker image |
| `platforms` | String | `all` | Platforms to install (e.g., `arm64,riscv64,arm`) | | `platforms` | String | `all` | Platforms to install (e.g., `arm64,riscv64,arm`) |
### outputs ### outputs

View File

@ -18,7 +18,7 @@ describe('getInputs', () => {
0, 0,
new Map<string, string>([]), new Map<string, string>([]),
{ {
image: 'docker.io/tonistiigi/binfmt:latest', image: 'gitea.icodef.com/codfrm/binfmt:latest',
platforms: 'all', platforms: 'all',
} as context.Inputs } as context.Inputs
], ],
@ -39,7 +39,7 @@ describe('getInputs', () => {
['platforms', 'arm64, riscv64, arm '], ['platforms', 'arm64, riscv64, arm '],
]), ]),
{ {
image: 'docker.io/tonistiigi/binfmt:latest', image: 'gitea.icodef.com/codfrm/binfmt:latest',
platforms: 'arm64,riscv64,arm', platforms: 'arm64,riscv64,arm',
} as context.Inputs } as context.Inputs
] ]

View File

@ -8,8 +8,8 @@ branding:
inputs: inputs:
image: image:
description: 'QEMU static binaries Docker image (e.g. tonistiigi/binfmt:latest)' description: 'QEMU static binaries Docker image (e.g. gitea.icodef.com/codfrm/binfmt:latest)'
default: 'docker.io/tonistiigi/binfmt:latest' default: 'gitea.icodef.com/codfrm/binfmt:latest'
required: false required: false
platforms: platforms:
description: 'Platforms to install (e.g. arm64,riscv64,arm)' description: 'Platforms to install (e.g. arm64,riscv64,arm)'

View File

@ -5,16 +5,9 @@ ARG NODE_VERSION=20
FROM node:${NODE_VERSION}-alpine AS base FROM node:${NODE_VERSION}-alpine AS base
RUN apk add --no-cache cpio findutils git RUN apk add --no-cache cpio findutils git
WORKDIR /src WORKDIR /src
RUN --mount=type=bind,target=.,rw \
--mount=type=cache,target=/src/.yarn/cache <<EOT
corepack enable
yarn --version
yarn config set --home enableTelemetry 0
EOT
FROM base AS deps FROM base AS deps
RUN --mount=type=bind,target=.,rw \ RUN --mount=type=bind,target=.,rw \
--mount=type=cache,target=/src/.yarn/cache \
--mount=type=cache,target=/src/node_modules \ --mount=type=cache,target=/src/node_modules \
yarn install && mkdir /vendor && cp yarn.lock /vendor yarn install && mkdir /vendor && cp yarn.lock /vendor
@ -27,7 +20,7 @@ RUN --mount=type=bind,target=.,rw <<EOT
git add -A git add -A
cp -rf /vendor/* . cp -rf /vendor/* .
if [ -n "$(git status --porcelain -- yarn.lock)" ]; then if [ -n "$(git status --porcelain -- yarn.lock)" ]; then
echo >&2 'ERROR: Vendor result differs. Please vendor your package with "docker buildx bake vendor"' echo >&2 'ERROR: Vendor result differs. Please vendor your package with "docker buildx bake vendor-update"'
git status --porcelain -- yarn.lock git status --porcelain -- yarn.lock
exit 1 exit 1
fi fi
@ -35,7 +28,6 @@ EOT
FROM deps AS build FROM deps AS build
RUN --mount=type=bind,target=.,rw \ RUN --mount=type=bind,target=.,rw \
--mount=type=cache,target=/src/.yarn/cache \
--mount=type=cache,target=/src/node_modules \ --mount=type=cache,target=/src/node_modules \
yarn run build && mkdir /out && cp -Rf dist /out/ yarn run build && mkdir /out && cp -Rf dist /out/
@ -56,23 +48,20 @@ EOT
FROM deps AS format FROM deps AS format
RUN --mount=type=bind,target=.,rw \ RUN --mount=type=bind,target=.,rw \
--mount=type=cache,target=/src/.yarn/cache \
--mount=type=cache,target=/src/node_modules \ --mount=type=cache,target=/src/node_modules \
yarn run format \ yarn run format \
&& mkdir /out && find . -name '*.ts' -not -path './node_modules/*' -not -path './.yarn/*' | cpio -pdm /out && mkdir /out && find . -name '*.ts' -not -path './node_modules/*' | cpio -pdm /out
FROM scratch AS format-update FROM scratch AS format-update
COPY --from=format /out / COPY --from=format /out /
FROM deps AS lint FROM deps AS lint
RUN --mount=type=bind,target=.,rw \ RUN --mount=type=bind,target=.,rw \
--mount=type=cache,target=/src/.yarn/cache \
--mount=type=cache,target=/src/node_modules \ --mount=type=cache,target=/src/node_modules \
yarn run lint yarn run lint
FROM deps AS test FROM deps AS test
RUN --mount=type=bind,target=.,rw \ RUN --mount=type=bind,target=.,rw \
--mount=type=cache,target=/src/.yarn/cache \
--mount=type=cache,target=/src/node_modules \ --mount=type=cache,target=/src/node_modules \
yarn run test --coverage --coverageDirectory=/tmp/coverage yarn run test --coverage --coverageDirectory=/tmp/coverage

103
dist/index.js generated vendored

File diff suppressed because one or more lines are too long

2
dist/index.js.map generated vendored

File diff suppressed because one or more lines are too long

3558
dist/licenses.txt generated vendored

File diff suppressed because it is too large Load Diff

View File

@ -3,7 +3,7 @@ group "default" {
} }
group "pre-checkin" { group "pre-checkin" {
targets = ["vendor", "format", "build"] targets = ["vendor-update", "format", "build"]
} }
group "validate" { group "validate" {
@ -34,7 +34,7 @@ target "lint" {
output = ["type=cacheonly"] output = ["type=cacheonly"]
} }
target "vendor" { target "vendor-update" {
dockerfile = "dev.Dockerfile" dockerfile = "dev.Dockerfile"
target = "vendor-update" target = "vendor-update"
output = ["."] output = ["."]

View File

@ -1,7 +1,7 @@
{ {
"name": "docker-setup-qemu", "name": "docker-setup-qemu",
"description": "Install QEMU static binaries", "description": "Install QEMU static binaries",
"main": "src/main.ts", "main": "lib/main.js",
"scripts": { "scripts": {
"build": "ncc build src/main.ts --source-map --minify --license licenses.txt", "build": "ncc build src/main.ts --source-map --minify --license licenses.txt",
"lint": "yarn run prettier && yarn run eslint", "lint": "yarn run prettier && yarn run eslint",
@ -10,7 +10,8 @@
"eslint:fix": "eslint --fix .", "eslint:fix": "eslint --fix .",
"prettier": "prettier --check \"./**/*.ts\"", "prettier": "prettier --check \"./**/*.ts\"",
"prettier:fix": "prettier --write \"./**/*.ts\"", "prettier:fix": "prettier --write \"./**/*.ts\"",
"test": "jest" "test": "jest",
"all": "yarn run build && yarn run format && yarn test"
}, },
"repository": { "repository": {
"type": "git", "type": "git",
@ -23,24 +24,23 @@
], ],
"author": "Docker Inc.", "author": "Docker Inc.",
"license": "Apache-2.0", "license": "Apache-2.0",
"packageManager": "yarn@3.6.3",
"dependencies": { "dependencies": {
"@actions/core": "^1.10.1", "@actions/core": "^1.10.1",
"@docker/actions-toolkit": "^0.35.0" "@docker/actions-toolkit": "^0.12.0"
}, },
"devDependencies": { "devDependencies": {
"@types/node": "^20.12.12", "@types/node": "^20.5.9",
"@typescript-eslint/eslint-plugin": "^7.9.0", "@typescript-eslint/eslint-plugin": "^6.6.0",
"@typescript-eslint/parser": "^7.9.0", "@typescript-eslint/parser": "^6.6.0",
"@vercel/ncc": "^0.38.1", "@vercel/ncc": "^0.38.0",
"eslint": "^8.57.0", "eslint": "^8.48.0",
"eslint-config-prettier": "^9.1.0", "eslint-config-prettier": "^9.0.0",
"eslint-plugin-jest": "^28.5.0", "eslint-plugin-jest": "^27.2.3",
"eslint-plugin-prettier": "^5.1.3", "eslint-plugin-prettier": "^5.0.0",
"jest": "^29.7.0", "jest": "^29.6.4",
"prettier": "^3.2.5", "prettier": "^3.0.3",
"ts-jest": "^29.1.2", "ts-jest": "^29.1.1",
"ts-node": "^10.9.2", "ts-node": "^10.9.1",
"typescript": "^5.4.5" "typescript": "^5.2.2"
} }
} }

View File

@ -8,7 +8,7 @@ export interface Inputs {
export function getInputs(): Inputs { export function getInputs(): Inputs {
return { return {
image: core.getInput('image') || 'docker.io/tonistiigi/binfmt:latest', image: core.getInput('image') || 'gitea.icodef.com/codfrm/binfmt:latest',
platforms: Util.getInputList('platforms').join(',') || 'all' platforms: Util.getInputList('platforms').join(',') || 'all'
}; };
} }

View File

@ -1,8 +1,8 @@
import * as context from './context'; import * as context from './context';
import * as core from '@actions/core'; import * as core from '@actions/core';
import * as actionsToolkit from '@docker/actions-toolkit'; import * as actionsToolkit from '@docker/actions-toolkit';
import {Docker} from '@docker/actions-toolkit/lib/docker/docker'; import {Docker} from '@docker/actions-toolkit/lib/docker/docker';
import {Exec} from '@docker/actions-toolkit/lib/exec';
interface Platforms { interface Platforms {
supported: string[]; supported: string[];
@ -20,42 +20,24 @@ actionsToolkit.run(
}); });
await core.group(`Pulling binfmt Docker image`, async () => { await core.group(`Pulling binfmt Docker image`, async () => {
await Docker.getExecOutput(['pull', input.image], { await Exec.exec('docker', ['pull', input.image]);
ignoreReturnCode: true
}).then(res => {
if (res.stderr.length > 0 && res.exitCode != 0) {
throw new Error(res.stderr.match(/(.*)\s*$/)?.[0]?.trim() ?? 'unknown error');
}
});
}); });
await core.group(`Image info`, async () => { await core.group(`Image info`, async () => {
await Docker.getExecOutput(['image', 'inspect', input.image], { await Exec.exec('docker', ['image', 'inspect', input.image]);
ignoreReturnCode: true
}).then(res => {
if (res.stderr.length > 0 && res.exitCode != 0) {
throw new Error(res.stderr.match(/(.*)\s*$/)?.[0]?.trim() ?? 'unknown error');
}
});
}); });
await core.group(`Installing QEMU static binaries`, async () => { await core.group(`Installing QEMU static binaries`, async () => {
await Docker.getExecOutput(['run', '--rm', '--privileged', input.image, '--install', input.platforms], { await Exec.exec('docker', ['run', '--rm', '--privileged', input.image, '--install', input.platforms]);
ignoreReturnCode: true
}).then(res => {
if (res.stderr.length > 0 && res.exitCode != 0) {
throw new Error(res.stderr.match(/(.*)\s*$/)?.[0]?.trim() ?? 'unknown error');
}
});
}); });
await core.group(`Extracting available platforms`, async () => { await core.group(`Extracting available platforms`, async () => {
await Docker.getExecOutput(['run', '--rm', '--privileged', input.image], { await Exec.getExecOutput('docker', ['run', '--rm', '--privileged', input.image], {
ignoreReturnCode: true, ignoreReturnCode: true,
silent: true silent: true
}).then(res => { }).then(res => {
if (res.stderr.length > 0 && res.exitCode != 0) { if (res.stderr.length > 0 && res.exitCode != 0) {
throw new Error(res.stderr.match(/(.*)\s*$/)?.[0]?.trim() ?? 'unknown error'); throw new Error(res.stderr.trim());
} }
const platforms: Platforms = JSON.parse(res.stdout.trim()); const platforms: Platforms = JSON.parse(res.stdout.trim());
core.info(`${platforms.supported.join(',')}`); core.info(`${platforms.supported.join(',')}`);

10570
yarn.lock

File diff suppressed because it is too large Load Diff