Compare commits

..

No commits in common. "master" and "v2" have entirely different histories.
master ... v2

34 changed files with 3616 additions and 10596 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.*

View File

@ -1,3 +0,0 @@
/dist/**
/coverage/**
/node_modules/**

View File

@ -1,12 +1,11 @@
{ {
"env": { "env": {
"node": true, "node": true,
"es6": true, "es2021": true,
"jest": true "jest": true
}, },
"extends": [ "extends": [
"eslint:recommended", "eslint:recommended",
"plugin:@typescript-eslint/eslint-recommended",
"plugin:@typescript-eslint/recommended", "plugin:@typescript-eslint/recommended",
"plugin:jest/recommended", "plugin:jest/recommended",
"plugin:prettier/recommended" "plugin:prettier/recommended"

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

1
.github/CODEOWNERS vendored Normal file
View File

@ -0,0 +1 @@
* @crazy-max

View File

@ -1,3 +0,0 @@
# Code of conduct
- [Moby community guidelines](https://github.com/moby/moby/blob/master/CONTRIBUTING.md#moby-community-guidelines)

View File

@ -14,7 +14,7 @@ to the public under the [project's open source license](LICENSE).
5. Format code and build javascript artifacts: `docker buildx bake pre-checkin` 5. Format code and build javascript artifacts: `docker buildx bake pre-checkin`
6. Validate all code has correctly formatted and built: `docker buildx bake validate` 6. Validate all code has correctly formatted and built: `docker buildx bake validate`
7. Push to your fork and [submit a pull request](https://github.com/docker/setup-qemu-action/compare) 7. Push to your fork and [submit a pull request](https://github.com/docker/setup-qemu-action/compare)
8. Pat yourself on the back and wait for your pull request to be reviewed and merged. 8. Pat your self on the back and wait for your pull request to be reviewed and merged.
Here are a few things you can do that will increase the likelihood of your pull request being accepted: Here are a few things you can do that will increase the likelihood of your pull request being accepted:

View File

@ -1,101 +0,0 @@
# https://docs.github.com/en/communities/using-templates-to-encourage-useful-issues-and-pull-requests/syntax-for-githubs-form-schema
name: Bug Report
description: Report a bug
labels:
- status/triage
body:
- type: markdown
attributes:
value: |
Thank you for taking the time to report a bug!
If this is a security issue please report it to the [Docker Security team](mailto:security@docker.com).
- type: checkboxes
attributes:
label: Contributing guidelines
description: >
Make sure you've read the contributing guidelines before proceeding.
options:
- label: I've read the [contributing guidelines](https://github.com/docker/setup-qemu-action/blob/master/.github/CONTRIBUTING.md) and wholeheartedly agree
required: true
- type: checkboxes
attributes:
label: "I've found a bug, and:"
description: |
Make sure that your request fulfills all of the following requirements.
If one requirement cannot be satisfied, explain in detail why.
options:
- label: The documentation does not mention anything about my problem
- label: There are no open or closed issues that are related to my problem
- type: textarea
attributes:
label: Description
description: >
Provide a brief description of the bug in 1-2 sentences.
validations:
required: true
- type: textarea
attributes:
label: Expected behaviour
description: >
Describe precisely what you'd expect to happen.
validations:
required: true
- type: textarea
attributes:
label: Actual behaviour
description: >
Describe precisely what is actually happening.
validations:
required: true
- type: input
attributes:
label: Repository URL
description: >
Enter the URL of the repository where you are experiencing the
issue. If your repository is private, provide a link to a minimal
repository that reproduces the issue.
- type: input
attributes:
label: Workflow run URL
description: >
Enter the URL of the GitHub Action workflow run if public (e.g.
`https://github.com/<user>/<repo>/actions/runs/<id>`)
- type: textarea
attributes:
label: YAML workflow
description: |
Provide the YAML of the workflow that's causing the issue.
Make sure to remove any sensitive information.
render: yaml
validations:
required: true
- type: textarea
attributes:
label: Workflow logs
description: >
[Attach](https://docs.github.com/en/get-started/writing-on-github/working-with-advanced-formatting/attaching-files)
the [log file of your workflow run](https://docs.github.com/en/actions/managing-workflow-runs/using-workflow-run-logs#downloading-logs)
and make sure to remove any sensitive information.
- type: textarea
attributes:
label: BuildKit logs
description: >
If applicable, provide the [BuildKit container logs](https://docs.docker.com/build/ci/github-actions/configure-builder/#buildkit-container-logs)
render: text
- type: textarea
attributes:
label: Additional info
description: |
Provide any additional information that could be useful.

34
.github/ISSUE_TEMPLATE/bug_report.md vendored Normal file
View File

@ -0,0 +1,34 @@
---
name: Bug report
about: Create a report to help us improve
---
### Behaviour
#### Steps to reproduce this issue
1.
2.
3.
#### Expected behaviour
> Tell us what should happen
#### Actual behaviour
> Tell us what happens instead
### Configuration
* Repository URL (if public):
* Build URL (if public):
```yml
# paste your YAML workflow file here and remove sensitive data
```
### Logs
> Download the [log file of your build](https://docs.github.com/en/actions/managing-workflow-runs/using-workflow-run-logs#downloading-logs)
> and [attach it](https://docs.github.com/en/github/managing-your-work-on-github/file-attachments-on-issues-and-pull-requests) to this issue.

View File

@ -1,9 +0,0 @@
# https://docs.github.com/en/communities/using-templates-to-encourage-useful-issues-and-pull-requests/configuring-issue-templates-for-your-repository#configuring-the-template-chooser
blank_issues_enabled: true
contact_links:
- name: Questions and Discussions
url: https://github.com/docker/setup-qemu-action/discussions/new
about: Use Github Discussions to ask questions and/or open discussion topics.
- name: Documentation
url: https://docs.docker.com/build/ci/github-actions/
about: Read the documentation.

View File

@ -1,15 +0,0 @@
# https://docs.github.com/en/communities/using-templates-to-encourage-useful-issues-and-pull-requests/syntax-for-githubs-form-schema
name: Feature request
description: Missing functionality? Come tell us about it!
labels:
- kind/enhancement
- status/triage
body:
- type: textarea
id: description
attributes:
label: Description
description: What is the feature you want to see?
validations:
required: true

12
.github/SECURITY.md vendored
View File

@ -1,12 +0,0 @@
# Reporting security issues
The project maintainers take security seriously. If you discover a security
issue, please bring it to their attention right away!
**Please _DO NOT_ file a public issue**, instead send your report privately to
[security@docker.com](mailto:security@docker.com).
Security reports are greatly appreciated, and we will publicly thank you for it.
We also like to send gifts&mdash;if you'd like Docker swag, make sure to let
us know. We currently do not offer a paid security bounty program, but are not
ruling it out in the future.

31
.github/SUPPORT.md vendored Normal file
View File

@ -0,0 +1,31 @@
# Support [![](https://isitmaintained.com/badge/resolution/docker/setup-qemu-action.svg)](https://isitmaintained.com/project/docker/setup-qemu-action)
First, [be a good guy](https://github.com/kossnocorp/etiquette/blob/master/README.md).
## Reporting an issue
Please do a search in [open issues](https://github.com/docker/setup-qemu-action/issues?utf8=%E2%9C%93&q=) to see if the issue or feature request has already been filed.
If you find your issue already exists, make relevant comments and add your [reaction](https://github.com/blog/2119-add-reactions-to-pull-requests-issues-and-comments). Use a reaction in place of a "+1" comment.
:+1: - upvote
:-1: - downvote
If you cannot find an existing issue that describes your bug or feature, submit an issue using the guidelines below.
## Writing good bug reports and feature requests
File a single issue per problem and feature request.
* Do not enumerate multiple bugs or feature requests in the same issue.
* Do not add your issue as a comment to an existing issue unless it's for the identical input. Many issues look similar, but have different causes.
The more information you can provide, the more likely someone will be successful reproducing the issue and finding a fix.
You are now ready to [create a new issue](https://github.com/docker/setup-qemu-action/issues/new/choose)!
## Closure policy
* Issues that don't have the information requested above (when applicable) will be closed immediately and the poster directed to the support guidelines.
* Issues that go a week without a response from original poster are subject to closure at our discretion.

View File

@ -11,7 +11,6 @@ updates:
directory: "/" directory: "/"
schedule: schedule:
interval: "daily" interval: "daily"
versioning-strategy: "increase"
allow: allow:
- dependency-type: "production" - dependency-type: "production"
labels: labels:

View File

@ -1,9 +1,5 @@
name: ci name: ci
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
on: on:
schedule: schedule:
- cron: '0 10 * * *' - cron: '0 10 * * *'
@ -16,20 +12,6 @@ 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:
@ -44,7 +26,7 @@ jobs:
steps: steps:
- -
name: Checkout name: Checkout
uses: actions/checkout@v4 uses: actions/checkout@v3
- -
name: Set up QEMU name: Set up QEMU
id: qemu id: qemu
@ -61,11 +43,11 @@ jobs:
steps: steps:
- -
name: Checkout name: Checkout
uses: actions/checkout@v4 uses: actions/checkout@v3
- -
name: Stop docker name: Stop docker
run: | run: |
sudo systemctl stop docker docker.socket sudo systemctl stop docker
- -
name: Set up QEMU name: Set up QEMU
id: qemu id: qemu
@ -79,45 +61,3 @@ jobs:
echo "::error::Should have failed" echo "::error::Should have failed"
exit 1 exit 1
fi fi
cache-image:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
cache:
- true
- false
steps:
-
name: Checkout
uses: actions/checkout@v4
-
name: Set up QEMU
id: qemu
uses: ./
with:
image: tonistiigi/binfmt:master
cache-image: ${{ matrix.cache }}
-
name: Available platforms
run: echo ${{ steps.qemu.outputs.platforms }}
version:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
image:
- tonistiigi/binfmt:master
- tonistiigi/binfmt:latest
- tonistiigi/binfmt:qemu-v7.0.0
steps:
-
name: Checkout
uses: actions/checkout@v4
-
name: Set up QEMU
uses: ./
with:
image: ${{ matrix.image }}

View File

@ -1,21 +0,0 @@
name: publish
on:
release:
types:
- published
jobs:
publish:
runs-on: ubuntu-latest
permissions:
contents: read
id-token: write
packages: write
steps:
-
name: Checkout
uses: actions/checkout@v4
-
name: Publish
uses: actions/publish-immutable-action@v0.0.4

View File

@ -1,9 +1,5 @@
name: test name: test
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
on: on:
push: push:
branches: branches:
@ -15,14 +11,16 @@ jobs:
test: test:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
-
name: Checkout
uses: actions/checkout@v3
- -
name: Test name: Test
uses: docker/bake-action@v6 uses: docker/bake-action@v3
with: with:
targets: test targets: test
- -
name: Upload coverage name: Upload coverage
uses: codecov/codecov-action@v5 uses: codecov/codecov-action@v3
with: with:
files: ./coverage/clover.xml file: ./coverage/clover.xml
token: ${{ secrets.CODECOV_TOKEN }}

View File

@ -1,9 +1,5 @@
name: validate name: validate
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
on: on:
push: push:
branches: branches:
@ -15,17 +11,16 @@ jobs:
prepare: prepare:
runs-on: ubuntu-latest runs-on: ubuntu-latest
outputs: outputs:
targets: ${{ steps.generate.outputs.targets }} targets: ${{ steps.targets.outputs.matrix }}
steps: steps:
- -
name: Checkout name: Checkout
uses: actions/checkout@v4 uses: actions/checkout@v3
- -
name: List targets name: Targets matrix
id: generate id: targets
uses: docker/bake-action/subaction/list-targets@v6 run: |
with: echo "matrix=$(docker buildx bake validate --print | jq -cr '.group.validate.targets')" >> $GITHUB_OUTPUT
target: validate
validate: validate:
runs-on: ubuntu-latest runs-on: ubuntu-latest
@ -36,8 +31,11 @@ jobs:
matrix: matrix:
target: ${{ fromJson(needs.prepare.outputs.targets) }} target: ${{ fromJson(needs.prepare.outputs.targets) }}
steps: steps:
-
name: Checkout
uses: actions/checkout@v3
- -
name: Validate name: Validate
uses: docker/bake-action@v6 uses: docker/bake-action@v3
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/

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

@ -32,37 +32,23 @@ jobs:
steps: steps:
- -
name: Set up QEMU name: Set up QEMU
uses: docker/setup-qemu-action@v3 uses: docker/setup-qemu-action@v2
``` ```
> [!NOTE]
> If you are using [`docker/setup-buildx-action`](https://github.com/docker/setup-buildx-action),
> this action should come before it:
>
> ```yaml
> -
> name: Set up QEMU
> uses: docker/setup-qemu-action@v3
> -
> name: Set up Docker Buildx
> uses: docker/setup-buildx-action@v3
> ```
## Customizing ## Customizing
### inputs ### inputs
The 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 |
|---------------|--------|-------------------------------------------------------------------------------|----------------------------------------------------| |-------------|--------|-------------------------------------------------------------------------------|--------------------------------------------------|
| `image` | String | [`tonistiigi/binfmt:latest`](https://hub.docker.com/r/tonistiigi/binfmt/tags) | QEMU static binaries Docker image | | `image` | String | [`tonistiigi/binfmt:latest`](https://hub.docker.com/r/tonistiigi/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`) |
| `cache-image` | Bool | `true` | Cache binfmt image to GitHub Actions cache backend |
### outputs ### outputs
The following outputs are available: Following outputs are available
| Name | Type | Description | | Name | Type | Description |
|---------------|---------|---------------------------------------| |---------------|---------|---------------------------------------|

View File

@ -16,13 +16,10 @@ describe('getInputs', () => {
test.each([ test.each([
[ [
0, 0,
new Map<string, string>([ new Map<string, string>([]),
['cache-image', 'true'],
]),
{ {
image: 'docker.io/tonistiigi/binfmt:latest', image: 'tonistiigi/binfmt:latest',
platforms: 'all', platforms: 'all',
cacheImage: true,
} as context.Inputs } as context.Inputs
], ],
[ [
@ -30,24 +27,20 @@ describe('getInputs', () => {
new Map<string, string>([ new Map<string, string>([
['image', 'docker/binfmt:latest'], ['image', 'docker/binfmt:latest'],
['platforms', 'arm64,riscv64,arm'], ['platforms', 'arm64,riscv64,arm'],
['cache-image', 'false'],
]), ]),
{ {
image: 'docker/binfmt:latest', image: 'docker/binfmt:latest',
platforms: 'arm64,riscv64,arm', platforms: 'arm64,riscv64,arm',
cacheImage: false,
} as context.Inputs } as context.Inputs
], ],
[ [
2, 2,
new Map<string, string>([ new Map<string, string>([
['platforms', 'arm64, riscv64, arm '], ['platforms', 'arm64, riscv64, arm '],
['cache-image', 'true'],
]), ]),
{ {
image: 'docker.io/tonistiigi/binfmt:latest', image: 'tonistiigi/binfmt:latest',
platforms: 'arm64,riscv64,arm', platforms: 'arm64,riscv64,arm',
cacheImage: true,
} as context.Inputs } as context.Inputs
] ]
])( ])(

View File

@ -9,22 +9,17 @@ branding:
inputs: inputs:
image: image:
description: 'QEMU static binaries Docker image (e.g. tonistiigi/binfmt:latest)' description: 'QEMU static binaries Docker image (e.g. tonistiigi/binfmt:latest)'
default: 'docker.io/tonistiigi/binfmt:latest' default: 'tonistiigi/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)'
default: 'all' default: 'all'
required: false required: false
cache-image:
description: 'Cache binfmt image to GitHub Actions cache backend'
default: 'true'
required: false
outputs: outputs:
platforms: platforms:
description: 'Available platforms (comma separated)' description: 'Available platforms (comma separated)'
runs: runs:
using: 'node20' using: 'node16'
main: 'dist/index.js' main: 'dist/index.js'
post: 'dist/index.js'

View File

@ -1,20 +1,13 @@
# syntax=docker/dockerfile:1 # syntax=docker/dockerfile:1
ARG NODE_VERSION=20 ARG NODE_VERSION=16
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,25 +48,22 @@ 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 --coverageDirectory=/tmp/coverage
FROM scratch AS test-coverage FROM scratch AS test-coverage
COPY --from=test /tmp/coverage / COPY --from=test /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

3552
dist/licenses.txt generated vendored

File diff suppressed because it is too large Load Diff

View File

@ -1,15 +1,9 @@
target "_common" {
args = {
BUILDKIT_CONTEXT_KEEP_GIT_DIR = 1
}
}
group "default" { group "default" {
targets = ["build"] targets = ["build"]
} }
group "pre-checkin" { group "pre-checkin" {
targets = ["vendor", "format", "build"] targets = ["vendor-update", "format", "build"]
} }
group "validate" { group "validate" {
@ -17,49 +11,42 @@ group "validate" {
} }
target "build" { target "build" {
inherits = ["_common"]
dockerfile = "dev.Dockerfile" dockerfile = "dev.Dockerfile"
target = "build-update" target = "build-update"
output = ["."] output = ["."]
} }
target "build-validate" { target "build-validate" {
inherits = ["_common"]
dockerfile = "dev.Dockerfile" dockerfile = "dev.Dockerfile"
target = "build-validate" target = "build-validate"
output = ["type=cacheonly"] output = ["type=cacheonly"]
} }
target "format" { target "format" {
inherits = ["_common"]
dockerfile = "dev.Dockerfile" dockerfile = "dev.Dockerfile"
target = "format-update" target = "format-update"
output = ["."] output = ["."]
} }
target "lint" { target "lint" {
inherits = ["_common"]
dockerfile = "dev.Dockerfile" dockerfile = "dev.Dockerfile"
target = "lint" target = "lint"
output = ["type=cacheonly"] output = ["type=cacheonly"]
} }
target "vendor" { target "vendor-update" {
inherits = ["_common"]
dockerfile = "dev.Dockerfile" dockerfile = "dev.Dockerfile"
target = "vendor-update" target = "vendor-update"
output = ["."] output = ["."]
} }
target "vendor-validate" { target "vendor-validate" {
inherits = ["_common"]
dockerfile = "dev.Dockerfile" dockerfile = "dev.Dockerfile"
target = "vendor-validate" target = "vendor-validate"
output = ["type=cacheonly"] output = ["type=cacheonly"]
} }
target "test" { target "test" {
inherits = ["_common"]
dockerfile = "dev.Dockerfile" dockerfile = "dev.Dockerfile"
target = "test-coverage" target = "test-coverage"
output = ["./coverage"] output = ["./coverage"]

View File

@ -1,16 +1,13 @@
{ {
"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": "eslint src/**/*.ts __tests__/**/*.ts",
"format": "yarn run prettier:fix && yarn run eslint:fix", "format": "eslint --fix src/**/*.ts __tests__/**/*.ts",
"eslint": "eslint --max-warnings=0 .", "test": "jest --coverage",
"eslint:fix": "eslint --fix .", "all": "yarn run build && yarn run format && yarn test"
"prettier": "prettier --check \"./**/*.ts\"",
"prettier:fix": "prettier --write \"./**/*.ts\"",
"test": "jest"
}, },
"repository": { "repository": {
"type": "git", "type": "git",
@ -21,26 +18,31 @@
"docker", "docker",
"qemu" "qemu"
], ],
"author": "Docker Inc.", "author": "Docker",
"contributors": [
{
"name": "CrazyMax",
"url": "https://crazymax.dev"
}
],
"license": "Apache-2.0", "license": "Apache-2.0",
"packageManager": "yarn@3.6.3",
"dependencies": { "dependencies": {
"@actions/core": "^1.11.1", "@actions/core": "^1.10.0",
"@docker/actions-toolkit": "^0.56.0" "@docker/actions-toolkit": "^0.3.0"
}, },
"devDependencies": { "devDependencies": {
"@types/node": "^20.12.12", "@types/node": "^16.18.21",
"@typescript-eslint/eslint-plugin": "^7.9.0", "@typescript-eslint/eslint-plugin": "^5.56.0",
"@typescript-eslint/parser": "^7.9.0", "@typescript-eslint/parser": "^5.56.0",
"@vercel/ncc": "^0.38.1", "@vercel/ncc": "^0.36.1",
"eslint": "^8.57.0", "eslint": "^8.36.0",
"eslint-config-prettier": "^9.1.0", "eslint-config-prettier": "^8.8.0",
"eslint-plugin-jest": "^28.5.0", "eslint-plugin-jest": "^27.2.1",
"eslint-plugin-prettier": "^5.1.3", "eslint-plugin-prettier": "^4.2.1",
"jest": "^29.7.0", "jest": "^29.5.0",
"prettier": "^3.2.5", "prettier": "^2.8.7",
"ts-jest": "^29.1.2", "ts-jest": "^29.0.5",
"ts-node": "^10.9.2", "ts-node": "^10.9.1",
"typescript": "^5.4.5" "typescript": "^4.9.5"
} }
} }

View File

@ -4,13 +4,11 @@ import {Util} from '@docker/actions-toolkit/lib/util';
export interface Inputs { export interface Inputs {
image: string; image: string;
platforms: string; platforms: string;
cacheImage: boolean;
} }
export function getInputs(): Inputs { export function getInputs(): Inputs {
return { return {
image: core.getInput('image') || 'docker.io/tonistiigi/binfmt:latest', image: core.getInput('image') || 'tonistiigi/binfmt:latest',
platforms: Util.getInputList('platforms').join(',') || 'all', platforms: Util.getInputList('platforms').join(',') || 'all'
cacheImage: core.getBooleanInput('cache-image')
}; };
} }

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,46 +20,24 @@ actionsToolkit.run(
}); });
await core.group(`Pulling binfmt Docker image`, async () => { await core.group(`Pulling binfmt Docker image`, async () => {
await Docker.pull(input.image, input.cacheImage); await Exec.exec('docker', ['pull', input.image]);
}); });
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(`Binfmt version`, async () => {
await Docker.getExecOutput(['run', '--rm', '--privileged', input.image, '--version'], {
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(',')}`);

9940
yarn.lock

File diff suppressed because it is too large Load Diff