-
Notifications
You must be signed in to change notification settings - Fork 54
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #18 from buildkite/lambda-support
Add a lambda function for executing stats
- Loading branch information
Showing
14 changed files
with
837 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,18 @@ | ||
steps: | ||
- | ||
name: "📦" | ||
- name: ":golang:" | ||
command: "make build" | ||
artifact_paths: "build/*" | ||
plugins: | ||
- docker-compose: | ||
run: "build" | ||
|
||
- name: ":lambda:" | ||
command: "make build-lambda" | ||
artifact_paths: "build/*" | ||
|
||
- wait | ||
|
||
- | ||
name: "Release to :s3:" | ||
- name: "Release to :s3:" | ||
command: ".buildkite/upload.sh" | ||
branches: "master" | ||
agents: | ||
queue: "deploy" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
build/ | ||
handler.zip |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
package main | ||
|
||
import ( | ||
"bytes" | ||
"encoding/json" | ||
"log" | ||
"os" | ||
"time" | ||
|
||
"github.com/eawsy/aws-lambda-go/service/lambda/runtime" | ||
"gopkg.in/buildkite/go-buildkite.v2/buildkite" | ||
) | ||
|
||
func handle(evt json.RawMessage, ctx *runtime.Context) (interface{}, error) { | ||
output := &bytes.Buffer{} | ||
log.SetOutput(output) | ||
|
||
org := os.Getenv("BUILDKITE_ORG") | ||
token := os.Getenv("BUILDKITE_TOKEN") | ||
|
||
config, err := buildkite.NewTokenConfig(token, false) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
client := buildkite.NewClient(config.Client()) | ||
t := time.Now() | ||
|
||
res, err := collectResults(client, collectOpts{ | ||
OrgSlug: org, | ||
Historical: time.Hour * 24, | ||
}) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
dumpResults(res) | ||
|
||
err = cloudwatchSend(res) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
log.Printf("Finished in %s", time.Now().Sub(t)) | ||
return output.String(), nil | ||
} | ||
|
||
func init() { | ||
runtime.HandleFunc(handle) | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.