Skip to content

Commit

Permalink
Merge pull request #2439 from crazy-max/ci-split-validate
Browse files Browse the repository at this point in the history
ci(validate): split lint
  • Loading branch information
tonistiigi committed May 1, 2024
2 parents 1fb5d2a + 6d95fb5 commit 1d88c4b
Showing 1 changed file with 58 additions and 9 deletions.
67 changes: 58 additions & 9 deletions .github/workflows/validate.yml
Expand Up @@ -17,17 +17,63 @@ on:
- '.github/releases.json'

jobs:
prepare:
runs-on: ubuntu-22.04
outputs:
includes: ${{ steps.matrix.outputs.includes }}
steps:
-
name: Checkout
uses: actions/checkout@v4
-
name: Matrix
id: matrix
uses: actions/github-script@v7
with:
script: |
let def = {};
await core.group(`Parsing definition`, async () => {
const printEnv = Object.assign({}, process.env, {
GOLANGCI_LINT_MULTIPLATFORM: process.env.GITHUB_REPOSITORY === 'docker/buildx' ? '1' : ''
});
const resPrint = await exec.getExecOutput('docker', ['buildx', 'bake', 'validate', '--print'], {
ignoreReturnCode: true,
env: printEnv
});
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));
});
validate:
runs-on: ubuntu-22.04
needs:
- prepare
strategy:
fail-fast: false
matrix:
target:
- lint
- lint-gopls
- validate-vendor
- validate-docs
- validate-generated-files
include: ${{ fromJson(needs.prepare.outputs.includes) }}
steps:
-
name: Prepare
Expand All @@ -44,6 +90,9 @@ jobs:
with:
version: latest
-
name: Run
run: |
make ${{ matrix.target }}
name: Validate
uses: docker/bake-action@v4
with:
targets: ${{ matrix.target }}
set: |
*.platform=${{ matrix.platform }}

0 comments on commit 1d88c4b

Please sign in to comment.