Skip to content

Commit

Permalink
Extend workflows_template.libsonnet to make it possible to select cgo…
Browse files Browse the repository at this point in the history
… platforms (#224)

* Extend workflows_template.libsonnet to make it possible to select cgo platforms

* Also update the copy steps
  • Loading branch information
mortenmj authored Oct 7, 2024
1 parent 8abbcfa commit 0941111
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions tools/github_workflows/workflows_template.libsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
},
],

local getJobs(binaries, containers, doUpload) = {
local getJobs(binaries, containers, doUpload, enableCgo) = {
build_and_test: {
'runs-on': 'ubuntu-latest',
steps: [
Expand Down Expand Up @@ -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])
Expand All @@ -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],
Expand Down Expand Up @@ -187,12 +192,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),
},
},
}

0 comments on commit 0941111

Please sign in to comment.