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:
|
||||
runs-on: ubuntu-latest
|
||||
outputs:
|
||||
validate-targets: ${{ steps.validate-targets.outputs.matrix }}
|
||||
artifact-platforms: ${{ steps.artifact-platforms.outputs.matrix }}
|
||||
validate-includes: ${{ steps.validate.outputs.includes }}
|
||||
artifact-platforms: ${{ steps.artifact.outputs.platforms }}
|
||||
steps:
|
||||
-
|
||||
name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
-
|
||||
name: Validate targets matrix
|
||||
id: validate-targets
|
||||
run: |
|
||||
echo "matrix=$(docker buildx bake validate --print | jq -cr '.target | keys')" >> $GITHUB_OUTPUT
|
||||
name: Validate matrix
|
||||
id: validate
|
||||
uses: actions/github-script@v7
|
||||
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
|
||||
id: artifact-platforms
|
||||
run: |
|
||||
echo "matrix=$(docker buildx bake artifact-all --print | jq -cr '.target."artifact-all".platforms')" >> $GITHUB_OUTPUT
|
||||
name: Artifact matrix
|
||||
id: artifact
|
||||
uses: actions/github-script@v7
|
||||
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:
|
||||
runs-on: ubuntu-latest
|
||||
env:
|
||||
GOLANGCI_LINT_MULTIPLATFORM: 1
|
||||
needs:
|
||||
- prepare
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
target: ${{ fromJson(needs.prepare.outputs.validate-targets) }}
|
||||
include: ${{ fromJson(needs.prepare.outputs.validate-includes) }}
|
||||
steps:
|
||||
-
|
||||
name: Checkout
|
||||
@@ -66,6 +117,8 @@ jobs:
|
||||
with:
|
||||
source: .
|
||||
targets: ${{ matrix.target }}
|
||||
set: |
|
||||
*.platform=${{ matrix.platform }}
|
||||
|
||||
test:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
Reference in New Issue
Block a user