mirror of
https://github.com/docker/setup-buildx-action.git
synced 2025-04-22 02:09:30 +02:00
Compare commits
232 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
941183f0a0 | ||
|
311b62b254 | ||
|
afeb29a6e0 | ||
|
b560416601 | ||
|
516bb780e5 | ||
|
11445527f0 | ||
|
b5ca514318 | ||
|
1418a4ef33 | ||
|
93acf831ce | ||
|
f7ce87c1d6 | ||
|
aa1e2a0b49 | ||
|
673e008776 | ||
|
ba31df4664 | ||
|
5475af18ec | ||
|
acacad903e | ||
|
6a25f988bd | ||
|
ca1af179f5 | ||
|
6524bf65af | ||
|
8d5e0747fc | ||
|
7199e57b35 | ||
|
db63cee3de | ||
|
043ebe137f | ||
|
686da9073d | ||
|
a3d74876b8 | ||
|
4dcdbcec48 | ||
|
1a8ac74316 | ||
|
e827ebe8ba | ||
|
adacc1474e | ||
|
0f069ddc17 | ||
|
d036b3238c | ||
|
460e45646d | ||
|
93aa1c807f | ||
|
d391aad55c | ||
|
e5b688ea46 | ||
|
c47758b77c | ||
|
8fea382513 | ||
|
2874e980e8 | ||
|
8026d2bc36 | ||
|
e51aab53e9 | ||
|
fd7390e14d | ||
|
910a304005 | ||
|
3623ee443e | ||
|
e0e5ecf670 | ||
|
5334dd0cdd | ||
|
214bb6dac1 | ||
|
818c69a4ea | ||
|
b467d6aa7a | ||
|
7594cf3831 | ||
|
988b5a0280 | ||
|
2c215620b8 | ||
|
3382292cd5 | ||
|
3d68780484 | ||
|
d069e98648 | ||
|
8b850f86dc | ||
|
aa33708b10 | ||
|
2d99e3412d | ||
|
4dab43650b | ||
|
49a04d6890 | ||
|
a6ade2e34f | ||
|
2f2694b8d1 | ||
|
0a4bab6632 | ||
|
2ad185228a | ||
|
560ac469d6 | ||
|
b3a341759e | ||
|
4fd812986e | ||
|
3386dc4251 | ||
|
d191aef416 | ||
|
f686054aab | ||
|
78547859d7 | ||
|
830928c706 | ||
|
26d2aec173 | ||
|
ab17e3ec80 | ||
|
d79cb80903 | ||
|
13cf78894f | ||
|
0e592087a0 | ||
|
47032b9b53 | ||
|
abe89fb761 | ||
|
e027232c25 | ||
|
5d9397e7ca | ||
|
e9ab4c6a14 | ||
|
748835b452 | ||
|
554c728605 | ||
|
1c1261e632 | ||
|
5138f76647 | ||
|
eddcf46655 | ||
|
2740b29678 | ||
|
1113efed2b | ||
|
8a2a7ad780 | ||
|
e3c7deb79b | ||
|
be3701b211 | ||
|
e2ed622d10 | ||
|
b73b950903 | ||
|
157d6d0106 | ||
|
a530e948ad | ||
|
28ecb964cd | ||
|
dc25d8b2ee | ||
|
d70bba72b1 | ||
|
7638634cb7 | ||
|
c68420fe0b | ||
|
2b51285047 | ||
|
0f00370563 | ||
|
11c9683db9 | ||
|
56a16b8f2a | ||
|
c23f46eb91 | ||
|
f876da6242 | ||
|
b7cf918227 | ||
|
0150f0ed7a | ||
|
d89f1f9116 | ||
|
12d65f6595 | ||
|
8e1cfa56de | ||
|
0d103c3126 | ||
|
f19477aacd | ||
|
a4180f835d | ||
|
524315340d | ||
|
3679a54023 | ||
|
37a22a2fb2 | ||
|
65afe610a1 | ||
|
fcb8f722fd | ||
|
f62b9a17c0 | ||
|
74c5b717e5 | ||
|
0d7aea7476 | ||
|
edfb0fe620 | ||
|
ee40da0772 | ||
|
02e65a5ab9 | ||
|
6d5347c402 | ||
|
ab3fcb73e7 | ||
|
3762d454f3 | ||
|
cdd4983d88 | ||
|
a3e8dc13a7 | ||
|
5d98624985 | ||
|
fa0a3f8db8 | ||
|
0d99838e0e | ||
|
dedd61cf5d | ||
|
a9e6efb8d7 | ||
|
572af8c114 | ||
|
8bda7f18d0 | ||
|
36dc84a6af | ||
|
1eaf7017ec | ||
|
35db0cdb94 | ||
|
524ee0563f | ||
|
91c74bb1dc | ||
|
7d508e5a8a | ||
|
c9db9161e9 | ||
|
f95db51fdd | ||
|
998a87c2c1 | ||
|
28bae59336 | ||
|
c215341715 | ||
|
02e9319239 | ||
|
5c9160effc | ||
|
1283140f57 | ||
|
c6afe06e4a | ||
|
f35e0d5a04 | ||
|
baeb468fb2 | ||
|
8e48232775 | ||
|
a52126db3d | ||
|
2afcb42c88 | ||
|
2fbc37fd36 | ||
|
23d726350c | ||
|
885d1462b8 | ||
|
e5fad018d0 | ||
|
45161fd92a | ||
|
a4d51f53dd | ||
|
93b8ecaa2c | ||
|
7703e82fbc | ||
|
0005881963 | ||
|
b699069f49 | ||
|
9bfc5497b8 | ||
|
b92d4d8769 | ||
|
285be6c835 | ||
|
4c0219f9ac | ||
|
0db41bf51b | ||
|
62fc1a1dd6 | ||
|
2a1a44ac4a | ||
|
a6c26a99ef | ||
|
a5a7f565d9 | ||
|
7d7611f95b | ||
|
16c0bc4a6e | ||
|
ebcacb9c21 | ||
|
496a823b8b | ||
|
a56031a493 | ||
|
922550f064 | ||
|
ecf95283f0 | ||
|
b2a38ee0c6 | ||
|
7f79690cac | ||
|
bdd549bec0 | ||
|
be4a3855af | ||
|
6c4dbb29f6 | ||
|
6a58db7e0d | ||
|
d56292e348 | ||
|
790eb2db47 | ||
|
2a81c53912 | ||
|
00b2400aad | ||
|
484614d7a1 | ||
|
d95759405f | ||
|
5bb6d36be0 | ||
|
a99c5e53ef | ||
|
fc1a41d2e5 | ||
|
95cefc3c57 | ||
|
8ec3610541 | ||
|
a946f06b5d | ||
|
ce223e774e | ||
|
d267e74486 | ||
|
d350de3bba | ||
|
45a8690f10 | ||
|
b167a89702 | ||
|
81d4866861 | ||
|
07aea5fc9c | ||
|
1d91983c26 | ||
|
496312bcb8 | ||
|
4b4e9c3e2d | ||
|
eb27bcbef3 | ||
|
b7471d4240 | ||
|
e2df91e851 | ||
|
85ce96bcbc | ||
|
f549413411 | ||
|
99988698a5 | ||
|
e30725c029 | ||
|
f1dc97ee10 | ||
|
51ecd0a47f | ||
|
830f01a409 | ||
|
8b13d483f2 | ||
|
03a7a3d9fb | ||
|
30389db034 | ||
|
05ca2e6f5e | ||
|
774ea5c2f1 | ||
|
534bd3c5e6 | ||
|
0f5a2d6712 | ||
|
987520896f | ||
|
a19c171088 | ||
|
347dac9901 | ||
|
2dd22fa31c | ||
|
dd904132a2 |
@ -1,2 +1,12 @@
|
|||||||
/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.*
|
||||||
|
3
.eslintignore
Normal file
3
.eslintignore
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
/dist/**
|
||||||
|
/coverage/**
|
||||||
|
/node_modules/**
|
@ -1,11 +1,12 @@
|
|||||||
{
|
{
|
||||||
"env": {
|
"env": {
|
||||||
"node": true,
|
"node": true,
|
||||||
"es2021": true,
|
"es6": true,
|
||||||
"jest/globals": 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
2
.gitattributes
vendored
@ -1,2 +1,4 @@
|
|||||||
|
/.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
1
.github/CODEOWNERS
vendored
@ -1 +0,0 @@
|
|||||||
* @crazy-max
|
|
3
.github/CODE_OF_CONDUCT.md
vendored
Normal file
3
.github/CODE_OF_CONDUCT.md
vendored
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
# Code of conduct
|
||||||
|
|
||||||
|
- [Moby community guidelines](https://github.com/moby/moby/blob/master/CONTRIBUTING.md#moby-community-guidelines)
|
101
.github/ISSUE_TEMPLATE/bug.yml
vendored
Normal file
101
.github/ISSUE_TEMPLATE/bug.yml
vendored
Normal file
@ -0,0 +1,101 @@
|
|||||||
|
# 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-buildx-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
34
.github/ISSUE_TEMPLATE/bug_report.md
vendored
@ -1,34 +0,0 @@
|
|||||||
---
|
|
||||||
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.
|
|
9
.github/ISSUE_TEMPLATE/config.yml
vendored
Normal file
9
.github/ISSUE_TEMPLATE/config.yml
vendored
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
# 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-buildx-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.
|
15
.github/ISSUE_TEMPLATE/feature.yml
vendored
Normal file
15
.github/ISSUE_TEMPLATE/feature.yml
vendored
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
# 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
Normal file
12
.github/SECURITY.md
vendored
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
# 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—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
31
.github/SUPPORT.md
vendored
@ -1,31 +0,0 @@
|
|||||||
# Support [](https://isitmaintained.com/project/docker/setup-buildx-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-buildx-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-buildx-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.
|
|
1
.github/dependabot.yml
vendored
1
.github/dependabot.yml
vendored
@ -11,6 +11,7 @@ updates:
|
|||||||
directory: "/"
|
directory: "/"
|
||||||
schedule:
|
schedule:
|
||||||
interval: "daily"
|
interval: "daily"
|
||||||
|
versioning-strategy: "increase"
|
||||||
allow:
|
allow:
|
||||||
- dependency-type: "production"
|
- dependency-type: "production"
|
||||||
labels:
|
labels:
|
||||||
|
BIN
.github/setup-buildx-action.png
vendored
BIN
.github/setup-buildx-action.png
vendored
Binary file not shown.
Before Width: | Height: | Size: 11 KiB After Width: | Height: | Size: 15 KiB |
211
.github/workflows/ci.yml
vendored
211
.github/workflows/ci.yml
vendored
@ -1,8 +1,13 @@
|
|||||||
name: ci
|
name: ci
|
||||||
|
|
||||||
|
concurrency:
|
||||||
|
group: ${{ github.workflow }}-${{ github.ref }}
|
||||||
|
cancel-in-progress: true
|
||||||
|
|
||||||
on:
|
on:
|
||||||
|
workflow_dispatch:
|
||||||
schedule:
|
schedule:
|
||||||
- cron: '0 10 * * *' # everyday at 10am
|
- cron: '0 10 * * *'
|
||||||
push:
|
push:
|
||||||
branches:
|
branches:
|
||||||
- 'master'
|
- 'master'
|
||||||
@ -10,9 +15,6 @@ on:
|
|||||||
tags:
|
tags:
|
||||||
- 'v*'
|
- 'v*'
|
||||||
pull_request:
|
pull_request:
|
||||||
branches:
|
|
||||||
- 'master'
|
|
||||||
- 'releases/v*'
|
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
main:
|
main:
|
||||||
@ -21,13 +23,16 @@ jobs:
|
|||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
buildx-version:
|
buildx-version:
|
||||||
- latest
|
|
||||||
- v0.4.1
|
|
||||||
- ""
|
- ""
|
||||||
|
- "latest"
|
||||||
|
- "v0.4.1"
|
||||||
|
- "cloud:latest"
|
||||||
|
- "cloud:v0.11.2-desktop.2"
|
||||||
|
- "lab:latest"
|
||||||
steps:
|
steps:
|
||||||
-
|
-
|
||||||
name: Checkout
|
name: Checkout
|
||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v4
|
||||||
-
|
-
|
||||||
name: Set up Docker Buildx
|
name: Set up Docker Buildx
|
||||||
id: buildx
|
id: buildx
|
||||||
@ -46,7 +51,7 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
-
|
-
|
||||||
name: Checkout
|
name: Checkout
|
||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v4
|
||||||
-
|
-
|
||||||
name: Set up Docker Buildx 1
|
name: Set up Docker Buildx 1
|
||||||
uses: ./
|
uses: ./
|
||||||
@ -59,11 +64,11 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
-
|
-
|
||||||
name: Checkout
|
name: Checkout
|
||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v4
|
||||||
-
|
-
|
||||||
name: Stop docker
|
name: Stop docker
|
||||||
run: |
|
run: |
|
||||||
sudo systemctl stop docker
|
sudo systemctl stop docker docker.socket
|
||||||
-
|
-
|
||||||
name: Set up Docker Buildx
|
name: Set up Docker Buildx
|
||||||
id: buildx
|
id: buildx
|
||||||
@ -80,14 +85,14 @@ jobs:
|
|||||||
-
|
-
|
||||||
name: Dump context
|
name: Dump context
|
||||||
if: always()
|
if: always()
|
||||||
uses: crazy-max/ghaction-dump-context@v1
|
uses: crazy-max/ghaction-dump-context@v2
|
||||||
|
|
||||||
debug:
|
debug:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
-
|
-
|
||||||
name: Checkout
|
name: Checkout
|
||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v4
|
||||||
-
|
-
|
||||||
name: Create Dockerfile
|
name: Create Dockerfile
|
||||||
run: |
|
run: |
|
||||||
@ -97,7 +102,7 @@ jobs:
|
|||||||
EOL
|
EOL
|
||||||
-
|
-
|
||||||
name: Set up QEMU
|
name: Set up QEMU
|
||||||
uses: docker/setup-qemu-action@v2
|
uses: docker/setup-qemu-action@v3
|
||||||
-
|
-
|
||||||
name: Set up Docker Buildx
|
name: Set up Docker Buildx
|
||||||
uses: ./
|
uses: ./
|
||||||
@ -105,7 +110,7 @@ jobs:
|
|||||||
buildkitd-flags: --debug
|
buildkitd-flags: --debug
|
||||||
-
|
-
|
||||||
name: Build
|
name: Build
|
||||||
uses: docker/build-push-action@v4
|
uses: docker/build-push-action@v6
|
||||||
with:
|
with:
|
||||||
context: .
|
context: .
|
||||||
platforms: linux/amd64,linux/arm64,linux/ppc64le
|
platforms: linux/amd64,linux/arm64,linux/ppc64le
|
||||||
@ -115,7 +120,7 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
-
|
-
|
||||||
name: Checkout
|
name: Checkout
|
||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v4
|
||||||
-
|
-
|
||||||
name: Set up Docker Buildx
|
name: Set up Docker Buildx
|
||||||
uses: ./
|
uses: ./
|
||||||
@ -137,7 +142,7 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
-
|
-
|
||||||
name: Checkout
|
name: Checkout
|
||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v4
|
||||||
-
|
-
|
||||||
name: Set up Docker Buildx
|
name: Set up Docker Buildx
|
||||||
uses: ./
|
uses: ./
|
||||||
@ -160,7 +165,7 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
-
|
-
|
||||||
name: Checkout
|
name: Checkout
|
||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v4
|
||||||
-
|
-
|
||||||
name: Set up Docker Buildx
|
name: Set up Docker Buildx
|
||||||
uses: ./
|
uses: ./
|
||||||
@ -173,7 +178,7 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
-
|
-
|
||||||
name: Checkout
|
name: Checkout
|
||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v4
|
||||||
-
|
-
|
||||||
name: Set up Docker Buildx
|
name: Set up Docker Buildx
|
||||||
uses: ./
|
uses: ./
|
||||||
@ -206,7 +211,7 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
-
|
-
|
||||||
name: Checkout
|
name: Checkout
|
||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v4
|
||||||
-
|
-
|
||||||
name: Create context
|
name: Create context
|
||||||
run: |
|
run: |
|
||||||
@ -228,7 +233,7 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
-
|
-
|
||||||
name: Checkout
|
name: Checkout
|
||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v4
|
||||||
-
|
-
|
||||||
name: Create buildkitd conf
|
name: Create buildkitd conf
|
||||||
run: |
|
run: |
|
||||||
@ -248,10 +253,10 @@ jobs:
|
|||||||
uses: ./
|
uses: ./
|
||||||
with:
|
with:
|
||||||
buildkitd-flags: --debug
|
buildkitd-flags: --debug
|
||||||
config: /tmp/buildkitd.toml
|
buildkitd-config: /tmp/buildkitd.toml
|
||||||
-
|
-
|
||||||
name: Build
|
name: Build
|
||||||
uses: docker/build-push-action@v4
|
uses: docker/build-push-action@v6
|
||||||
with:
|
with:
|
||||||
context: .
|
context: .
|
||||||
|
|
||||||
@ -260,7 +265,7 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
-
|
-
|
||||||
name: Checkout
|
name: Checkout
|
||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v4
|
||||||
-
|
-
|
||||||
name: Create Dockerfile
|
name: Create Dockerfile
|
||||||
run: |
|
run: |
|
||||||
@ -272,13 +277,13 @@ jobs:
|
|||||||
uses: ./
|
uses: ./
|
||||||
with:
|
with:
|
||||||
buildkitd-flags: --debug
|
buildkitd-flags: --debug
|
||||||
config-inline: |
|
buildkitd-config-inline: |
|
||||||
debug = true
|
debug = true
|
||||||
[registry."docker.io"]
|
[registry."docker.io"]
|
||||||
mirrors = ["mirror.gcr.io"]
|
mirrors = ["mirror.gcr.io"]
|
||||||
-
|
-
|
||||||
name: Build
|
name: Build
|
||||||
uses: docker/build-push-action@v4
|
uses: docker/build-push-action@v6
|
||||||
with:
|
with:
|
||||||
context: .
|
context: .
|
||||||
|
|
||||||
@ -288,8 +293,7 @@ jobs:
|
|||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
buildx-version:
|
buildx-version:
|
||||||
- latest
|
- v0.9.1
|
||||||
- v0.4.1
|
|
||||||
- ""
|
- ""
|
||||||
qemu-platforms:
|
qemu-platforms:
|
||||||
- all
|
- all
|
||||||
@ -297,10 +301,10 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
-
|
-
|
||||||
name: Checkout
|
name: Checkout
|
||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v4
|
||||||
-
|
-
|
||||||
name: Set up QEMU
|
name: Set up QEMU
|
||||||
uses: docker/setup-qemu-action@v2
|
uses: docker/setup-qemu-action@v3
|
||||||
with:
|
with:
|
||||||
platforms: ${{ matrix.qemu-platforms }}
|
platforms: ${{ matrix.qemu-platforms }}
|
||||||
-
|
-
|
||||||
@ -326,7 +330,7 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
-
|
-
|
||||||
name: Checkout
|
name: Checkout
|
||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v4
|
||||||
-
|
-
|
||||||
name: Set up Docker Buildx
|
name: Set up Docker Buildx
|
||||||
uses: ./
|
uses: ./
|
||||||
@ -349,11 +353,15 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
-
|
-
|
||||||
name: Checkout
|
name: Checkout
|
||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v4
|
||||||
-
|
-
|
||||||
name: Uninstall docker cli
|
name: Uninstall docker cli
|
||||||
run: |
|
run: |
|
||||||
|
if dpkg -s "docker-ce" >/dev/null 2>&1; then
|
||||||
|
sudo dpkg -r --force-depends docker-ce-cli docker-buildx-plugin
|
||||||
|
else
|
||||||
sudo apt-get purge -y moby-cli moby-buildx
|
sudo apt-get purge -y moby-cli moby-buildx
|
||||||
|
fi
|
||||||
-
|
-
|
||||||
name: Set up Docker Buildx
|
name: Set up Docker Buildx
|
||||||
uses: ./
|
uses: ./
|
||||||
@ -373,11 +381,15 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
-
|
-
|
||||||
name: Checkout
|
name: Checkout
|
||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v4
|
||||||
-
|
-
|
||||||
name: Uninstall docker cli
|
name: Uninstall docker cli
|
||||||
run: |
|
run: |
|
||||||
|
if dpkg -s "docker-ce" >/dev/null 2>&1; then
|
||||||
|
sudo dpkg -r --force-depends docker-ce-cli docker-buildx-plugin
|
||||||
|
else
|
||||||
sudo apt-get purge -y moby-cli moby-buildx
|
sudo apt-get purge -y moby-cli moby-buildx
|
||||||
|
fi
|
||||||
-
|
-
|
||||||
name: Set up Docker Buildx
|
name: Set up Docker Buildx
|
||||||
uses: ./
|
uses: ./
|
||||||
@ -400,11 +412,15 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
-
|
-
|
||||||
name: Checkout
|
name: Checkout
|
||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v4
|
||||||
-
|
-
|
||||||
name: Uninstall docker cli
|
name: Uninstall docker cli
|
||||||
run: |
|
run: |
|
||||||
|
if dpkg -s "docker-ce" >/dev/null 2>&1; then
|
||||||
|
sudo dpkg -r --force-depends docker-ce-cli docker-buildx-plugin
|
||||||
|
else
|
||||||
sudo apt-get purge -y moby-cli moby-buildx
|
sudo apt-get purge -y moby-cli moby-buildx
|
||||||
|
fi
|
||||||
-
|
-
|
||||||
name: Set up Docker Buildx
|
name: Set up Docker Buildx
|
||||||
id: buildx
|
id: buildx
|
||||||
@ -426,7 +442,7 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
-
|
-
|
||||||
name: Checkout
|
name: Checkout
|
||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v4
|
||||||
-
|
-
|
||||||
name: Create dummy contexts
|
name: Create dummy contexts
|
||||||
run: |
|
run: |
|
||||||
@ -455,12 +471,135 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
-
|
-
|
||||||
name: Checkout
|
name: Checkout
|
||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v4
|
||||||
-
|
-
|
||||||
name: Set up QEMU
|
name: Set up QEMU
|
||||||
uses: docker/setup-qemu-action@v2
|
uses: docker/setup-qemu-action@v3
|
||||||
-
|
-
|
||||||
name: Set up Docker Buildx
|
name: Set up Docker Buildx
|
||||||
uses: ./
|
uses: ./
|
||||||
with:
|
with:
|
||||||
platforms: linux/amd64
|
platforms: linux/amd64
|
||||||
|
|
||||||
|
docker-context:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
-
|
||||||
|
name: Checkout
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
-
|
||||||
|
name: Create Docker context
|
||||||
|
run: |
|
||||||
|
docker context create foo
|
||||||
|
docker context use foo
|
||||||
|
-
|
||||||
|
name: Set up Docker Buildx
|
||||||
|
uses: ./
|
||||||
|
with:
|
||||||
|
driver: docker
|
||||||
|
|
||||||
|
cleanup:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
|
matrix:
|
||||||
|
cleanup:
|
||||||
|
- true
|
||||||
|
- false
|
||||||
|
steps:
|
||||||
|
-
|
||||||
|
name: Checkout
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
-
|
||||||
|
name: Set up Docker Buildx
|
||||||
|
uses: ./
|
||||||
|
with:
|
||||||
|
cleanup: ${{ matrix.cleanup }}
|
||||||
|
|
||||||
|
k3s:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
|
matrix:
|
||||||
|
version:
|
||||||
|
- v0.11.0
|
||||||
|
- v0.10.5
|
||||||
|
steps:
|
||||||
|
-
|
||||||
|
name: Checkout
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
-
|
||||||
|
name: Install k3s
|
||||||
|
uses: crazy-max/.github/.github/actions/install-k3s@f5cb4a109b7a3b466a2ac293ef4bb13f1571acd7
|
||||||
|
-
|
||||||
|
name: Set up Docker Buildx
|
||||||
|
id: buildx
|
||||||
|
uses: ./
|
||||||
|
with:
|
||||||
|
version: ${{ matrix.version }}
|
||||||
|
driver: kubernetes
|
||||||
|
platforms: linux/amd64
|
||||||
|
driver-opts: |
|
||||||
|
image=moby/buildkit:buildx-stable-1
|
||||||
|
qemu.install=true
|
||||||
|
append: |
|
||||||
|
- platforms: linux/arm64
|
||||||
|
driver-opts:
|
||||||
|
- image=moby/buildkit:buildx-stable-1
|
||||||
|
- qemu.install=true
|
||||||
|
- platforms: linux/s390x
|
||||||
|
driver-opts:
|
||||||
|
- image=moby/buildkit:buildx-stable-1
|
||||||
|
- qemu.install=true
|
||||||
|
-
|
||||||
|
name: Create Dockerfile
|
||||||
|
run: |
|
||||||
|
cat > ./Dockerfile <<EOL
|
||||||
|
FROM alpine
|
||||||
|
RUN uname -a
|
||||||
|
EOL
|
||||||
|
-
|
||||||
|
name: Build
|
||||||
|
uses: docker/build-push-action@master
|
||||||
|
with:
|
||||||
|
context: .
|
||||||
|
|
||||||
|
cache-binary:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
|
matrix:
|
||||||
|
cache:
|
||||||
|
- true
|
||||||
|
- false
|
||||||
|
steps:
|
||||||
|
-
|
||||||
|
name: Checkout
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
-
|
||||||
|
name: Set up Docker Buildx
|
||||||
|
uses: ./
|
||||||
|
with:
|
||||||
|
version: v0.11.2
|
||||||
|
cache-binary: ${{ matrix.cache }}
|
||||||
|
|
||||||
|
windows-error:
|
||||||
|
runs-on: windows-latest
|
||||||
|
steps:
|
||||||
|
-
|
||||||
|
name: Checkout
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
-
|
||||||
|
name: Set up Docker Buildx
|
||||||
|
id: buildx
|
||||||
|
continue-on-error: true
|
||||||
|
uses: ./
|
||||||
|
-
|
||||||
|
name: Check
|
||||||
|
run: |
|
||||||
|
echo "${{ toJson(steps.buildx) }}"
|
||||||
|
if [ "${{ steps.buildx.outcome }}" != "failure" ] || [ "${{ steps.buildx.conclusion }}" != "success" ]; then
|
||||||
|
echo "::error::Should have failed"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
shell: bash
|
||||||
|
21
.github/workflows/publish.yml
vendored
Normal file
21
.github/workflows/publish.yml
vendored
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
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
|
21
.github/workflows/test.yml
vendored
21
.github/workflows/test.yml
vendored
@ -1,14 +1,15 @@
|
|||||||
name: test
|
name: test
|
||||||
|
|
||||||
|
concurrency:
|
||||||
|
group: ${{ github.workflow }}-${{ github.ref }}
|
||||||
|
cancel-in-progress: true
|
||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
branches:
|
branches:
|
||||||
- 'master'
|
- 'master'
|
||||||
- 'releases/v*'
|
- 'releases/v*'
|
||||||
pull_request:
|
pull_request:
|
||||||
branches:
|
|
||||||
- 'master'
|
|
||||||
- 'releases/v*'
|
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
test:
|
test:
|
||||||
@ -16,22 +17,18 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
-
|
-
|
||||||
name: Checkout
|
name: Checkout
|
||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v4
|
||||||
-
|
|
||||||
name: Validate
|
|
||||||
uses: docker/bake-action@v2
|
|
||||||
with:
|
|
||||||
targets: validate
|
|
||||||
-
|
-
|
||||||
name: Set up Docker Buildx
|
name: Set up Docker Buildx
|
||||||
uses: ./
|
uses: ./
|
||||||
-
|
-
|
||||||
name: Test
|
name: Test
|
||||||
uses: docker/bake-action@v2
|
uses: docker/bake-action@v6
|
||||||
with:
|
with:
|
||||||
targets: test
|
targets: test
|
||||||
-
|
-
|
||||||
name: Upload coverage
|
name: Upload coverage
|
||||||
uses: codecov/codecov-action@v3
|
uses: codecov/codecov-action@v5
|
||||||
with:
|
with:
|
||||||
file: ./coverage/clover.xml
|
files: ./coverage/clover.xml
|
||||||
|
token: ${{ secrets.CODECOV_TOKEN }}
|
||||||
|
43
.github/workflows/validate.yml
vendored
Normal file
43
.github/workflows/validate.yml
vendored
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
name: validate
|
||||||
|
|
||||||
|
concurrency:
|
||||||
|
group: ${{ github.workflow }}-${{ github.ref }}
|
||||||
|
cancel-in-progress: true
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- 'master'
|
||||||
|
- 'releases/v*'
|
||||||
|
pull_request:
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
prepare:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
outputs:
|
||||||
|
targets: ${{ steps.generate.outputs.targets }}
|
||||||
|
steps:
|
||||||
|
-
|
||||||
|
name: Checkout
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
-
|
||||||
|
name: List targets
|
||||||
|
id: generate
|
||||||
|
uses: docker/bake-action/subaction/list-targets@v6
|
||||||
|
with:
|
||||||
|
target: validate
|
||||||
|
|
||||||
|
validate:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
needs:
|
||||||
|
- prepare
|
||||||
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
|
matrix:
|
||||||
|
target: ${{ fromJson(needs.prepare.outputs.targets) }}
|
||||||
|
steps:
|
||||||
|
-
|
||||||
|
name: Validate
|
||||||
|
uses: docker/bake-action@v6
|
||||||
|
with:
|
||||||
|
targets: ${{ matrix.target }}
|
71
.gitignore
vendored
71
.gitignore
vendored
@ -1,12 +1,5 @@
|
|||||||
/.dev
|
# https://raw.githubusercontent.com/github/gitignore/main/Node.gitignore
|
||||||
node_modules
|
|
||||||
lib
|
|
||||||
|
|
||||||
# Jetbrains
|
|
||||||
/.idea
|
|
||||||
/*.iml
|
|
||||||
|
|
||||||
# Rest of the file pulled from https://github.com/github/gitignore/blob/master/Node.gitignore
|
|
||||||
# Logs
|
# Logs
|
||||||
logs
|
logs
|
||||||
*.log
|
*.log
|
||||||
@ -14,6 +7,7 @@ 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
|
||||||
@ -24,34 +18,14 @@ 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
|
||||||
|
|
||||||
@ -61,36 +35,19 @@ typings/
|
|||||||
# 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 variables file
|
# dotenv environment variable files
|
||||||
.env
|
.env
|
||||||
.env.test
|
.env.development.local
|
||||||
|
.env.test.local
|
||||||
|
.env.production.local
|
||||||
|
.env.local
|
||||||
|
|
||||||
# parcel-bundler cache (https://parceljs.org/)
|
# yarn v2
|
||||||
.cache
|
.yarn/cache
|
||||||
|
.yarn/unplugged
|
||||||
# next.js build output
|
.yarn/build-state.yml
|
||||||
.next
|
.yarn/install-state.gz
|
||||||
|
.pnp.*
|
||||||
# nuxt.js build output
|
|
||||||
.nuxt
|
|
||||||
|
|
||||||
# vuepress build output
|
|
||||||
.vuepress/dist
|
|
||||||
|
|
||||||
# Serverless directories
|
|
||||||
.serverless/
|
|
||||||
|
|
||||||
# FuseBox cache
|
|
||||||
.fusebox/
|
|
||||||
|
|
||||||
# DynamoDB Local files
|
|
||||||
.dynamodb/
|
|
||||||
|
6
.prettierignore
Normal file
6
.prettierignore
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
# Dependency directories
|
||||||
|
node_modules/
|
||||||
|
jspm_packages/
|
||||||
|
|
||||||
|
# yarn v2
|
||||||
|
.yarn/
|
541
.yarn/plugins/@yarnpkg/plugin-interactive-tools.cjs
vendored
Normal file
541
.yarn/plugins/@yarnpkg/plugin-interactive-tools.cjs
vendored
Normal file
File diff suppressed because one or more lines are too long
13
.yarnrc.yml
Normal file
13
.yarnrc.yml
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
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"
|
97
README.md
97
README.md
@ -20,14 +20,12 @@ ___
|
|||||||
|
|
||||||
* [Usage](#usage)
|
* [Usage](#usage)
|
||||||
* [Configuring your builder](#configuring-your-builder)
|
* [Configuring your builder](#configuring-your-builder)
|
||||||
* [Version pinning](#version-pinning)
|
|
||||||
* [Customizing](#customizing)
|
* [Customizing](#customizing)
|
||||||
* [inputs](#inputs)
|
* [inputs](#inputs)
|
||||||
* [outputs](#outputs)
|
* [outputs](#outputs)
|
||||||
* [environment variables](#environment-variables)
|
* [environment variables](#environment-variables)
|
||||||
* [Notes](#notes)
|
* [Notes](#notes)
|
||||||
* [`nodes` output](#nodes-output)
|
* [`nodes` output](#nodes-output)
|
||||||
* [BuildKit container logs](#buildkit-container-logs)
|
|
||||||
* [Contributing](#contributing)
|
* [Contributing](#contributing)
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
@ -44,53 +42,36 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
-
|
-
|
||||||
name: Checkout
|
name: Checkout
|
||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v4
|
||||||
-
|
-
|
||||||
# Add support for more platforms with QEMU (optional)
|
# Add support for more platforms with QEMU (optional)
|
||||||
# https://github.com/docker/setup-qemu-action
|
# https://github.com/docker/setup-qemu-action
|
||||||
name: Set up QEMU
|
name: Set up QEMU
|
||||||
uses: docker/setup-qemu-action@v2
|
uses: docker/setup-qemu-action@v3
|
||||||
-
|
-
|
||||||
name: Set up Docker Buildx
|
name: Set up Docker Buildx
|
||||||
uses: docker/setup-buildx-action@v2
|
uses: docker/setup-buildx-action@v3
|
||||||
```
|
```
|
||||||
|
|
||||||
## Configuring your builder
|
## Configuring your builder
|
||||||
|
|
||||||
See https://docs.docker.com/build/ci/github-actions/configure-builder/
|
* [Version pinning](https://docs.docker.com/build/ci/github-actions/configure-builder/#version-pinning): Pin to a specific Buildx or BuildKit version
|
||||||
|
* [BuildKit container logs](https://docs.docker.com/build/ci/github-actions/configure-builder/#buildkit-container-logs): Enable BuildKit container logs for debugging purposes
|
||||||
## Version pinning
|
* [BuildKit Daemon configuration](https://docs.docker.com/build/ci/github-actions/configure-builder/#buildkit-daemon-configuration)
|
||||||
|
* [Registry mirror](https://docs.docker.com/build/ci/github-actions/configure-builder/#registry-mirror): Configure a registry mirror for your builds
|
||||||
This action builds images using [Buildx](https://github.com/docker/buildx) and
|
* [Max parallelism](https://docs.docker.com/build/ci/github-actions/configure-builder/#max-parallelism): Configure the maximum parallelism for your builds
|
||||||
[BuildKit](https://github.com/moby/buildkit). By default, the action will
|
* [Append additional nodes to the builder](https://docs.docker.com/build/ci/github-actions/configure-builder/#append-additional-nodes-to-the-builder): Create additional nodes for your builder
|
||||||
attempt to use the latest version of Buildx available on the GitHub Runner
|
* [Authentication for remote builders](https://docs.docker.com/build/ci/github-actions/configure-builder/#authentication-for-remote-builders)
|
||||||
(the build client) and the latest release of BuildKit (the build server).
|
* [SSH authentication](https://docs.docker.com/build/ci/github-actions/configure-builder/#ssh-authentication): Authenticate to a remote builder using SSH
|
||||||
|
* [TLS authentication](https://docs.docker.com/build/ci/github-actions/configure-builder/#tls-authentication): Authenticate to a remote builder using TLS
|
||||||
To pin to a specific version of Buildx, use the `version` input. For example,
|
* [Standalone mode](https://docs.docker.com/build/ci/github-actions/configure-builder/#standalone-mode): Use Buildx as a standalone binary (without the Docker CLI)
|
||||||
to pin to Buildx v0.10.0:
|
* [Isolated builders](https://docs.docker.com/build/ci/github-actions/configure-builder/#isolated-builders): Create isolated builders for your builds
|
||||||
|
|
||||||
```yaml
|
|
||||||
- name: Set up Docker Buildx
|
|
||||||
uses: docker/setup-buildx-action@v2
|
|
||||||
with:
|
|
||||||
version: v0.10.0
|
|
||||||
```
|
|
||||||
|
|
||||||
To pin to a specific version of BuildKit, use the `image` option in the
|
|
||||||
`driver-opts` input. For example, to pin to BuildKit v0.11.0:
|
|
||||||
|
|
||||||
```yaml
|
|
||||||
- name: Set up Docker Buildx
|
|
||||||
uses: docker/setup-buildx-action@v2
|
|
||||||
with:
|
|
||||||
driver-opts: image=moby/buildkit:v0.11.0
|
|
||||||
```
|
|
||||||
|
|
||||||
## Customizing
|
## Customizing
|
||||||
|
|
||||||
### inputs
|
### inputs
|
||||||
|
|
||||||
Following inputs can be used as `step.with` keys:
|
The following inputs can be used as `step.with` keys:
|
||||||
|
|
||||||
> `List` type is a newline-delimited string
|
> `List` type is a newline-delimited string
|
||||||
> ```yaml
|
> ```yaml
|
||||||
@ -99,36 +80,44 @@ Following inputs can be used as `step.with` keys:
|
|||||||
> network=host
|
> network=host
|
||||||
> ```
|
> ```
|
||||||
|
|
||||||
> `CSV` type must be a newline-delimited string
|
> `CSV` type must be a comma-delimited string
|
||||||
> ```yaml
|
> ```yaml
|
||||||
> platforms: linux/amd64,linux/arm64
|
> platforms: linux/amd64,linux/arm64
|
||||||
> ```
|
> ```
|
||||||
|
|
||||||
| Name | Type | Description |
|
| Name | Type | Default | Description |
|
||||||
|-------------------|----------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|
|------------------------------|----------|--------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|
||||||
| `version` | String | [Buildx](https://github.com/docker/buildx) version. (eg. `v0.3.0`, `latest`, `https://github.com/docker/buildx.git#master`) |
|
| `version` | String | | [Buildx](https://github.com/docker/buildx) version. (eg. `v0.3.0`, `latest`, `https://github.com/docker/buildx.git#master`) |
|
||||||
| `driver` | String | Sets the [builder driver](https://docs.docker.com/engine/reference/commandline/buildx_create/#driver) to be used (default `docker-container`) |
|
| `driver` | String | `docker-container` | Sets the [builder driver](https://docs.docker.com/engine/reference/commandline/buildx_create/#driver) to be used |
|
||||||
| `driver-opts` | List | List of additional [driver-specific options](https://docs.docker.com/engine/reference/commandline/buildx_create/#driver-opt) (eg. `image=moby/buildkit:master`) |
|
| `driver-opts` | List | | List of additional [driver-specific options](https://docs.docker.com/engine/reference/commandline/buildx_create/#driver-opt) (eg. `image=moby/buildkit:master`) |
|
||||||
| `buildkitd-flags` | String | [Flags for buildkitd](https://docs.docker.com/engine/reference/commandline/buildx_create/#buildkitd-flags) daemon (since [buildx v0.3.0](https://github.com/docker/buildx/releases/tag/v0.3.0)) |
|
| `buildkitd-flags` | String | | [BuildKit daemon flags](https://docs.docker.com/engine/reference/commandline/buildx_create/#buildkitd-flags) |
|
||||||
| `install` | Bool | Sets up `docker build` command as an alias to `docker buildx` (default `false`) |
|
| `buildkitd-config` \* | String | | [BuildKit daemon config file](https://docs.docker.com/engine/reference/commandline/buildx_create/#config) |
|
||||||
| `use` | Bool | Switch to this builder instance (default `true`) |
|
| `buildkitd-config-inline` \* | String | | Same as `buildkitd-config` but inline |
|
||||||
| `endpoint` | String | [Optional address for docker socket](https://docs.docker.com/engine/reference/commandline/buildx_create/#description) or context from `docker context ls` |
|
| `install` | Bool | `false` | Sets up `docker build` command as an alias to `docker buildx` |
|
||||||
| `platforms` | List/CSV | Fixed [platforms](https://docs.docker.com/engine/reference/commandline/buildx_create/#platform) for current node. If not empty, values take priority over the detected ones. |
|
| `use` | Bool | `true` | Switch to this builder instance |
|
||||||
| `config`¹ | String | [BuildKit config file](https://docs.docker.com/engine/reference/commandline/buildx_create/#config) |
|
| `endpoint` | String | | [Optional address for docker socket](https://docs.docker.com/engine/reference/commandline/buildx_create/#description) or context from `docker context ls` |
|
||||||
| `config-inline`¹ | String | Same as `config` but inline |
|
| `platforms` | List/CSV | | Fixed [platforms](https://docs.docker.com/engine/reference/commandline/buildx_create/#platform) for current node. If not empty, values take priority over the detected ones. |
|
||||||
| `append` | YAML | [Append additional nodes](docs/advanced/append-nodes.md) to the builder |
|
| `append` | YAML | | [Append additional nodes](https://docs.docker.com/build/ci/github-actions/configure-builder/#append-additional-nodes-to-the-builder) to the builder |
|
||||||
|
| `cache-binary` | Bool | `true` | Cache buildx binary to GitHub Actions cache backend |
|
||||||
|
| `cleanup` | Bool | `true` | Cleanup temp files and remove builder at the end of a job |
|
||||||
|
|
||||||
> * ¹ `config` and `config-inline` are mutually exclusive
|
> [!IMPORTANT]
|
||||||
|
> If you set the `buildkitd-flags` input, the default flags (`--allow-insecure-entitlement security.insecure --allow-insecure-entitlement network.host`)
|
||||||
|
> will be reset. If you want to retain the default behavior, make sure to
|
||||||
|
> include these flags in your custom `buildkitd-flags` value.
|
||||||
|
|
||||||
|
> [!NOTE]
|
||||||
|
> `buildkitd-config` and `buildkitd-config-inline` are mutually exclusive.
|
||||||
|
|
||||||
### outputs
|
### outputs
|
||||||
|
|
||||||
Following outputs are available
|
The following outputs are available:
|
||||||
|
|
||||||
| Name | Type | Description |
|
| Name | Type | Description |
|
||||||
|-------------|--------|-------------------------------------------------|
|
|-------------|--------|-----------------------------------------------------|
|
||||||
| `name` | String | Builder name |
|
| `name` | String | Builder name |
|
||||||
| `driver` | String | Builder driver |
|
| `driver` | String | Builder driver |
|
||||||
| `platforms` | String | Builder node platforms (preferred or available) |
|
| `platforms` | String | Builder node platforms (preferred and/or available) |
|
||||||
| `nodes` | JSON | Builder [nodes metadata](#nodes-output) |
|
| `nodes` | JSON | Builder [nodes metadata](#nodes-output) |
|
||||||
|
|
||||||
### environment variables
|
### environment variables
|
||||||
@ -170,10 +159,6 @@ The following [official docker environment variables](https://docs.docker.com/en
|
|||||||
| `buildkit` | String | BuildKit version |
|
| `buildkit` | String | BuildKit version |
|
||||||
| `platforms` | String | Platforms available |
|
| `platforms` | String | Platforms available |
|
||||||
|
|
||||||
### BuildKit container logs
|
|
||||||
|
|
||||||
See https://docs.docker.com/build/ci/github-actions/configure-builder/#buildkit-container-logs
|
|
||||||
|
|
||||||
## Contributing
|
## Contributing
|
||||||
|
|
||||||
Want to contribute? Awesome! You can find information about contributing to
|
Want to contribute? Awesome! You can find information about contributing to
|
||||||
|
@ -1,88 +0,0 @@
|
|||||||
import {describe, expect, test, beforeEach} from '@jest/globals';
|
|
||||||
import * as fs from 'fs';
|
|
||||||
import * as os from 'os';
|
|
||||||
import * as path from 'path';
|
|
||||||
import * as auth from '../src/auth';
|
|
||||||
|
|
||||||
const tmpdir = fs.mkdtempSync(path.join(os.tmpdir(), 'docker-setup-buildx-jest')).split(path.sep).join(path.posix.sep);
|
|
||||||
const dockerConfigHome = path.join(tmpdir, '.docker');
|
|
||||||
const credsdir = path.join(dockerConfigHome, 'buildx', 'creds');
|
|
||||||
|
|
||||||
describe('setCredentials', () => {
|
|
||||||
beforeEach(() => {
|
|
||||||
process.env = Object.keys(process.env).reduce((object, key) => {
|
|
||||||
if (!key.startsWith(auth.envPrefix)) {
|
|
||||||
object[key] = process.env[key];
|
|
||||||
}
|
|
||||||
return object;
|
|
||||||
}, {});
|
|
||||||
});
|
|
||||||
|
|
||||||
// prettier-ignore
|
|
||||||
test.each([
|
|
||||||
[
|
|
||||||
'mycontext',
|
|
||||||
'docker-container',
|
|
||||||
{},
|
|
||||||
[],
|
|
||||||
[]
|
|
||||||
],
|
|
||||||
[
|
|
||||||
'docker-container://mycontainer',
|
|
||||||
'docker-container',
|
|
||||||
{},
|
|
||||||
[],
|
|
||||||
[]
|
|
||||||
],
|
|
||||||
[
|
|
||||||
'tcp://graviton2:1234',
|
|
||||||
'remote',
|
|
||||||
{},
|
|
||||||
[],
|
|
||||||
[]
|
|
||||||
],
|
|
||||||
[
|
|
||||||
'tcp://graviton2:1234',
|
|
||||||
'remote',
|
|
||||||
{
|
|
||||||
'BUILDER_NODE_0_AUTH_TLS_CACERT': 'foo',
|
|
||||||
'BUILDER_NODE_0_AUTH_TLS_CERT': 'foo',
|
|
||||||
'BUILDER_NODE_0_AUTH_TLS_KEY': 'foo'
|
|
||||||
},
|
|
||||||
[
|
|
||||||
path.join(credsdir, 'cacert_graviton2-1234.pem'),
|
|
||||||
path.join(credsdir, 'cert_graviton2-1234.pem'),
|
|
||||||
path.join(credsdir, 'key_graviton2-1234.pem')
|
|
||||||
],
|
|
||||||
[
|
|
||||||
`cacert=${path.join(credsdir, 'cacert_graviton2-1234.pem')}`,
|
|
||||||
`cert=${path.join(credsdir, 'cert_graviton2-1234.pem')}`,
|
|
||||||
`key=${path.join(credsdir, 'key_graviton2-1234.pem')}`
|
|
||||||
]
|
|
||||||
],
|
|
||||||
[
|
|
||||||
'tcp://graviton2:1234',
|
|
||||||
'docker-container',
|
|
||||||
{
|
|
||||||
'BUILDER_NODE_0_AUTH_TLS_CACERT': 'foo',
|
|
||||||
'BUILDER_NODE_0_AUTH_TLS_CERT': 'foo',
|
|
||||||
'BUILDER_NODE_0_AUTH_TLS_KEY': 'foo'
|
|
||||||
},
|
|
||||||
[
|
|
||||||
path.join(credsdir, 'cacert_graviton2-1234.pem'),
|
|
||||||
path.join(credsdir, 'cert_graviton2-1234.pem'),
|
|
||||||
path.join(credsdir, 'key_graviton2-1234.pem')
|
|
||||||
],
|
|
||||||
[]
|
|
||||||
],
|
|
||||||
])('given %p endpoint', async (endpoint: string, driver: string, envs: Record<string, string>, expectedFiles: Array<string>, expectedOpts: Array<string>) => {
|
|
||||||
fs.mkdirSync(credsdir, {recursive: true});
|
|
||||||
for (const [key, value] of Object.entries(envs)) {
|
|
||||||
process.env[key] = value;
|
|
||||||
}
|
|
||||||
expect(auth.setCredentials(credsdir, 0, driver, endpoint)).toEqual(expectedOpts);
|
|
||||||
expectedFiles.forEach( (file) => {
|
|
||||||
expect(fs.existsSync(file)).toBe(true);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
@ -1,261 +0,0 @@
|
|||||||
import {describe, expect, it, jest, test} from '@jest/globals';
|
|
||||||
import * as fs from 'fs';
|
|
||||||
import * as os from 'os';
|
|
||||||
import * as path from 'path';
|
|
||||||
import * as buildx from '../src/buildx';
|
|
||||||
import * as context from '../src/context';
|
|
||||||
import * as semver from 'semver';
|
|
||||||
import * as exec from '@actions/exec';
|
|
||||||
|
|
||||||
const tmpdir = fs.mkdtempSync(path.join(os.tmpdir(), 'docker-setup-buildx-')).split(path.sep).join(path.posix.sep);
|
|
||||||
jest.spyOn(context, 'tmpDir').mockImplementation((): string => {
|
|
||||||
return tmpdir;
|
|
||||||
});
|
|
||||||
|
|
||||||
const tmpname = path.join(tmpdir, '.tmpname').split(path.sep).join(path.posix.sep);
|
|
||||||
jest.spyOn(context, 'tmpNameSync').mockImplementation((): string => {
|
|
||||||
return tmpname;
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('isAvailable', () => {
|
|
||||||
const execSpy = jest.spyOn(exec, 'getExecOutput');
|
|
||||||
buildx.isAvailable();
|
|
||||||
|
|
||||||
// eslint-disable-next-line jest/no-standalone-expect
|
|
||||||
expect(execSpy).toHaveBeenCalledWith(`docker`, ['buildx'], {
|
|
||||||
silent: true,
|
|
||||||
ignoreReturnCode: true
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('isAvailable standalone', () => {
|
|
||||||
const execSpy = jest.spyOn(exec, 'getExecOutput');
|
|
||||||
buildx.isAvailable(true);
|
|
||||||
|
|
||||||
// eslint-disable-next-line jest/no-standalone-expect
|
|
||||||
expect(execSpy).toHaveBeenCalledWith(`buildx`, [], {
|
|
||||||
silent: true,
|
|
||||||
ignoreReturnCode: true
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('getVersion', () => {
|
|
||||||
it('valid', async () => {
|
|
||||||
const version = await buildx.getVersion();
|
|
||||||
expect(semver.valid(version)).not.toBeNull();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('parseVersion', () => {
|
|
||||||
test.each([
|
|
||||||
['github.com/docker/buildx 0.4.1+azure bda4882a65349ca359216b135896bddc1d92461c', '0.4.1'],
|
|
||||||
['github.com/docker/buildx v0.4.1 bda4882a65349ca359216b135896bddc1d92461c', '0.4.1'],
|
|
||||||
['github.com/docker/buildx v0.4.2 fb7b670b764764dc4716df3eba07ffdae4cc47b2', '0.4.2'],
|
|
||||||
['github.com/docker/buildx f117971 f11797113e5a9b86bd976329c5dbb8a8bfdfadfa', 'f117971']
|
|
||||||
])('given %p', async (stdout, expected) => {
|
|
||||||
expect(buildx.parseVersion(stdout)).toEqual(expected);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('satisfies', () => {
|
|
||||||
test.each([
|
|
||||||
['0.4.1', '>=0.3.2', true],
|
|
||||||
['bda4882a65349ca359216b135896bddc1d92461c', '>0.1.0', false],
|
|
||||||
['f117971', '>0.6.0', true]
|
|
||||||
])('given %p', async (version, range, expected) => {
|
|
||||||
expect(buildx.satisfies(version, range)).toBe(expected);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('inspect', () => {
|
|
||||||
it('valid', async () => {
|
|
||||||
const builder = await buildx.inspect('');
|
|
||||||
expect(builder).not.toBeUndefined();
|
|
||||||
expect(builder.name).not.toEqual('');
|
|
||||||
expect(builder.driver).not.toEqual('');
|
|
||||||
expect(builder.nodes).not.toEqual({});
|
|
||||||
}, 100000);
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('parseInspect', () => {
|
|
||||||
// prettier-ignore
|
|
||||||
test.each([
|
|
||||||
[
|
|
||||||
'inspect1.txt',
|
|
||||||
{
|
|
||||||
"nodes": [
|
|
||||||
{
|
|
||||||
"name": "builder-5cb467f7-0940-47e1-b94b-d51f54054d620",
|
|
||||||
"endpoint": "unix:///var/run/docker.sock",
|
|
||||||
"status": "running",
|
|
||||||
"buildkitd-flags": "--allow-insecure-entitlement security.insecure --allow-insecure-entitlement network.host",
|
|
||||||
"buildkit": "v0.10.4",
|
|
||||||
"platforms": "linux/amd64,linux/amd64/v2,linux/amd64/v3,linux/amd64/v4,linux/arm64,linux/riscv64,linux/386,linux/arm/v7,linux/arm/v6"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"name": "builder-5cb467f7-0940-47e1-b94b-d51f54054d62",
|
|
||||||
"driver": "docker-container"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
[
|
|
||||||
'inspect2.txt',
|
|
||||||
{
|
|
||||||
"nodes": [
|
|
||||||
{
|
|
||||||
"name": "builder-5f449644-ff29-48af-8344-abb0292d06730",
|
|
||||||
"endpoint": "unix:///var/run/docker.sock",
|
|
||||||
"driver-opts": [
|
|
||||||
"image=moby/buildkit:latest"
|
|
||||||
],
|
|
||||||
"status": "running",
|
|
||||||
"buildkitd-flags": "--allow-insecure-entitlement security.insecure --allow-insecure-entitlement network.host",
|
|
||||||
"buildkit": "v0.10.4",
|
|
||||||
"platforms": "linux/amd64,linux/amd64/v2,linux/amd64/v3,linux/amd64/v4,linux/386"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"name": "builder-5f449644-ff29-48af-8344-abb0292d0673",
|
|
||||||
"driver": "docker-container"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
[
|
|
||||||
'inspect3.txt',
|
|
||||||
{
|
|
||||||
"nodes": [
|
|
||||||
{
|
|
||||||
"name": "builder-9929e463-7954-4dc3-89cd-514cca29ff800",
|
|
||||||
"endpoint": "unix:///var/run/docker.sock",
|
|
||||||
"driver-opts": [
|
|
||||||
"image=moby/buildkit:master",
|
|
||||||
"network=host"
|
|
||||||
],
|
|
||||||
"status": "running",
|
|
||||||
"buildkitd-flags": "--allow-insecure-entitlement security.insecure --allow-insecure-entitlement network.host",
|
|
||||||
"buildkit": "3fab389",
|
|
||||||
"platforms": "linux/amd64,linux/amd64/v2,linux/amd64/v3,linux/amd64/v4,linux/386"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"name": "builder-9929e463-7954-4dc3-89cd-514cca29ff80",
|
|
||||||
"driver": "docker-container"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
[
|
|
||||||
'inspect4.txt',
|
|
||||||
{
|
|
||||||
"nodes": [
|
|
||||||
{
|
|
||||||
"name": "default",
|
|
||||||
"endpoint": "default",
|
|
||||||
"status": "running",
|
|
||||||
"buildkit": "20.10.17",
|
|
||||||
"platforms": "linux/amd64,linux/arm64,linux/riscv64,linux/ppc64le,linux/s390x,linux/386,linux/arm/v7,linux/arm/v6"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"name": "default",
|
|
||||||
"driver": "docker"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
[
|
|
||||||
'inspect5.txt',
|
|
||||||
{
|
|
||||||
"nodes": [
|
|
||||||
{
|
|
||||||
"name": "aws_graviton2",
|
|
||||||
"endpoint": "tcp://1.23.45.67:1234",
|
|
||||||
"driver-opts": [
|
|
||||||
"cert=/home/user/.certs/aws_graviton2/cert.pem",
|
|
||||||
"key=/home/user/.certs/aws_graviton2/key.pem",
|
|
||||||
"cacert=/home/user/.certs/aws_graviton2/ca.pem"
|
|
||||||
],
|
|
||||||
"status": "running",
|
|
||||||
"platforms": "darwin/arm64,linux/arm64,linux/arm/v5,linux/arm/v6,linux/arm/v7,windows/arm64"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"name": "remote-builder",
|
|
||||||
"driver": "remote"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
[
|
|
||||||
'inspect6.txt',
|
|
||||||
{
|
|
||||||
"nodes": [
|
|
||||||
{
|
|
||||||
"name": "builder-17cfff01-48d9-4c3d-9332-9992e308a5100",
|
|
||||||
"endpoint": "unix:///var/run/docker.sock",
|
|
||||||
"status": "running",
|
|
||||||
"buildkitd-flags": "--allow-insecure-entitlement security.insecure --allow-insecure-entitlement network.host",
|
|
||||||
"platforms": "linux/amd64,linux/amd64/v2,linux/amd64/v3,linux/386"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"name": "builder-17cfff01-48d9-4c3d-9332-9992e308a510",
|
|
||||||
"driver": "docker-container"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
])('given %p', async (inspectFile, expected) => {
|
|
||||||
expect(await buildx.parseInspect(fs.readFileSync(path.join(__dirname, 'fixtures', inspectFile)).toString())).toEqual(expected);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('build', () => {
|
|
||||||
const tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), 'setup-buildx-'));
|
|
||||||
|
|
||||||
// eslint-disable-next-line jest/no-disabled-tests
|
|
||||||
it.skip('builds refs/pull/648/head', async () => {
|
|
||||||
const buildxBin = await buildx.build('https://github.com/docker/buildx.git#refs/pull/648/head', tmpDir, false);
|
|
||||||
expect(fs.existsSync(buildxBin)).toBe(true);
|
|
||||||
}, 100000);
|
|
||||||
|
|
||||||
// eslint-disable-next-line jest/no-disabled-tests
|
|
||||||
it.skip('builds 67bd6f4dc82a9cd96f34133dab3f6f7af803bb14', async () => {
|
|
||||||
const buildxBin = await buildx.build('https://github.com/docker/buildx.git#67bd6f4dc82a9cd96f34133dab3f6f7af803bb14', tmpDir, false);
|
|
||||||
expect(fs.existsSync(buildxBin)).toBe(true);
|
|
||||||
}, 100000);
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('install', () => {
|
|
||||||
const tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), 'setup-buildx-'));
|
|
||||||
test.each([
|
|
||||||
['v0.4.1', false],
|
|
||||||
['latest', false],
|
|
||||||
['v0.4.1', true],
|
|
||||||
['latest', true]
|
|
||||||
])(
|
|
||||||
'acquires %p of buildx (standalone: %p)',
|
|
||||||
async (version, standalone) => {
|
|
||||||
const buildxBin = await buildx.install(version, tmpDir, standalone);
|
|
||||||
expect(fs.existsSync(buildxBin)).toBe(true);
|
|
||||||
},
|
|
||||||
100000
|
|
||||||
);
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('getConfig', () => {
|
|
||||||
test.each([
|
|
||||||
['debug = true', false, 'debug = true', false],
|
|
||||||
[`notfound.toml`, true, '', true],
|
|
||||||
[
|
|
||||||
`${path.join(__dirname, 'fixtures', 'buildkitd.toml').split(path.sep).join(path.posix.sep)}`,
|
|
||||||
true,
|
|
||||||
`debug = true
|
|
||||||
[registry."docker.io"]
|
|
||||||
mirrors = ["mirror.gcr.io"]
|
|
||||||
`,
|
|
||||||
false
|
|
||||||
]
|
|
||||||
])('given %p config', async (val, file, exValue, invalid) => {
|
|
||||||
try {
|
|
||||||
let config: string;
|
|
||||||
if (file) {
|
|
||||||
config = await buildx.getConfigFile(val);
|
|
||||||
} else {
|
|
||||||
config = await buildx.getConfigInline(val);
|
|
||||||
}
|
|
||||||
expect(true).toBe(!invalid);
|
|
||||||
expect(config).toEqual(tmpname);
|
|
||||||
const configValue = fs.readFileSync(tmpname, 'utf-8');
|
|
||||||
expect(configValue).toEqual(exValue);
|
|
||||||
} catch (err) {
|
|
||||||
// eslint-disable-next-line jest/no-conditional-expect
|
|
||||||
expect(true).toBe(invalid);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
@ -1,22 +1,40 @@
|
|||||||
import {beforeEach, describe, expect, it, jest, test} from '@jest/globals';
|
import {beforeEach, describe, expect, jest, test} from '@jest/globals';
|
||||||
import * as fs from 'fs';
|
import * as fs from 'fs';
|
||||||
import * as os from 'os';
|
|
||||||
import * as path from 'path';
|
import * as path from 'path';
|
||||||
import * as uuid from 'uuid';
|
import {Buildx} from '@docker/actions-toolkit/lib/buildx/buildx';
|
||||||
|
import {Context} from '@docker/actions-toolkit/lib/context';
|
||||||
|
import {Docker} from '@docker/actions-toolkit/lib/docker/docker';
|
||||||
|
import {Toolkit} from '@docker/actions-toolkit/lib/toolkit';
|
||||||
|
import {Node} from '@docker/actions-toolkit/lib/types/buildx/builder';
|
||||||
|
|
||||||
import * as context from '../src/context';
|
import * as context from '../src/context';
|
||||||
import * as nodes from '../src/nodes';
|
|
||||||
|
|
||||||
const tmpdir = fs.mkdtempSync(path.join(os.tmpdir(), 'docker-setup-buildx-')).split(path.sep).join(path.posix.sep);
|
const fixturesDir = path.join(__dirname, 'fixtures');
|
||||||
jest.spyOn(context, 'tmpDir').mockImplementation((): string => {
|
// prettier-ignore
|
||||||
return tmpdir;
|
const tmpDir = path.join(process.env.TEMP || '/tmp', 'setup-buildx-jest');
|
||||||
|
const tmpName = path.join(tmpDir, '.tmpname-jest');
|
||||||
|
|
||||||
|
jest.spyOn(Context, 'tmpDir').mockImplementation((): string => {
|
||||||
|
if (!fs.existsSync(tmpDir)) {
|
||||||
|
fs.mkdirSync(tmpDir, {recursive: true});
|
||||||
|
}
|
||||||
|
return tmpDir;
|
||||||
});
|
});
|
||||||
|
|
||||||
jest.spyOn(context, 'tmpNameSync').mockImplementation((): string => {
|
jest.spyOn(Context, 'tmpName').mockImplementation((): string => {
|
||||||
return path.join(tmpdir, '.tmpname').split(path.sep).join(path.posix.sep);
|
return tmpName;
|
||||||
});
|
});
|
||||||
|
|
||||||
jest.mock('uuid');
|
jest.mock('crypto', () => {
|
||||||
jest.spyOn(uuid, 'v4').mockReturnValue('9b1deb4d-3b7d-4bad-9bdd-2b0d7b3dcb6d');
|
return {
|
||||||
|
...(jest.requireActual('crypto') as object),
|
||||||
|
randomUUID: jest.fn(() => '9b1deb4d-3b7d-4bad-9bdd-2b0d7b3dcb6d')
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
|
jest.spyOn(Docker, 'context').mockImplementation((): Promise<string> => {
|
||||||
|
return Promise.resolve('default');
|
||||||
|
});
|
||||||
|
|
||||||
describe('getCreateArgs', () => {
|
describe('getCreateArgs', () => {
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
@ -32,9 +50,12 @@ describe('getCreateArgs', () => {
|
|||||||
test.each([
|
test.each([
|
||||||
[
|
[
|
||||||
0,
|
0,
|
||||||
|
'v0.10.3',
|
||||||
new Map<string, string>([
|
new Map<string, string>([
|
||||||
['install', 'false'],
|
['install', 'false'],
|
||||||
['use', 'true'],
|
['use', 'true'],
|
||||||
|
['cache-binary', 'true'],
|
||||||
|
['cleanup', 'true'],
|
||||||
]),
|
]),
|
||||||
[
|
[
|
||||||
'create',
|
'create',
|
||||||
@ -46,10 +67,13 @@ describe('getCreateArgs', () => {
|
|||||||
],
|
],
|
||||||
[
|
[
|
||||||
1,
|
1,
|
||||||
|
'v0.10.3',
|
||||||
new Map<string, string>([
|
new Map<string, string>([
|
||||||
['driver', 'docker'],
|
['driver', 'docker'],
|
||||||
['install', 'false'],
|
['install', 'false'],
|
||||||
['use', 'true'],
|
['use', 'true'],
|
||||||
|
['cache-binary', 'true'],
|
||||||
|
['cleanup', 'true'],
|
||||||
]),
|
]),
|
||||||
[
|
[
|
||||||
'create',
|
'create',
|
||||||
@ -61,10 +85,13 @@ describe('getCreateArgs', () => {
|
|||||||
],
|
],
|
||||||
[
|
[
|
||||||
2,
|
2,
|
||||||
|
'v0.10.3',
|
||||||
new Map<string, string>([
|
new Map<string, string>([
|
||||||
['install', 'false'],
|
['install', 'false'],
|
||||||
['use', 'false'],
|
['use', 'false'],
|
||||||
['driver-opts', 'image=moby/buildkit:master\nnetwork=host'],
|
['driver-opts', 'image=moby/buildkit:master\nnetwork=host'],
|
||||||
|
['cache-binary', 'true'],
|
||||||
|
['cleanup', 'true'],
|
||||||
]),
|
]),
|
||||||
[
|
[
|
||||||
'create',
|
'create',
|
||||||
@ -77,11 +104,14 @@ describe('getCreateArgs', () => {
|
|||||||
],
|
],
|
||||||
[
|
[
|
||||||
3,
|
3,
|
||||||
|
'v0.10.3',
|
||||||
new Map<string, string>([
|
new Map<string, string>([
|
||||||
['driver', 'remote'],
|
['driver', 'remote'],
|
||||||
['endpoint', 'tls://foo:1234'],
|
['endpoint', 'tls://foo:1234'],
|
||||||
['install', 'false'],
|
['install', 'false'],
|
||||||
['use', 'true'],
|
['use', 'true'],
|
||||||
|
['cache-binary', 'true'],
|
||||||
|
['cleanup', 'true'],
|
||||||
]),
|
]),
|
||||||
[
|
[
|
||||||
'create',
|
'create',
|
||||||
@ -93,12 +123,15 @@ describe('getCreateArgs', () => {
|
|||||||
],
|
],
|
||||||
[
|
[
|
||||||
4,
|
4,
|
||||||
|
'v0.10.3',
|
||||||
new Map<string, string>([
|
new Map<string, string>([
|
||||||
['driver', 'remote'],
|
['driver', 'remote'],
|
||||||
['platforms', 'linux/arm64,linux/arm/v7'],
|
['platforms', 'linux/arm64,linux/arm/v7'],
|
||||||
['endpoint', 'tls://foo:1234'],
|
['endpoint', 'tls://foo:1234'],
|
||||||
['install', 'false'],
|
['install', 'false'],
|
||||||
['use', 'true'],
|
['use', 'true'],
|
||||||
|
['cache-binary', 'true'],
|
||||||
|
['cleanup', 'true'],
|
||||||
]),
|
]),
|
||||||
[
|
[
|
||||||
'create',
|
'create',
|
||||||
@ -111,10 +144,13 @@ describe('getCreateArgs', () => {
|
|||||||
],
|
],
|
||||||
[
|
[
|
||||||
5,
|
5,
|
||||||
|
'v0.10.3',
|
||||||
new Map<string, string>([
|
new Map<string, string>([
|
||||||
['install', 'false'],
|
['install', 'false'],
|
||||||
['use', 'false'],
|
['use', 'false'],
|
||||||
['driver-opts', `"env.no_proxy=localhost,127.0.0.1,.mydomain"`],
|
['driver-opts', `"env.no_proxy=localhost,127.0.0.1,.mydomain"`],
|
||||||
|
['cache-binary', 'true'],
|
||||||
|
['cleanup', 'true'],
|
||||||
]),
|
]),
|
||||||
[
|
[
|
||||||
'create',
|
'create',
|
||||||
@ -126,10 +162,13 @@ describe('getCreateArgs', () => {
|
|||||||
],
|
],
|
||||||
[
|
[
|
||||||
6,
|
6,
|
||||||
|
'v0.10.3',
|
||||||
new Map<string, string>([
|
new Map<string, string>([
|
||||||
['install', 'false'],
|
['install', 'false'],
|
||||||
['use', 'false'],
|
['use', 'false'],
|
||||||
['platforms', 'linux/amd64\n"linux/arm64,linux/arm/v7"'],
|
['platforms', 'linux/amd64\n"linux/arm64,linux/arm/v7"'],
|
||||||
|
['cache-binary', 'true'],
|
||||||
|
['cleanup', 'true'],
|
||||||
]),
|
]),
|
||||||
[
|
[
|
||||||
'create',
|
'create',
|
||||||
@ -139,14 +178,88 @@ describe('getCreateArgs', () => {
|
|||||||
'--platform', 'linux/amd64,linux/arm64,linux/arm/v7'
|
'--platform', 'linux/amd64,linux/arm64,linux/arm/v7'
|
||||||
]
|
]
|
||||||
],
|
],
|
||||||
|
[
|
||||||
|
7,
|
||||||
|
'v0.10.3',
|
||||||
|
new Map<string, string>([
|
||||||
|
['install', 'false'],
|
||||||
|
['use', 'false'],
|
||||||
|
['driver', 'unknown'],
|
||||||
|
['cache-binary', 'true'],
|
||||||
|
['cleanup', 'true'],
|
||||||
|
]),
|
||||||
|
[
|
||||||
|
'create',
|
||||||
|
'--name', 'builder-9b1deb4d-3b7d-4bad-9bdd-2b0d7b3dcb6d',
|
||||||
|
'--driver', 'unknown',
|
||||||
|
]
|
||||||
|
],
|
||||||
|
[
|
||||||
|
8,
|
||||||
|
'v0.10.3',
|
||||||
|
new Map<string, string>([
|
||||||
|
['install', 'false'],
|
||||||
|
['use', 'false'],
|
||||||
|
['buildkitd-config', path.join(fixturesDir, 'buildkitd.toml')],
|
||||||
|
['cache-binary', 'true'],
|
||||||
|
['cleanup', 'true'],
|
||||||
|
]),
|
||||||
|
[
|
||||||
|
'create',
|
||||||
|
'--name', 'builder-9b1deb4d-3b7d-4bad-9bdd-2b0d7b3dcb6d',
|
||||||
|
'--driver', 'docker-container',
|
||||||
|
'--buildkitd-flags', '--allow-insecure-entitlement security.insecure --allow-insecure-entitlement network.host',
|
||||||
|
'--config', tmpName,
|
||||||
|
]
|
||||||
|
],
|
||||||
|
[
|
||||||
|
9,
|
||||||
|
'v0.10.3',
|
||||||
|
new Map<string, string>([
|
||||||
|
['install', 'false'],
|
||||||
|
['use', 'false'],
|
||||||
|
['buildkitd-config-inline', 'debug = true'],
|
||||||
|
['cache-binary', 'true'],
|
||||||
|
['cleanup', 'true'],
|
||||||
|
]),
|
||||||
|
[
|
||||||
|
'create',
|
||||||
|
'--name', 'builder-9b1deb4d-3b7d-4bad-9bdd-2b0d7b3dcb6d',
|
||||||
|
'--driver', 'docker-container',
|
||||||
|
'--buildkitd-flags', '--allow-insecure-entitlement security.insecure --allow-insecure-entitlement network.host',
|
||||||
|
'--config', tmpName,
|
||||||
|
]
|
||||||
|
],
|
||||||
|
[
|
||||||
|
10,
|
||||||
|
'v0.10.3',
|
||||||
|
new Map<string, string>([
|
||||||
|
['install', 'false'],
|
||||||
|
['use', 'false'],
|
||||||
|
['driver', 'cloud'],
|
||||||
|
['buildkitd-flags', '--allow-insecure-entitlement network.host'],
|
||||||
|
['cache-binary', 'true'],
|
||||||
|
['cleanup', 'true'],
|
||||||
|
]),
|
||||||
|
[
|
||||||
|
'create',
|
||||||
|
'--name', 'builder-9b1deb4d-3b7d-4bad-9bdd-2b0d7b3dcb6d',
|
||||||
|
'--driver', 'cloud',
|
||||||
|
'--buildkitd-flags', '--allow-insecure-entitlement network.host',
|
||||||
|
]
|
||||||
|
]
|
||||||
])(
|
])(
|
||||||
'[%d] given %p as inputs, returns %p',
|
'[%d] given buildx %s and %p as inputs, returns %p',
|
||||||
async (num: number, inputs: Map<string, string>, expected: Array<string>) => {
|
async (num: number, buildxVersion: string, inputs: Map<string, string>, expected: Array<string>) => {
|
||||||
inputs.forEach((value: string, name: string) => {
|
inputs.forEach((value: string, name: string) => {
|
||||||
setInput(name, value);
|
setInput(name, value);
|
||||||
});
|
});
|
||||||
|
const toolkit = new Toolkit();
|
||||||
|
jest.spyOn(Buildx.prototype, 'version').mockImplementation(async (): Promise<string> => {
|
||||||
|
return buildxVersion;
|
||||||
|
});
|
||||||
const inp = await context.getInputs();
|
const inp = await context.getInputs();
|
||||||
const res = await context.getCreateArgs(inp, '0.9.0');
|
const res = await context.getCreateArgs(inp, toolkit);
|
||||||
expect(res).toEqual(expected);
|
expect(res).toEqual(expected);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
@ -166,9 +279,12 @@ describe('getAppendArgs', () => {
|
|||||||
test.each([
|
test.each([
|
||||||
[
|
[
|
||||||
0,
|
0,
|
||||||
|
'v0.10.3',
|
||||||
new Map<string, string>([
|
new Map<string, string>([
|
||||||
['install', 'false'],
|
['install', 'false'],
|
||||||
['use', 'true'],
|
['use', 'true'],
|
||||||
|
['cache-binary', 'true'],
|
||||||
|
['cleanup', 'true'],
|
||||||
]),
|
]),
|
||||||
{
|
{
|
||||||
"name": "aws_graviton2",
|
"name": "aws_graviton2",
|
||||||
@ -191,85 +307,154 @@ describe('getAppendArgs', () => {
|
|||||||
]
|
]
|
||||||
]
|
]
|
||||||
])(
|
])(
|
||||||
'[%d] given %p as inputs, returns %p',
|
'[%d] given buildx %s and %p as inputs, returns %p',
|
||||||
async (num: number, inputs: Map<string, string>, node: nodes.Node, expected: Array<string>) => {
|
async (num: number, buildxVersion: string, inputs: Map<string, string>, node: Node, expected: Array<string>) => {
|
||||||
inputs.forEach((value: string, name: string) => {
|
inputs.forEach((value: string, name: string) => {
|
||||||
setInput(name, value);
|
setInput(name, value);
|
||||||
});
|
});
|
||||||
|
const toolkit = new Toolkit();
|
||||||
|
jest.spyOn(Buildx.prototype, 'version').mockImplementation(async (): Promise<string> => {
|
||||||
|
return buildxVersion;
|
||||||
|
});
|
||||||
const inp = await context.getInputs();
|
const inp = await context.getInputs();
|
||||||
const res = await context.getAppendArgs(inp, node, '0.9.0');
|
const res = await context.getAppendArgs(inp, node, toolkit);
|
||||||
expect(res).toEqual(expected);
|
expect(res).toEqual(expected);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('getInputList', () => {
|
describe('getVersion', () => {
|
||||||
it('handles single line correctly', async () => {
|
beforeEach(() => {
|
||||||
await setInput('foo', 'bar');
|
process.env = Object.keys(process.env).reduce((object, key) => {
|
||||||
const res = await context.getInputList('foo');
|
if (!key.startsWith('INPUT_')) {
|
||||||
expect(res).toEqual(['bar']);
|
object[key] = process.env[key];
|
||||||
|
}
|
||||||
|
return object;
|
||||||
|
}, {});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('handles multiple lines correctly', async () => {
|
// prettier-ignore
|
||||||
setInput('foo', 'bar\nbaz');
|
test.each([
|
||||||
const res = await context.getInputList('foo');
|
[
|
||||||
expect(res).toEqual(['bar', 'baz']);
|
0,
|
||||||
});
|
new Map<string, string>([
|
||||||
|
// defaults
|
||||||
it('remove empty lines correctly', async () => {
|
['install', 'false'],
|
||||||
setInput('foo', 'bar\n\nbaz');
|
['use', 'true'],
|
||||||
const res = await context.getInputList('foo');
|
['cache-binary', 'true'],
|
||||||
expect(res).toEqual(['bar', 'baz']);
|
['cleanup', 'true'],
|
||||||
});
|
]),
|
||||||
|
''
|
||||||
it('handles comma correctly', async () => {
|
],
|
||||||
setInput('foo', 'bar,baz');
|
[
|
||||||
const res = await context.getInputList('foo');
|
1,
|
||||||
expect(res).toEqual(['bar', 'baz']);
|
new Map<string, string>([
|
||||||
});
|
['version', 'latest'],
|
||||||
|
// defaults
|
||||||
it('remove empty result correctly', async () => {
|
['install', 'false'],
|
||||||
setInput('foo', 'bar,baz,');
|
['use', 'true'],
|
||||||
const res = await context.getInputList('foo');
|
['cache-binary', 'true'],
|
||||||
expect(res).toEqual(['bar', 'baz']);
|
['cleanup', 'true']
|
||||||
});
|
]),
|
||||||
|
'latest'
|
||||||
it('handles different new lines correctly', async () => {
|
],
|
||||||
setInput('foo', 'bar\r\nbaz');
|
[
|
||||||
const res = await context.getInputList('foo');
|
2,
|
||||||
expect(res).toEqual(['bar', 'baz']);
|
new Map<string, string>([
|
||||||
});
|
['version', 'edge'],
|
||||||
|
// defaults
|
||||||
it('handles different new lines and comma correctly', async () => {
|
['install', 'false'],
|
||||||
setInput('foo', 'bar\r\nbaz,bat');
|
['use', 'true'],
|
||||||
const res = await context.getInputList('foo');
|
['cache-binary', 'true'],
|
||||||
expect(res).toEqual(['bar', 'baz', 'bat']);
|
['cleanup', 'true']
|
||||||
});
|
]),
|
||||||
|
'edge'
|
||||||
it('handles multiple lines and ignoring comma correctly', async () => {
|
],
|
||||||
setInput('driver-opts', 'image=moby/buildkit:master\nnetwork=host');
|
[
|
||||||
const res = await context.getInputList('driver-opts', true);
|
3,
|
||||||
expect(res).toEqual(['image=moby/buildkit:master', 'network=host']);
|
new Map<string, string>([
|
||||||
});
|
['version', 'v0.19.2'],
|
||||||
|
// defaults
|
||||||
it('handles different new lines and ignoring comma correctly', async () => {
|
['install', 'false'],
|
||||||
setInput('driver-opts', 'image=moby/buildkit:master\r\nnetwork=host');
|
['use', 'true'],
|
||||||
const res = await context.getInputList('driver-opts', true);
|
['cache-binary', 'true'],
|
||||||
expect(res).toEqual(['image=moby/buildkit:master', 'network=host']);
|
['cleanup', 'true']
|
||||||
});
|
]),
|
||||||
});
|
'v0.19.2'
|
||||||
|
],
|
||||||
describe('asyncForEach', () => {
|
[
|
||||||
it('executes async tasks sequentially', async () => {
|
4,
|
||||||
const testValues = [1, 2, 3, 4, 5];
|
new Map<string, string>([
|
||||||
const results: number[] = [];
|
['version', 'latest'],
|
||||||
|
['driver', 'cloud'],
|
||||||
await context.asyncForEach(testValues, async value => {
|
// defaults
|
||||||
results.push(value);
|
['install', 'false'],
|
||||||
});
|
['use', 'true'],
|
||||||
|
['cache-binary', 'true'],
|
||||||
expect(results).toEqual(testValues);
|
['cleanup', 'true']
|
||||||
|
]),
|
||||||
|
'cloud:latest'
|
||||||
|
],
|
||||||
|
[
|
||||||
|
5,
|
||||||
|
new Map<string, string>([
|
||||||
|
['version', 'edge'],
|
||||||
|
['driver', 'cloud'],
|
||||||
|
// defaults
|
||||||
|
['install', 'false'],
|
||||||
|
['use', 'true'],
|
||||||
|
['cache-binary', 'true'],
|
||||||
|
['cleanup', 'true']
|
||||||
|
]),
|
||||||
|
'cloud:edge'
|
||||||
|
],
|
||||||
|
[
|
||||||
|
6,
|
||||||
|
new Map<string, string>([
|
||||||
|
['driver', 'cloud'],
|
||||||
|
// defaults
|
||||||
|
['install', 'false'],
|
||||||
|
['use', 'true'],
|
||||||
|
['cache-binary', 'true'],
|
||||||
|
['cleanup', 'true'],
|
||||||
|
]),
|
||||||
|
'cloud:latest'
|
||||||
|
],
|
||||||
|
[
|
||||||
|
7,
|
||||||
|
new Map<string, string>([
|
||||||
|
['version', 'cloud:v0.11.2-desktop.2'],
|
||||||
|
['driver', 'cloud'],
|
||||||
|
// defaults
|
||||||
|
['install', 'false'],
|
||||||
|
['use', 'true'],
|
||||||
|
['cache-binary', 'true'],
|
||||||
|
['cleanup', 'true'],
|
||||||
|
]),
|
||||||
|
'cloud:v0.11.2-desktop.2'
|
||||||
|
],
|
||||||
|
[
|
||||||
|
8,
|
||||||
|
new Map<string, string>([
|
||||||
|
['version', 'cloud:v0.11.2-desktop.2'],
|
||||||
|
// defaults
|
||||||
|
['install', 'false'],
|
||||||
|
['use', 'true'],
|
||||||
|
['cache-binary', 'true'],
|
||||||
|
['cleanup', 'true'],
|
||||||
|
]),
|
||||||
|
'cloud:v0.11.2-desktop.2'
|
||||||
|
],
|
||||||
|
])(
|
||||||
|
'[%d] given %p as inputs, returns version %p',
|
||||||
|
async (num: number, inputs: Map<string, string>, expected: string) => {
|
||||||
|
inputs.forEach((value: string, name: string) => {
|
||||||
|
setInput(name, value);
|
||||||
});
|
});
|
||||||
|
const inp = await context.getInputs();
|
||||||
|
expect(context.getVersion(inp)).toEqual(expected);
|
||||||
|
}
|
||||||
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
// See: https://github.com/actions/toolkit/blob/master/packages/core/src/core.ts#L67
|
// See: https://github.com/actions/toolkit/blob/master/packages/core/src/core.ts#L67
|
||||||
|
@ -1,16 +0,0 @@
|
|||||||
import {describe, expect, it, jest} from '@jest/globals';
|
|
||||||
import * as docker from '../src/docker';
|
|
||||||
import * as exec from '@actions/exec';
|
|
||||||
|
|
||||||
describe('isAvailable', () => {
|
|
||||||
it('cli', () => {
|
|
||||||
const execSpy = jest.spyOn(exec, 'getExecOutput');
|
|
||||||
docker.isAvailable();
|
|
||||||
|
|
||||||
// eslint-disable-next-line jest/no-standalone-expect
|
|
||||||
expect(execSpy).toHaveBeenCalledWith(`docker`, undefined, {
|
|
||||||
silent: true,
|
|
||||||
ignoreReturnCode: true
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
@ -1,3 +1 @@
|
|||||||
debug = true
|
debug = true
|
||||||
[registry."docker.io"]
|
|
||||||
mirrors = ["mirror.gcr.io"]
|
|
||||||
|
@ -1,10 +0,0 @@
|
|||||||
Name: builder-5cb467f7-0940-47e1-b94b-d51f54054d62
|
|
||||||
Driver: docker-container
|
|
||||||
|
|
||||||
Nodes:
|
|
||||||
Name: builder-5cb467f7-0940-47e1-b94b-d51f54054d620
|
|
||||||
Endpoint: unix:///var/run/docker.sock
|
|
||||||
Status: running
|
|
||||||
Flags: --allow-insecure-entitlement security.insecure --allow-insecure-entitlement network.host
|
|
||||||
Buildkit: v0.10.4
|
|
||||||
Platforms: linux/amd64, linux/amd64/v2, linux/amd64/v3, linux/amd64/v4, linux/arm64, linux/riscv64, linux/386, linux/arm/v7, linux/arm/v6
|
|
@ -1,11 +0,0 @@
|
|||||||
Name: builder-5f449644-ff29-48af-8344-abb0292d0673
|
|
||||||
Driver: docker-container
|
|
||||||
|
|
||||||
Nodes:
|
|
||||||
Name: builder-5f449644-ff29-48af-8344-abb0292d06730
|
|
||||||
Endpoint: unix:///var/run/docker.sock
|
|
||||||
Driver Options: image="moby/buildkit:latest"
|
|
||||||
Status: running
|
|
||||||
Flags: --allow-insecure-entitlement security.insecure --allow-insecure-entitlement network.host
|
|
||||||
Buildkit: v0.10.4
|
|
||||||
Platforms: linux/amd64, linux/amd64/v2, linux/amd64/v3, linux/amd64/v4, linux/386
|
|
@ -1,11 +0,0 @@
|
|||||||
Name: builder-9929e463-7954-4dc3-89cd-514cca29ff80
|
|
||||||
Driver: docker-container
|
|
||||||
|
|
||||||
Nodes:
|
|
||||||
Name: builder-9929e463-7954-4dc3-89cd-514cca29ff800
|
|
||||||
Endpoint: unix:///var/run/docker.sock
|
|
||||||
Driver Options: image="moby/buildkit:master" network="host"
|
|
||||||
Status: running
|
|
||||||
Flags: --allow-insecure-entitlement security.insecure --allow-insecure-entitlement network.host
|
|
||||||
Buildkit: 3fab389
|
|
||||||
Platforms: linux/amd64, linux/amd64/v2, linux/amd64/v3, linux/amd64/v4, linux/386
|
|
@ -1,9 +0,0 @@
|
|||||||
Name: default
|
|
||||||
Driver: docker
|
|
||||||
|
|
||||||
Nodes:
|
|
||||||
Name: default
|
|
||||||
Endpoint: default
|
|
||||||
Status: running
|
|
||||||
Buildkit: 20.10.17
|
|
||||||
Platforms: linux/amd64, linux/arm64, linux/riscv64, linux/ppc64le, linux/s390x, linux/386, linux/arm/v7, linux/arm/v6
|
|
@ -1,9 +0,0 @@
|
|||||||
Name: remote-builder
|
|
||||||
Driver: remote
|
|
||||||
|
|
||||||
Nodes:
|
|
||||||
Name: aws_graviton2
|
|
||||||
Endpoint: tcp://1.23.45.67:1234
|
|
||||||
Driver Options: cert="/home/user/.certs/aws_graviton2/cert.pem" key="/home/user/.certs/aws_graviton2/key.pem" cacert="/home/user/.certs/aws_graviton2/ca.pem"
|
|
||||||
Status: running
|
|
||||||
Platforms: darwin/arm64*, linux/arm64*, linux/arm/v5*, linux/arm/v6*, linux/arm/v7*, windows/arm64*, linux/amd64, linux/amd64/v2, linux/riscv64, linux/ppc64le, linux/s390x, linux/mips64le, linux/mips64
|
|
@ -1,9 +0,0 @@
|
|||||||
Name: builder-17cfff01-48d9-4c3d-9332-9992e308a510
|
|
||||||
Driver: docker-container
|
|
||||||
|
|
||||||
Nodes:
|
|
||||||
Name: builder-17cfff01-48d9-4c3d-9332-9992e308a5100
|
|
||||||
Endpoint: unix:///var/run/docker.sock
|
|
||||||
Status: running
|
|
||||||
Flags: --allow-insecure-entitlement security.insecure --allow-insecure-entitlement network.host
|
|
||||||
Platforms: linux/amd64, linux/amd64/v2, linux/amd64/v3, linux/386
|
|
@ -1,9 +0,0 @@
|
|||||||
import {describe, expect, it} from '@jest/globals';
|
|
||||||
import * as git from '../src/git';
|
|
||||||
|
|
||||||
describe('git', () => {
|
|
||||||
it('returns git remote ref', async () => {
|
|
||||||
const ref: string = await git.getRemoteSha('https://github.com/docker/buildx.git', 'refs/pull/648/head');
|
|
||||||
expect(ref).toEqual('f11797113e5a9b86bd976329c5dbb8a8bfdfadfa');
|
|
||||||
});
|
|
||||||
});
|
|
@ -1,12 +0,0 @@
|
|||||||
import {describe, expect, test} from '@jest/globals';
|
|
||||||
import * as util from '../src/util';
|
|
||||||
|
|
||||||
describe('isValidUrl', () => {
|
|
||||||
test.each([
|
|
||||||
['https://github.com/docker/buildx.git', true],
|
|
||||||
['https://github.com/docker/buildx.git#refs/pull/648/head', true],
|
|
||||||
['v0.4.1', false]
|
|
||||||
])('given %p', async (url, expected) => {
|
|
||||||
expect(util.isValidUrl(url)).toEqual(expected);
|
|
||||||
});
|
|
||||||
});
|
|
34
action.yml
34
action.yml
@ -18,8 +18,13 @@ inputs:
|
|||||||
description: 'List of additional driver-specific options. (eg. image=moby/buildkit:master)'
|
description: 'List of additional driver-specific options. (eg. image=moby/buildkit:master)'
|
||||||
required: false
|
required: false
|
||||||
buildkitd-flags:
|
buildkitd-flags:
|
||||||
description: 'Flags for buildkitd daemon'
|
description: 'BuildKit daemon flags'
|
||||||
default: '--allow-insecure-entitlement security.insecure --allow-insecure-entitlement network.host'
|
required: false
|
||||||
|
buildkitd-config:
|
||||||
|
description: 'BuildKit daemon config file'
|
||||||
|
required: false
|
||||||
|
buildkitd-config-inline:
|
||||||
|
description: 'Inline BuildKit daemon config'
|
||||||
required: false
|
required: false
|
||||||
install:
|
install:
|
||||||
description: 'Sets up docker build command as an alias to docker buildx build'
|
description: 'Sets up docker build command as an alias to docker buildx build'
|
||||||
@ -35,15 +40,26 @@ inputs:
|
|||||||
platforms:
|
platforms:
|
||||||
description: 'Fixed platforms for current node. If not empty, values take priority over the detected ones'
|
description: 'Fixed platforms for current node. If not empty, values take priority over the detected ones'
|
||||||
required: false
|
required: false
|
||||||
config:
|
|
||||||
description: 'BuildKit config file'
|
|
||||||
required: false
|
|
||||||
config-inline:
|
|
||||||
description: 'Inline BuildKit config'
|
|
||||||
required: false
|
|
||||||
append:
|
append:
|
||||||
description: 'Append additional nodes to the builder'
|
description: 'Append additional nodes to the builder'
|
||||||
required: false
|
required: false
|
||||||
|
cache-binary:
|
||||||
|
description: 'Cache buildx binary to GitHub Actions cache backend'
|
||||||
|
default: 'true'
|
||||||
|
required: false
|
||||||
|
cleanup:
|
||||||
|
description: 'Cleanup temp files and remove builder at the end of a job'
|
||||||
|
default: 'true'
|
||||||
|
required: false
|
||||||
|
# TODO: remove deprecated config and config-inline inputs
|
||||||
|
config:
|
||||||
|
description: 'BuildKit daemon config file'
|
||||||
|
deprecationMessage: 'Use buildkitd-config instead'
|
||||||
|
required: false
|
||||||
|
config-inline:
|
||||||
|
description: 'Inline BuildKit daemon config'
|
||||||
|
deprecationMessage: 'Use buildkitd-config-inline instead'
|
||||||
|
required: false
|
||||||
|
|
||||||
outputs:
|
outputs:
|
||||||
name:
|
name:
|
||||||
@ -62,6 +78,6 @@ outputs:
|
|||||||
description: 'Builder node flags (deprecated, use nodes output instead)'
|
description: 'Builder node flags (deprecated, use nodes output instead)'
|
||||||
|
|
||||||
runs:
|
runs:
|
||||||
using: 'node16'
|
using: 'node20'
|
||||||
main: 'dist/index.js'
|
main: 'dist/index.js'
|
||||||
post: 'dist/index.js'
|
post: 'dist/index.js'
|
||||||
|
@ -1,15 +1,20 @@
|
|||||||
# syntax=docker/dockerfile:1
|
# syntax=docker/dockerfile:1
|
||||||
|
|
||||||
ARG NODE_VERSION=16
|
ARG NODE_VERSION=20
|
||||||
ARG DOCKER_VERSION=20.10.13
|
|
||||||
ARG BUILDX_VERSION=0.8.1
|
|
||||||
|
|
||||||
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
|
||||||
|
|
||||||
@ -22,7 +27,7 @@ set -e
|
|||||||
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-update"'
|
echo >&2 'ERROR: Vendor result differs. Please vendor your package with "docker buildx bake vendor"'
|
||||||
git status --porcelain -- yarn.lock
|
git status --porcelain -- yarn.lock
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
@ -30,6 +35,7 @@ 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/
|
||||||
|
|
||||||
@ -50,29 +56,25 @@ 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/*' | cpio -pdm /out
|
&& mkdir /out && find . -name '*.ts' -not -path './node_modules/*' -not -path './.yarn/*' | 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 docker:${DOCKER_VERSION} as docker
|
|
||||||
FROM docker/buildx-bin:${BUILDX_VERSION} as buildx
|
|
||||||
|
|
||||||
FROM deps AS test
|
FROM deps AS test
|
||||||
ENV RUNNER_TEMP=/tmp/github_runner
|
|
||||||
ENV RUNNER_TOOL_CACHE=/tmp/github_tool_cache
|
|
||||||
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 \
|
||||||
--mount=type=bind,from=docker,source=/usr/local/bin/docker,target=/usr/bin/docker \
|
yarn run test --coverage --coverageDirectory=/tmp/coverage
|
||||||
--mount=type=bind,from=buildx,source=/buildx,target=/usr/libexec/docker/cli-plugins/docker-buildx \
|
|
||||||
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 /
|
||||||
|
97
dist/index.js
generated
vendored
97
dist/index.js
generated
vendored
File diff suppressed because one or more lines are too long
2
dist/index.js.map
generated
vendored
2
dist/index.js.map
generated
vendored
File diff suppressed because one or more lines are too long
3281
dist/licenses.txt
generated
vendored
3281
dist/licenses.txt
generated
vendored
File diff suppressed because it is too large
Load Diff
2
dist/sourcemap-register.js
generated
vendored
2
dist/sourcemap-register.js
generated
vendored
File diff suppressed because one or more lines are too long
@ -1,9 +1,15 @@
|
|||||||
|
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-update", "format", "build"]
|
targets = ["vendor", "format", "build"]
|
||||||
}
|
}
|
||||||
|
|
||||||
group "validate" {
|
group "validate" {
|
||||||
@ -11,42 +17,49 @@ 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-update" {
|
target "vendor" {
|
||||||
|
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"]
|
||||||
|
@ -1,3 +0,0 @@
|
|||||||
# Append additional nodes to the builder
|
|
||||||
|
|
||||||
This page has moved to [Docker Docs website](https://docs.docker.com/build/ci/github-actions/configure-builder/#append-additional-nodes-to-the-builder)
|
|
@ -1,3 +0,0 @@
|
|||||||
# Authentication support
|
|
||||||
|
|
||||||
This page has moved to [Docker Docs website](https://docs.docker.com/build/ci/github-actions/configure-builder/#authentication-for-remote-builders)
|
|
@ -1,3 +0,0 @@
|
|||||||
# BuildKit daemon configuration
|
|
||||||
|
|
||||||
This page has moved to [Docker Docs website](https://docs.docker.com/build/ci/github-actions/configure-builder/#daemon-configuration)
|
|
@ -1,3 +0,0 @@
|
|||||||
# Standalone mode
|
|
||||||
|
|
||||||
This page has moved to [Docker Docs website](https://docs.docker.com/build/ci/github-actions/configure-builder/#standalone-mode)
|
|
@ -1,7 +1,21 @@
|
|||||||
|
import fs from 'fs';
|
||||||
|
import os from 'os';
|
||||||
|
import path from 'path';
|
||||||
|
|
||||||
|
const tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), 'docker-setup-buildx-action-')).split(path.sep).join(path.posix.sep);
|
||||||
|
|
||||||
|
process.env = Object.assign({}, process.env, {
|
||||||
|
TEMP: tmpDir,
|
||||||
|
GITHUB_REPOSITORY: 'docker/setup-buildx-action',
|
||||||
|
RUNNER_TEMP: path.join(tmpDir, 'runner-temp').split(path.sep).join(path.posix.sep),
|
||||||
|
RUNNER_TOOL_CACHE: path.join(tmpDir, 'runner-tool-cache').split(path.sep).join(path.posix.sep)
|
||||||
|
}) as {
|
||||||
|
[key: string]: string;
|
||||||
|
};
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
clearMocks: true,
|
clearMocks: true,
|
||||||
moduleFileExtensions: ['js', 'ts'],
|
moduleFileExtensions: ['js', 'ts'],
|
||||||
setupFiles: ['dotenv/config'],
|
|
||||||
testMatch: ['**/*.test.ts'],
|
testMatch: ['**/*.test.ts'],
|
||||||
transform: {
|
transform: {
|
||||||
'^.+\\.ts$': 'ts-jest'
|
'^.+\\.ts$': 'ts-jest'
|
||||||
@ -9,5 +23,7 @@ module.exports = {
|
|||||||
moduleNameMapper: {
|
moduleNameMapper: {
|
||||||
'^csv-parse/sync': '<rootDir>/node_modules/csv-parse/dist/cjs/sync.cjs'
|
'^csv-parse/sync': '<rootDir>/node_modules/csv-parse/dist/cjs/sync.cjs'
|
||||||
},
|
},
|
||||||
|
collectCoverageFrom: ['src/**/{!(main.ts),}.ts'],
|
||||||
|
coveragePathIgnorePatterns: ['lib/', 'node_modules/', '__tests__/'],
|
||||||
verbose: true
|
verbose: true
|
||||||
};
|
};
|
||||||
|
67
package.json
67
package.json
@ -1,13 +1,16 @@
|
|||||||
{
|
{
|
||||||
"name": "docker-setup-buildx",
|
"name": "docker-setup-buildx",
|
||||||
"description": "Set up Docker Buildx",
|
"description": "Set up Docker Buildx",
|
||||||
"main": "lib/main.js",
|
"main": "src/main.ts",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "ncc build src/main.ts --source-map --minify --license licenses.txt",
|
"build": "ncc build --source-map --minify --license licenses.txt",
|
||||||
"lint": "eslint src/**/*.ts __tests__/**/*.ts",
|
"lint": "yarn run prettier && yarn run eslint",
|
||||||
"format": "eslint --fix src/**/*.ts __tests__/**/*.ts",
|
"format": "yarn run prettier:fix && yarn run eslint:fix",
|
||||||
"test": "jest --coverage",
|
"eslint": "eslint --max-warnings=0 .",
|
||||||
"all": "yarn run build && yarn run format && yarn test"
|
"eslint:fix": "eslint --fix .",
|
||||||
|
"prettier": "prettier --check \"./**/*.ts\"",
|
||||||
|
"prettier:fix": "prettier --write \"./**/*.ts\"",
|
||||||
|
"test": "jest"
|
||||||
},
|
},
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
@ -18,41 +21,29 @@
|
|||||||
"docker",
|
"docker",
|
||||||
"buildx"
|
"buildx"
|
||||||
],
|
],
|
||||||
"author": "Docker",
|
"author": "Docker Inc.",
|
||||||
"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.10.0",
|
"@actions/core": "^1.11.1",
|
||||||
"@actions/exec": "^1.1.1",
|
"@docker/actions-toolkit": "^0.56.0",
|
||||||
"@actions/tool-cache": "^2.0.1",
|
"js-yaml": "^4.1.0"
|
||||||
"@docker/actions-toolkit": "^0.1.0-beta.4",
|
|
||||||
"csv-parse": "^5.3.4",
|
|
||||||
"js-yaml": "^4.1.0",
|
|
||||||
"semver": "^7.3.7",
|
|
||||||
"tmp": "^0.2.1",
|
|
||||||
"uuid": "^9.0.0"
|
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/node": "^16.11.26",
|
"@types/js-yaml": "^4.0.9",
|
||||||
"@types/semver": "^7.3.9",
|
"@types/node": "^20.12.12",
|
||||||
"@types/tmp": "^0.2.3",
|
"@types/uuid": "^10.0.0",
|
||||||
"@typescript-eslint/eslint-plugin": "^5.14.0",
|
"@typescript-eslint/eslint-plugin": "^7.9.0",
|
||||||
"@typescript-eslint/parser": "^5.14.0",
|
"@typescript-eslint/parser": "^7.9.0",
|
||||||
"@vercel/ncc": "^0.33.3",
|
"@vercel/ncc": "^0.38.1",
|
||||||
"dotenv": "^16.0.0",
|
"eslint": "^8.57.0",
|
||||||
"eslint": "^8.11.0",
|
"eslint-config-prettier": "^9.1.0",
|
||||||
"eslint-config-prettier": "^8.5.0",
|
"eslint-plugin-jest": "^28.5.0",
|
||||||
"eslint-plugin-jest": "^26.1.1",
|
"eslint-plugin-prettier": "^5.1.3",
|
||||||
"eslint-plugin-prettier": "^4.0.0",
|
"jest": "^29.7.0",
|
||||||
"jest": "^27.2.5",
|
"prettier": "^3.2.5",
|
||||||
"prettier": "^2.3.1",
|
"ts-jest": "^29.1.2",
|
||||||
"ts-jest": "^27.1.2",
|
"ts-node": "^10.9.2",
|
||||||
"ts-node": "^10.7.0",
|
"typescript": "^5.4.5"
|
||||||
"typescript": "^4.4.4"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
51
src/auth.ts
51
src/auth.ts
@ -1,51 +0,0 @@
|
|||||||
import * as fs from 'fs';
|
|
||||||
|
|
||||||
export const envPrefix = 'BUILDER_NODE';
|
|
||||||
|
|
||||||
export function setCredentials(credsdir: string, index: number, driver: string, endpoint: string): Array<string> {
|
|
||||||
let url: URL;
|
|
||||||
try {
|
|
||||||
url = new URL(endpoint);
|
|
||||||
} catch (e) {
|
|
||||||
return [];
|
|
||||||
}
|
|
||||||
switch (url.protocol) {
|
|
||||||
case 'tcp:': {
|
|
||||||
return setBuildKitClientCerts(credsdir, index, driver, url);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return [];
|
|
||||||
}
|
|
||||||
|
|
||||||
function setBuildKitClientCerts(credsdir: string, index: number, driver: string, endpoint: URL): Array<string> {
|
|
||||||
const driverOpts: Array<string> = [];
|
|
||||||
const buildkitCacert = process.env[`${envPrefix}_${index}_AUTH_TLS_CACERT`] || '';
|
|
||||||
const buildkitCert = process.env[`${envPrefix}_${index}_AUTH_TLS_CERT`] || '';
|
|
||||||
const buildkitKey = process.env[`${envPrefix}_${index}_AUTH_TLS_KEY`] || '';
|
|
||||||
if (buildkitCacert.length == 0 && buildkitCert.length == 0 && buildkitKey.length == 0) {
|
|
||||||
return driverOpts;
|
|
||||||
}
|
|
||||||
let host = endpoint.hostname;
|
|
||||||
if (endpoint.port.length > 0) {
|
|
||||||
host += `-${endpoint.port}`;
|
|
||||||
}
|
|
||||||
if (buildkitCacert.length > 0) {
|
|
||||||
const cacertpath = `${credsdir}/cacert_${host}.pem`;
|
|
||||||
fs.writeFileSync(cacertpath, buildkitCacert);
|
|
||||||
driverOpts.push(`cacert=${cacertpath}`);
|
|
||||||
}
|
|
||||||
if (buildkitCert.length > 0) {
|
|
||||||
const certpath = `${credsdir}/cert_${host}.pem`;
|
|
||||||
fs.writeFileSync(certpath, buildkitCert);
|
|
||||||
driverOpts.push(`cert=${certpath}`);
|
|
||||||
}
|
|
||||||
if (buildkitKey.length > 0) {
|
|
||||||
const keypath = `${credsdir}/key_${host}.pem`;
|
|
||||||
fs.writeFileSync(keypath, buildkitKey);
|
|
||||||
driverOpts.push(`key=${keypath}`);
|
|
||||||
}
|
|
||||||
if (driver != 'remote') {
|
|
||||||
return [];
|
|
||||||
}
|
|
||||||
return driverOpts;
|
|
||||||
}
|
|
376
src/buildx.ts
376
src/buildx.ts
@ -1,376 +0,0 @@
|
|||||||
import * as fs from 'fs';
|
|
||||||
import * as path from 'path';
|
|
||||||
import * as semver from 'semver';
|
|
||||||
import * as util from 'util';
|
|
||||||
import * as context from './context';
|
|
||||||
import * as git from './git';
|
|
||||||
import * as core from '@actions/core';
|
|
||||||
import * as exec from '@actions/exec';
|
|
||||||
import * as tc from '@actions/tool-cache';
|
|
||||||
import {Install as BuildxInstall} from '@docker/actions-toolkit/lib/buildx/install';
|
|
||||||
import {GitHubRelease} from '@docker/actions-toolkit/lib/types/github';
|
|
||||||
|
|
||||||
export type Builder = {
|
|
||||||
name?: string;
|
|
||||||
driver?: string;
|
|
||||||
nodes: Node[];
|
|
||||||
};
|
|
||||||
|
|
||||||
export type Node = {
|
|
||||||
name?: string;
|
|
||||||
endpoint?: string;
|
|
||||||
'driver-opts'?: Array<string>;
|
|
||||||
status?: string;
|
|
||||||
'buildkitd-flags'?: string;
|
|
||||||
buildkit?: string;
|
|
||||||
platforms?: string;
|
|
||||||
};
|
|
||||||
|
|
||||||
export async function getConfigInline(s: string): Promise<string> {
|
|
||||||
return getConfig(s, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
export async function getConfigFile(s: string): Promise<string> {
|
|
||||||
return getConfig(s, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
export async function getConfig(s: string, file: boolean): Promise<string> {
|
|
||||||
if (file) {
|
|
||||||
if (!fs.existsSync(s)) {
|
|
||||||
throw new Error(`config file ${s} not found`);
|
|
||||||
}
|
|
||||||
s = fs.readFileSync(s, {encoding: 'utf-8'});
|
|
||||||
}
|
|
||||||
const configFile = context.tmpNameSync({
|
|
||||||
tmpdir: context.tmpDir()
|
|
||||||
});
|
|
||||||
fs.writeFileSync(configFile, s);
|
|
||||||
return configFile;
|
|
||||||
}
|
|
||||||
|
|
||||||
export async function isAvailable(standalone?: boolean): Promise<boolean> {
|
|
||||||
const cmd = getCommand([], standalone);
|
|
||||||
return await exec
|
|
||||||
.getExecOutput(cmd.commandLine, cmd.args, {
|
|
||||||
ignoreReturnCode: true,
|
|
||||||
silent: true
|
|
||||||
})
|
|
||||||
.then(res => {
|
|
||||||
if (res.stderr.length > 0 && res.exitCode != 0) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return res.exitCode == 0;
|
|
||||||
})
|
|
||||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
||||||
.catch(error => {
|
|
||||||
return false;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
export async function getVersion(standalone?: boolean): Promise<string> {
|
|
||||||
const cmd = getCommand(['version'], standalone);
|
|
||||||
return await exec
|
|
||||||
.getExecOutput(cmd.commandLine, cmd.args, {
|
|
||||||
ignoreReturnCode: true,
|
|
||||||
silent: true
|
|
||||||
})
|
|
||||||
.then(res => {
|
|
||||||
if (res.stderr.length > 0 && res.exitCode != 0) {
|
|
||||||
throw new Error(res.stderr.trim());
|
|
||||||
}
|
|
||||||
return parseVersion(res.stdout.trim());
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
export function parseVersion(stdout: string): string {
|
|
||||||
const matches = /\sv?([0-9a-f]{7}|[0-9.]+)/.exec(stdout);
|
|
||||||
if (!matches) {
|
|
||||||
throw new Error(`Cannot parse buildx version`);
|
|
||||||
}
|
|
||||||
return matches[1];
|
|
||||||
}
|
|
||||||
|
|
||||||
export function satisfies(version: string, range: string): boolean {
|
|
||||||
return semver.satisfies(version, range) || /^[0-9a-f]{7}$/.exec(version) !== null;
|
|
||||||
}
|
|
||||||
|
|
||||||
export async function inspect(name: string, standalone?: boolean): Promise<Builder> {
|
|
||||||
const cmd = getCommand(['inspect', name], standalone);
|
|
||||||
return await exec
|
|
||||||
.getExecOutput(cmd.commandLine, cmd.args, {
|
|
||||||
ignoreReturnCode: true,
|
|
||||||
silent: true
|
|
||||||
})
|
|
||||||
.then(res => {
|
|
||||||
if (res.stderr.length > 0 && res.exitCode != 0) {
|
|
||||||
throw new Error(res.stderr.trim());
|
|
||||||
}
|
|
||||||
return parseInspect(res.stdout);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
export async function parseInspect(data: string): Promise<Builder> {
|
|
||||||
const builder: Builder = {
|
|
||||||
nodes: []
|
|
||||||
};
|
|
||||||
let node: Node = {};
|
|
||||||
for (const line of data.trim().split(`\n`)) {
|
|
||||||
const [key, ...rest] = line.split(':');
|
|
||||||
const value = rest.map(v => v.trim()).join(':');
|
|
||||||
if (key.length == 0 || value.length == 0) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
switch (key.toLowerCase()) {
|
|
||||||
case 'name': {
|
|
||||||
if (builder.name == undefined) {
|
|
||||||
builder.name = value;
|
|
||||||
} else {
|
|
||||||
if (Object.keys(node).length > 0) {
|
|
||||||
builder.nodes.push(node);
|
|
||||||
node = {};
|
|
||||||
}
|
|
||||||
node.name = value;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case 'driver': {
|
|
||||||
builder.driver = value;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case 'endpoint': {
|
|
||||||
node.endpoint = value;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case 'driver options': {
|
|
||||||
node['driver-opts'] = (value.match(/(\w+)="([^"]*)"/g) || []).map(v => v.replace(/^(.*)="(.*)"$/g, '$1=$2'));
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case 'status': {
|
|
||||||
node.status = value;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case 'flags': {
|
|
||||||
node['buildkitd-flags'] = value;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case 'buildkit': {
|
|
||||||
node.buildkit = value;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case 'platforms': {
|
|
||||||
let platforms: Array<string> = [];
|
|
||||||
// if a preferred platform is being set then use only these
|
|
||||||
// https://docs.docker.com/engine/reference/commandline/buildx_inspect/#get-information-about-a-builder-instance
|
|
||||||
if (value.includes('*')) {
|
|
||||||
for (const platform of value.split(', ')) {
|
|
||||||
if (platform.includes('*')) {
|
|
||||||
platforms.push(platform.replace('*', ''));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
// otherwise set all platforms available
|
|
||||||
platforms = value.split(', ');
|
|
||||||
}
|
|
||||||
node.platforms = platforms.join(',');
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (Object.keys(node).length > 0) {
|
|
||||||
builder.nodes.push(node);
|
|
||||||
}
|
|
||||||
return builder;
|
|
||||||
}
|
|
||||||
|
|
||||||
export async function build(inputBuildRef: string, dest: string, standalone: boolean): Promise<string> {
|
|
||||||
// eslint-disable-next-line prefer-const
|
|
||||||
let [repo, ref] = inputBuildRef.split('#');
|
|
||||||
if (ref.length == 0) {
|
|
||||||
ref = 'master';
|
|
||||||
}
|
|
||||||
|
|
||||||
let vspec: string;
|
|
||||||
if (ref.match(/^[0-9a-fA-F]{40}$/)) {
|
|
||||||
vspec = ref;
|
|
||||||
} else {
|
|
||||||
vspec = await git.getRemoteSha(repo, ref);
|
|
||||||
}
|
|
||||||
core.debug(`Tool version spec ${vspec}`);
|
|
||||||
|
|
||||||
let toolPath: string;
|
|
||||||
toolPath = tc.find('buildx', vspec);
|
|
||||||
if (!toolPath) {
|
|
||||||
const outFolder = path.join(context.tmpDir(), 'out').split(path.sep).join(path.posix.sep);
|
|
||||||
let buildWithStandalone = false;
|
|
||||||
const standaloneFound = await isAvailable(true);
|
|
||||||
const pluginFound = await isAvailable(false);
|
|
||||||
if (standalone && standaloneFound) {
|
|
||||||
core.debug(`Buildx standalone found, build with it`);
|
|
||||||
buildWithStandalone = true;
|
|
||||||
} else if (!standalone && pluginFound) {
|
|
||||||
core.debug(`Buildx plugin found, build with it`);
|
|
||||||
buildWithStandalone = false;
|
|
||||||
} else if (standaloneFound) {
|
|
||||||
core.debug(`Buildx plugin not found, but standalone found so trying to build with it`);
|
|
||||||
buildWithStandalone = true;
|
|
||||||
} else if (pluginFound) {
|
|
||||||
core.debug(`Buildx standalone not found, but plugin found so trying to build with it`);
|
|
||||||
buildWithStandalone = false;
|
|
||||||
} else {
|
|
||||||
throw new Error(`Neither buildx standalone or plugin have been found to build from ref`);
|
|
||||||
}
|
|
||||||
const buildCmd = getCommand(['build', '--target', 'binaries', '--build-arg', 'BUILDKIT_CONTEXT_KEEP_GIT_DIR=1', '--output', `type=local,dest=${outFolder}`, inputBuildRef], buildWithStandalone);
|
|
||||||
toolPath = await exec
|
|
||||||
.getExecOutput(buildCmd.commandLine, buildCmd.args, {
|
|
||||||
ignoreReturnCode: true
|
|
||||||
})
|
|
||||||
.then(res => {
|
|
||||||
if (res.stderr.length > 0 && res.exitCode != 0) {
|
|
||||||
core.warning(res.stderr.trim());
|
|
||||||
}
|
|
||||||
return tc.cacheFile(`${outFolder}/buildx`, context.osPlat == 'win32' ? 'docker-buildx.exe' : 'docker-buildx', 'buildx', vspec);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
if (standalone) {
|
|
||||||
return setStandalone(toolPath, dest);
|
|
||||||
}
|
|
||||||
return setPlugin(toolPath, dest);
|
|
||||||
}
|
|
||||||
|
|
||||||
export async function install(inputVersion: string, dest: string, standalone: boolean): Promise<string> {
|
|
||||||
const release: GitHubRelease = await BuildxInstall.getRelease(inputVersion);
|
|
||||||
core.debug(`Release ${release.tag_name} found`);
|
|
||||||
const version = release.tag_name.replace(/^v+|v+$/g, '');
|
|
||||||
|
|
||||||
let toolPath: string;
|
|
||||||
toolPath = tc.find('buildx', version);
|
|
||||||
if (!toolPath) {
|
|
||||||
const c = semver.clean(version) || '';
|
|
||||||
if (!semver.valid(c)) {
|
|
||||||
throw new Error(`Invalid Buildx version "${version}".`);
|
|
||||||
}
|
|
||||||
toolPath = await download(version);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (standalone) {
|
|
||||||
return setStandalone(toolPath, dest);
|
|
||||||
}
|
|
||||||
return setPlugin(toolPath, dest);
|
|
||||||
}
|
|
||||||
|
|
||||||
async function setStandalone(toolPath: string, dest: string): Promise<string> {
|
|
||||||
core.info('Standalone mode');
|
|
||||||
const toolBinPath = path.join(toolPath, context.osPlat == 'win32' ? 'docker-buildx.exe' : 'docker-buildx');
|
|
||||||
|
|
||||||
const binDir = path.join(dest, 'bin');
|
|
||||||
core.debug(`Bin dir is ${binDir}`);
|
|
||||||
if (!fs.existsSync(binDir)) {
|
|
||||||
fs.mkdirSync(binDir, {recursive: true});
|
|
||||||
}
|
|
||||||
|
|
||||||
const filename: string = context.osPlat == 'win32' ? 'buildx.exe' : 'buildx';
|
|
||||||
const buildxPath: string = path.join(binDir, filename);
|
|
||||||
core.debug(`Bin path is ${buildxPath}`);
|
|
||||||
fs.copyFileSync(toolBinPath, buildxPath);
|
|
||||||
|
|
||||||
core.info('Fixing perms');
|
|
||||||
fs.chmodSync(buildxPath, '0755');
|
|
||||||
|
|
||||||
core.addPath(binDir);
|
|
||||||
core.info('Added buildx to the path');
|
|
||||||
|
|
||||||
return buildxPath;
|
|
||||||
}
|
|
||||||
|
|
||||||
async function setPlugin(toolPath: string, dockerConfigHome: string): Promise<string> {
|
|
||||||
core.info('Docker plugin mode');
|
|
||||||
const toolBinPath = path.join(toolPath, context.osPlat == 'win32' ? 'docker-buildx.exe' : 'docker-buildx');
|
|
||||||
|
|
||||||
const pluginsDir: string = path.join(dockerConfigHome, 'cli-plugins');
|
|
||||||
core.debug(`Plugins dir is ${pluginsDir}`);
|
|
||||||
if (!fs.existsSync(pluginsDir)) {
|
|
||||||
fs.mkdirSync(pluginsDir, {recursive: true});
|
|
||||||
}
|
|
||||||
|
|
||||||
const filename: string = context.osPlat == 'win32' ? 'docker-buildx.exe' : 'docker-buildx';
|
|
||||||
const pluginPath: string = path.join(pluginsDir, filename);
|
|
||||||
core.debug(`Plugin path is ${pluginPath}`);
|
|
||||||
fs.copyFileSync(toolBinPath, pluginPath);
|
|
||||||
|
|
||||||
core.info('Fixing perms');
|
|
||||||
fs.chmodSync(pluginPath, '0755');
|
|
||||||
|
|
||||||
return pluginPath;
|
|
||||||
}
|
|
||||||
|
|
||||||
async function download(version: string): Promise<string> {
|
|
||||||
const targetFile: string = context.osPlat == 'win32' ? 'docker-buildx.exe' : 'docker-buildx';
|
|
||||||
const downloadUrl = util.format('https://github.com/docker/buildx/releases/download/v%s/%s', version, await filename(version));
|
|
||||||
core.info(`Downloading ${downloadUrl}`);
|
|
||||||
const downloadPath = await tc.downloadTool(downloadUrl);
|
|
||||||
core.debug(`Downloaded to ${downloadPath}`);
|
|
||||||
return await tc.cacheFile(downloadPath, targetFile, 'buildx', version);
|
|
||||||
}
|
|
||||||
|
|
||||||
async function filename(version: string): Promise<string> {
|
|
||||||
let arch: string;
|
|
||||||
switch (context.osArch) {
|
|
||||||
case 'x64': {
|
|
||||||
arch = 'amd64';
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case 'ppc64': {
|
|
||||||
arch = 'ppc64le';
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case 'arm': {
|
|
||||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
||||||
const arm_version = (process.config.variables as any).arm_version;
|
|
||||||
arch = arm_version ? 'arm-v' + arm_version : 'arm';
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
default: {
|
|
||||||
arch = context.osArch;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
const platform: string = context.osPlat == 'win32' ? 'windows' : context.osPlat;
|
|
||||||
const ext: string = context.osPlat == 'win32' ? '.exe' : '';
|
|
||||||
return util.format('buildx-v%s.%s-%s%s', version, platform, arch, ext);
|
|
||||||
}
|
|
||||||
|
|
||||||
export async function getBuildKitVersion(containerID: string): Promise<string> {
|
|
||||||
return exec
|
|
||||||
.getExecOutput(`docker`, ['inspect', '--format', '{{.Config.Image}}', containerID], {
|
|
||||||
ignoreReturnCode: true,
|
|
||||||
silent: true
|
|
||||||
})
|
|
||||||
.then(bkitimage => {
|
|
||||||
if (bkitimage.exitCode == 0 && bkitimage.stdout.length > 0) {
|
|
||||||
return exec
|
|
||||||
.getExecOutput(`docker`, ['run', '--rm', bkitimage.stdout.trim(), '--version'], {
|
|
||||||
ignoreReturnCode: true,
|
|
||||||
silent: true
|
|
||||||
})
|
|
||||||
.then(bkitversion => {
|
|
||||||
if (bkitversion.exitCode == 0 && bkitversion.stdout.length > 0) {
|
|
||||||
return `${bkitimage.stdout.trim()} => ${bkitversion.stdout.trim()}`;
|
|
||||||
} else if (bkitversion.stderr.length > 0) {
|
|
||||||
core.warning(bkitversion.stderr.trim());
|
|
||||||
}
|
|
||||||
return bkitversion.stdout.trim();
|
|
||||||
});
|
|
||||||
} else if (bkitimage.stderr.length > 0) {
|
|
||||||
core.warning(bkitimage.stderr.trim());
|
|
||||||
}
|
|
||||||
return bkitimage.stdout.trim();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
export function getCommand(args: Array<string>, standalone?: boolean) {
|
|
||||||
return {
|
|
||||||
commandLine: standalone ? 'buildx' : 'docker',
|
|
||||||
args: standalone ? args : ['buildx', ...args]
|
|
||||||
};
|
|
||||||
}
|
|
130
src/context.ts
130
src/context.ts
@ -1,27 +1,14 @@
|
|||||||
import fs from 'fs';
|
import * as crypto from 'crypto';
|
||||||
import * as os from 'os';
|
|
||||||
import path from 'path';
|
|
||||||
import * as tmp from 'tmp';
|
|
||||||
import * as uuid from 'uuid';
|
|
||||||
import {parse} from 'csv-parse/sync';
|
|
||||||
import * as buildx from './buildx';
|
|
||||||
import * as nodes from './nodes';
|
|
||||||
import * as core from '@actions/core';
|
import * as core from '@actions/core';
|
||||||
|
|
||||||
let _tmpDir: string;
|
import {Docker} from '@docker/actions-toolkit/lib/docker/docker';
|
||||||
export const osPlat: string = os.platform();
|
import {Util} from '@docker/actions-toolkit/lib/util';
|
||||||
export const osArch: string = os.arch();
|
import {Toolkit} from '@docker/actions-toolkit/lib/toolkit';
|
||||||
|
|
||||||
export function tmpDir(): string {
|
import {Node} from '@docker/actions-toolkit/lib/types/buildx/builder';
|
||||||
if (!_tmpDir) {
|
|
||||||
_tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), 'docker-setup-buildx-')).split(path.sep).join(path.posix.sep);
|
|
||||||
}
|
|
||||||
return _tmpDir;
|
|
||||||
}
|
|
||||||
|
|
||||||
export function tmpNameSync(options?: tmp.TmpNameOptions): string {
|
export const builderNodeEnvPrefix = 'BUILDER_NODE';
|
||||||
return tmp.tmpNameSync(options);
|
const defaultBuildkitdFlags = '--allow-insecure-entitlement security.insecure --allow-insecure-entitlement network.host';
|
||||||
}
|
|
||||||
|
|
||||||
export interface Inputs {
|
export interface Inputs {
|
||||||
version: string;
|
version: string;
|
||||||
@ -29,44 +16,50 @@ export interface Inputs {
|
|||||||
driver: string;
|
driver: string;
|
||||||
driverOpts: string[];
|
driverOpts: string[];
|
||||||
buildkitdFlags: string;
|
buildkitdFlags: string;
|
||||||
|
buildkitdConfig: string;
|
||||||
|
buildkitdConfigInline: string;
|
||||||
platforms: string[];
|
platforms: string[];
|
||||||
install: boolean;
|
install: boolean;
|
||||||
use: boolean;
|
use: boolean;
|
||||||
endpoint: string;
|
endpoint: string;
|
||||||
config: string;
|
|
||||||
configInline: string;
|
|
||||||
append: string;
|
append: string;
|
||||||
|
cacheBinary: boolean;
|
||||||
|
cleanup: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function getInputs(): Promise<Inputs> {
|
export async function getInputs(): Promise<Inputs> {
|
||||||
return {
|
return {
|
||||||
version: core.getInput('version'),
|
version: core.getInput('version'),
|
||||||
name: getBuilderName(core.getInput('driver') || 'docker-container'),
|
name: await getBuilderName(core.getInput('driver') || 'docker-container'),
|
||||||
driver: core.getInput('driver') || 'docker-container',
|
driver: core.getInput('driver') || 'docker-container',
|
||||||
driverOpts: await getInputList('driver-opts', true),
|
driverOpts: Util.getInputList('driver-opts', {ignoreComma: true, quote: false}),
|
||||||
buildkitdFlags: core.getInput('buildkitd-flags') || '--allow-insecure-entitlement security.insecure --allow-insecure-entitlement network.host',
|
buildkitdFlags: core.getInput('buildkitd-flags'),
|
||||||
platforms: await getInputList('platforms', false, true),
|
platforms: Util.getInputList('platforms'),
|
||||||
install: core.getBooleanInput('install'),
|
install: core.getBooleanInput('install'),
|
||||||
use: core.getBooleanInput('use'),
|
use: core.getBooleanInput('use'),
|
||||||
endpoint: core.getInput('endpoint'),
|
endpoint: core.getInput('endpoint'),
|
||||||
config: core.getInput('config'),
|
buildkitdConfig: core.getInput('buildkitd-config') || core.getInput('config'),
|
||||||
configInline: core.getInput('config-inline'),
|
buildkitdConfigInline: core.getInput('buildkitd-config-inline') || core.getInput('config-inline'),
|
||||||
append: core.getInput('append')
|
append: core.getInput('append'),
|
||||||
|
cacheBinary: core.getBooleanInput('cache-binary'),
|
||||||
|
cleanup: core.getBooleanInput('cleanup')
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getBuilderName(driver: string): string {
|
export async function getBuilderName(driver: string): Promise<string> {
|
||||||
return driver == 'docker' ? 'default' : `builder-${uuid.v4()}`;
|
return driver == 'docker' ? await Docker.context() : `builder-${crypto.randomUUID()}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function getCreateArgs(inputs: Inputs, buildxVersion: string): Promise<Array<string>> {
|
export async function getCreateArgs(inputs: Inputs, toolkit: Toolkit): Promise<Array<string>> {
|
||||||
const args: Array<string> = ['create', '--name', inputs.name, '--driver', inputs.driver];
|
const args: Array<string> = ['create', '--name', inputs.name, '--driver', inputs.driver];
|
||||||
if (buildx.satisfies(buildxVersion, '>=0.3.0')) {
|
if (await toolkit.buildx.versionSatisfies('>=0.3.0')) {
|
||||||
await asyncForEach(inputs.driverOpts, async driverOpt => {
|
await Util.asyncForEach(inputs.driverOpts, async (driverOpt: string) => {
|
||||||
args.push('--driver-opt', driverOpt);
|
args.push('--driver-opt', driverOpt);
|
||||||
});
|
});
|
||||||
if (inputs.driver != 'remote' && inputs.buildkitdFlags) {
|
if (inputs.buildkitdFlags) {
|
||||||
args.push('--buildkitd-flags', inputs.buildkitdFlags);
|
args.push('--buildkitd-flags', inputs.buildkitdFlags);
|
||||||
|
} else if (driverSupportsBuildkitdFlags(inputs.driver)) {
|
||||||
|
args.push('--buildkitd-flags', defaultBuildkitdFlags);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (inputs.platforms.length > 0) {
|
if (inputs.platforms.length > 0) {
|
||||||
@ -75,12 +68,10 @@ export async function getCreateArgs(inputs: Inputs, buildxVersion: string): Prom
|
|||||||
if (inputs.use) {
|
if (inputs.use) {
|
||||||
args.push('--use');
|
args.push('--use');
|
||||||
}
|
}
|
||||||
if (inputs.driver != 'remote') {
|
if (inputs.buildkitdConfig) {
|
||||||
if (inputs.config) {
|
args.push('--config', toolkit.buildkit.config.resolveFromFile(inputs.buildkitdConfig));
|
||||||
args.push('--config', await buildx.getConfigFile(inputs.config));
|
} else if (inputs.buildkitdConfigInline) {
|
||||||
} else if (inputs.configInline) {
|
args.push('--config', toolkit.buildkit.config.resolveFromString(inputs.buildkitdConfigInline));
|
||||||
args.push('--config', await buildx.getConfigInline(inputs.configInline));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if (inputs.endpoint) {
|
if (inputs.endpoint) {
|
||||||
args.push(inputs.endpoint);
|
args.push(inputs.endpoint);
|
||||||
@ -88,17 +79,21 @@ export async function getCreateArgs(inputs: Inputs, buildxVersion: string): Prom
|
|||||||
return args;
|
return args;
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function getAppendArgs(inputs: Inputs, node: nodes.Node, buildxVersion: string): Promise<Array<string>> {
|
export async function getAppendArgs(inputs: Inputs, node: Node, toolkit: Toolkit): Promise<Array<string>> {
|
||||||
const args: Array<string> = ['create', '--name', inputs.name, '--append'];
|
const args: Array<string> = ['create', '--name', inputs.name, '--append'];
|
||||||
if (node.name) {
|
if (node.name) {
|
||||||
args.push('--node', node.name);
|
args.push('--node', node.name);
|
||||||
|
} else if (inputs.driver == 'kubernetes' && (await toolkit.buildx.versionSatisfies('<0.11.0'))) {
|
||||||
|
args.push('--node', `node-${crypto.randomUUID()}`);
|
||||||
}
|
}
|
||||||
if (node['driver-opts'] && buildx.satisfies(buildxVersion, '>=0.3.0')) {
|
if (node['driver-opts'] && (await toolkit.buildx.versionSatisfies('>=0.3.0'))) {
|
||||||
await asyncForEach(node['driver-opts'], async driverOpt => {
|
await Util.asyncForEach(node['driver-opts'], async (driverOpt: string) => {
|
||||||
args.push('--driver-opt', driverOpt);
|
args.push('--driver-opt', driverOpt);
|
||||||
});
|
});
|
||||||
if (inputs.driver != 'remote' && node['buildkitd-flags']) {
|
if (node['buildkitd-flags']) {
|
||||||
args.push('--buildkitd-flags', node['buildkitd-flags']);
|
args.push('--buildkitd-flags', node['buildkitd-flags']);
|
||||||
|
} else if (driverSupportsBuildkitdFlags(inputs.driver)) {
|
||||||
|
args.push('--buildkitd-flags', defaultBuildkitdFlags);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (node.platforms) {
|
if (node.platforms) {
|
||||||
@ -110,47 +105,28 @@ export async function getAppendArgs(inputs: Inputs, node: nodes.Node, buildxVers
|
|||||||
return args;
|
return args;
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function getInspectArgs(inputs: Inputs, buildxVersion: string): Promise<Array<string>> {
|
export async function getInspectArgs(inputs: Inputs, toolkit: Toolkit): Promise<Array<string>> {
|
||||||
const args: Array<string> = ['inspect', '--bootstrap'];
|
const args: Array<string> = ['inspect', '--bootstrap'];
|
||||||
if (buildx.satisfies(buildxVersion, '>=0.4.0')) {
|
if (await toolkit.buildx.versionSatisfies('>=0.4.0')) {
|
||||||
args.push('--builder', inputs.name);
|
args.push('--builder', inputs.name);
|
||||||
}
|
}
|
||||||
return args;
|
return args;
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function getInputList(name: string, ignoreComma?: boolean, escapeQuotes?: boolean): Promise<string[]> {
|
function driverSupportsBuildkitdFlags(driver: string): boolean {
|
||||||
const res: Array<string> = [];
|
return driver == '' || driver == 'docker-container' || driver == 'docker' || driver == 'kubernetes';
|
||||||
|
|
||||||
const items = core.getInput(name);
|
|
||||||
if (items == '') {
|
|
||||||
return res;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const records = parse(items, {
|
export function getVersion(inputs: Inputs): string {
|
||||||
columns: false,
|
const version = inputs.version;
|
||||||
relaxQuotes: true,
|
if (inputs.driver === 'cloud') {
|
||||||
comment: '#',
|
if (!version || version === 'latest') {
|
||||||
relaxColumnCount: true,
|
return 'cloud:latest';
|
||||||
skipEmptyLines: true,
|
|
||||||
quote: escapeQuotes ? `"` : false
|
|
||||||
});
|
|
||||||
|
|
||||||
for (const record of records as Array<string[]>) {
|
|
||||||
if (record.length == 1) {
|
|
||||||
res.push(record[0]);
|
|
||||||
continue;
|
|
||||||
} else if (!ignoreComma) {
|
|
||||||
res.push(...record);
|
|
||||||
continue;
|
|
||||||
}
|
}
|
||||||
res.push(record.join(','));
|
if (version.startsWith('cloud:') || version.startsWith('lab:')) {
|
||||||
|
return version;
|
||||||
}
|
}
|
||||||
|
return `cloud:${version}`;
|
||||||
return res.filter(item => item).map(pat => pat.trim());
|
|
||||||
}
|
}
|
||||||
|
return version;
|
||||||
export const asyncForEach = async (array, callback) => {
|
|
||||||
for (let index = 0; index < array.length; index++) {
|
|
||||||
await callback(array[index], index, array);
|
|
||||||
}
|
}
|
||||||
};
|
|
||||||
|
@ -1,19 +0,0 @@
|
|||||||
import * as exec from '@actions/exec';
|
|
||||||
|
|
||||||
export async function isAvailable(): Promise<boolean> {
|
|
||||||
return await exec
|
|
||||||
.getExecOutput('docker', undefined, {
|
|
||||||
ignoreReturnCode: true,
|
|
||||||
silent: true
|
|
||||||
})
|
|
||||||
.then(res => {
|
|
||||||
if (res.stderr.length > 0 && res.exitCode != 0) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return res.exitCode == 0;
|
|
||||||
})
|
|
||||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
||||||
.catch(error => {
|
|
||||||
return false;
|
|
||||||
});
|
|
||||||
}
|
|
19
src/git.ts
19
src/git.ts
@ -1,19 +0,0 @@
|
|||||||
import * as exec from '@actions/exec';
|
|
||||||
|
|
||||||
export async function getRemoteSha(repo: string, ref: string): Promise<string> {
|
|
||||||
return await exec
|
|
||||||
.getExecOutput(`git`, ['ls-remote', repo, ref], {
|
|
||||||
ignoreReturnCode: true,
|
|
||||||
silent: true
|
|
||||||
})
|
|
||||||
.then(res => {
|
|
||||||
if (res.stderr.length > 0 && res.exitCode != 0) {
|
|
||||||
throw new Error(res.stderr);
|
|
||||||
}
|
|
||||||
const [rsha] = res.stdout.trim().split(/[\s\t]/);
|
|
||||||
if (rsha.length == 0) {
|
|
||||||
throw new Error(`Cannot find remote ref for ${repo}#${ref}`);
|
|
||||||
}
|
|
||||||
return rsha;
|
|
||||||
});
|
|
||||||
}
|
|
325
src/main.ts
325
src/main.ts
@ -1,111 +1,201 @@
|
|||||||
|
import * as crypto from 'crypto';
|
||||||
import * as fs from 'fs';
|
import * as fs from 'fs';
|
||||||
import * as os from 'os';
|
import * as yaml from 'js-yaml';
|
||||||
import * as path from 'path';
|
|
||||||
import * as auth from './auth';
|
|
||||||
import * as buildx from './buildx';
|
|
||||||
import * as context from './context';
|
|
||||||
import * as docker from './docker';
|
|
||||||
import * as nodes from './nodes';
|
|
||||||
import * as stateHelper from './state-helper';
|
|
||||||
import * as util from './util';
|
|
||||||
import * as core from '@actions/core';
|
import * as core from '@actions/core';
|
||||||
import * as exec from '@actions/exec';
|
import * as actionsToolkit from '@docker/actions-toolkit';
|
||||||
|
|
||||||
async function run(): Promise<void> {
|
import {Buildx} from '@docker/actions-toolkit/lib/buildx/buildx';
|
||||||
try {
|
import {Builder} from '@docker/actions-toolkit/lib/buildx/builder';
|
||||||
|
import {Docker} from '@docker/actions-toolkit/lib/docker/docker';
|
||||||
|
import {Exec} from '@docker/actions-toolkit/lib/exec';
|
||||||
|
import {Toolkit} from '@docker/actions-toolkit/lib/toolkit';
|
||||||
|
import {Util} from '@docker/actions-toolkit/lib/util';
|
||||||
|
|
||||||
|
import {Node} from '@docker/actions-toolkit/lib/types/buildx/builder';
|
||||||
|
import {ContextInfo} from '@docker/actions-toolkit/lib/types/docker/docker';
|
||||||
|
|
||||||
|
import * as context from './context';
|
||||||
|
import * as stateHelper from './state-helper';
|
||||||
|
|
||||||
|
actionsToolkit.run(
|
||||||
|
// main
|
||||||
|
async () => {
|
||||||
const inputs: context.Inputs = await context.getInputs();
|
const inputs: context.Inputs = await context.getInputs();
|
||||||
const dockerConfigHome: string = process.env.DOCKER_CONFIG || path.join(os.homedir(), '.docker');
|
stateHelper.setCleanup(inputs.cleanup);
|
||||||
|
const version = context.getVersion(inputs);
|
||||||
|
|
||||||
// standalone if docker cli not available
|
const toolkit = new Toolkit();
|
||||||
const standalone = !(await docker.isAvailable());
|
const standalone = await toolkit.buildx.isStandalone();
|
||||||
stateHelper.setStandalone(standalone);
|
stateHelper.setStandalone(standalone);
|
||||||
|
|
||||||
core.startGroup(`Docker info`);
|
await core.group(`Docker info`, async () => {
|
||||||
if (standalone) {
|
try {
|
||||||
core.info(`Docker info skipped in standalone mode`);
|
await Docker.printVersion();
|
||||||
} else {
|
await Docker.printInfo();
|
||||||
await exec.exec('docker', ['version'], {
|
} catch (e) {
|
||||||
failOnStdErr: false
|
core.info(e.message);
|
||||||
});
|
|
||||||
await exec.exec('docker', ['info'], {
|
|
||||||
failOnStdErr: false
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
core.endGroup();
|
});
|
||||||
|
|
||||||
if (util.isValidUrl(inputs.version)) {
|
let toolPath;
|
||||||
|
if (Util.isValidRef(version)) {
|
||||||
if (standalone) {
|
if (standalone) {
|
||||||
throw new Error(`Cannot build from source without the Docker CLI`);
|
throw new Error(`Cannot build from source without the Docker CLI`);
|
||||||
}
|
}
|
||||||
core.startGroup(`Build and install buildx`);
|
await core.group(`Build buildx from source`, async () => {
|
||||||
await buildx.build(inputs.version, dockerConfigHome, standalone);
|
toolPath = await toolkit.buildxInstall.build(version, !inputs.cacheBinary);
|
||||||
core.endGroup();
|
});
|
||||||
} else if (!(await buildx.isAvailable(standalone)) || inputs.version) {
|
} else if (!(await toolkit.buildx.isAvailable()) || version) {
|
||||||
core.startGroup(`Download and install buildx`);
|
await core.group(`Download buildx from GitHub Releases`, async () => {
|
||||||
await buildx.install(inputs.version || 'latest', standalone ? context.tmpDir() : dockerConfigHome, standalone);
|
toolPath = await toolkit.buildxInstall.download(version || 'latest', !inputs.cacheBinary);
|
||||||
core.endGroup();
|
});
|
||||||
|
}
|
||||||
|
if (toolPath) {
|
||||||
|
await core.group(`Install buildx`, async () => {
|
||||||
|
if (standalone) {
|
||||||
|
await toolkit.buildxInstall.installStandalone(toolPath);
|
||||||
|
} else {
|
||||||
|
await toolkit.buildxInstall.installPlugin(toolPath);
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
const buildxVersion = await buildx.getVersion(standalone);
|
|
||||||
await core.group(`Buildx version`, async () => {
|
await core.group(`Buildx version`, async () => {
|
||||||
const versionCmd = buildx.getCommand(['version'], standalone);
|
await toolkit.buildx.printVersion();
|
||||||
await exec.exec(versionCmd.commandLine, versionCmd.args, {
|
|
||||||
failOnStdErr: false
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
core.setOutput('name', inputs.name);
|
core.setOutput('name', inputs.name);
|
||||||
stateHelper.setBuilderName(inputs.name);
|
stateHelper.setBuilderName(inputs.name);
|
||||||
|
stateHelper.setBuilderDriver(inputs.driver);
|
||||||
|
|
||||||
const credsdir = path.join(dockerConfigHome, 'buildx', 'creds', inputs.name);
|
fs.mkdirSync(Buildx.certsDir, {recursive: true});
|
||||||
fs.mkdirSync(credsdir, {recursive: true});
|
stateHelper.setCertsDir(Buildx.certsDir);
|
||||||
stateHelper.setCredsDir(credsdir);
|
|
||||||
|
// if the default context has TLS data loaded and endpoint is not set, then
|
||||||
|
// we create a temporary docker context only if driver is docker-container
|
||||||
|
// https://github.com/docker/buildx/blob/b96ad59f64d40873e4959336d294b648bb3937fe/builder/builder.go#L489
|
||||||
|
// https://github.com/docker/setup-buildx-action/issues/105
|
||||||
|
if (!standalone && inputs.driver == 'docker-container' && (await Docker.context()) == 'default' && inputs.endpoint.length == 0) {
|
||||||
|
let defaultContextWithTLS: boolean = false;
|
||||||
|
await core.group(`Inspecting default docker context`, async () => {
|
||||||
|
await Docker.getExecOutput(['context', 'inspect', '--format=json', 'default'], {
|
||||||
|
ignoreReturnCode: true,
|
||||||
|
silent: true
|
||||||
|
}).then(res => {
|
||||||
|
if (res.stderr.length > 0 && res.exitCode != 0) {
|
||||||
|
core.info(`Cannot inspect default docker context: ${res.stderr.trim()}`);
|
||||||
|
} else {
|
||||||
|
try {
|
||||||
|
const contextInfo = (<Array<ContextInfo>>JSON.parse(res.stdout.trim()))[0];
|
||||||
|
core.info(JSON.stringify(JSON.parse(res.stdout.trim()), undefined, 2));
|
||||||
|
const hasTLSData = Object.keys(contextInfo.Endpoints).length > 0 && Object.values(contextInfo.Endpoints)[0].TLSData !== undefined;
|
||||||
|
const hasTLSMaterial = Object.keys(contextInfo.TLSMaterial).length > 0 && Object.values(contextInfo.TLSMaterial)[0].length > 0;
|
||||||
|
defaultContextWithTLS = hasTLSData || hasTLSMaterial;
|
||||||
|
} catch (e) {
|
||||||
|
core.info(`Unable to parse default docker context info: ${e}`);
|
||||||
|
core.info(res.stdout.trim());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
if (defaultContextWithTLS) {
|
||||||
|
const tmpDockerContext = `buildx-${crypto.randomUUID()}`;
|
||||||
|
await core.group(`Creating temp docker context (TLS data loaded in default one)`, async () => {
|
||||||
|
await Docker.getExecOutput(['context', 'create', tmpDockerContext], {
|
||||||
|
ignoreReturnCode: true
|
||||||
|
}).then(res => {
|
||||||
|
if (res.stderr.length > 0 && res.exitCode != 0) {
|
||||||
|
core.warning(`Cannot create docker context ${tmpDockerContext}: ${res.stderr.match(/(.*)\s*$/)?.[0]?.trim() ?? 'unknown error'}`);
|
||||||
|
} else {
|
||||||
|
core.info(`Setting builder endpoint to ${tmpDockerContext} context`);
|
||||||
|
inputs.endpoint = tmpDockerContext;
|
||||||
|
stateHelper.setTmpDockerContext(tmpDockerContext);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (inputs.driver !== 'docker') {
|
if (inputs.driver !== 'docker') {
|
||||||
core.startGroup(`Creating a new builder instance`);
|
await core.group(`Creating a new builder instance`, async () => {
|
||||||
const authOpts = auth.setCredentials(credsdir, 0, inputs.driver, inputs.endpoint);
|
const certsDriverOpts = Buildx.resolveCertsDriverOpts(inputs.driver, inputs.endpoint, {
|
||||||
if (authOpts.length > 0) {
|
cacert: process.env[`${context.builderNodeEnvPrefix}_0_AUTH_TLS_CACERT`],
|
||||||
inputs.driverOpts = [...inputs.driverOpts, ...authOpts];
|
cert: process.env[`${context.builderNodeEnvPrefix}_0_AUTH_TLS_CERT`],
|
||||||
|
key: process.env[`${context.builderNodeEnvPrefix}_0_AUTH_TLS_KEY`]
|
||||||
|
});
|
||||||
|
if (certsDriverOpts.length > 0) {
|
||||||
|
inputs.driverOpts = [...inputs.driverOpts, ...certsDriverOpts];
|
||||||
}
|
}
|
||||||
const createCmd = buildx.getCommand(await context.getCreateArgs(inputs, buildxVersion), standalone);
|
const createCmd = await toolkit.buildx.getCommand(await context.getCreateArgs(inputs, toolkit));
|
||||||
await exec.exec(createCmd.commandLine, createCmd.args);
|
await Exec.getExecOutput(createCmd.command, createCmd.args, {
|
||||||
core.endGroup();
|
ignoreReturnCode: true
|
||||||
|
}).then(res => {
|
||||||
|
if (res.stderr.length > 0 && res.exitCode != 0) {
|
||||||
|
throw new Error(res.stderr.match(/(.*)\s*$/)?.[0]?.trim() ?? 'unknown error');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
if (inputs.append) {
|
if (inputs.append) {
|
||||||
core.startGroup(`Appending node(s) to builder`);
|
await core.group(`Appending node(s) to builder`, async () => {
|
||||||
let nodeIndex = 1;
|
let nodeIndex = 1;
|
||||||
for (const node of nodes.Parse(inputs.append)) {
|
const nodes = yaml.load(inputs.append) as Node[];
|
||||||
const authOpts = auth.setCredentials(credsdir, nodeIndex, inputs.driver, node.endpoint || '');
|
for (const node of nodes) {
|
||||||
if (authOpts.length > 0) {
|
const certsDriverOpts = Buildx.resolveCertsDriverOpts(inputs.driver, `${node.endpoint}`, {
|
||||||
node['driver-opts'] = [...(node['driver-opts'] || []), ...authOpts];
|
cacert: process.env[`${context.builderNodeEnvPrefix}_${nodeIndex}_AUTH_TLS_CACERT`],
|
||||||
|
cert: process.env[`${context.builderNodeEnvPrefix}_${nodeIndex}_AUTH_TLS_CERT`],
|
||||||
|
key: process.env[`${context.builderNodeEnvPrefix}_${nodeIndex}_AUTH_TLS_KEY`]
|
||||||
|
});
|
||||||
|
if (certsDriverOpts.length > 0) {
|
||||||
|
node['driver-opts'] = [...(node['driver-opts'] || []), ...certsDriverOpts];
|
||||||
}
|
}
|
||||||
const appendCmd = buildx.getCommand(await context.getAppendArgs(inputs, node, buildxVersion), standalone);
|
const appendCmd = await toolkit.buildx.getCommand(await context.getAppendArgs(inputs, node, toolkit));
|
||||||
await exec.exec(appendCmd.commandLine, appendCmd.args);
|
await Exec.getExecOutput(appendCmd.command, appendCmd.args, {
|
||||||
|
ignoreReturnCode: true
|
||||||
|
}).then(res => {
|
||||||
|
if (res.stderr.length > 0 && res.exitCode != 0) {
|
||||||
|
throw new Error(`Failed to append node ${node.name}: ${res.stderr.match(/(.*)\s*$/)?.[0]?.trim() ?? 'unknown error'}`);
|
||||||
|
}
|
||||||
|
});
|
||||||
nodeIndex++;
|
nodeIndex++;
|
||||||
}
|
}
|
||||||
core.endGroup();
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
core.startGroup(`Booting builder`);
|
await core.group(`Booting builder`, async () => {
|
||||||
const inspectCmd = buildx.getCommand(await context.getInspectArgs(inputs, buildxVersion), standalone);
|
const inspectCmd = await toolkit.buildx.getCommand(await context.getInspectArgs(inputs, toolkit));
|
||||||
await exec.exec(inspectCmd.commandLine, inspectCmd.args);
|
await Exec.getExecOutput(inspectCmd.command, inspectCmd.args, {
|
||||||
core.endGroup();
|
ignoreReturnCode: true
|
||||||
|
}).then(res => {
|
||||||
|
if (res.stderr.length > 0 && res.exitCode != 0) {
|
||||||
|
throw new Error(res.stderr.match(/(.*)\s*$/)?.[0]?.trim() ?? 'unknown error');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
if (inputs.install) {
|
if (inputs.install) {
|
||||||
if (standalone) {
|
if (standalone) {
|
||||||
throw new Error(`Cannot set buildx as default builder without the Docker CLI`);
|
throw new Error(`Cannot set buildx as default builder without the Docker CLI`);
|
||||||
}
|
}
|
||||||
core.startGroup(`Setting buildx as default builder`);
|
await core.group(`Setting buildx as default builder`, async () => {
|
||||||
await exec.exec('docker', ['buildx', 'install']);
|
const installCmd = await toolkit.buildx.getCommand(['install']);
|
||||||
core.endGroup();
|
await Exec.getExecOutput(installCmd.command, installCmd.args, {
|
||||||
|
ignoreReturnCode: true
|
||||||
|
}).then(res => {
|
||||||
|
if (res.stderr.length > 0 && res.exitCode != 0) {
|
||||||
|
throw new Error(res.stderr.match(/(.*)\s*$/)?.[0]?.trim() ?? 'unknown error');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
core.startGroup(`Inspect builder`);
|
const builderInspect = await toolkit.builder.inspect(inputs.name);
|
||||||
const builder = await buildx.inspect(inputs.name, standalone);
|
const firstNode = builderInspect.nodes[0];
|
||||||
const firstNode = builder.nodes[0];
|
|
||||||
|
await core.group(`Inspect builder`, async () => {
|
||||||
const reducedPlatforms: Array<string> = [];
|
const reducedPlatforms: Array<string> = [];
|
||||||
for (const node of builder.nodes) {
|
for (const node of builderInspect.nodes) {
|
||||||
for (const platform of node.platforms?.split(',') || []) {
|
for (const platform of node.platforms?.split(',') || []) {
|
||||||
if (reducedPlatforms.indexOf(platform) > -1) {
|
if (reducedPlatforms.indexOf(platform) > -1) {
|
||||||
continue;
|
continue;
|
||||||
@ -113,70 +203,81 @@ async function run(): Promise<void> {
|
|||||||
reducedPlatforms.push(platform);
|
reducedPlatforms.push(platform);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
core.info(JSON.stringify(builder, undefined, 2));
|
core.info(JSON.stringify(builderInspect, undefined, 2));
|
||||||
core.setOutput('driver', builder.driver);
|
core.setOutput('driver', builderInspect.driver);
|
||||||
core.setOutput('platforms', reducedPlatforms.join(','));
|
core.setOutput('platforms', reducedPlatforms.join(','));
|
||||||
core.setOutput('nodes', JSON.stringify(builder.nodes, undefined, 2));
|
core.setOutput('nodes', JSON.stringify(builderInspect.nodes, undefined, 2));
|
||||||
core.setOutput('endpoint', firstNode.endpoint); // TODO: deprecated, to be removed in a later version
|
core.setOutput('endpoint', firstNode.endpoint); // TODO: deprecated, to be removed in a later version
|
||||||
core.setOutput('status', firstNode.status); // TODO: deprecated, to be removed in a later version
|
core.setOutput('status', firstNode.status); // TODO: deprecated, to be removed in a later version
|
||||||
core.setOutput('flags', firstNode['buildkitd-flags']); // TODO: deprecated, to be removed in a later version
|
core.setOutput('flags', firstNode['buildkitd-flags']); // TODO: deprecated, to be removed in a later version
|
||||||
core.endGroup();
|
});
|
||||||
|
|
||||||
if (!standalone && builder.driver == 'docker-container') {
|
if (!standalone && builderInspect.driver == 'docker-container') {
|
||||||
stateHelper.setContainerName(`buildx_buildkit_${firstNode.name}`);
|
stateHelper.setContainerName(`${Buildx.containerNamePrefix}${firstNode.name}`);
|
||||||
core.startGroup(`BuildKit version`);
|
await core.group(`BuildKit version`, async () => {
|
||||||
for (const node of builder.nodes) {
|
for (const node of builderInspect.nodes) {
|
||||||
const bkvers = await buildx.getBuildKitVersion(`buildx_buildkit_${node.name}`);
|
const buildkitVersion = await toolkit.buildkit.getVersion(node);
|
||||||
core.info(`${node.name}: ${bkvers}`);
|
core.info(`${node.name}: ${buildkitVersion}`);
|
||||||
}
|
}
|
||||||
core.endGroup();
|
});
|
||||||
}
|
}
|
||||||
if (core.isDebug() || firstNode['buildkitd-flags']?.includes('--debug')) {
|
if (core.isDebug() || firstNode['buildkitd-flags']?.includes('--debug')) {
|
||||||
stateHelper.setDebug('true');
|
stateHelper.setDebug('true');
|
||||||
}
|
}
|
||||||
} catch (error) {
|
},
|
||||||
core.setFailed(error.message);
|
// post
|
||||||
}
|
async () => {
|
||||||
}
|
|
||||||
|
|
||||||
async function cleanup(): Promise<void> {
|
|
||||||
if (stateHelper.IsDebug && stateHelper.containerName.length > 0) {
|
if (stateHelper.IsDebug && stateHelper.containerName.length > 0) {
|
||||||
core.startGroup(`BuildKit container logs`);
|
await core.group(`BuildKit container logs`, async () => {
|
||||||
await exec
|
await Docker.getExecOutput(['logs', `${stateHelper.containerName}`], {
|
||||||
.getExecOutput('docker', ['logs', `${stateHelper.containerName}`], {
|
|
||||||
ignoreReturnCode: true
|
ignoreReturnCode: true
|
||||||
})
|
}).then(res => {
|
||||||
.then(res => {
|
|
||||||
if (res.stderr.length > 0 && res.exitCode != 0) {
|
if (res.stderr.length > 0 && res.exitCode != 0) {
|
||||||
core.warning(res.stderr.trim());
|
core.warning(res.stderr.match(/(.*)\s*$/)?.[0]?.trim() ?? 'unknown error');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
core.endGroup();
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
if (stateHelper.builderName.length > 0) {
|
if (!stateHelper.cleanup) {
|
||||||
core.startGroup(`Removing builder`);
|
return;
|
||||||
const rmCmd = buildx.getCommand(['rm', stateHelper.builderName], /true/i.test(stateHelper.standalone));
|
}
|
||||||
await exec
|
|
||||||
.getExecOutput(rmCmd.commandLine, rmCmd.args, {
|
if (stateHelper.builderDriver != 'docker' && stateHelper.builderName.length > 0) {
|
||||||
|
await core.group(`Removing builder`, async () => {
|
||||||
|
const buildx = new Buildx({standalone: stateHelper.standalone});
|
||||||
|
const builder = new Builder({buildx: buildx});
|
||||||
|
if (await builder.exists(stateHelper.builderName)) {
|
||||||
|
const rmCmd = await buildx.getCommand(['rm', stateHelper.builderName]);
|
||||||
|
await Exec.getExecOutput(rmCmd.command, rmCmd.args, {
|
||||||
ignoreReturnCode: true
|
ignoreReturnCode: true
|
||||||
})
|
}).then(res => {
|
||||||
.then(res => {
|
|
||||||
if (res.stderr.length > 0 && res.exitCode != 0) {
|
if (res.stderr.length > 0 && res.exitCode != 0) {
|
||||||
core.warning(res.stderr.trim());
|
core.warning(res.stderr.match(/(.*)\s*$/)?.[0]?.trim() ?? 'unknown error');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
core.endGroup();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (stateHelper.credsDir.length > 0 && fs.existsSync(stateHelper.credsDir)) {
|
|
||||||
core.info(`Cleaning up credentials`);
|
|
||||||
fs.rmSync(stateHelper.credsDir, {recursive: true});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!stateHelper.IsPost) {
|
|
||||||
run();
|
|
||||||
} else {
|
} else {
|
||||||
cleanup();
|
core.info(`${stateHelper.builderName} does not exist`);
|
||||||
}
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
if (stateHelper.tmpDockerContext) {
|
||||||
|
await core.group(`Removing temp docker context`, async () => {
|
||||||
|
await Exec.getExecOutput('docker', ['context', 'rm', '-f', stateHelper.tmpDockerContext], {
|
||||||
|
ignoreReturnCode: true
|
||||||
|
}).then(res => {
|
||||||
|
if (res.stderr.length > 0 && res.exitCode != 0) {
|
||||||
|
core.warning(`${res.stderr.match(/(.*)\s*$/)?.[0]?.trim() ?? 'unknown error'}`);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
if (stateHelper.certsDir.length > 0 && fs.existsSync(stateHelper.certsDir)) {
|
||||||
|
await core.group(`Cleaning up certificates`, async () => {
|
||||||
|
fs.rmSync(stateHelper.certsDir, {recursive: true});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
13
src/nodes.ts
13
src/nodes.ts
@ -1,13 +0,0 @@
|
|||||||
import * as yaml from 'js-yaml';
|
|
||||||
|
|
||||||
export type Node = {
|
|
||||||
name?: string;
|
|
||||||
endpoint?: string;
|
|
||||||
'driver-opts'?: Array<string>;
|
|
||||||
'buildkitd-flags'?: string;
|
|
||||||
platforms?: string;
|
|
||||||
};
|
|
||||||
|
|
||||||
export function Parse(data: string): Node[] {
|
|
||||||
return yaml.load(data) as Node[];
|
|
||||||
}
|
|
@ -1,11 +1,13 @@
|
|||||||
import * as core from '@actions/core';
|
import * as core from '@actions/core';
|
||||||
|
|
||||||
export const IsPost = !!process.env['STATE_isPost'];
|
|
||||||
export const IsDebug = !!process.env['STATE_isDebug'];
|
export const IsDebug = !!process.env['STATE_isDebug'];
|
||||||
export const standalone = process.env['STATE_standalone'] || '';
|
export const standalone = /true/i.test(process.env['STATE_standalone'] || '');
|
||||||
export const builderName = process.env['STATE_builderName'] || '';
|
export const builderName = process.env['STATE_builderName'] || '';
|
||||||
|
export const builderDriver = process.env['STATE_builderDriver'] || '';
|
||||||
export const containerName = process.env['STATE_containerName'] || '';
|
export const containerName = process.env['STATE_containerName'] || '';
|
||||||
export const credsDir = process.env['STATE_credsDir'] || '';
|
export const certsDir = process.env['STATE_certsDir'] || '';
|
||||||
|
export const tmpDockerContext = process.env['STATE_tmpDockerContext'] || '';
|
||||||
|
export const cleanup = /true/i.test(process.env['STATE_cleanup'] || '');
|
||||||
|
|
||||||
export function setDebug(debug: string) {
|
export function setDebug(debug: string) {
|
||||||
core.saveState('isDebug', debug);
|
core.saveState('isDebug', debug);
|
||||||
@ -19,14 +21,22 @@ export function setBuilderName(builderName: string) {
|
|||||||
core.saveState('builderName', builderName);
|
core.saveState('builderName', builderName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function setBuilderDriver(builderDriver: string) {
|
||||||
|
core.saveState('builderDriver', builderDriver);
|
||||||
|
}
|
||||||
|
|
||||||
export function setContainerName(containerName: string) {
|
export function setContainerName(containerName: string) {
|
||||||
core.saveState('containerName', containerName);
|
core.saveState('containerName', containerName);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function setCredsDir(credsDir: string) {
|
export function setCertsDir(certsDir: string) {
|
||||||
core.saveState('credsDir', credsDir);
|
core.saveState('certsDir', certsDir);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!IsPost) {
|
export function setTmpDockerContext(tmpDockerContext: string) {
|
||||||
core.saveState('isPost', 'true');
|
core.saveState('tmpDockerContext', tmpDockerContext);
|
||||||
|
}
|
||||||
|
|
||||||
|
export function setCleanup(cleanup: boolean) {
|
||||||
|
core.saveState('cleanup', cleanup);
|
||||||
}
|
}
|
||||||
|
@ -1,8 +0,0 @@
|
|||||||
export function isValidUrl(url: string): boolean {
|
|
||||||
try {
|
|
||||||
new URL(url);
|
|
||||||
} catch (e) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
@ -1,19 +1,21 @@
|
|||||||
{
|
{
|
||||||
"compilerOptions": {
|
"compilerOptions": {
|
||||||
|
"esModuleInterop": true,
|
||||||
"target": "es6",
|
"target": "es6",
|
||||||
"module": "commonjs",
|
"module": "commonjs",
|
||||||
|
"strict": true,
|
||||||
"newLine": "lf",
|
"newLine": "lf",
|
||||||
"outDir": "./lib",
|
"outDir": "./lib",
|
||||||
"rootDir": "./src",
|
"rootDir": "./src",
|
||||||
"esModuleInterop": true,
|
|
||||||
"forceConsistentCasingInFileNames": true,
|
"forceConsistentCasingInFileNames": true,
|
||||||
"strict": true,
|
|
||||||
"noImplicitAny": false,
|
"noImplicitAny": false,
|
||||||
|
"resolveJsonModule": true,
|
||||||
"useUnknownInCatchVariables": false,
|
"useUnknownInCatchVariables": false,
|
||||||
},
|
},
|
||||||
"exclude": [
|
"exclude": [
|
||||||
|
"./__tests__/**/*",
|
||||||
|
"./lib/**/*",
|
||||||
"node_modules",
|
"node_modules",
|
||||||
"**/*.test.ts",
|
|
||||||
"jest.config.ts"
|
"jest.config.ts"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user