Compare commits
29 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
477e96d237 | ||
|
|
05e3bb5b86 | ||
|
|
11c483e5c9 | ||
|
|
491039b9e3 | ||
|
|
a777edf0f6 | ||
|
|
a60e66444e | ||
|
|
f94786cf56 | ||
|
|
09e67cefea | ||
|
|
c5fb2b6f30 | ||
|
|
1416ff392b | ||
|
|
e4b0b455d8 | ||
|
|
ce4ab4d3d2 | ||
|
|
b7405db71f | ||
|
|
fbf0d5ba85 | ||
|
|
66531a2912 | ||
|
|
1c34ae09f0 | ||
|
|
6df98c1aad | ||
|
|
a9bd3f5b6b | ||
|
|
f7a8b21610 | ||
|
|
8177e153d6 | ||
|
|
a14ead6486 | ||
|
|
f9de623b1d | ||
|
|
202104bf16 | ||
|
|
b6b4cf170e | ||
|
|
311ae1dacc | ||
|
|
163d33a2bd | ||
|
|
d283be916f | ||
|
|
ffc7d98a98 | ||
|
|
d36bef4156 |
156
.github/buildx-releases.json
vendored
156
.github/buildx-releases.json
vendored
@@ -1,43 +1,125 @@
|
||||
{
|
||||
"latest": {
|
||||
"id": 165067169,
|
||||
"tag_name": "v0.16.0",
|
||||
"html_url": "https://github.com/docker/buildx/releases/tag/v0.16.0",
|
||||
"id": 167152950,
|
||||
"tag_name": "v0.16.2",
|
||||
"html_url": "https://github.com/docker/buildx/releases/tag/v0.16.2",
|
||||
"assets": [
|
||||
"https://github.com/docker/buildx/releases/download/v0.16.0/buildx-v0.16.0.darwin-amd64",
|
||||
"https://github.com/docker/buildx/releases/download/v0.16.0/buildx-v0.16.0.darwin-amd64.provenance.json",
|
||||
"https://github.com/docker/buildx/releases/download/v0.16.0/buildx-v0.16.0.darwin-amd64.sbom.json",
|
||||
"https://github.com/docker/buildx/releases/download/v0.16.0/buildx-v0.16.0.darwin-arm64",
|
||||
"https://github.com/docker/buildx/releases/download/v0.16.0/buildx-v0.16.0.darwin-arm64.provenance.json",
|
||||
"https://github.com/docker/buildx/releases/download/v0.16.0/buildx-v0.16.0.darwin-arm64.sbom.json",
|
||||
"https://github.com/docker/buildx/releases/download/v0.16.0/buildx-v0.16.0.linux-amd64",
|
||||
"https://github.com/docker/buildx/releases/download/v0.16.0/buildx-v0.16.0.linux-amd64.provenance.json",
|
||||
"https://github.com/docker/buildx/releases/download/v0.16.0/buildx-v0.16.0.linux-amd64.sbom.json",
|
||||
"https://github.com/docker/buildx/releases/download/v0.16.0/buildx-v0.16.0.linux-arm-v6",
|
||||
"https://github.com/docker/buildx/releases/download/v0.16.0/buildx-v0.16.0.linux-arm-v6.provenance.json",
|
||||
"https://github.com/docker/buildx/releases/download/v0.16.0/buildx-v0.16.0.linux-arm-v6.sbom.json",
|
||||
"https://github.com/docker/buildx/releases/download/v0.16.0/buildx-v0.16.0.linux-arm-v7",
|
||||
"https://github.com/docker/buildx/releases/download/v0.16.0/buildx-v0.16.0.linux-arm-v7.provenance.json",
|
||||
"https://github.com/docker/buildx/releases/download/v0.16.0/buildx-v0.16.0.linux-arm-v7.sbom.json",
|
||||
"https://github.com/docker/buildx/releases/download/v0.16.0/buildx-v0.16.0.linux-arm64",
|
||||
"https://github.com/docker/buildx/releases/download/v0.16.0/buildx-v0.16.0.linux-arm64.provenance.json",
|
||||
"https://github.com/docker/buildx/releases/download/v0.16.0/buildx-v0.16.0.linux-arm64.sbom.json",
|
||||
"https://github.com/docker/buildx/releases/download/v0.16.0/buildx-v0.16.0.linux-ppc64le",
|
||||
"https://github.com/docker/buildx/releases/download/v0.16.0/buildx-v0.16.0.linux-ppc64le.provenance.json",
|
||||
"https://github.com/docker/buildx/releases/download/v0.16.0/buildx-v0.16.0.linux-ppc64le.sbom.json",
|
||||
"https://github.com/docker/buildx/releases/download/v0.16.0/buildx-v0.16.0.linux-riscv64",
|
||||
"https://github.com/docker/buildx/releases/download/v0.16.0/buildx-v0.16.0.linux-riscv64.provenance.json",
|
||||
"https://github.com/docker/buildx/releases/download/v0.16.0/buildx-v0.16.0.linux-riscv64.sbom.json",
|
||||
"https://github.com/docker/buildx/releases/download/v0.16.0/buildx-v0.16.0.linux-s390x",
|
||||
"https://github.com/docker/buildx/releases/download/v0.16.0/buildx-v0.16.0.linux-s390x.provenance.json",
|
||||
"https://github.com/docker/buildx/releases/download/v0.16.0/buildx-v0.16.0.linux-s390x.sbom.json",
|
||||
"https://github.com/docker/buildx/releases/download/v0.16.0/buildx-v0.16.0.windows-amd64.exe",
|
||||
"https://github.com/docker/buildx/releases/download/v0.16.0/buildx-v0.16.0.windows-amd64.provenance.json",
|
||||
"https://github.com/docker/buildx/releases/download/v0.16.0/buildx-v0.16.0.windows-amd64.sbom.json",
|
||||
"https://github.com/docker/buildx/releases/download/v0.16.0/buildx-v0.16.0.windows-arm64.exe",
|
||||
"https://github.com/docker/buildx/releases/download/v0.16.0/buildx-v0.16.0.windows-arm64.provenance.json",
|
||||
"https://github.com/docker/buildx/releases/download/v0.16.0/buildx-v0.16.0.windows-arm64.sbom.json",
|
||||
"https://github.com/docker/buildx/releases/download/v0.16.0/checksums.txt"
|
||||
"https://github.com/docker/buildx/releases/download/v0.16.2/buildx-v0.16.2.darwin-amd64",
|
||||
"https://github.com/docker/buildx/releases/download/v0.16.2/buildx-v0.16.2.darwin-amd64.provenance.json",
|
||||
"https://github.com/docker/buildx/releases/download/v0.16.2/buildx-v0.16.2.darwin-amd64.sbom.json",
|
||||
"https://github.com/docker/buildx/releases/download/v0.16.2/buildx-v0.16.2.darwin-arm64",
|
||||
"https://github.com/docker/buildx/releases/download/v0.16.2/buildx-v0.16.2.darwin-arm64.provenance.json",
|
||||
"https://github.com/docker/buildx/releases/download/v0.16.2/buildx-v0.16.2.darwin-arm64.sbom.json",
|
||||
"https://github.com/docker/buildx/releases/download/v0.16.2/buildx-v0.16.2.linux-amd64",
|
||||
"https://github.com/docker/buildx/releases/download/v0.16.2/buildx-v0.16.2.linux-amd64.provenance.json",
|
||||
"https://github.com/docker/buildx/releases/download/v0.16.2/buildx-v0.16.2.linux-amd64.sbom.json",
|
||||
"https://github.com/docker/buildx/releases/download/v0.16.2/buildx-v0.16.2.linux-arm-v6",
|
||||
"https://github.com/docker/buildx/releases/download/v0.16.2/buildx-v0.16.2.linux-arm-v6.provenance.json",
|
||||
"https://github.com/docker/buildx/releases/download/v0.16.2/buildx-v0.16.2.linux-arm-v6.sbom.json",
|
||||
"https://github.com/docker/buildx/releases/download/v0.16.2/buildx-v0.16.2.linux-arm-v7",
|
||||
"https://github.com/docker/buildx/releases/download/v0.16.2/buildx-v0.16.2.linux-arm-v7.provenance.json",
|
||||
"https://github.com/docker/buildx/releases/download/v0.16.2/buildx-v0.16.2.linux-arm-v7.sbom.json",
|
||||
"https://github.com/docker/buildx/releases/download/v0.16.2/buildx-v0.16.2.linux-arm64",
|
||||
"https://github.com/docker/buildx/releases/download/v0.16.2/buildx-v0.16.2.linux-arm64.provenance.json",
|
||||
"https://github.com/docker/buildx/releases/download/v0.16.2/buildx-v0.16.2.linux-arm64.sbom.json",
|
||||
"https://github.com/docker/buildx/releases/download/v0.16.2/buildx-v0.16.2.linux-ppc64le",
|
||||
"https://github.com/docker/buildx/releases/download/v0.16.2/buildx-v0.16.2.linux-ppc64le.provenance.json",
|
||||
"https://github.com/docker/buildx/releases/download/v0.16.2/buildx-v0.16.2.linux-ppc64le.sbom.json",
|
||||
"https://github.com/docker/buildx/releases/download/v0.16.2/buildx-v0.16.2.linux-riscv64",
|
||||
"https://github.com/docker/buildx/releases/download/v0.16.2/buildx-v0.16.2.linux-riscv64.provenance.json",
|
||||
"https://github.com/docker/buildx/releases/download/v0.16.2/buildx-v0.16.2.linux-riscv64.sbom.json",
|
||||
"https://github.com/docker/buildx/releases/download/v0.16.2/buildx-v0.16.2.linux-s390x",
|
||||
"https://github.com/docker/buildx/releases/download/v0.16.2/buildx-v0.16.2.linux-s390x.provenance.json",
|
||||
"https://github.com/docker/buildx/releases/download/v0.16.2/buildx-v0.16.2.linux-s390x.sbom.json",
|
||||
"https://github.com/docker/buildx/releases/download/v0.16.2/buildx-v0.16.2.windows-amd64.exe",
|
||||
"https://github.com/docker/buildx/releases/download/v0.16.2/buildx-v0.16.2.windows-amd64.provenance.json",
|
||||
"https://github.com/docker/buildx/releases/download/v0.16.2/buildx-v0.16.2.windows-amd64.sbom.json",
|
||||
"https://github.com/docker/buildx/releases/download/v0.16.2/buildx-v0.16.2.windows-arm64.exe",
|
||||
"https://github.com/docker/buildx/releases/download/v0.16.2/buildx-v0.16.2.windows-arm64.provenance.json",
|
||||
"https://github.com/docker/buildx/releases/download/v0.16.2/buildx-v0.16.2.windows-arm64.sbom.json",
|
||||
"https://github.com/docker/buildx/releases/download/v0.16.2/checksums.txt"
|
||||
]
|
||||
},
|
||||
"v0.16.2": {
|
||||
"id": 167152950,
|
||||
"tag_name": "v0.16.2",
|
||||
"html_url": "https://github.com/docker/buildx/releases/tag/v0.16.2",
|
||||
"assets": [
|
||||
"https://github.com/docker/buildx/releases/download/v0.16.2/buildx-v0.16.2.darwin-amd64",
|
||||
"https://github.com/docker/buildx/releases/download/v0.16.2/buildx-v0.16.2.darwin-amd64.provenance.json",
|
||||
"https://github.com/docker/buildx/releases/download/v0.16.2/buildx-v0.16.2.darwin-amd64.sbom.json",
|
||||
"https://github.com/docker/buildx/releases/download/v0.16.2/buildx-v0.16.2.darwin-arm64",
|
||||
"https://github.com/docker/buildx/releases/download/v0.16.2/buildx-v0.16.2.darwin-arm64.provenance.json",
|
||||
"https://github.com/docker/buildx/releases/download/v0.16.2/buildx-v0.16.2.darwin-arm64.sbom.json",
|
||||
"https://github.com/docker/buildx/releases/download/v0.16.2/buildx-v0.16.2.linux-amd64",
|
||||
"https://github.com/docker/buildx/releases/download/v0.16.2/buildx-v0.16.2.linux-amd64.provenance.json",
|
||||
"https://github.com/docker/buildx/releases/download/v0.16.2/buildx-v0.16.2.linux-amd64.sbom.json",
|
||||
"https://github.com/docker/buildx/releases/download/v0.16.2/buildx-v0.16.2.linux-arm-v6",
|
||||
"https://github.com/docker/buildx/releases/download/v0.16.2/buildx-v0.16.2.linux-arm-v6.provenance.json",
|
||||
"https://github.com/docker/buildx/releases/download/v0.16.2/buildx-v0.16.2.linux-arm-v6.sbom.json",
|
||||
"https://github.com/docker/buildx/releases/download/v0.16.2/buildx-v0.16.2.linux-arm-v7",
|
||||
"https://github.com/docker/buildx/releases/download/v0.16.2/buildx-v0.16.2.linux-arm-v7.provenance.json",
|
||||
"https://github.com/docker/buildx/releases/download/v0.16.2/buildx-v0.16.2.linux-arm-v7.sbom.json",
|
||||
"https://github.com/docker/buildx/releases/download/v0.16.2/buildx-v0.16.2.linux-arm64",
|
||||
"https://github.com/docker/buildx/releases/download/v0.16.2/buildx-v0.16.2.linux-arm64.provenance.json",
|
||||
"https://github.com/docker/buildx/releases/download/v0.16.2/buildx-v0.16.2.linux-arm64.sbom.json",
|
||||
"https://github.com/docker/buildx/releases/download/v0.16.2/buildx-v0.16.2.linux-ppc64le",
|
||||
"https://github.com/docker/buildx/releases/download/v0.16.2/buildx-v0.16.2.linux-ppc64le.provenance.json",
|
||||
"https://github.com/docker/buildx/releases/download/v0.16.2/buildx-v0.16.2.linux-ppc64le.sbom.json",
|
||||
"https://github.com/docker/buildx/releases/download/v0.16.2/buildx-v0.16.2.linux-riscv64",
|
||||
"https://github.com/docker/buildx/releases/download/v0.16.2/buildx-v0.16.2.linux-riscv64.provenance.json",
|
||||
"https://github.com/docker/buildx/releases/download/v0.16.2/buildx-v0.16.2.linux-riscv64.sbom.json",
|
||||
"https://github.com/docker/buildx/releases/download/v0.16.2/buildx-v0.16.2.linux-s390x",
|
||||
"https://github.com/docker/buildx/releases/download/v0.16.2/buildx-v0.16.2.linux-s390x.provenance.json",
|
||||
"https://github.com/docker/buildx/releases/download/v0.16.2/buildx-v0.16.2.linux-s390x.sbom.json",
|
||||
"https://github.com/docker/buildx/releases/download/v0.16.2/buildx-v0.16.2.windows-amd64.exe",
|
||||
"https://github.com/docker/buildx/releases/download/v0.16.2/buildx-v0.16.2.windows-amd64.provenance.json",
|
||||
"https://github.com/docker/buildx/releases/download/v0.16.2/buildx-v0.16.2.windows-amd64.sbom.json",
|
||||
"https://github.com/docker/buildx/releases/download/v0.16.2/buildx-v0.16.2.windows-arm64.exe",
|
||||
"https://github.com/docker/buildx/releases/download/v0.16.2/buildx-v0.16.2.windows-arm64.provenance.json",
|
||||
"https://github.com/docker/buildx/releases/download/v0.16.2/buildx-v0.16.2.windows-arm64.sbom.json",
|
||||
"https://github.com/docker/buildx/releases/download/v0.16.2/checksums.txt"
|
||||
]
|
||||
},
|
||||
"v0.16.1": {
|
||||
"id": 166111587,
|
||||
"tag_name": "v0.16.1",
|
||||
"html_url": "https://github.com/docker/buildx/releases/tag/v0.16.1",
|
||||
"assets": [
|
||||
"https://github.com/docker/buildx/releases/download/v0.16.1/buildx-v0.16.1.darwin-amd64",
|
||||
"https://github.com/docker/buildx/releases/download/v0.16.1/buildx-v0.16.1.darwin-amd64.provenance.json",
|
||||
"https://github.com/docker/buildx/releases/download/v0.16.1/buildx-v0.16.1.darwin-amd64.sbom.json",
|
||||
"https://github.com/docker/buildx/releases/download/v0.16.1/buildx-v0.16.1.darwin-arm64",
|
||||
"https://github.com/docker/buildx/releases/download/v0.16.1/buildx-v0.16.1.darwin-arm64.provenance.json",
|
||||
"https://github.com/docker/buildx/releases/download/v0.16.1/buildx-v0.16.1.darwin-arm64.sbom.json",
|
||||
"https://github.com/docker/buildx/releases/download/v0.16.1/buildx-v0.16.1.linux-amd64",
|
||||
"https://github.com/docker/buildx/releases/download/v0.16.1/buildx-v0.16.1.linux-amd64.provenance.json",
|
||||
"https://github.com/docker/buildx/releases/download/v0.16.1/buildx-v0.16.1.linux-amd64.sbom.json",
|
||||
"https://github.com/docker/buildx/releases/download/v0.16.1/buildx-v0.16.1.linux-arm-v6",
|
||||
"https://github.com/docker/buildx/releases/download/v0.16.1/buildx-v0.16.1.linux-arm-v6.provenance.json",
|
||||
"https://github.com/docker/buildx/releases/download/v0.16.1/buildx-v0.16.1.linux-arm-v6.sbom.json",
|
||||
"https://github.com/docker/buildx/releases/download/v0.16.1/buildx-v0.16.1.linux-arm-v7",
|
||||
"https://github.com/docker/buildx/releases/download/v0.16.1/buildx-v0.16.1.linux-arm-v7.provenance.json",
|
||||
"https://github.com/docker/buildx/releases/download/v0.16.1/buildx-v0.16.1.linux-arm-v7.sbom.json",
|
||||
"https://github.com/docker/buildx/releases/download/v0.16.1/buildx-v0.16.1.linux-arm64",
|
||||
"https://github.com/docker/buildx/releases/download/v0.16.1/buildx-v0.16.1.linux-arm64.provenance.json",
|
||||
"https://github.com/docker/buildx/releases/download/v0.16.1/buildx-v0.16.1.linux-arm64.sbom.json",
|
||||
"https://github.com/docker/buildx/releases/download/v0.16.1/buildx-v0.16.1.linux-ppc64le",
|
||||
"https://github.com/docker/buildx/releases/download/v0.16.1/buildx-v0.16.1.linux-ppc64le.provenance.json",
|
||||
"https://github.com/docker/buildx/releases/download/v0.16.1/buildx-v0.16.1.linux-ppc64le.sbom.json",
|
||||
"https://github.com/docker/buildx/releases/download/v0.16.1/buildx-v0.16.1.linux-riscv64",
|
||||
"https://github.com/docker/buildx/releases/download/v0.16.1/buildx-v0.16.1.linux-riscv64.provenance.json",
|
||||
"https://github.com/docker/buildx/releases/download/v0.16.1/buildx-v0.16.1.linux-riscv64.sbom.json",
|
||||
"https://github.com/docker/buildx/releases/download/v0.16.1/buildx-v0.16.1.linux-s390x",
|
||||
"https://github.com/docker/buildx/releases/download/v0.16.1/buildx-v0.16.1.linux-s390x.provenance.json",
|
||||
"https://github.com/docker/buildx/releases/download/v0.16.1/buildx-v0.16.1.linux-s390x.sbom.json",
|
||||
"https://github.com/docker/buildx/releases/download/v0.16.1/buildx-v0.16.1.windows-amd64.exe",
|
||||
"https://github.com/docker/buildx/releases/download/v0.16.1/buildx-v0.16.1.windows-amd64.provenance.json",
|
||||
"https://github.com/docker/buildx/releases/download/v0.16.1/buildx-v0.16.1.windows-amd64.sbom.json",
|
||||
"https://github.com/docker/buildx/releases/download/v0.16.1/buildx-v0.16.1.windows-arm64.exe",
|
||||
"https://github.com/docker/buildx/releases/download/v0.16.1/buildx-v0.16.1.windows-arm64.provenance.json",
|
||||
"https://github.com/docker/buildx/releases/download/v0.16.1/buildx-v0.16.1.windows-arm64.sbom.json",
|
||||
"https://github.com/docker/buildx/releases/download/v0.16.1/checksums.txt"
|
||||
]
|
||||
},
|
||||
"v0.16.0": {
|
||||
|
||||
30
.github/docker-releases.json
vendored
30
.github/docker-releases.json
vendored
@@ -1,8 +1,32 @@
|
||||
{
|
||||
"latest": {
|
||||
"id": 163311279,
|
||||
"tag_name": "v27.0.3",
|
||||
"html_url": "https://github.com/moby/moby/releases/tag/v27.0.3",
|
||||
"id": 166797236,
|
||||
"tag_name": "v27.1.1",
|
||||
"html_url": "https://github.com/moby/moby/releases/tag/v27.1.1",
|
||||
"assets": []
|
||||
},
|
||||
"v25.0.6": {
|
||||
"id": 167195013,
|
||||
"tag_name": "v25.0.6",
|
||||
"html_url": "https://github.com/moby/moby/releases/tag/v25.0.6",
|
||||
"assets": []
|
||||
},
|
||||
"v27.1.1": {
|
||||
"id": 166797236,
|
||||
"tag_name": "v27.1.1",
|
||||
"html_url": "https://github.com/moby/moby/releases/tag/v27.1.1",
|
||||
"assets": []
|
||||
},
|
||||
"v26.1.5": {
|
||||
"id": 166954867,
|
||||
"tag_name": "v26.1.5",
|
||||
"html_url": "https://github.com/moby/moby/releases/tag/v26.1.5",
|
||||
"assets": []
|
||||
},
|
||||
"v27.1.0": {
|
||||
"id": 166495917,
|
||||
"tag_name": "v27.1.0",
|
||||
"html_url": "https://github.com/moby/moby/releases/tag/v27.1.0",
|
||||
"assets": []
|
||||
},
|
||||
"v27.0.3": {
|
||||
|
||||
4
.github/workflows/test.yml
vendored
4
.github/workflows/test.yml
vendored
@@ -15,8 +15,8 @@ on:
|
||||
|
||||
env:
|
||||
NODE_VERSION: "20"
|
||||
BUILDX_VERSION: "v0.16.0"
|
||||
BUILDKIT_IMAGE: "moby/buildkit:v0.15.0"
|
||||
BUILDX_VERSION: "v0.16.2"
|
||||
BUILDKIT_IMAGE: "moby/buildkit:v0.15.1"
|
||||
|
||||
jobs:
|
||||
test:
|
||||
|
||||
74
__tests__/buildx/buildx.test.itg.ts
Normal file
74
__tests__/buildx/buildx.test.itg.ts
Normal file
@@ -0,0 +1,74 @@
|
||||
/**
|
||||
* Copyright 2024 actions-toolkit authors
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import {describe, expect, it} from '@jest/globals';
|
||||
import * as fs from 'fs';
|
||||
import * as path from 'path';
|
||||
import * as core from '@actions/core';
|
||||
|
||||
import {Buildx} from '../../src/buildx/buildx';
|
||||
import {Build} from '../../src/buildx/build';
|
||||
import {Exec} from '../../src/exec';
|
||||
|
||||
const fixturesDir = path.join(__dirname, '..', 'fixtures');
|
||||
|
||||
// prettier-ignore
|
||||
const tmpDir = path.join(process.env.TEMP || '/tmp', 'buildx-jest');
|
||||
|
||||
const maybe = !process.env.GITHUB_ACTIONS || (process.env.GITHUB_ACTIONS === 'true' && process.env.ImageOS && process.env.ImageOS.startsWith('ubuntu')) ? describe : describe.skip;
|
||||
|
||||
maybe('convertWarningsToGitHubAnnotations', () => {
|
||||
it('annotate lint issues', async () => {
|
||||
const buildx = new Buildx();
|
||||
const build = new Build({buildx: buildx});
|
||||
|
||||
fs.mkdirSync(tmpDir, {recursive: true});
|
||||
await expect(
|
||||
(async () => {
|
||||
// prettier-ignore
|
||||
const buildCmd = await buildx.getCommand([
|
||||
'--builder', process.env.CTN_BUILDER_NAME ?? 'default',
|
||||
'build',
|
||||
'-f', path.join(fixturesDir, 'lint.Dockerfile'),
|
||||
fixturesDir,
|
||||
'--metadata-file', build.getMetadataFilePath()
|
||||
]);
|
||||
await Exec.exec(buildCmd.command, buildCmd.args, {
|
||||
env: Object.assign({}, process.env, {
|
||||
BUILDX_METADATA_WARNINGS: 'true'
|
||||
}) as {
|
||||
[key: string]: string;
|
||||
}
|
||||
});
|
||||
})()
|
||||
).resolves.not.toThrow();
|
||||
|
||||
const metadata = build.resolveMetadata();
|
||||
expect(metadata).toBeDefined();
|
||||
const buildRef = build.resolveRef(metadata);
|
||||
expect(buildRef).toBeDefined();
|
||||
const buildWarnings = build.resolveWarnings(metadata);
|
||||
expect(buildWarnings).toBeDefined();
|
||||
|
||||
const annotations = await Buildx.convertWarningsToGitHubAnnotations(buildWarnings ?? [], [buildRef ?? '']);
|
||||
expect(annotations).toBeDefined();
|
||||
expect(annotations?.length).toBeGreaterThan(0);
|
||||
|
||||
for (const annotation of annotations ?? []) {
|
||||
core.warning(annotation.message, annotation);
|
||||
}
|
||||
});
|
||||
});
|
||||
@@ -20,6 +20,12 @@ import {Docker} from '../../src/docker/docker';
|
||||
|
||||
const maybe = !process.env.GITHUB_ACTIONS || (process.env.GITHUB_ACTIONS === 'true' && process.env.ImageOS && process.env.ImageOS.startsWith('ubuntu')) ? describe : describe.skip;
|
||||
|
||||
maybe('isDaemonRunning', () => {
|
||||
it('checks if daemon is running', async () => {
|
||||
expect(await Docker.isDaemonRunning()).toBe(true);
|
||||
});
|
||||
});
|
||||
|
||||
maybe('pull', () => {
|
||||
// prettier-ignore
|
||||
test.each([
|
||||
|
||||
@@ -22,7 +22,6 @@ import osm = require('os');
|
||||
import * as rimraf from 'rimraf';
|
||||
|
||||
import {Docker} from '../../src/docker/docker';
|
||||
import {Exec} from '../../src/exec';
|
||||
|
||||
import {ConfigFile} from '../../src/types/docker/docker';
|
||||
|
||||
@@ -105,48 +104,132 @@ describe('isAvailable', () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe('context', () => {
|
||||
it('call docker context show', async () => {
|
||||
const execSpy = jest.spyOn(Exec, 'getExecOutput');
|
||||
await Docker.context().catch(() => {
|
||||
// noop
|
||||
});
|
||||
expect(execSpy).toHaveBeenCalledWith(`docker`, ['context', 'inspect', '--format', '{{.Name}}'], {
|
||||
describe('exec', () => {
|
||||
it('returns docker version', async () => {
|
||||
const execSpy = jest.spyOn(Docker, 'exec');
|
||||
await Docker.exec(['version'], {
|
||||
ignoreReturnCode: true,
|
||||
silent: true
|
||||
});
|
||||
expect(execSpy).toHaveBeenCalledTimes(1);
|
||||
const callfunc = execSpy.mock.calls[0];
|
||||
expect(Object.keys(callfunc[1]?.env || {}).length).toBeGreaterThan(0);
|
||||
const env = callfunc[1]?.env;
|
||||
expect(env).toHaveProperty('DOCKER_CONTENT_TRUST');
|
||||
expect(env?.DOCKER_CONTENT_TRUST).toBe('false');
|
||||
if (callfunc[1]?.env) {
|
||||
// already checked env
|
||||
callfunc[1].env = undefined;
|
||||
}
|
||||
expect(callfunc).toEqual([
|
||||
['version'],
|
||||
{
|
||||
ignoreReturnCode: true,
|
||||
silent: true
|
||||
}
|
||||
]);
|
||||
});
|
||||
});
|
||||
|
||||
describe('getExecOutput', () => {
|
||||
it('returns docker version', async () => {
|
||||
const execSpy = jest.spyOn(Docker, 'getExecOutput');
|
||||
await Docker.getExecOutput(['version'], {
|
||||
ignoreReturnCode: true,
|
||||
silent: true
|
||||
});
|
||||
expect(execSpy).toHaveBeenCalledTimes(1);
|
||||
const callfunc = execSpy.mock.calls[0];
|
||||
expect(Object.keys(callfunc[1]?.env || {}).length).toBeGreaterThan(0);
|
||||
const env = callfunc[1]?.env;
|
||||
expect(env).toHaveProperty('DOCKER_CONTENT_TRUST');
|
||||
expect(env?.DOCKER_CONTENT_TRUST).toBe('false');
|
||||
if (callfunc[1]?.env) {
|
||||
// already checked env
|
||||
callfunc[1].env = undefined;
|
||||
}
|
||||
expect(callfunc).toEqual([
|
||||
['version'],
|
||||
{
|
||||
ignoreReturnCode: true,
|
||||
silent: true
|
||||
}
|
||||
]);
|
||||
});
|
||||
});
|
||||
|
||||
describe('context', () => {
|
||||
it('call docker context show', async () => {
|
||||
const execSpy = jest.spyOn(Docker, 'getExecOutput');
|
||||
await Docker.context().catch(() => {
|
||||
// noop
|
||||
});
|
||||
expect(execSpy).toHaveBeenCalledTimes(1);
|
||||
const callfunc = execSpy.mock.calls[0];
|
||||
if (callfunc && callfunc[1]) {
|
||||
// we don't want to check env opt
|
||||
callfunc[1].env = undefined;
|
||||
}
|
||||
expect(callfunc).toEqual([
|
||||
['context', 'inspect', '--format', '{{.Name}}'],
|
||||
{
|
||||
ignoreReturnCode: true,
|
||||
silent: true
|
||||
}
|
||||
]);
|
||||
});
|
||||
});
|
||||
|
||||
describe('contextInspect', () => {
|
||||
it('call docker context inspect', async () => {
|
||||
const execSpy = jest.spyOn(Exec, 'getExecOutput');
|
||||
const execSpy = jest.spyOn(Docker, 'getExecOutput');
|
||||
await Docker.contextInspect('foo').catch(() => {
|
||||
// noop
|
||||
});
|
||||
expect(execSpy).toHaveBeenCalledWith(`docker`, ['context', 'inspect', '--format=json', 'foo'], {
|
||||
ignoreReturnCode: true,
|
||||
silent: true
|
||||
});
|
||||
expect(execSpy).toHaveBeenCalledTimes(1);
|
||||
const callfunc = execSpy.mock.calls[0];
|
||||
if (callfunc && callfunc[1]) {
|
||||
// we don't want to check env opt
|
||||
callfunc[1].env = undefined;
|
||||
}
|
||||
expect(callfunc).toEqual([
|
||||
['context', 'inspect', '--format=json', 'foo'],
|
||||
{
|
||||
ignoreReturnCode: true,
|
||||
silent: true
|
||||
}
|
||||
]);
|
||||
});
|
||||
});
|
||||
|
||||
describe('printVersion', () => {
|
||||
it('call docker version', async () => {
|
||||
const execSpy = jest.spyOn(Exec, 'exec');
|
||||
const execSpy = jest.spyOn(Docker, 'exec');
|
||||
await Docker.printVersion().catch(() => {
|
||||
// noop
|
||||
});
|
||||
expect(execSpy).toHaveBeenCalledWith(`docker`, ['version']);
|
||||
expect(execSpy).toHaveBeenCalledTimes(1);
|
||||
const callfunc = execSpy.mock.calls[0];
|
||||
if (callfunc && callfunc[1]) {
|
||||
// we don't want to check env opt
|
||||
callfunc[1].env = undefined;
|
||||
}
|
||||
expect(callfunc).toEqual([['version']]);
|
||||
});
|
||||
});
|
||||
|
||||
describe('printInfo', () => {
|
||||
it('call docker info', async () => {
|
||||
const execSpy = jest.spyOn(Exec, 'exec');
|
||||
const execSpy = jest.spyOn(Docker, 'exec');
|
||||
await Docker.printInfo().catch(() => {
|
||||
// noop
|
||||
});
|
||||
expect(execSpy).toHaveBeenCalledWith(`docker`, ['info']);
|
||||
expect(execSpy).toHaveBeenCalledTimes(1);
|
||||
const callfunc = execSpy.mock.calls[0];
|
||||
if (callfunc && callfunc[1]) {
|
||||
// we don't want to check env opt
|
||||
callfunc[1].env = undefined;
|
||||
}
|
||||
expect(callfunc).toEqual([['info']]);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -295,40 +295,3 @@ maybe('writeBuildSummary', () => {
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
maybe('annotateBuildWarnings', () => {
|
||||
it('annoate lint issues', async () => {
|
||||
const buildx = new Buildx();
|
||||
const build = new Build({buildx: buildx});
|
||||
|
||||
fs.mkdirSync(tmpDir, {recursive: true});
|
||||
await expect(
|
||||
(async () => {
|
||||
// prettier-ignore
|
||||
const buildCmd = await buildx.getCommand([
|
||||
'--builder', process.env.CTN_BUILDER_NAME ?? 'default',
|
||||
'build',
|
||||
'-f', path.join(fixturesDir, 'lint.Dockerfile'),
|
||||
fixturesDir,
|
||||
'--metadata-file', build.getMetadataFilePath()
|
||||
]);
|
||||
await Exec.exec(buildCmd.command, buildCmd.args, {
|
||||
env: Object.assign({}, process.env, {
|
||||
BUILDX_METADATA_WARNINGS: 'true'
|
||||
}) as {
|
||||
[key: string]: string;
|
||||
}
|
||||
});
|
||||
})()
|
||||
).resolves.not.toThrow();
|
||||
|
||||
const metadata = build.resolveMetadata();
|
||||
expect(metadata).toBeDefined();
|
||||
const buildRef = build.resolveRef(metadata);
|
||||
expect(buildRef).toBeDefined();
|
||||
const buildWarnings = build.resolveWarnings(metadata);
|
||||
expect(buildWarnings).toBeDefined();
|
||||
|
||||
await GitHub.annotateBuildWarnings(path.join(fixturesDir, 'lint.Dockerfile'), buildWarnings);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -416,6 +416,34 @@ lines`;
|
||||
});
|
||||
});
|
||||
|
||||
describe('isPathRelativeTo', () => {
|
||||
it('should return true for a child path directly inside the parent path', () => {
|
||||
const parentPath = '/home/user/projects';
|
||||
const childPath = '/home/user/projects/subproject';
|
||||
expect(Util.isPathRelativeTo(parentPath, childPath)).toBe(true);
|
||||
});
|
||||
it('should return true for a deeply nested child path inside the parent path', () => {
|
||||
const parentPath = '/home/user';
|
||||
const childPath = '/home/user/projects/subproject/module';
|
||||
expect(Util.isPathRelativeTo(parentPath, childPath)).toBe(true);
|
||||
});
|
||||
it('should return false for a child path outside the parent path', () => {
|
||||
const parentPath = '/home/user/projects';
|
||||
const childPath = '/home/user/otherprojects/subproject';
|
||||
expect(Util.isPathRelativeTo(parentPath, childPath)).toBe(false);
|
||||
});
|
||||
it('should return true for a child path specified with relative segments', () => {
|
||||
const parentPath = '/home/user/projects';
|
||||
const childPath = '/home/user/projects/../projects/subproject';
|
||||
expect(Util.isPathRelativeTo(parentPath, childPath)).toBe(true);
|
||||
});
|
||||
it('should return false when the child path is actually a parent path', () => {
|
||||
const parentPath = '/home/user/projects/subproject';
|
||||
const childPath = '/home/user/projects';
|
||||
expect(Util.isPathRelativeTo(parentPath, childPath)).toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
// See: https://github.com/actions/toolkit/blob/a1b068ec31a042ff1e10a522d8fdf0b8869d53ca/packages/core/src/core.ts#L89
|
||||
function getInputName(name: string): string {
|
||||
return `INPUT_${name.replace(/ /g, '_').toUpperCase()}`;
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
ARG NODE_VERSION=20
|
||||
ARG DOCKER_VERSION=26.0.2
|
||||
ARG BUILDX_VERSION=0.16.0
|
||||
ARG BUILDX_VERSION=0.16.2
|
||||
|
||||
FROM node:${NODE_VERSION}-alpine AS base
|
||||
RUN apk add --no-cache cpio findutils git
|
||||
|
||||
@@ -63,7 +63,7 @@
|
||||
"he": "^1.2.0",
|
||||
"js-yaml": "^4.1.0",
|
||||
"jwt-decode": "^4.0.0",
|
||||
"semver": "^7.6.2",
|
||||
"semver": "^7.6.3",
|
||||
"tar-stream": "^3.1.7",
|
||||
"tmp": "^0.2.3"
|
||||
},
|
||||
|
||||
@@ -19,8 +19,8 @@ import * as semver from 'semver';
|
||||
|
||||
import {Buildx} from '../buildx/buildx';
|
||||
import {Builder} from '../buildx/builder';
|
||||
import {Docker} from '../docker/docker';
|
||||
import {Config} from './config';
|
||||
import {Exec} from '../exec';
|
||||
|
||||
import {BuilderInfo, NodeInfo} from '../types/buildx/builder';
|
||||
|
||||
@@ -51,13 +51,13 @@ export class BuildKit {
|
||||
|
||||
private async getVersionWithinImage(nodeName: string): Promise<string> {
|
||||
core.debug(`BuildKit.getVersionWithinImage nodeName: ${nodeName}`);
|
||||
return Exec.getExecOutput(`docker`, ['inspect', '--format', '{{.Config.Image}}', `${Buildx.containerNamePrefix}${nodeName}`], {
|
||||
return Docker.getExecOutput(['inspect', '--format', '{{.Config.Image}}', `${Buildx.containerNamePrefix}${nodeName}`], {
|
||||
ignoreReturnCode: true,
|
||||
silent: true
|
||||
}).then(bkitimage => {
|
||||
if (bkitimage.exitCode == 0 && bkitimage.stdout.length > 0) {
|
||||
core.debug(`BuildKit.getVersionWithinImage image: ${bkitimage.stdout.trim()}`);
|
||||
return Exec.getExecOutput(`docker`, ['run', '--rm', bkitimage.stdout.trim(), '--version'], {
|
||||
return Docker.getExecOutput(['run', '--rm', bkitimage.stdout.trim(), '--version'], {
|
||||
ignoreReturnCode: true,
|
||||
silent: true
|
||||
}).then(bkitversion => {
|
||||
|
||||
@@ -19,10 +19,16 @@ import path from 'path';
|
||||
import * as core from '@actions/core';
|
||||
import * as semver from 'semver';
|
||||
|
||||
import {Git} from '../buildkit/git';
|
||||
import {Docker} from '../docker/docker';
|
||||
import {GitHub} from '../github';
|
||||
import {Exec} from '../exec';
|
||||
import {Util} from '../util';
|
||||
|
||||
import {VertexWarning} from '../types/buildkit/client';
|
||||
import {GitURL} from '../types/buildkit/git';
|
||||
import {Cert, LocalRefsOpts, LocalRefsResponse, LocalState} from '../types/buildx/buildx';
|
||||
import {GitHubAnnotation} from '../types/github';
|
||||
|
||||
export interface BuildxOpts {
|
||||
standalone?: boolean;
|
||||
@@ -266,4 +272,151 @@ export class Buildx {
|
||||
|
||||
return refs;
|
||||
}
|
||||
|
||||
public static async convertWarningsToGitHubAnnotations(warnings: Array<VertexWarning>, buildRefs: Array<string>, refsDir?: string): Promise<Array<GitHubAnnotation> | undefined> {
|
||||
if (warnings.length === 0) {
|
||||
return;
|
||||
}
|
||||
const fnGitURL = function (inp: string): GitURL | undefined {
|
||||
try {
|
||||
return Git.parseURL(inp);
|
||||
} catch (e) {
|
||||
// noop
|
||||
}
|
||||
};
|
||||
const fnLocalState = function (ref: string): LocalState | undefined {
|
||||
try {
|
||||
return Buildx.localState(ref, refsDir);
|
||||
} catch (e) {
|
||||
core.debug(`Buildx.convertWarningsToGitHubAnnotations(${ref}): local state not found: ${e.message}`);
|
||||
}
|
||||
};
|
||||
|
||||
interface Dockerfile {
|
||||
path: string;
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
content?: any;
|
||||
remote?: boolean;
|
||||
}
|
||||
|
||||
const dockerfiles: Array<Dockerfile> = [];
|
||||
for (const ref of buildRefs) {
|
||||
const ls = fnLocalState(ref);
|
||||
if (!ls) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (ls.DockerfilePath == '-') {
|
||||
// exclude dockerfile from stdin
|
||||
core.debug(`Buildx.convertWarningsToGitHubAnnotations(${ref}): skipping stdin Dockerfile`);
|
||||
continue;
|
||||
} else if (ls.DockerfilePath == '') {
|
||||
ls.DockerfilePath = 'Dockerfile';
|
||||
}
|
||||
|
||||
const gitURL = fnGitURL(ls.LocalPath);
|
||||
if (gitURL) {
|
||||
core.debug(`Buildx.convertWarningsToGitHubAnnotations(${ref}): git context detected: ${ls.LocalPath}`);
|
||||
const remoteHost = gitURL.host.replace(/:.*/, '');
|
||||
if (remoteHost !== 'github.com' && !remoteHost.endsWith('.ghe.com')) {
|
||||
// we only support running actions on GitHub for now
|
||||
// we might add support for GitLab in the future
|
||||
core.debug(`Buildx.convertWarningsToGitHubAnnotations(${ref}): not a GitHub repo: ${remoteHost}`);
|
||||
continue;
|
||||
}
|
||||
// if repository matches then we can link to the Dockerfile
|
||||
const remoteRepo = gitURL.path.replace(/^\//, '').replace(/\.git$/, '');
|
||||
if (remoteRepo !== GitHub.repository) {
|
||||
core.debug(`Buildx.convertWarningsToGitHubAnnotations(${ref}): not same GitHub repo: ${remoteRepo} != ${GitHub.repository}`);
|
||||
continue;
|
||||
}
|
||||
dockerfiles.push({
|
||||
path: ls.DockerfilePath, // dockerfile path is always relative for a git context
|
||||
remote: true
|
||||
});
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!fs.existsSync(ls.DockerfilePath)) {
|
||||
core.debug(`Buildx.convertWarningsToGitHubAnnotations: Dockerfile not found from localstate ref ${ref}: ${ls.DockerfilePath}`);
|
||||
continue;
|
||||
}
|
||||
|
||||
const workspaceDir = GitHub.workspace;
|
||||
// only treat dockerfile path relative to GitHub actions workspace dir
|
||||
if (Util.isPathRelativeTo(workspaceDir, ls.DockerfilePath)) {
|
||||
dockerfiles.push({
|
||||
path: path.relative(workspaceDir, ls.DockerfilePath),
|
||||
content: btoa(fs.readFileSync(ls.DockerfilePath, {encoding: 'utf-8'}))
|
||||
});
|
||||
} else {
|
||||
core.debug(`Buildx.convertWarningsToGitHubAnnotations: skipping Dockerfile outside of workspace: ${ls.DockerfilePath}`);
|
||||
}
|
||||
}
|
||||
|
||||
if (dockerfiles.length === 0) {
|
||||
core.debug(`Buildx.convertWarningsToGitHubAnnotations: no Dockerfiles found`);
|
||||
return;
|
||||
}
|
||||
core.debug(`Buildx.convertWarningsToGitHubAnnotations: found ${dockerfiles.length} Dockerfiles: ${JSON.stringify(dockerfiles, null, 2)}`);
|
||||
|
||||
const annotations: Array<GitHubAnnotation> = [];
|
||||
for (const warning of warnings) {
|
||||
if (!warning.detail || !warning.short) {
|
||||
core.debug(`Buildx.convertWarningsToGitHubAnnotations: skipping warning without detail or short`);
|
||||
continue;
|
||||
}
|
||||
|
||||
const warningSourceFilename = warning.sourceInfo?.filename;
|
||||
const warningSourceData = warning.sourceInfo?.data;
|
||||
if (!warningSourceFilename || !warningSourceData) {
|
||||
core.debug(`Buildx.convertWarningsToGitHubAnnotations: skipping warning without source info filename or data`);
|
||||
continue;
|
||||
}
|
||||
|
||||
const title = warning.detail.map(encoded => atob(encoded)).join(' ');
|
||||
let message = atob(warning.short).replace(/\s\(line \d+\)$/, '');
|
||||
if (warning.url) {
|
||||
// https://github.com/docker/buildx/blob/d8c9ebde1fdcf659f1fa3efa6ccc27a28b0f1564/commands/build.go#L854
|
||||
message += `\nMore info: ${warning.url}`;
|
||||
}
|
||||
|
||||
// GitHub's annotations don't clearly show ranges of lines, so we'll just
|
||||
// show the first line: https://github.com/orgs/community/discussions/129899
|
||||
const startLine = warning.range && warning.range.length > 0 ? warning.range[0]?.start.line : undefined;
|
||||
|
||||
// TODO: When GitHub's annotations support showing ranges properly, we can use this code
|
||||
// let startLine: number | undefined, endLine: number | undefined;
|
||||
// for (const range of warning.range ?? []) {
|
||||
// if (range.start.line && (!startLine || range.start.line < startLine)) {
|
||||
// startLine = range.start.line;
|
||||
// }
|
||||
// if (range.end.line && (!endLine || range.end.line > endLine)) {
|
||||
// endLine = range.end.line;
|
||||
// }
|
||||
// }
|
||||
|
||||
let annotated = false;
|
||||
for (const dockerfile of dockerfiles) {
|
||||
// a valid dockerfile path and content is required to match the warning
|
||||
// source info or always assume it's valid if this is a remote git
|
||||
// context as we can't read the content of the Dockerfile in this case.
|
||||
if (dockerfile.remote || (dockerfile.path.endsWith(warningSourceFilename) && dockerfile.content === warningSourceData)) {
|
||||
annotations.push({
|
||||
title: title,
|
||||
message: message,
|
||||
file: dockerfile.path,
|
||||
startLine: startLine
|
||||
});
|
||||
annotated = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!annotated) {
|
||||
core.debug(`Buildx.convertWarningsToGitHubAnnotations: skipping warning without matching Dockerfile ${warningSourceFilename}: ${title}`);
|
||||
}
|
||||
}
|
||||
|
||||
return annotations;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -50,6 +50,9 @@ export class History {
|
||||
if (!(await Docker.isAvailable())) {
|
||||
throw new Error('Docker is required to export a build record');
|
||||
}
|
||||
if (!(await Docker.isDaemonRunning())) {
|
||||
throw new Error('Docker daemon needs to be running to export a build record');
|
||||
}
|
||||
if (!(await this.buildx.versionSatisfies('>=0.13.0'))) {
|
||||
throw new Error('Buildx >= 0.13.0 is required to export a build record');
|
||||
}
|
||||
@@ -137,7 +140,11 @@ export class History {
|
||||
]
|
||||
core.info(`[command]docker ${dockerRunArgs.join(' ')}`);
|
||||
dockerRunProc = spawn('docker', dockerRunArgs, {
|
||||
stdio: ['pipe', 'pipe', 'inherit']
|
||||
stdio: ['pipe', 'pipe', 'inherit'],
|
||||
env: {
|
||||
...process.env,
|
||||
DOCKER_CONTENT_TRUST: 'false'
|
||||
}
|
||||
});
|
||||
fs.createReadStream(buildxOutFifoPath).pipe(dockerRunProc.stdin);
|
||||
dockerRunProc.stdout.pipe(fs.createWriteStream(buildxInFifoPath));
|
||||
|
||||
@@ -18,6 +18,7 @@ import fs from 'fs';
|
||||
import os from 'os';
|
||||
import path from 'path';
|
||||
import * as core from '@actions/core';
|
||||
import {ExecOptions, ExecOutput} from '@actions/exec';
|
||||
import * as io from '@actions/io';
|
||||
|
||||
import {Context} from '../context';
|
||||
@@ -53,12 +54,47 @@ export class Docker {
|
||||
});
|
||||
}
|
||||
|
||||
public static async isDaemonRunning(): Promise<boolean> {
|
||||
try {
|
||||
await Docker.getExecOutput([`version`], {
|
||||
silent: true
|
||||
});
|
||||
return true;
|
||||
} catch (e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public static async exec(args?: string[], options?: ExecOptions): Promise<number> {
|
||||
return Exec.exec('docker', args, Docker.execOptions(options));
|
||||
}
|
||||
|
||||
public static async getExecOutput(args?: string[], options?: ExecOptions): Promise<ExecOutput> {
|
||||
return Exec.getExecOutput('docker', args, Docker.execOptions(options));
|
||||
}
|
||||
|
||||
private static execOptions(options?: ExecOptions): ExecOptions {
|
||||
if (!options) {
|
||||
options = {};
|
||||
}
|
||||
if (!options.env) {
|
||||
options.env = Object.assign({}, process.env, {
|
||||
DOCKER_CONTENT_TRUST: 'false'
|
||||
}) as {
|
||||
[key: string]: string;
|
||||
};
|
||||
} else {
|
||||
options.env.DOCKER_CONTENT_TRUST = 'false';
|
||||
}
|
||||
return options;
|
||||
}
|
||||
|
||||
public static async context(name?: string): Promise<string> {
|
||||
const args = ['context', 'inspect', '--format', '{{.Name}}'];
|
||||
if (name) {
|
||||
args.push(name);
|
||||
}
|
||||
return await Exec.getExecOutput(`docker`, args, {
|
||||
return await Docker.getExecOutput(args, {
|
||||
ignoreReturnCode: true,
|
||||
silent: true
|
||||
}).then(res => {
|
||||
@@ -74,7 +110,7 @@ export class Docker {
|
||||
if (name) {
|
||||
args.push(name);
|
||||
}
|
||||
return await Exec.getExecOutput(`docker`, args, {
|
||||
return await Docker.getExecOutput(args, {
|
||||
ignoreReturnCode: true,
|
||||
silent: true
|
||||
}).then(res => {
|
||||
@@ -86,11 +122,11 @@ export class Docker {
|
||||
}
|
||||
|
||||
public static async printVersion(): Promise<void> {
|
||||
await Exec.exec('docker', ['version']);
|
||||
await Docker.exec(['version']);
|
||||
}
|
||||
|
||||
public static async printInfo(): Promise<void> {
|
||||
await Exec.exec('docker', ['info']);
|
||||
await Docker.exec(['info']);
|
||||
}
|
||||
|
||||
public static parseRepoTag(image: string): {repository: string; tag: string} {
|
||||
@@ -138,7 +174,7 @@ export class Docker {
|
||||
cacheFoundPath = await imageCache.find();
|
||||
if (cacheFoundPath) {
|
||||
core.info(`Image found from cache in ${cacheFoundPath}`);
|
||||
await Exec.getExecOutput(`docker`, ['load', '-i', cacheFoundPath], {
|
||||
await Docker.getExecOutput(['load', '-i', cacheFoundPath], {
|
||||
ignoreReturnCode: true
|
||||
}).then(res => {
|
||||
if (res.stderr.length > 0 && res.exitCode != 0) {
|
||||
@@ -149,7 +185,7 @@ export class Docker {
|
||||
}
|
||||
|
||||
let pulled = true;
|
||||
await Exec.getExecOutput(`docker`, ['pull', image], {
|
||||
await Docker.getExecOutput(['pull', image], {
|
||||
ignoreReturnCode: true
|
||||
}).then(res => {
|
||||
if (res.stderr.length > 0 && res.exitCode != 0) {
|
||||
@@ -165,7 +201,7 @@ export class Docker {
|
||||
|
||||
if (cache && pulled) {
|
||||
const imageTarPath = path.join(Context.tmpDir(), `${Util.hash(image)}.tar`);
|
||||
await Exec.getExecOutput(`docker`, ['save', '-o', imageTarPath, image], {
|
||||
await Docker.getExecOutput(['save', '-o', imageTarPath, image], {
|
||||
ignoreReturnCode: true
|
||||
}).then(async res => {
|
||||
if (res.stderr.length > 0 && res.exitCode != 0) {
|
||||
|
||||
@@ -28,6 +28,7 @@ import * as io from '@actions/io';
|
||||
import * as tc from '@actions/tool-cache';
|
||||
|
||||
import {Context} from '../context';
|
||||
import {Docker} from './docker';
|
||||
import {Exec} from '../exec';
|
||||
import {Util} from '../util';
|
||||
import {limaYamlData, dockerServiceLogsPs1, setupDockerWinPs1} from './assets';
|
||||
@@ -219,8 +220,8 @@ export class Install {
|
||||
});
|
||||
|
||||
await core.group('Create Docker context', async () => {
|
||||
await Exec.exec('docker', ['context', 'create', this.contextName, '--docker', `host=${dockerHost}`]);
|
||||
await Exec.exec('docker', ['context', 'use', this.contextName]);
|
||||
await Docker.exec(['context', 'create', this.contextName, '--docker', `host=${dockerHost}`]);
|
||||
await Docker.exec(['context', 'use', this.contextName]);
|
||||
});
|
||||
|
||||
return dockerHost;
|
||||
@@ -288,7 +289,8 @@ EOF`,
|
||||
await Exec.getExecOutput(`docker version`, undefined, {
|
||||
silent: true,
|
||||
env: Object.assign({}, envs, {
|
||||
DOCKER_HOST: dockerHost
|
||||
DOCKER_HOST: dockerHost,
|
||||
DOCKER_CONTENT_TRUST: 'false'
|
||||
}) as {
|
||||
[key: string]: string;
|
||||
}
|
||||
@@ -309,8 +311,8 @@ EOF`,
|
||||
});
|
||||
|
||||
await core.group('Create Docker context', async () => {
|
||||
await Exec.exec('docker', ['context', 'create', this.contextName, '--docker', `host=${dockerHost}`]);
|
||||
await Exec.exec('docker', ['context', 'use', this.contextName]);
|
||||
await Docker.exec(['context', 'create', this.contextName, '--docker', `host=${dockerHost}`]);
|
||||
await Docker.exec(['context', 'use', this.contextName]);
|
||||
});
|
||||
|
||||
return dockerHost;
|
||||
@@ -352,8 +354,8 @@ EOF`,
|
||||
});
|
||||
|
||||
await core.group('Create Docker context', async () => {
|
||||
await Exec.exec('docker', ['context', 'create', this.contextName, '--docker', `host=${dockerHost}`]);
|
||||
await Exec.exec('docker', ['context', 'use', this.contextName]);
|
||||
await Docker.exec(['context', 'create', this.contextName, '--docker', `host=${dockerHost}`]);
|
||||
await Docker.exec(['context', 'use', this.contextName]);
|
||||
});
|
||||
|
||||
return dockerHost;
|
||||
@@ -395,7 +397,7 @@ EOF`,
|
||||
await Exec.exec('limactl', ['delete', '--tty=false', this.limaInstanceName, '--force']);
|
||||
});
|
||||
await core.group('Removing Docker context', async () => {
|
||||
await Exec.exec('docker', ['context', 'rm', '-f', this.contextName]);
|
||||
await Docker.exec(['context', 'rm', '-f', this.contextName]);
|
||||
});
|
||||
await core.group(`Cleaning up runDir`, async () => {
|
||||
await Exec.exec('sudo', ['rm', '-rf', this.runDir]);
|
||||
@@ -411,7 +413,7 @@ EOF`,
|
||||
await Util.sleep(5);
|
||||
});
|
||||
await core.group('Removing Docker context', async () => {
|
||||
await Exec.exec('docker', ['context', 'rm', '-f', this.contextName]);
|
||||
await Docker.exec(['context', 'rm', '-f', this.contextName]);
|
||||
});
|
||||
await core.group(`Cleaning up runDir`, async () => {
|
||||
await Exec.exec('sudo', ['rm', '-rf', this.runDir], {
|
||||
@@ -427,7 +429,7 @@ EOF`,
|
||||
await Exec.exec(logCmd.command, logCmd.args);
|
||||
});
|
||||
await core.group('Removing Docker context', async () => {
|
||||
await Exec.exec('docker', ['context', 'rm', '-f', this.contextName]);
|
||||
await Docker.exec(['context', 'rm', '-f', this.contextName]);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -37,7 +37,6 @@ import {jwtDecode, JwtPayload} from 'jwt-decode';
|
||||
|
||||
import {Util} from './util';
|
||||
|
||||
import {VertexWarning} from './types/buildkit/client';
|
||||
import {BuildSummaryOpts, GitHubActionsRuntimeToken, GitHubActionsRuntimeTokenAC, GitHubRepo, UploadArtifactOpts, UploadArtifactResponse} from './types/github';
|
||||
|
||||
export interface GitHubOpts {
|
||||
@@ -77,6 +76,10 @@ export class GitHub {
|
||||
return `${github.context.repo.owner}/${github.context.repo.repo}`;
|
||||
}
|
||||
|
||||
static get workspace(): string {
|
||||
return process.env.GITHUB_WORKSPACE || process.cwd();
|
||||
}
|
||||
|
||||
static get runId(): number {
|
||||
return process.env.GITHUB_RUN_ID ? +process.env.GITHUB_RUN_ID : github.context.runId;
|
||||
}
|
||||
@@ -342,39 +345,4 @@ export class GitHub {
|
||||
core.info(`Writing summary`);
|
||||
await sum.addSeparator().write();
|
||||
}
|
||||
|
||||
public static async annotateBuildWarnings(source: string, warnings?: Array<VertexWarning>): Promise<void> {
|
||||
(warnings ?? []).forEach(warning => {
|
||||
if (!warning.detail || !warning.short) {
|
||||
return;
|
||||
}
|
||||
const title = warning.detail.map(encoded => atob(encoded)).join(' ');
|
||||
let message = atob(warning.short).replace(/\s\(line \d+\)$/, '');
|
||||
if (warning.url) {
|
||||
// https://github.com/docker/buildx/blob/d8c9ebde1fdcf659f1fa3efa6ccc27a28b0f1564/commands/build.go#L854
|
||||
message += `\nMore info: ${warning.url}`;
|
||||
}
|
||||
|
||||
// GitHub annotations don't clearly show ranges of lines, so we'll just
|
||||
// show the first line
|
||||
const startLine = warning.range && warning.range.length > 0 ? warning.range[0]?.start.line : undefined;
|
||||
|
||||
// TODO: When GitHub annotations support showing ranges properly, we can use this code
|
||||
// let startLine: number | undefined, endLine: number | undefined;
|
||||
// for (const range of warning.range ?? []) {
|
||||
// if (range.start.line && (!startLine || range.start.line < startLine)) {
|
||||
// startLine = range.start.line;
|
||||
// }
|
||||
// if (range.end.line && (!endLine || range.end.line > endLine)) {
|
||||
// endLine = range.end.line;
|
||||
// }
|
||||
// }
|
||||
|
||||
core.warning(message, {
|
||||
title: title,
|
||||
file: source,
|
||||
startLine: startLine
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import {AnnotationProperties} from '@actions/core';
|
||||
import {components as OctoOpenApiTypes} from '@octokit/openapi-types';
|
||||
import {JwtPayload} from 'jwt-decode';
|
||||
|
||||
@@ -38,6 +39,10 @@ export interface GitHubActionsRuntimeTokenAC {
|
||||
Permission: number;
|
||||
}
|
||||
|
||||
export interface GitHubAnnotation extends AnnotationProperties {
|
||||
message: string;
|
||||
}
|
||||
|
||||
export interface UploadArtifactOpts {
|
||||
filename: string;
|
||||
mimeType?: string;
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
|
||||
import crypto from 'crypto';
|
||||
import fs from 'fs';
|
||||
import path from 'path';
|
||||
import * as core from '@actions/core';
|
||||
import * as io from '@actions/io';
|
||||
import {parse} from 'csv-parse/sync';
|
||||
@@ -189,4 +190,10 @@ export class Util {
|
||||
public static countLines(input: string): number {
|
||||
return input.split(/\r\n|\r|\n/).length;
|
||||
}
|
||||
|
||||
public static isPathRelativeTo(parentPath: string, childPath: string): boolean {
|
||||
const rpp = path.resolve(parentPath);
|
||||
const rcp = path.resolve(childPath);
|
||||
return rcp.startsWith(rpp.endsWith(path.sep) ? rpp : `${rpp}${path.sep}`);
|
||||
}
|
||||
}
|
||||
|
||||
10
yarn.lock
10
yarn.lock
@@ -1136,7 +1136,7 @@ __metadata:
|
||||
jwt-decode: ^4.0.0
|
||||
prettier: ^3.2.5
|
||||
rimraf: ^5.0.5
|
||||
semver: ^7.6.2
|
||||
semver: ^7.6.3
|
||||
tar-stream: ^3.1.7
|
||||
tmp: ^0.2.3
|
||||
ts-jest: ^29.1.2
|
||||
@@ -7406,12 +7406,12 @@ __metadata:
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"semver@npm:^7.6.2":
|
||||
version: 7.6.2
|
||||
resolution: "semver@npm:7.6.2"
|
||||
"semver@npm:^7.6.3":
|
||||
version: 7.6.3
|
||||
resolution: "semver@npm:7.6.3"
|
||||
bin:
|
||||
semver: bin/semver.js
|
||||
checksum: 40f6a95101e8d854357a644da1b8dd9d93ce786d5c6a77227bc69dbb17bea83d0d1d1d7c4cd5920a6df909f48e8bd8a5909869535007f90278289f2451d0292d
|
||||
checksum: 4110ec5d015c9438f322257b1c51fe30276e5f766a3f64c09edd1d7ea7118ecbc3f379f3b69032bacf13116dc7abc4ad8ce0d7e2bd642e26b0d271b56b61a7d8
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
|
||||
Reference in New Issue
Block a user