From 6d95fb586e05d325243690eaf2c1350cfb8090ad Mon Sep 17 00:00:00 2001 From: CrazyMax <1951866+crazy-max@users.noreply.github.com> Date: Tue, 30 Apr 2024 10:14:59 +0200 Subject: [PATCH] ci(validate): split lint Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com> --- .github/workflows/validate.yml | 67 +++++++++++++++++++++++++++++----- 1 file changed, 58 insertions(+), 9 deletions(-) diff --git a/.github/workflows/validate.yml b/.github/workflows/validate.yml index da4539064e4..33e8ee5cc3c 100644 --- a/.github/workflows/validate.yml +++ b/.github/workflows/validate.yml @@ -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 @@ -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 }}