Skip to content

Commit

Permalink
matrix-gen: bake matrix support
Browse files Browse the repository at this point in the history
Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
  • Loading branch information
crazy-max committed Nov 9, 2023
1 parent 766622b commit dd48614
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 1 deletion.
18 changes: 18 additions & 0 deletions .github/workflows/ci-matrix-gen.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,21 @@ jobs:
name: Show matrix
run: |
echo matrix=${{ steps.gen.outputs.matrix }}
group-matrix:
runs-on: ubuntu-latest
steps:
-
name: Checkout
uses: actions/checkout@v4
-
name: Matrix gen
id: gen
uses: ./subaction/matrix-gen
with:
workdir: ./test/group-matrix
target: validate
-
name: Show matrix
run: |
echo matrix=${{ steps.gen.outputs.matrix }}
5 changes: 4 additions & 1 deletion subaction/matrix-gen/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,10 @@ runs:
});
await core.group(`Set matrix`, async () => {
const matrix = def.group[target].targets;
let matrix = [];
for (const [key, value] of Object.entries(def.target)) {
matrix.push(key);
}
core.info(`matrix: ${JSON.stringify(matrix)}`);
core.setOutput('matrix', JSON.stringify(matrix));
});
31 changes: 31 additions & 0 deletions test/group-matrix/docker-bake.hcl
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
group "validate" {
targets = ["lint", "validate-vendor", "validate-doctoc"]
}

target "lint" {
name = "lint-${buildtags.name}"
dockerfile = "./hack/dockerfiles/lint.Dockerfile"
target = buildtags.target
output = ["type=cacheonly"]
matrix = {
buildtags = [
{ name = "default", tags = "", target = "golangci-lint" },
{ name = "labs", tags = "dfrunsecurity dfparents", target = "golangci-lint" },
{ name = "nydus", tags = "nydus", target = "golangci-lint" },
{ name = "yaml", tags = "", target = "yamllint" },
{ name = "proto", tags = "", target = "protolint" },
]
}
}

target "validate-vendor" {
dockerfile = "./hack/dockerfiles/vendor.Dockerfile"
target = "validate"
output = ["type=cacheonly"]
}

target "validate-doctoc" {
dockerfile = "./hack/dockerfiles/doctoc.Dockerfile"
target = "validate-toc"
output = ["type=cacheonly"]
}

0 comments on commit dd48614

Please sign in to comment.