Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 11 additions & 17 deletions .drone.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1319,11 +1319,6 @@ image_pull_secrets:
kind: pipeline
type: kubernetes
name: push-build-linux-arm64
environment:
BUILDBOX_VERSION: teleport11
GID: "1000"
RUNTIME: go1.20.3
UID: "1000"
trigger:
event:
include:
Expand Down Expand Up @@ -1366,9 +1361,10 @@ steps:
pull: if-not-exists
commands:
- cd "/go/src/github.com/gravitational/teleport/build.assets/tooling"
- go run ./cmd/gh-trigger-workflow -owner ${DRONE_REPO_OWNER} -repo teleport.e -workflow
release-linux-arm64.yml -workflow-ref=${DRONE_BRANCH} -input oss-teleport-ref=${DRONE_COMMIT}
-input upload-artifacts=false -input oss-teleport-repo="${DRONE_REPO}"
- 'go run ./cmd/gh-trigger-workflow -owner ${DRONE_REPO_OWNER} -repo teleport.e
-tag-workflow -timeout 1h0m0s -workflow release-linux-arm64.yml -workflow-ref=${DRONE_BRANCH}
-input oss-teleport-repo=${DRONE_REPO} -input oss-teleport-ref=${DRONE_COMMIT}
-input "upload-artifacts=false" '
environment:
GHA_APP_KEY:
from_secret: GITHUB_WORKFLOW_APP_PRIVATE_KEY
Expand Down Expand Up @@ -5284,11 +5280,6 @@ image_pull_secrets:
kind: pipeline
type: kubernetes
name: build-linux-arm64
environment:
BUILDBOX_VERSION: teleport11
GID: "1000"
RUNTIME: go1.20.3
UID: "1000"
trigger:
event:
include:
Expand All @@ -5303,6 +5294,8 @@ workspace:
path: /go
clone:
disable: true
depends_on:
- clean-up-previous-build
steps:
- name: Check out code
image: docker:git
Expand All @@ -5328,9 +5321,10 @@ steps:
pull: if-not-exists
commands:
- cd "/go/src/github.com/gravitational/teleport/build.assets/tooling"
- go run ./cmd/gh-trigger-workflow -owner ${DRONE_REPO_OWNER} -repo teleport.e -workflow
release-linux-arm64.yml -workflow-ref=${DRONE_TAG} -input oss-teleport-ref=${DRONE_TAG}
-input upload-artifacts=true -input oss-teleport-repo="${DRONE_REPO}"
- 'go run ./cmd/gh-trigger-workflow -owner ${DRONE_REPO_OWNER} -repo teleport.e
-tag-workflow -timeout 1h0m0s -workflow release-linux-arm64.yml -workflow-ref=${DRONE_TAG}
-input oss-teleport-repo=${DRONE_REPO} -input oss-teleport-ref=${DRONE_TAG} -input
"upload-artifacts=true" '
environment:
GHA_APP_KEY:
from_secret: GITHUB_WORKFLOW_APP_PRIVATE_KEY
Expand Down Expand Up @@ -20291,6 +20285,6 @@ image_pull_secrets:
- DOCKERHUB_CREDENTIALS
---
kind: signature
hmac: 5f920d6511d5e89e2bfa788d11b42a8db5b3f6f5c98500b137b6fba4d1ab03ee
hmac: b797d960837073d77869974db84306e894dc81b4a8cde6e24fdb7056eb15a65e

...
51 changes: 34 additions & 17 deletions dronegen/gha.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,27 +14,48 @@

package main

import "fmt"
import (
"fmt"
"strings"
"time"
)

type ghaBuildType struct {
buildType
trigger
namePrefix string
uploadArtifacts bool
srcRefVar string
workflowRefVar string
slackOnError bool
pipelineName string
ghaWorkflow string
srcRefVar string
workflowRef string
timeout time.Duration
slackOnError bool
dependsOn []string
inputs map[string]string
}

func ghaBuildPipeline(b ghaBuildType) pipeline {
p := newKubePipeline(fmt.Sprintf("%sbuild-%s-%s", b.namePrefix, b.os, b.arch))
p := newKubePipeline(b.pipelineName)
p.Trigger = b.trigger
p.Workspace = workspace{Path: "/go"}
p.Environment = map[string]value{
"BUILDBOX_VERSION": buildboxVersion,
"RUNTIME": goRuntime,
"UID": {raw: "1000"},
"GID": {raw: "1000"},
p.DependsOn = append(p.DependsOn, b.dependsOn...)

var cmd strings.Builder
cmd.WriteString(`go run ./cmd/gh-trigger-workflow `)
cmd.WriteString(`-owner ${DRONE_REPO_OWNER} `)
cmd.WriteString(`-repo teleport.e `)
cmd.WriteString(`-tag-workflow `)
fmt.Fprintf(&cmd, `-timeout %s `, b.timeout.String())
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you run make dronegen? I see the timeout setting being added here but I don't see it anywhere in the .drone.yml in this changeset.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oops. Good catch. Fixed.

fmt.Fprintf(&cmd, `-workflow %s `, b.ghaWorkflow)
fmt.Fprintf(&cmd, `-workflow-ref=%s `, b.workflowRef)

// If we don't need to build teleport...
if b.srcRefVar != "" {
cmd.WriteString(`-input oss-teleport-repo=${DRONE_REPO} `)
fmt.Fprintf(&cmd, `-input oss-teleport-ref=${%s} `, b.srcRefVar)
}

for k, v := range b.inputs {
fmt.Fprintf(&cmd, `-input "%s=%s" `, k, v)
}

p.Steps = []step{
Expand All @@ -56,11 +77,7 @@ func ghaBuildPipeline(b ghaBuildType) pipeline {
},
Commands: []string{
`cd "/go/src/github.com/gravitational/teleport/build.assets/tooling"`,
`go run ./cmd/gh-trigger-workflow -owner ${DRONE_REPO_OWNER} -repo teleport.e -workflow release-linux-arm64.yml ` +
fmt.Sprintf(`-workflow-ref=${%s} `, b.workflowRefVar) +
fmt.Sprintf(`-input oss-teleport-ref=${%s} `, b.srcRefVar) +
fmt.Sprintf(`-input upload-artifacts=%t `, b.uploadArtifacts) +
`-input oss-teleport-repo="${DRONE_REPO}"`,
cmd.String(),
},
},
}
Expand Down
21 changes: 13 additions & 8 deletions dronegen/push.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,10 @@

package main

import "fmt"
import (
"fmt"
"time"
)

// pushCheckoutCommands builds a list of commands for Drone to check out a git commit on a push build
func pushCheckoutCommands(b buildType) []string {
Expand Down Expand Up @@ -72,13 +75,15 @@ func pushPipelines() []pipeline {
}

ps = append(ps, ghaBuildPipeline(ghaBuildType{
buildType: buildType{os: "linux", arch: "arm64"},
trigger: triggerPush,
namePrefix: "push-",
uploadArtifacts: false,
slackOnError: true,
srcRefVar: "DRONE_COMMIT",
workflowRefVar: "DRONE_BRANCH",
buildType: buildType{os: "linux", arch: "arm64"},
trigger: triggerPush,
pipelineName: "push-build-linux-arm64",
ghaWorkflow: "release-linux-arm64.yml",
timeout: 60 * time.Minute,
slackOnError: true,
srcRefVar: "DRONE_COMMIT",
workflowRef: "${DRONE_BRANCH}",
inputs: map[string]string{"upload-artifacts": "false"},
}))

// Only amd64 Windows is supported for now.
Expand Down
15 changes: 10 additions & 5 deletions dronegen/tag.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ package main
import (
"fmt"
"strings"
"time"
)

const (
Expand Down Expand Up @@ -189,11 +190,15 @@ func tagPipelines() []pipeline {
}

ps = append(ps, ghaBuildPipeline(ghaBuildType{
buildType: buildType{os: "linux", arch: "arm64", fips: false},
trigger: triggerTag,
uploadArtifacts: true,
srcRefVar: "DRONE_TAG",
workflowRefVar: "DRONE_TAG",
buildType: buildType{os: "linux", arch: "arm64", fips: false},
trigger: triggerTag,
pipelineName: "build-linux-arm64",
ghaWorkflow: "release-linux-arm64.yml",
srcRefVar: "DRONE_TAG",
workflowRef: "${DRONE_TAG}",
timeout: 60 * time.Minute,
dependsOn: []string{tagCleanupPipelineName},
inputs: map[string]string{"upload-artifacts": "true"},
}))

// Only amd64 Windows is supported for now.
Expand Down