airtap / sauce

Sauce Labs browser provider.
MIT License
0 stars 1 forks source link

Possible to send build numbers / tagging info to Sauce Labs for annotation purposes? #8

Closed jzombie closed 3 years ago

jzombie commented 3 years ago

Is it possible to add build numbers, and / or tagging, to Sauce Labs builds by using this?

https://wiki.saucelabs.com/display/DOCS/Annotating+Tests+with+the+Sauce+Labs+REST+API

My builds show up as Sauce Labs Unknown in the badge status. The simple-peer repository (https://github.com/feross/simple-peer) doesn't seem to be annotating with build numbers, and their badge shows up as building just fine.

vweevers commented 3 years ago

How are build numbers and badges related? We do send a build number and name to Sauce Labs:

https://github.com/airtap/sauce/blob/a18342709ae5be520a65610a84184b873ab59eeb/index.js#L136-L137

Could it be a cache issue (which is common with badges)? How long ago did your build run?

jzombie commented 3 years ago

I last ran it 10 hours ago: https://app.saucelabs.com/open_sauce/user/zenosmosis/tests/vdc

My badge URL is https://saucelabs.com/buildstatus/zenosmosis; repo is https://github.com/jzombie/webrtc-peer

vweevers commented 3 years ago

Try using the https://app.saucelabs.com/ domain, I saw on matrix images that the saucelabs.com no longer works.

jzombie commented 3 years ago

Same results: https://app.saucelabs.com/buildstatus/zenosmosis

jzombie commented 3 years ago

In regards to the build correlation, this is the email I received from one of their engineers.


Our engineers mentioned that the badge shows unknown, because you're not using builds. Once you add a build to your tests, the badge will work.

For example, this test shows null for the build value. https://app.saucelabs.com/tests/e3a04d4372854163a897e1a0ee79499e

https://wiki.saucelabs.com/display/DOCS/Best+Practice%3A+Use+Build+IDs%2C+Tags%2C+and+Names+to+Identify+Your+Tests

Best, Hanssen

vweevers commented 3 years ago

I tried a bunch of others (abstract-leveldown, level-js, level-ci - all using Airtap 4) and their badges work. Maybe that's because they previously used Airtap 3 and the badge status still reflects old builds.

I'll check the build numbers.

jzombie commented 3 years ago

Thanks!

vweevers commented 3 years ago

I reckon it's because https://github.com/nkt/build-number/blob/master/index.js doesn't support GitHub Actions. We can add a github-specific id here:

https://github.com/airtap/sauce/blob/a18342709ae5be520a65610a84184b873ab59eeb/index.js#L132

I.e. const build = buildNumber() || process.env.GITHUB_RUN_ID.

jzombie commented 3 years ago

Nice, I can do a temporary fork and try it if needed.

vweevers commented 3 years ago

Please do, thank you!

I'm not 100% sure GITHUB_RUN_ID is the right variable. It's documented as:

A unique number for each run within a repository. This number does not change if you re-run the workflow run.

Which, if Sauce Labs supports this, should mean that a previous build status will be overwritten (e.g. when a temporary failure occurred and you retry the workflow run).

jzombie commented 3 years ago

There is also GITHUB_RUN_NUMBER.

If I get it to work, I'll submit a patch.

Thanks for the help getting me started here.

jzombie commented 3 years ago

Here's the PR: https://github.com/airtap/sauce/pull/9