Skip to content

ci: Replace DataDog CI with custom upload script #169

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Feb 7, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Fix job cancelation override
  • Loading branch information
kylecarbs committed Feb 6, 2022
commit 49799a0ededdd4c85e15df51752615ba1baadf7d
2 changes: 2 additions & 0 deletions .github/workflows/coder.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,7 @@ jobs:
env:
DATADOG_API_KEY: ${{ secrets.DATADOG_API_KEY }}
DD_DATABASE: fake
GIT_COMMIT_MESSAGE: ${{ github.event.head_commit.message }}
run: go run scripts/datadog-cireport/main.go gotests.xml

- name: Test with PostgreSQL Database
Expand All @@ -177,6 +178,7 @@ jobs:
env:
DATADOG_API_KEY: ${{ secrets.DATADOG_API_KEY }}
DD_DATABASE: postgresql
GIT_COMMIT_MESSAGE: ${{ github.event.head_commit.message }}
run: go run scripts/datadog-cireport/main.go gotests.xml

- uses: codecov/codecov-action@v2
Expand Down
7 changes: 7 additions & 0 deletions coderd/provisionerdaemons.go
Original file line number Diff line number Diff line change
Expand Up @@ -377,6 +377,13 @@ func (server *provisionerdServer) CancelJob(ctx context.Context, cancelJob *prot
if err != nil {
return nil, xerrors.Errorf("parse job id: %w", err)
}
job, err := server.Database.GetProvisionerJobByID(ctx, jobID)
if err != nil {
return nil, xerrors.Errorf("get provisioner job: %w", err)
}
if job.CompletedAt.Valid {
return nil, xerrors.Errorf("job already completed")
}
err = server.Database.UpdateProvisionerJobWithCompleteByID(ctx, database.UpdateProvisionerJobWithCompleteByIDParams{
ID: jobID,
CompletedAt: sql.NullTime{
Expand Down
14 changes: 10 additions & 4 deletions scripts/datadog-cireport/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ func main() {
pipelineURL += fmt.Sprintf("/attempts/%s", os.Getenv("GITHUB_RUN_ATTEMPT"))
}

commitMessage, err := exec.Command("git", "show", "-s", "--format=%s").CombinedOutput()
commitMessage, err := exec.Command("git", "log", "-1", "--pretty=format:%s").CombinedOutput()
if err != nil {
log.Fatalf("Get commit message: %s", err)
}
Expand All @@ -63,7 +63,7 @@ func main() {
"service": "coder",
"_dd.cireport_version": "2",

"database": os.Getenv("DD_DATABASE"),
"test.traits": fmt.Sprintf(`{"database":["%s"]}`, os.Getenv("DD_DATABASE")),

// Additional tags found in DataDog docs. See:
// https://docs.datadoghq.com/continuous_integration/setup_tests/junit_upload/#collecting-environment-configuration-metadata
Expand All @@ -82,7 +82,7 @@ func main() {
"git.commit.sha": githubSHA,
"git.repository_url": fmt.Sprintf("%s/%s.git", githubServerURL, githubRepository),

"git.commit.message": strings.TrimSpace(string(commitMessage)),
"git.commit.message": string(commitMessage),
"git.commit.author.name": commitParts[0],
"git.commit.author.email": commitParts[1],
"git.commit.author.date": commitParts[2],
Expand Down Expand Up @@ -174,5 +174,11 @@ func main() {
if err != nil {
log.Fatalf("Pretty print: %s", err)
}
_, _ = fmt.Printf("Status code: %d\nResponse: %s\n", res.StatusCode, msg)
_, _ = fmt.Println(string(msg))
msg, err = json.MarshalIndent(tags, "", "\t")
if err != nil {
log.Fatalf("Marshal tags: %s", err)
}
_, _ = fmt.Println(string(msg))
_, _ = fmt.Printf("Status: %d\n", res.StatusCode)
}