mirror of
https://github.com/crazy-max/diun.git
synced 2025-12-21 13:23:09 +01:00
Merge pull request #1424 from crazy-max/ci-split-validate
ci: split validate target per platform
This commit is contained in:
79
.github/workflows/build.yml
vendored
79
.github/workflows/build.yml
vendored
@@ -26,33 +26,84 @@ jobs:
|
|||||||
prepare:
|
prepare:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
outputs:
|
outputs:
|
||||||
validate-targets: ${{ steps.validate-targets.outputs.matrix }}
|
validate-includes: ${{ steps.validate.outputs.includes }}
|
||||||
artifact-platforms: ${{ steps.artifact-platforms.outputs.matrix }}
|
artifact-platforms: ${{ steps.artifact.outputs.platforms }}
|
||||||
steps:
|
steps:
|
||||||
-
|
-
|
||||||
name: Checkout
|
name: Checkout
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
-
|
-
|
||||||
name: Validate targets matrix
|
name: Validate matrix
|
||||||
id: validate-targets
|
id: validate
|
||||||
run: |
|
uses: actions/github-script@v7
|
||||||
echo "matrix=$(docker buildx bake validate --print | jq -cr '.target | keys')" >> $GITHUB_OUTPUT
|
env:
|
||||||
|
GOLANGCI_LINT_MULTIPLATFORM: 1
|
||||||
|
with:
|
||||||
|
script: |
|
||||||
|
let def = {};
|
||||||
|
await core.group(`Parsing definition`, async () => {
|
||||||
|
const resPrint = await exec.getExecOutput('docker', ['buildx', 'bake', 'validate', '--print'], {
|
||||||
|
ignoreReturnCode: true
|
||||||
|
});
|
||||||
|
if (resPrint.stderr.length > 0 && resPrint.exitCode != 0) {
|
||||||
|
throw new Error(res.stderr);
|
||||||
|
}
|
||||||
|
def = JSON.parse(resPrint.stdout.trim());
|
||||||
|
});
|
||||||
|
await core.group(`Generating matrix`, async () => {
|
||||||
|
const includes = [];
|
||||||
|
for (const targetName of Object.keys(def.target)) {
|
||||||
|
const target = def.target[targetName];
|
||||||
|
if (target.platforms && target.platforms.length > 0) {
|
||||||
|
target.platforms.forEach(platform => {
|
||||||
|
includes.push({
|
||||||
|
target: targetName,
|
||||||
|
platform: platform
|
||||||
|
});
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
includes.push({
|
||||||
|
target: targetName
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
core.info(JSON.stringify(includes, null, 2));
|
||||||
|
core.setOutput('includes', JSON.stringify(includes));
|
||||||
|
});
|
||||||
-
|
-
|
||||||
name: Artifact platforms matrix
|
name: Artifact matrix
|
||||||
id: artifact-platforms
|
id: artifact
|
||||||
run: |
|
uses: actions/github-script@v7
|
||||||
echo "matrix=$(docker buildx bake artifact-all --print | jq -cr '.target."artifact-all".platforms')" >> $GITHUB_OUTPUT
|
with:
|
||||||
|
script: |
|
||||||
|
const targetName = 'artifact-all';
|
||||||
|
let def = {};
|
||||||
|
await core.group(`Parsing definition`, async () => {
|
||||||
|
const resPrint = await exec.getExecOutput('docker', ['buildx', 'bake', targetName, '--print'], {
|
||||||
|
ignoreReturnCode: true
|
||||||
|
});
|
||||||
|
if (resPrint.stderr.length > 0 && resPrint.exitCode != 0) {
|
||||||
|
throw new Error(res.stderr);
|
||||||
|
}
|
||||||
|
def = JSON.parse(resPrint.stdout.trim());
|
||||||
|
});
|
||||||
|
await core.group(`Generating matrix`, async () => {
|
||||||
|
const platforms = def.target?.[targetName]?.platforms ?? [];
|
||||||
|
if (platforms.length === 0) {
|
||||||
|
throw new Error(`No platforms found for ${targetName} target`);
|
||||||
|
}
|
||||||
|
core.info(JSON.stringify(platforms, null, 2));
|
||||||
|
core.setOutput('platforms', JSON.stringify(platforms));
|
||||||
|
});
|
||||||
|
|
||||||
validate:
|
validate:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
env:
|
|
||||||
GOLANGCI_LINT_MULTIPLATFORM: 1
|
|
||||||
needs:
|
needs:
|
||||||
- prepare
|
- prepare
|
||||||
strategy:
|
strategy:
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
target: ${{ fromJson(needs.prepare.outputs.validate-targets) }}
|
include: ${{ fromJson(needs.prepare.outputs.validate-includes) }}
|
||||||
steps:
|
steps:
|
||||||
-
|
-
|
||||||
name: Checkout
|
name: Checkout
|
||||||
@@ -66,6 +117,8 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
source: .
|
source: .
|
||||||
targets: ${{ matrix.target }}
|
targets: ${{ matrix.target }}
|
||||||
|
set: |
|
||||||
|
*.platform=${{ matrix.platform }}
|
||||||
|
|
||||||
test:
|
test:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
|||||||
Reference in New Issue
Block a user