Skip to content
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

add buildkite upload #68

Merged
merged 1 commit into from
Nov 28, 2023
Merged

add buildkite upload #68

merged 1 commit into from
Nov 28, 2023

Conversation

finn-block
Copy link
Contributor

and re-arranged some stuff:

  • split out all report renders to their own file
  • update result struct to track per-test runtime
  • disable failing web5-kt test
  • use web5-js test from web5-js repo, drop web5-js test from this repo
  • renamed the go package to reflect the current repo name

Copy link
Contributor

@andresuribe87 andresuribe87 left a comment

Choose a reason for hiding this comment

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

Should there be tests for the template producing pieces of the scaffolding?

.github/workflows/self-test.yaml Show resolved Hide resolved
return err
}

if resp.StatusCode > 299 {
Copy link
Contributor

Choose a reason for hiding this comment

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

Would it make sense to check <200?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I can't find any documentation on the expected error codes from buildkite for this endpoint, but > 299 will catch any normal error code. < 200 is "informational" (according to MDN)

Copy link
Member

Choose a reason for hiding this comment

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

we have a helper func in other libs that is like

func is200Status(code int) bool {
  return code / 200 != 2 
}

func addFormValue(writer *multipart.Writer, key, value string) error {
field, err := writer.CreateFormField(key)
if err != nil {
slog.Error("error creating form field", "key", key, "value", value)
Copy link
Contributor

Choose a reason for hiding this comment

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

I noticed the pattern of logging errors liberally, which results in logging the same error multiple times. This isn't a big deal, but wanted to share some principles I've found to produce very readable code with excellent logging of errors:

  • Return wrapped errors when calling a function that's exported from another package which returns an error, or when you want to add additional context.
  • Log at the root level where errors are bubbled up to.

Let me elaborate with an example.

func runCmd() {
  if err := buildkiteUpload(); err != nil {
    slog.Error("uploading buildkite", err)
  }
}

func buildkiteUpload() error {
  if err := addFormValue("foo"); err != nil {
    return errors.Wrap(err, "adding form value foo")
  }
  if err := addFormValue("bar"); err != nil {
    return errors.Wrap(err, "adding form value bar")
  }
  return nil
}

func addFormValue() error {
   if err := DoExternalPackageCallThatMayError(); err != nil {
    return errors.Wrap(err, "doing external package call")
  }
  return nil
}

Notice how logging is only done at the top level function. When reading the log, the causality chain will be readable. I.e. the error will be logged as adding form value foo : doing external package call : memory failed to allocate. Additionally, the stack trace will also be logged, so you know exactly where the problem was.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm certainly familiar with that pattern, but personally prefer the the context messages related to the error to be logged on separate lines. I find it more readable. If the exact same message is getting repeated multiple times, that's an issue, but this is just adding context that may or may not be relevant to help understand where the error originated. I find the pattern of having an increasingly long error message with all the context on a single line to be confusing and hard to read.

If people have strong opinions, I'm happy to change this, but if it's my code and I'm going to have to debug it, I would prefer the approach i've adopted.

Copy link
Contributor

Choose a reason for hiding this comment

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

I've already expressed my opinion :)
No big deal, I think it's an implementation detail.

@@ -11,7 +11,11 @@ jobs:
- uses: actions/checkout@v3
- uses: actions/setup-go@v4
- name: run for all SDKs
run: cd test-harness && go run ./cmd/web5-test-harness many sdks/* && mv _site ../_site
run: |
git clone https://github.com/TBD54566975/web5-js.git
Copy link
Member

Choose a reason for hiding this comment

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

nit: let's favor ssh checkout over https

Copy link
Contributor Author

Choose a reason for hiding this comment

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

this results in a failure (ci output):

image

@andresuribe87
Copy link
Contributor

@finn-tbd just wanted to make sure you didn't miss #68 (review)

tl;dr; should all the code in here be tested? Apologies if it's being tested already and I missed it.

Otherwise this lgtm

@finn-block
Copy link
Contributor Author

finn-block commented Nov 28, 2023

@andresuribe87 this is all tested, most of it in the branch's CI:

edit: unless you're talking about more automated correctness verification like unit tests or something. I don't feel those are necessary right now, especially with the desire to increase our velocity, but if others disagree I'm open to looking at ways to unit test the templates.

Fixes #65

and re-arranged some stuff:
* split out all report renders to their own file
* update result struct to track per-test runtime
* disable failing web5-kt test
* use web5-js test from web5-js repo, drop web5-js test from this repo
* renamed the go package to reflect the current repo name
@andresuribe87
Copy link
Contributor

edit: unless you're talking about more automated correctness verification like unit tests or something. I don't feel those are necessary right now, especially with the desire to increase our velocity, but if others disagree I'm open to looking at ways to unit test the templates.

I was talking about those automated tests. I'd expect things to be really easy to test if you already have samples. I would argue not having them decreases our velocity in the medium term, as modifications to anything in the upload pipeline will be hard to verify.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants