Compare commits
38 Commits
v0.1.0-rc.
...
v0.1.0
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
16bbae82de | ||
|
|
8b597ca8bc | ||
|
|
dc9c9bc2b7 | ||
|
|
63659873d5 | ||
|
|
6327a9b5dc | ||
|
|
50b16df20c | ||
|
|
0b1e18cfc2 | ||
|
|
741d2e1319 | ||
|
|
9e10ac6818 | ||
|
|
65f12dcfd0 | ||
|
|
46da20f01d | ||
|
|
0af3fda4f0 | ||
|
|
6179a5a445 | ||
|
|
26d9901f07 | ||
|
|
462c95e83d | ||
|
|
e185293749 | ||
|
|
2d1ce9a223 | ||
|
|
2d105f7337 | ||
|
|
5df47fe964 | ||
|
|
61527248dd | ||
|
|
210b7421e4 | ||
|
|
e9aa8365e3 | ||
|
|
85557d0e0d | ||
|
|
a7448298e0 | ||
|
|
d0929eeb16 | ||
|
|
da9600bbef | ||
|
|
70fba4e078 | ||
|
|
a89868cdc5 | ||
|
|
49bde5a54a | ||
|
|
4fcbf75fc4 | ||
|
|
314f8f431e | ||
|
|
7fb0476dc8 | ||
|
|
9b9ff70b75 | ||
|
|
e7eee6e401 | ||
|
|
b2fd32e0ef | ||
|
|
417136db1e | ||
|
|
e033e82024 | ||
|
|
b3328f5ec4 |
30
.github/docker-releases.json
vendored
30
.github/docker-releases.json
vendored
@@ -1,8 +1,32 @@
|
||||
{
|
||||
"latest": {
|
||||
"id": 91964526,
|
||||
"tag_name": "v23.0.1",
|
||||
"html_url": "https://github.com/moby/moby/releases/tag/v23.0.1",
|
||||
"id": 98122882,
|
||||
"tag_name": "v23.0.3",
|
||||
"html_url": "https://github.com/moby/moby/releases/tag/v23.0.3",
|
||||
"assets": []
|
||||
},
|
||||
"v23.0.3": {
|
||||
"id": 98122882,
|
||||
"tag_name": "v23.0.3",
|
||||
"html_url": "https://github.com/moby/moby/releases/tag/v23.0.3",
|
||||
"assets": []
|
||||
},
|
||||
"v20.10.24": {
|
||||
"id": 98096018,
|
||||
"tag_name": "v20.10.24",
|
||||
"html_url": "https://github.com/moby/moby/releases/tag/v20.10.24",
|
||||
"assets": []
|
||||
},
|
||||
"v24.0.0-beta.1": {
|
||||
"id": 97703002,
|
||||
"tag_name": "v24.0.0-beta.1",
|
||||
"html_url": "https://github.com/moby/moby/releases/tag/v24.0.0-beta.1",
|
||||
"assets": []
|
||||
},
|
||||
"v23.0.2": {
|
||||
"id": 97163508,
|
||||
"tag_name": "v23.0.2",
|
||||
"html_url": "https://github.com/moby/moby/releases/tag/v23.0.2",
|
||||
"assets": []
|
||||
},
|
||||
"v23.0.1": {
|
||||
|
||||
4
.github/workflows/build.yml
vendored
4
.github/workflows/build.yml
vendored
@@ -1,5 +1,9 @@
|
||||
name: build
|
||||
|
||||
concurrency:
|
||||
group: ${{ github.workflow }}-${{ github.ref }}
|
||||
cancel-in-progress: true
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
|
||||
2
.github/workflows/buildx-releases-json.yml
vendored
2
.github/workflows/buildx-releases-json.yml
vendored
@@ -45,7 +45,7 @@ jobs:
|
||||
git add -A .
|
||||
-
|
||||
name: Create PR
|
||||
uses: peter-evans/create-pull-request@2b011faafdcbc9ceb11414d64d0573f37c774b04
|
||||
uses: peter-evans/create-pull-request@5b4a9f6a9e2af26e5f02351490b90d01eb8ec1e5
|
||||
with:
|
||||
base: main
|
||||
branch: bot/buildx-releases-json
|
||||
|
||||
2
.github/workflows/docker-releases-json.yml
vendored
2
.github/workflows/docker-releases-json.yml
vendored
@@ -45,7 +45,7 @@ jobs:
|
||||
git add -A .
|
||||
-
|
||||
name: Create PR
|
||||
uses: peter-evans/create-pull-request@2b011faafdcbc9ceb11414d64d0573f37c774b04
|
||||
uses: peter-evans/create-pull-request@5b4a9f6a9e2af26e5f02351490b90d01eb8ec1e5
|
||||
with:
|
||||
base: main
|
||||
branch: bot/docker-releases-json
|
||||
|
||||
45
.github/workflows/e2e.yml
vendored
45
.github/workflows/e2e.yml
vendored
@@ -1,45 +0,0 @@
|
||||
name: e2e
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
push:
|
||||
branches:
|
||||
- 'main'
|
||||
pull_request:
|
||||
paths-ignore:
|
||||
- '.github/*-releases.json'
|
||||
|
||||
jobs:
|
||||
test:
|
||||
runs-on: ${{ matrix.os }}
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
os:
|
||||
- ubuntu-latest
|
||||
- macos-latest
|
||||
- windows-latest
|
||||
steps:
|
||||
-
|
||||
name: Checkout
|
||||
uses: actions/checkout@v3
|
||||
-
|
||||
name: Setup Node
|
||||
uses: actions/setup-node@v3
|
||||
with:
|
||||
node-version: 16
|
||||
cache: 'yarn'
|
||||
-
|
||||
name: Install
|
||||
run: yarn install
|
||||
-
|
||||
name: Test
|
||||
run: yarn test-coverage:e2e --coverageDirectory=./coverage
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
-
|
||||
name: Upload coverage
|
||||
uses: codecov/codecov-action@v3
|
||||
with:
|
||||
file: ./coverage/clover.xml
|
||||
flags: e2e
|
||||
4
.github/workflows/publish.yml
vendored
4
.github/workflows/publish.yml
vendored
@@ -1,5 +1,9 @@
|
||||
name: publish
|
||||
|
||||
concurrency:
|
||||
group: ${{ github.workflow }}-${{ github.ref }}
|
||||
cancel-in-progress: true
|
||||
|
||||
on:
|
||||
push:
|
||||
tags:
|
||||
|
||||
97
.github/workflows/test.yml
vendored
97
.github/workflows/test.yml
vendored
@@ -1,6 +1,11 @@
|
||||
name: test
|
||||
|
||||
concurrency:
|
||||
group: ${{ github.workflow }}-${{ github.ref }}
|
||||
cancel-in-progress: true
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
push:
|
||||
branches:
|
||||
- 'main'
|
||||
@@ -9,25 +14,6 @@ on:
|
||||
- '.github/*-releases.json'
|
||||
|
||||
jobs:
|
||||
validate:
|
||||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
target:
|
||||
- lint
|
||||
- vendor-validate
|
||||
- license-validate
|
||||
steps:
|
||||
-
|
||||
name: Checkout
|
||||
uses: actions/checkout@v3
|
||||
-
|
||||
name: Validate
|
||||
uses: docker/bake-action@v2
|
||||
with:
|
||||
targets: ${{ matrix.target }}
|
||||
|
||||
test:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
@@ -47,3 +33,76 @@ jobs:
|
||||
with:
|
||||
file: ./coverage/clover.xml
|
||||
flags: unit
|
||||
|
||||
prepare-itg:
|
||||
runs-on: ubuntu-latest
|
||||
outputs:
|
||||
matrix: ${{ steps.tests.outputs.matrix }}
|
||||
steps:
|
||||
-
|
||||
name: Checkout
|
||||
uses: actions/checkout@v3
|
||||
-
|
||||
name: Setup Node
|
||||
uses: actions/setup-node@v3
|
||||
with:
|
||||
node-version: 16
|
||||
cache: 'yarn'
|
||||
-
|
||||
name: Install
|
||||
run: yarn install
|
||||
-
|
||||
name: Create matrix
|
||||
id: tests
|
||||
run: |
|
||||
declare -a tests
|
||||
for test in $(yarn run test:itg-list); do
|
||||
tests+=("${test#$(pwd)/__tests__/}")
|
||||
done
|
||||
echo "matrix=$(echo ${tests[@]} | jq -cR 'split(" ")')" >>${GITHUB_OUTPUT}
|
||||
-
|
||||
name: Show matrix
|
||||
run: |
|
||||
echo ${{ steps.tests.outputs.matrix }}
|
||||
|
||||
test-itg:
|
||||
runs-on: ${{ matrix.os }}
|
||||
needs:
|
||||
- prepare-itg
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
test: ${{ fromJson(needs.prepare-itg.outputs.matrix) }}
|
||||
os:
|
||||
- ubuntu-latest
|
||||
- macos-latest
|
||||
- windows-latest
|
||||
exclude:
|
||||
- os: macos-latest
|
||||
test: buildx/bake.test.itg.ts
|
||||
- os: windows-latest
|
||||
test: buildx/bake.test.itg.ts
|
||||
steps:
|
||||
-
|
||||
name: Checkout
|
||||
uses: actions/checkout@v3
|
||||
-
|
||||
name: Setup Node
|
||||
uses: actions/setup-node@v3
|
||||
with:
|
||||
node-version: 16
|
||||
cache: 'yarn'
|
||||
-
|
||||
name: Install
|
||||
run: yarn install
|
||||
-
|
||||
name: Test
|
||||
run: yarn test:itg-coverage --runTestsByPath __tests__/${{ matrix.test }} --coverageDirectory=./coverage
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
-
|
||||
name: Upload coverage
|
||||
uses: codecov/codecov-action@v3
|
||||
with:
|
||||
file: ./coverage/clover.xml
|
||||
flags: itg
|
||||
|
||||
47
.github/workflows/validate.yml
vendored
Normal file
47
.github/workflows/validate.yml
vendored
Normal file
@@ -0,0 +1,47 @@
|
||||
name: validate
|
||||
|
||||
concurrency:
|
||||
group: ${{ github.workflow }}-${{ github.ref }}
|
||||
cancel-in-progress: true
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
push:
|
||||
branches:
|
||||
- 'main'
|
||||
pull_request:
|
||||
paths-ignore:
|
||||
- '.github/*-releases.json'
|
||||
|
||||
jobs:
|
||||
prepare:
|
||||
runs-on: ubuntu-20.04
|
||||
outputs:
|
||||
targets: ${{ steps.targets.outputs.matrix }}
|
||||
steps:
|
||||
-
|
||||
name: Checkout
|
||||
uses: actions/checkout@v3
|
||||
-
|
||||
name: Matrix
|
||||
id: targets
|
||||
run: |
|
||||
echo "matrix=$(docker buildx bake validate --print | jq -cr '.group.validate.targets')" >> $GITHUB_OUTPUT
|
||||
|
||||
validate:
|
||||
runs-on: ubuntu-latest
|
||||
needs:
|
||||
- prepare
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
target: ${{ fromJson(needs.prepare.outputs.targets) }}
|
||||
steps:
|
||||
-
|
||||
name: Checkout
|
||||
uses: actions/checkout@v3
|
||||
-
|
||||
name: Validate
|
||||
uses: docker/bake-action@v2
|
||||
with:
|
||||
targets: ${{ matrix.target }}
|
||||
1
.github/workflows/virtual-env.yml
vendored
1
.github/workflows/virtual-env.yml
vendored
@@ -23,7 +23,6 @@ jobs:
|
||||
- ubuntu-latest
|
||||
- ubuntu-22.04
|
||||
- ubuntu-20.04
|
||||
- ubuntu-18.04
|
||||
steps:
|
||||
-
|
||||
name: File system
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
[](https://www.npmjs.com/package/@docker/actions-toolkit)
|
||||
[](https://github.com/docker/actions-toolkit/actions?workflow=build)
|
||||
[](https://github.com/docker/actions-toolkit/actions?workflow=test)
|
||||
[](https://github.com/docker/actions-toolkit/actions?workflow=e2e)
|
||||
[](https://github.com/docker/actions-toolkit/actions?workflow=validate)
|
||||
[](https://codecov.io/gh/docker/actions-toolkit)
|
||||
|
||||
# Actions Toolkit
|
||||
|
||||
@@ -59,7 +59,7 @@ describe('resolve', () => {
|
||||
`,
|
||||
null
|
||||
]
|
||||
])('given %p config', async (val, file, exValue, error: Error) => {
|
||||
])('given %p config', async (val: string, file: boolean, exValue: string, error: Error | null) => {
|
||||
try {
|
||||
const buildkit = new BuildKit();
|
||||
let config: string;
|
||||
|
||||
43
__tests__/buildx/bake.test.itg.ts
Normal file
43
__tests__/buildx/bake.test.itg.ts
Normal file
@@ -0,0 +1,43 @@
|
||||
/**
|
||||
* Copyright 2023 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 {beforeEach, describe, expect, jest, test} from '@jest/globals';
|
||||
import * as fs from 'fs';
|
||||
import * as path from 'path';
|
||||
|
||||
import {Bake} from '../../src/buildx/bake';
|
||||
import {BakeDefinition} from '../../src/types/bake';
|
||||
|
||||
const fixturesDir = path.join(__dirname, '..', 'fixtures');
|
||||
|
||||
beforeEach(() => {
|
||||
jest.clearAllMocks();
|
||||
});
|
||||
|
||||
describe('parseDefinitions', () => {
|
||||
// prettier-ignore
|
||||
test.each([
|
||||
[
|
||||
['https://github.com/docker/buildx.git#v0.10.4'],
|
||||
['binaries-cross'],
|
||||
path.join(fixturesDir, 'bake-buildx-0.10.4-binaries-cross.json')
|
||||
]
|
||||
])('given %p', async (sources: string[], targets: string[], out: string) => {
|
||||
const bake = new Bake();
|
||||
const expectedDef = <BakeDefinition>JSON.parse(fs.readFileSync(out, {encoding: 'utf-8'}).trim())
|
||||
expect(await bake.parseDefinitions(sources, targets)).toEqual(expectedDef);
|
||||
});
|
||||
});
|
||||
@@ -15,6 +15,7 @@
|
||||
*/
|
||||
|
||||
import {beforeEach, describe, expect, jest, test} from '@jest/globals';
|
||||
import * as fs from 'fs';
|
||||
import * as path from 'path';
|
||||
|
||||
import {Bake} from '../../src/buildx/bake';
|
||||
@@ -30,67 +31,19 @@ describe('parseDefinitions', () => {
|
||||
// prettier-ignore
|
||||
test.each([
|
||||
[
|
||||
[path.join(fixturesDir, 'bake.hcl')],
|
||||
[path.join(fixturesDir, 'bake-01.hcl')],
|
||||
['validate'],
|
||||
{
|
||||
"group": {
|
||||
"default": {
|
||||
"targets": [
|
||||
"validate"
|
||||
]
|
||||
},
|
||||
"validate": {
|
||||
"targets": [
|
||||
"lint",
|
||||
"validate-vendor",
|
||||
"validate-docs"
|
||||
]
|
||||
}
|
||||
},
|
||||
"target": {
|
||||
"lint": {
|
||||
"context": ".",
|
||||
"dockerfile": "./hack/dockerfiles/lint.Dockerfile",
|
||||
"args": {
|
||||
"BUILDKIT_CONTEXT_KEEP_GIT_DIR": "1",
|
||||
"GO_VERSION": "1.20"
|
||||
},
|
||||
"output": [
|
||||
"type=cacheonly"
|
||||
]
|
||||
},
|
||||
"validate-docs": {
|
||||
"context": ".",
|
||||
"dockerfile": "./hack/dockerfiles/docs.Dockerfile",
|
||||
"args": {
|
||||
"BUILDKIT_CONTEXT_KEEP_GIT_DIR": "1",
|
||||
"BUILDX_EXPERIMENTAL": "1",
|
||||
"FORMATS": "md",
|
||||
"GO_VERSION": "1.20"
|
||||
},
|
||||
"target": "validate",
|
||||
"output": [
|
||||
"type=cacheonly"
|
||||
]
|
||||
},
|
||||
"validate-vendor": {
|
||||
"context": ".",
|
||||
"dockerfile": "./hack/dockerfiles/vendor.Dockerfile",
|
||||
"args": {
|
||||
"BUILDKIT_CONTEXT_KEEP_GIT_DIR": "1",
|
||||
"GO_VERSION": "1.20"
|
||||
},
|
||||
"target": "validate",
|
||||
"output": [
|
||||
"type=cacheonly"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
path.join(fixturesDir, 'bake-01-validate.json')
|
||||
],
|
||||
[
|
||||
[path.join(fixturesDir, 'bake-02.hcl')],
|
||||
['build'],
|
||||
path.join(fixturesDir, 'bake-02-build.json')
|
||||
]
|
||||
])('given %p', async (files, targets, expected: BakeDefinition) => {
|
||||
])('given %p', async (sources: string[], targets: string[], out: string) => {
|
||||
const bake = new Bake();
|
||||
expect(await bake.parseDefinitions(files, targets)).toEqual(expected);
|
||||
const expectedDef = <BakeDefinition>JSON.parse(fs.readFileSync(out, {encoding: 'utf-8'}).trim())
|
||||
expect(await bake.parseDefinitions(sources, targets)).toEqual(expectedDef);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -106,7 +59,17 @@ describe('hasLocalExporter', () => {
|
||||
]
|
||||
},
|
||||
}
|
||||
},
|
||||
} as unknown as BakeDefinition,
|
||||
false
|
||||
],
|
||||
[
|
||||
{
|
||||
"target": {
|
||||
"build": {
|
||||
"target": "build"
|
||||
},
|
||||
}
|
||||
} as unknown as BakeDefinition,
|
||||
false
|
||||
],
|
||||
[
|
||||
@@ -118,7 +81,7 @@ describe('hasLocalExporter', () => {
|
||||
]
|
||||
},
|
||||
}
|
||||
},
|
||||
} as unknown as BakeDefinition,
|
||||
true
|
||||
],
|
||||
[
|
||||
@@ -130,7 +93,7 @@ describe('hasLocalExporter', () => {
|
||||
]
|
||||
},
|
||||
}
|
||||
},
|
||||
} as unknown as BakeDefinition,
|
||||
false
|
||||
],
|
||||
[
|
||||
@@ -142,7 +105,7 @@ describe('hasLocalExporter', () => {
|
||||
]
|
||||
},
|
||||
}
|
||||
},
|
||||
} as unknown as BakeDefinition,
|
||||
false
|
||||
],
|
||||
[
|
||||
@@ -154,7 +117,7 @@ describe('hasLocalExporter', () => {
|
||||
]
|
||||
},
|
||||
}
|
||||
},
|
||||
} as unknown as BakeDefinition,
|
||||
true
|
||||
],
|
||||
[
|
||||
@@ -166,7 +129,7 @@ describe('hasLocalExporter', () => {
|
||||
]
|
||||
},
|
||||
}
|
||||
},
|
||||
} as unknown as BakeDefinition,
|
||||
true
|
||||
]
|
||||
])('given %o returns %p', async (def: BakeDefinition, expected: boolean) => {
|
||||
@@ -186,7 +149,7 @@ describe('hasTarExporter', () => {
|
||||
]
|
||||
},
|
||||
}
|
||||
},
|
||||
} as unknown as BakeDefinition,
|
||||
false
|
||||
],
|
||||
[
|
||||
@@ -198,7 +161,7 @@ describe('hasTarExporter', () => {
|
||||
]
|
||||
},
|
||||
}
|
||||
},
|
||||
} as unknown as BakeDefinition,
|
||||
false
|
||||
],
|
||||
[
|
||||
@@ -210,7 +173,7 @@ describe('hasTarExporter', () => {
|
||||
]
|
||||
},
|
||||
}
|
||||
},
|
||||
} as unknown as BakeDefinition,
|
||||
false
|
||||
],
|
||||
[
|
||||
@@ -222,7 +185,7 @@ describe('hasTarExporter', () => {
|
||||
]
|
||||
},
|
||||
}
|
||||
},
|
||||
} as unknown as BakeDefinition,
|
||||
true
|
||||
],
|
||||
[
|
||||
@@ -235,7 +198,7 @@ describe('hasTarExporter', () => {
|
||||
]
|
||||
},
|
||||
}
|
||||
},
|
||||
} as unknown as BakeDefinition,
|
||||
true
|
||||
],
|
||||
[
|
||||
@@ -247,7 +210,7 @@ describe('hasTarExporter', () => {
|
||||
]
|
||||
},
|
||||
}
|
||||
},
|
||||
} as unknown as BakeDefinition,
|
||||
true
|
||||
],
|
||||
[
|
||||
@@ -259,7 +222,7 @@ describe('hasTarExporter', () => {
|
||||
]
|
||||
},
|
||||
}
|
||||
},
|
||||
} as unknown as BakeDefinition,
|
||||
false
|
||||
],
|
||||
[
|
||||
@@ -271,7 +234,7 @@ describe('hasTarExporter', () => {
|
||||
]
|
||||
},
|
||||
}
|
||||
},
|
||||
} as unknown as BakeDefinition,
|
||||
false
|
||||
],
|
||||
])('given %o returns %p', async (def: BakeDefinition, expected: boolean) => {
|
||||
@@ -291,7 +254,7 @@ describe('hasDockerExporter', () => {
|
||||
]
|
||||
},
|
||||
}
|
||||
},
|
||||
} as unknown as BakeDefinition,
|
||||
false,
|
||||
undefined
|
||||
],
|
||||
@@ -304,7 +267,7 @@ describe('hasDockerExporter', () => {
|
||||
]
|
||||
},
|
||||
}
|
||||
},
|
||||
} as unknown as BakeDefinition,
|
||||
true,
|
||||
undefined
|
||||
],
|
||||
@@ -318,7 +281,7 @@ describe('hasDockerExporter', () => {
|
||||
]
|
||||
},
|
||||
}
|
||||
},
|
||||
} as unknown as BakeDefinition,
|
||||
true,
|
||||
undefined
|
||||
],
|
||||
@@ -331,7 +294,7 @@ describe('hasDockerExporter', () => {
|
||||
]
|
||||
},
|
||||
}
|
||||
},
|
||||
} as unknown as BakeDefinition,
|
||||
false,
|
||||
undefined
|
||||
],
|
||||
@@ -344,7 +307,7 @@ describe('hasDockerExporter', () => {
|
||||
]
|
||||
},
|
||||
}
|
||||
},
|
||||
} as unknown as BakeDefinition,
|
||||
false,
|
||||
undefined
|
||||
],
|
||||
@@ -357,7 +320,7 @@ describe('hasDockerExporter', () => {
|
||||
]
|
||||
},
|
||||
}
|
||||
},
|
||||
} as unknown as BakeDefinition,
|
||||
false,
|
||||
undefined
|
||||
],
|
||||
@@ -371,7 +334,7 @@ describe('hasDockerExporter', () => {
|
||||
]
|
||||
},
|
||||
}
|
||||
},
|
||||
} as unknown as BakeDefinition,
|
||||
true,
|
||||
undefined
|
||||
],
|
||||
@@ -384,7 +347,7 @@ describe('hasDockerExporter', () => {
|
||||
]
|
||||
},
|
||||
}
|
||||
},
|
||||
} as unknown as BakeDefinition,
|
||||
false,
|
||||
undefined
|
||||
],
|
||||
@@ -397,7 +360,7 @@ describe('hasDockerExporter', () => {
|
||||
]
|
||||
},
|
||||
}
|
||||
},
|
||||
} as unknown as BakeDefinition,
|
||||
false,
|
||||
undefined
|
||||
],
|
||||
@@ -410,7 +373,7 @@ describe('hasDockerExporter', () => {
|
||||
]
|
||||
},
|
||||
}
|
||||
},
|
||||
} as unknown as BakeDefinition,
|
||||
false,
|
||||
undefined
|
||||
],
|
||||
@@ -423,7 +386,7 @@ describe('hasDockerExporter', () => {
|
||||
]
|
||||
},
|
||||
}
|
||||
},
|
||||
} as unknown as BakeDefinition,
|
||||
true,
|
||||
false
|
||||
],
|
||||
@@ -436,7 +399,7 @@ describe('hasDockerExporter', () => {
|
||||
]
|
||||
},
|
||||
}
|
||||
},
|
||||
} as unknown as BakeDefinition,
|
||||
true,
|
||||
true
|
||||
],
|
||||
@@ -449,11 +412,11 @@ describe('hasDockerExporter', () => {
|
||||
]
|
||||
},
|
||||
}
|
||||
},
|
||||
} as unknown as BakeDefinition,
|
||||
true,
|
||||
true
|
||||
],
|
||||
])('given %o and load:%p returns %p', async (def: BakeDefinition, expected: boolean, load: boolean) => {
|
||||
])('given %o and load:%p returns %p', async (def: BakeDefinition, expected: boolean, load: boolean | undefined) => {
|
||||
expect(Bake.hasDockerExporter(def, load)).toEqual(expected);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -162,7 +162,7 @@ describe('resolveBuildSecret', () => {
|
||||
['=bbbbbbb', false, '', '', new Error('=bbbbbbb is not a valid secret')],
|
||||
[`foo=${path.join(fixturesDir, 'secret.txt')}`, true, 'foo', 'bar', null],
|
||||
[`notfound=secret`, true, '', '', new Error('secret file secret not found')]
|
||||
])('given %p key and %p secret', async (kvp: string, file: boolean, exKey: string, exValue: string, error: Error) => {
|
||||
])('given %p key and %p secret', async (kvp: string, file: boolean, exKey: string, exValue: string, error: Error | null) => {
|
||||
try {
|
||||
let secret: string;
|
||||
if (file) {
|
||||
|
||||
@@ -69,7 +69,7 @@ describe('download', () => {
|
||||
['linux', 's390x'],
|
||||
])(
|
||||
'acquires buildx for %s/%s', async (os, arch) => {
|
||||
jest.spyOn(osm, 'platform').mockImplementation(() => os);
|
||||
jest.spyOn(osm, 'platform').mockImplementation(() => os as NodeJS.Platform);
|
||||
jest.spyOn(osm, 'arch').mockImplementation(() => arch);
|
||||
const install = new Install();
|
||||
const buildxBin = await install.download('latest');
|
||||
@@ -129,6 +129,6 @@ describe('getRelease', () => {
|
||||
});
|
||||
|
||||
it('unknown release', async () => {
|
||||
await expect(Install.getRelease('foo')).rejects.toThrowError(new Error('Cannot find Buildx release foo in https://raw.githubusercontent.com/docker/actions-toolkit/main/.github/buildx-releases.json'));
|
||||
await expect(Install.getRelease('foo')).rejects.toThrow(new Error('Cannot find Buildx release foo in https://raw.githubusercontent.com/docker/actions-toolkit/main/.github/buildx-releases.json'));
|
||||
});
|
||||
});
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
*/
|
||||
|
||||
import path from 'path';
|
||||
import {describe, expect, test} from '@jest/globals';
|
||||
import {jest, describe, expect, test} from '@jest/globals';
|
||||
|
||||
import {Install} from '../../src/docker/install';
|
||||
import {Docker} from '../../src/docker/docker';
|
||||
@@ -24,6 +24,7 @@ import {Docker} from '../../src/docker/docker';
|
||||
const tmpDir = path.join(process.env.TEMP || '/tmp', 'docker-install-jest');
|
||||
|
||||
describe('install', () => {
|
||||
jest.retryTimes(2, {logErrorsBeforeRetry: true});
|
||||
// prettier-ignore
|
||||
test.each(['v23.0.0'])(
|
||||
'install docker %s', async (version) => {
|
||||
@@ -42,7 +42,7 @@ describe('download', () => {
|
||||
['v20.10.22', 'win32'],
|
||||
])(
|
||||
'acquires %p of docker (%s)', async (version, platformOS) => {
|
||||
jest.spyOn(osm, 'platform').mockImplementation(() => platformOS);
|
||||
jest.spyOn(osm, 'platform').mockImplementation(() => platformOS as NodeJS.Platform);
|
||||
const install = new Install({
|
||||
version: version,
|
||||
runDir: tmpDir,
|
||||
@@ -68,6 +68,6 @@ describe('getRelease', () => {
|
||||
});
|
||||
|
||||
it('unknown release', async () => {
|
||||
await expect(Install.getRelease('foo')).rejects.toThrowError(new Error('Cannot find Docker release foo in https://raw.githubusercontent.com/docker/actions-toolkit/main/.github/docker-releases.json'));
|
||||
await expect(Install.getRelease('foo')).rejects.toThrow(new Error('Cannot find Docker release foo in https://raw.githubusercontent.com/docker/actions-toolkit/main/.github/docker-releases.json'));
|
||||
});
|
||||
});
|
||||
|
||||
55
__tests__/fixtures/bake-01-validate.json
Normal file
55
__tests__/fixtures/bake-01-validate.json
Normal file
@@ -0,0 +1,55 @@
|
||||
{
|
||||
"group": {
|
||||
"default": {
|
||||
"targets": [
|
||||
"validate"
|
||||
]
|
||||
},
|
||||
"validate": {
|
||||
"targets": [
|
||||
"lint",
|
||||
"validate-vendor",
|
||||
"validate-docs"
|
||||
]
|
||||
}
|
||||
},
|
||||
"target": {
|
||||
"lint": {
|
||||
"context": ".",
|
||||
"dockerfile": "./hack/dockerfiles/lint.Dockerfile",
|
||||
"args": {
|
||||
"BUILDKIT_CONTEXT_KEEP_GIT_DIR": "1",
|
||||
"GO_VERSION": "1.20"
|
||||
},
|
||||
"output": [
|
||||
"type=cacheonly"
|
||||
]
|
||||
},
|
||||
"validate-docs": {
|
||||
"context": ".",
|
||||
"dockerfile": "./hack/dockerfiles/docs.Dockerfile",
|
||||
"args": {
|
||||
"BUILDKIT_CONTEXT_KEEP_GIT_DIR": "1",
|
||||
"BUILDX_EXPERIMENTAL": "1",
|
||||
"FORMATS": "md",
|
||||
"GO_VERSION": "1.20"
|
||||
},
|
||||
"target": "validate",
|
||||
"output": [
|
||||
"type=cacheonly"
|
||||
]
|
||||
},
|
||||
"validate-vendor": {
|
||||
"context": ".",
|
||||
"dockerfile": "./hack/dockerfiles/vendor.Dockerfile",
|
||||
"args": {
|
||||
"BUILDKIT_CONTEXT_KEEP_GIT_DIR": "1",
|
||||
"GO_VERSION": "1.20"
|
||||
},
|
||||
"target": "validate",
|
||||
"output": [
|
||||
"type=cacheonly"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
20
__tests__/fixtures/bake-02-build.json
Normal file
20
__tests__/fixtures/bake-02-build.json
Normal file
@@ -0,0 +1,20 @@
|
||||
{
|
||||
"group": {
|
||||
"default": {
|
||||
"targets": [
|
||||
"build"
|
||||
]
|
||||
}
|
||||
},
|
||||
"target": {
|
||||
"build": {
|
||||
"context": ".",
|
||||
"dockerfile": "Dockerfile",
|
||||
"args": {
|
||||
"BUILDKIT_CONTEXT_KEEP_GIT_DIR": "1",
|
||||
"GO_VERSION": "1.20"
|
||||
},
|
||||
"target": "build"
|
||||
}
|
||||
}
|
||||
}
|
||||
33
__tests__/fixtures/bake-02.hcl
Normal file
33
__tests__/fixtures/bake-02.hcl
Normal file
@@ -0,0 +1,33 @@
|
||||
// Copyright 2023 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.
|
||||
|
||||
variable "GO_VERSION" {
|
||||
default = "1.20"
|
||||
}
|
||||
|
||||
target "_common" {
|
||||
args = {
|
||||
GO_VERSION = GO_VERSION
|
||||
BUILDKIT_CONTEXT_KEEP_GIT_DIR = 1
|
||||
}
|
||||
}
|
||||
|
||||
group "default" {
|
||||
targets = ["build"]
|
||||
}
|
||||
|
||||
target "build" {
|
||||
inherits = ["_common"]
|
||||
target = "build"
|
||||
}
|
||||
36
__tests__/fixtures/bake-buildx-0.10.4-binaries-cross.json
Normal file
36
__tests__/fixtures/bake-buildx-0.10.4-binaries-cross.json
Normal file
@@ -0,0 +1,36 @@
|
||||
{
|
||||
"group": {
|
||||
"default": {
|
||||
"targets": [
|
||||
"binaries-cross"
|
||||
]
|
||||
}
|
||||
},
|
||||
"target": {
|
||||
"binaries-cross": {
|
||||
"context": "https://github.com/docker/buildx.git#v0.10.4",
|
||||
"dockerfile": "Dockerfile",
|
||||
"args": {
|
||||
"BUILDKIT_CONTEXT_KEEP_GIT_DIR": "1",
|
||||
"GO_VERSION": "1.19"
|
||||
},
|
||||
"target": "binaries",
|
||||
"platforms": [
|
||||
"darwin/amd64",
|
||||
"darwin/arm64",
|
||||
"linux/amd64",
|
||||
"linux/arm/v6",
|
||||
"linux/arm/v7",
|
||||
"linux/arm64",
|
||||
"linux/ppc64le",
|
||||
"linux/riscv64",
|
||||
"linux/s390x",
|
||||
"windows/amd64",
|
||||
"windows/arm64"
|
||||
],
|
||||
"output": [
|
||||
"./bin/build"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -108,7 +108,7 @@ describe('actionsRuntimeToken', () => {
|
||||
process.env.ACTIONS_RUNTIME_TOKEN = 'foo';
|
||||
expect(() => {
|
||||
GitHub.actionsRuntimeToken;
|
||||
}).toThrowError();
|
||||
}).toThrow();
|
||||
});
|
||||
it('fixture', async () => {
|
||||
process.env.ACTIONS_RUNTIME_TOKEN = fs.readFileSync(path.join(__dirname, 'fixtures', 'runtimeToken.txt')).toString().trim();
|
||||
@@ -131,11 +131,11 @@ describe('printActionsRuntimeTokenACs', () => {
|
||||
});
|
||||
it('empty', async () => {
|
||||
process.env.ACTIONS_RUNTIME_TOKEN = '';
|
||||
await expect(GitHub.printActionsRuntimeTokenACs()).rejects.toThrowError(new Error('ACTIONS_RUNTIME_TOKEN not set'));
|
||||
await expect(GitHub.printActionsRuntimeTokenACs()).rejects.toThrow(new Error('ACTIONS_RUNTIME_TOKEN not set'));
|
||||
});
|
||||
it('malformed', async () => {
|
||||
process.env.ACTIONS_RUNTIME_TOKEN = 'foo';
|
||||
await expect(GitHub.printActionsRuntimeTokenACs()).rejects.toThrowError(new Error("Cannot parse GitHub Actions Runtime Token: Invalid token specified: Cannot read properties of undefined (reading 'replace')"));
|
||||
await expect(GitHub.printActionsRuntimeTokenACs()).rejects.toThrow(new Error("Cannot parse GitHub Actions Runtime Token: Invalid token specified: Cannot read properties of undefined (reading 'replace')"));
|
||||
});
|
||||
it('refs/heads/master', async () => {
|
||||
const infoSpy = jest.spyOn(core, 'info');
|
||||
|
||||
@@ -194,13 +194,29 @@ describe('asyncForEach', () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe('isValidUrl', () => {
|
||||
describe('isValidURL', () => {
|
||||
test.each([
|
||||
['https://github.com/docker/buildx.git', true],
|
||||
['https://github.com/docker/buildx.git#refs/pull/648/head', true],
|
||||
['git@github.com:moby/buildkit.git', false],
|
||||
['git://github.com/user/repo.git', false],
|
||||
['github.com/moby/buildkit.git#main', false],
|
||||
['v0.4.1', false]
|
||||
])('given %p', async (url, expected) => {
|
||||
expect(Util.isValidUrl(url)).toEqual(expected);
|
||||
expect(Util.isValidURL(url)).toEqual(expected);
|
||||
});
|
||||
});
|
||||
|
||||
describe('isValidRef', () => {
|
||||
test.each([
|
||||
['https://github.com/docker/buildx.git', true],
|
||||
['https://github.com/docker/buildx.git#refs/pull/648/head', true],
|
||||
['git@github.com:moby/buildkit.git', true],
|
||||
['git://github.com/user/repo.git', true],
|
||||
['github.com/moby/buildkit.git#main', true],
|
||||
['v0.4.1', false]
|
||||
])('given %p', async (url, expected) => {
|
||||
expect(Util.isValidRef(url)).toEqual(expected);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -79,7 +79,7 @@ RUN --mount=type=bind,target=.,rw \
|
||||
--mount=type=bind,from=buildx,source=/buildx,target=/usr/libexec/docker/cli-plugins/docker-buildx \
|
||||
--mount=type=bind,from=buildx,source=/buildx,target=/usr/bin/buildx \
|
||||
--mount=type=secret,id=GITHUB_TOKEN \
|
||||
GITHUB_TOKEN=$(cat /run/secrets/GITHUB_TOKEN) yarn run test-coverage --coverageDirectory=/tmp/coverage
|
||||
GITHUB_TOKEN=$(cat /run/secrets/GITHUB_TOKEN) yarn run test:coverage --coverageDirectory=/tmp/coverage
|
||||
|
||||
FROM scratch AS test-coverage
|
||||
COPY --from=test /tmp/coverage /
|
||||
|
||||
@@ -19,7 +19,7 @@ module.exports = {
|
||||
testEnvironment: 'node',
|
||||
moduleFileExtensions: ['js', 'ts'],
|
||||
setupFiles: ['dotenv/config'],
|
||||
testMatch: ['**/*.test.e2e.ts'],
|
||||
testMatch: ['**/*.test.itg.ts'],
|
||||
testTimeout: 1800000, // 30 minutes
|
||||
transform: {
|
||||
'^.+\\.ts$': 'ts-jest'
|
||||
31
package.json
31
package.json
@@ -11,9 +11,10 @@
|
||||
"prettier": "prettier --check \"./**/*.ts\"",
|
||||
"prettier:fix": "prettier --write \"./**/*.ts\"",
|
||||
"test": "jest",
|
||||
"test:e2e": "jest -c jest.config.e2e.ts --runInBand --detectOpenHandles",
|
||||
"test-coverage": "jest --coverage",
|
||||
"test-coverage:e2e": "jest --coverage -c jest.config.e2e.ts --runInBand --detectOpenHandles"
|
||||
"test:coverage": "jest --coverage",
|
||||
"test:itg": "jest -c jest.config.itg.ts --runInBand --detectOpenHandles",
|
||||
"test:itg-list": "jest -c jest.config.itg.ts --listTests",
|
||||
"test:itg-coverage": "jest --coverage -c jest.config.itg.ts --runInBand --detectOpenHandles"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
@@ -54,28 +55,28 @@
|
||||
"csv-parse": "^5.3.6",
|
||||
"handlebars": "^4.7.7",
|
||||
"jwt-decode": "^3.1.2",
|
||||
"semver": "^7.3.8",
|
||||
"semver": "^7.4.0",
|
||||
"tmp": "^0.2.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/csv-parse": "^1.2.2",
|
||||
"@types/node": "^16.18.11",
|
||||
"@types/node": "^16.18.21",
|
||||
"@types/semver": "^7.3.13",
|
||||
"@types/tmp": "^0.2.3",
|
||||
"@typescript-eslint/eslint-plugin": "^5.49.0",
|
||||
"@typescript-eslint/parser": "^5.49.0",
|
||||
"@typescript-eslint/eslint-plugin": "^5.56.0",
|
||||
"@typescript-eslint/parser": "^5.56.0",
|
||||
"cpy-cli": "^4.2.0",
|
||||
"dotenv": "^16.0.3",
|
||||
"eslint": "^8.33.0",
|
||||
"eslint-config-prettier": "^8.6.0",
|
||||
"eslint": "^8.36.0",
|
||||
"eslint-config-prettier": "^8.8.0",
|
||||
"eslint-plugin-import": "^2.27.5",
|
||||
"eslint-plugin-jest": "^26.9.0",
|
||||
"eslint-plugin-jest": "^27.2.1",
|
||||
"eslint-plugin-prettier": "^4.2.1",
|
||||
"jest": "^27.5.1",
|
||||
"prettier": "^2.8.3",
|
||||
"rimraf": "^4.1.2",
|
||||
"ts-jest": "^27.1.5",
|
||||
"jest": "^29.5.0",
|
||||
"prettier": "^2.8.7",
|
||||
"rimraf": "^4.4.1",
|
||||
"ts-jest": "^29.0.5",
|
||||
"ts-node": "^10.9.1",
|
||||
"typescript": "^4.9.4"
|
||||
"typescript": "^4.9.5"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
import {Buildx} from './buildx';
|
||||
import {Exec} from '../exec';
|
||||
import {Inputs} from './inputs';
|
||||
import {Util} from '../util';
|
||||
|
||||
import {BakeDefinition} from '../types/bake';
|
||||
|
||||
@@ -31,16 +32,36 @@ export class Bake {
|
||||
this.buildx = opts?.buildx || new Buildx();
|
||||
}
|
||||
|
||||
public async parseDefinitions(files: Array<string>, targets: Array<string>): Promise<BakeDefinition> {
|
||||
public async parseDefinitions(sources: Array<string>, targets: Array<string>, workdir?: string): Promise<BakeDefinition> {
|
||||
const args = ['bake'];
|
||||
if (files) {
|
||||
for (const file of files) {
|
||||
args.push('--file', file);
|
||||
|
||||
let remoteDef;
|
||||
const files: Array<string> = [];
|
||||
if (sources) {
|
||||
for (const source of sources.map(v => v.trim())) {
|
||||
if (source.length == 0) {
|
||||
continue;
|
||||
}
|
||||
if (!Util.isValidRef(source)) {
|
||||
files.push(source);
|
||||
continue;
|
||||
}
|
||||
if (remoteDef) {
|
||||
throw new Error(`Only one remote bake definition is allowed`);
|
||||
}
|
||||
remoteDef = source;
|
||||
}
|
||||
}
|
||||
if (remoteDef) {
|
||||
args.push(remoteDef);
|
||||
}
|
||||
for (const file of files) {
|
||||
args.push('--file', file);
|
||||
}
|
||||
|
||||
const printCmd = await this.buildx.getCommand([...args, '--print', ...targets]);
|
||||
return await Exec.getExecOutput(printCmd.command, printCmd.args, {
|
||||
cwd: workdir,
|
||||
ignoreReturnCode: true,
|
||||
silent: true
|
||||
}).then(res => {
|
||||
@@ -67,7 +88,9 @@ export class Bake {
|
||||
const exporters = new Array<string>();
|
||||
for (const key in def.target) {
|
||||
const target = def.target[key];
|
||||
exporters.push(...target.output);
|
||||
if (target.output) {
|
||||
exporters.push(...target.output);
|
||||
}
|
||||
}
|
||||
return exporters;
|
||||
}
|
||||
|
||||
@@ -88,7 +88,7 @@ export class Install {
|
||||
if (res.stderr.length > 0 && res.exitCode != 0) {
|
||||
core.warning(res.stderr.trim());
|
||||
}
|
||||
return tc.cacheFile(`${outputDir}/buildx`, os.platform() == 'win32' ? 'docker-buildx.exe' : 'docker-buildx', 'buildx', vspec);
|
||||
return tc.cacheFile(`${outputDir}/buildx`, os.platform() == 'win32' ? 'docker-buildx.exe' : 'docker-buildx', 'buildx', vspec, this.platform());
|
||||
});
|
||||
}
|
||||
|
||||
@@ -179,7 +179,7 @@ export class Install {
|
||||
core.info(`Downloading ${downloadURL}`);
|
||||
const downloadPath = await tc.downloadTool(downloadURL);
|
||||
core.debug(`Install.fetchBinary downloadPath: ${downloadPath}`);
|
||||
return await tc.cacheFile(downloadPath, targetFile, 'buildx', version);
|
||||
return await tc.cacheFile(downloadPath, targetFile, 'buildx', version, this.platform());
|
||||
}
|
||||
|
||||
private platform(): string {
|
||||
|
||||
@@ -15,7 +15,8 @@
|
||||
*/
|
||||
|
||||
import {Buildx} from './buildx/buildx';
|
||||
import {Install} from './buildx/install';
|
||||
import {Install as BuildxInstall} from './buildx/install';
|
||||
import {Bake} from './buildx/bake';
|
||||
import {Builder} from './buildx/builder';
|
||||
import {BuildKit} from './buildkit/buildkit';
|
||||
import {GitHub} from './github';
|
||||
@@ -31,14 +32,16 @@ export interface ToolkitOpts {
|
||||
export class Toolkit {
|
||||
public github: GitHub;
|
||||
public buildx: Buildx;
|
||||
public buildxInstall: Install;
|
||||
public buildxInstall: BuildxInstall;
|
||||
public bake: Bake;
|
||||
public builder: Builder;
|
||||
public buildkit: BuildKit;
|
||||
|
||||
constructor(opts: ToolkitOpts = {}) {
|
||||
this.github = new GitHub({token: opts.githubToken});
|
||||
this.buildx = new Buildx();
|
||||
this.buildxInstall = new Install();
|
||||
this.buildxInstall = new BuildxInstall();
|
||||
this.bake = new Bake({buildx: this.buildx});
|
||||
this.builder = new Builder({buildx: this.buildx});
|
||||
this.buildkit = new BuildKit({buildx: this.buildx});
|
||||
}
|
||||
|
||||
@@ -24,22 +24,22 @@ export interface Group {
|
||||
}
|
||||
|
||||
export interface Target {
|
||||
args: Record<string, string>;
|
||||
attest: Array<string>;
|
||||
'cache-from': Array<string>;
|
||||
'cache-to': Array<string>;
|
||||
args?: Record<string, string>;
|
||||
attest?: Array<string>;
|
||||
'cache-from'?: Array<string>;
|
||||
'cache-to'?: Array<string>;
|
||||
context: string;
|
||||
contexts: Record<string, string>;
|
||||
contexts?: Record<string, string>;
|
||||
dockerfile: string;
|
||||
'dockerfile-inline': string;
|
||||
labels: Record<string, string>;
|
||||
'no-cache': boolean;
|
||||
'no-cache-filter': Array<string>;
|
||||
output: Array<string>;
|
||||
platforms: Array<string>;
|
||||
pull: boolean;
|
||||
secret: Array<string>;
|
||||
ssh: Array<string>;
|
||||
tags: Array<string>;
|
||||
target: string;
|
||||
'dockerfile-inline'?: string;
|
||||
labels?: Record<string, string>;
|
||||
'no-cache'?: boolean;
|
||||
'no-cache-filter'?: Array<string>;
|
||||
output?: Array<string>;
|
||||
platforms?: Array<string>;
|
||||
pull?: boolean;
|
||||
secret?: Array<string>;
|
||||
ssh?: Array<string>;
|
||||
tags?: Array<string>;
|
||||
target?: string;
|
||||
}
|
||||
|
||||
19
src/util.ts
19
src/util.ts
@@ -65,13 +65,26 @@ export class Util {
|
||||
}
|
||||
}
|
||||
|
||||
public static isValidUrl(url: string): boolean {
|
||||
public static isValidURL(urlStr: string): boolean {
|
||||
let url;
|
||||
try {
|
||||
new URL(url);
|
||||
url = new URL(urlStr);
|
||||
} catch (e) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
return url.protocol === 'http:' || url.protocol === 'https:';
|
||||
}
|
||||
|
||||
public static isValidRef(refStr: string): boolean {
|
||||
if (Util.isValidURL(refStr)) {
|
||||
return true;
|
||||
}
|
||||
for (const prefix of ['git://', 'github.com/', 'git@']) {
|
||||
if (refStr.startsWith(prefix)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static async powershellCommand(script: string, params?: Record<string, string>) {
|
||||
|
||||
Reference in New Issue
Block a user