From 30ff61d2245716bf745f1430cd0776cf79e65c95 Mon Sep 17 00:00:00 2001 From: Morten Mjelva Date: Sun, 6 Oct 2024 20:24:47 +0200 Subject: [PATCH 1/2] Extend workflows_template.libsonnet to make it possible to select cgo platforms --- tools/github_workflows/workflows_template.libsonnet | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tools/github_workflows/workflows_template.libsonnet b/tools/github_workflows/workflows_template.libsonnet index 8d0a80db..8cefc4ce 100644 --- a/tools/github_workflows/workflows_template.libsonnet +++ b/tools/github_workflows/workflows_template.libsonnet @@ -53,7 +53,7 @@ }, ], - local getJobs(binaries, containers, doUpload) = { + local getJobs(binaries, containers, doUpload, enableCgo) = { build_and_test: { 'runs-on': 'ubuntu-latest', steps: [ @@ -130,7 +130,7 @@ name: platform.name + ': build and test', run: ('bazel %s --platforms=@rules_go//go/toolchain:%s ' % [ platform.buildAndTestCommand, - platform.name, + platform.name + if enableCgo then '_cgo' else '', ]) + ( if platform.buildJustBinaries then std.join(' ', ['//cmd/' + binary for binary in binaries]) @@ -187,12 +187,12 @@ 'master.yaml': { name: 'master', on: { push: { branches: ['main', 'master'] } }, - jobs: getJobs(binaries, containers, true), + jobs: getJobs(binaries, containers, true, false), }, 'pull-requests.yaml': { name: 'pull-requests', on: { pull_request: { branches: ['main', 'master'] } }, - jobs: getJobs(binaries, containers, false), + jobs: getJobs(binaries, containers, false, false), }, }, } From 8f9886b2047b1f8497ea226aefa9b82e7e12f161 Mon Sep 17 00:00:00 2001 From: Morten Mjelva Date: Sun, 6 Oct 2024 23:26:50 +0200 Subject: [PATCH 2/2] Also update the copy steps --- tools/github_workflows/workflows_template.libsonnet | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/tools/github_workflows/workflows_template.libsonnet b/tools/github_workflows/workflows_template.libsonnet index 8cefc4ce..10169371 100644 --- a/tools/github_workflows/workflows_template.libsonnet +++ b/tools/github_workflows/workflows_template.libsonnet @@ -143,7 +143,12 @@ { name: '%s: copy %s' % [platform.name, binary], local executable = binary + platform.extension, - run: 'rm -f %s && bazel run --run_under cp --platforms=@rules_go//go/toolchain:%s //cmd/%s $(pwd)/%s' % [executable, platform.name, binary, executable], + run: 'rm -f %s && bazel run --run_under cp --platforms=@rules_go//go/toolchain:%s //cmd/%s $(pwd)/%s' % [ + executable, + platform.name + if enableCgo then '_cgo' else '', + binary, + executable, + ], }, { name: '%s: upload %s' % [platform.name, binary],