ubicloud/spec
Enes Cakir 0793488ad4 Set the workflow_job data when fetching from the GitHub API
Normally, we fill the `workflow_job` data of the `GithubRunner` object
when the `workflow_job.in_progress` webhook event is delivered. [^1]

We use the `head_branch` value from this data at runtime endpoints to
validate the scope cache.

When this data is missing, we try to retrieve it from the GitHub API.
Since this operation can be costly, it's a good idea to persist the
result if the same job needs the same data before the webhook is
delivered. [^2]

Since the GitHub API doesn't have proper filtering, we fetch all jobs of
the workflow run and try to find the corresponding runner using the
`runner_name` property.

As another improvement, we can update the `workflow_job` column of the
all jobs we've already fetched. We can use code similar to this, but I
need to think more about it. It's not good practice to update resources
other than the prog's subject, so we should also prevent to overwrite
existing data.

```ruby
jobs.each do |job|
  GithubRunner.where(id: UBID.to_uuid(job[:runner_name]), workflow_job: nil).update(workflow_job: Sequel.pg_jsonb(job.except("steps")))
end
```

[^1]: d4c19c2bec/routes/webhook/github.rb (L90)
[^2]: d4c19c2bec/routes/runtime/github.rb (L28)
2025-05-13 22:51:38 +03:00
..
clec Introduce autoloading of a test helper 2024-10-29 07:40:12 -07:00
lib Set the GitHub API's per_page value at the client level 2025-05-13 22:27:58 +03:00
model Pass the vm host family while assembling it 2025-05-13 17:25:23 +03:00
prog Enable GitHub client auto pagination explicitly 2025-05-13 22:22:24 +03:00
routes Set the workflow_job data when fetching from the GitHub API 2025-05-13 22:51:38 +03:00
scheduling Add a family filter to the VM host allocator 2025-05-13 17:25:23 +03:00
serializers Change rubocop TargetRubyVersion to 3.4 2025-04-26 06:51:19 +09:00
cli_config.ru Change CLI --version option to version command 2025-03-19 14:08:49 -07:00
cli_spec.rb Delete the UBI_TOKEN environment variable before testing for its absence 2025-04-08 22:22:45 +03:00
config_spec.rb Increase Config test coverage and delete unused lines 2023-08-07 01:05:05 +03:00
coverage_helper.rb Support coverage for specific rhizome files 2025-02-04 08:56:06 +01:00
db_spec.rb Add specs for the audit_log table 2025-05-13 06:38:49 +09:00
resource_methods_spec.rb Update specs to handle Object#inspect changes in Ruby 3.4 2025-04-23 06:01:19 +09:00
ruby_sdk_spec.rb Add inference api key support to the ruby sdk 2025-05-03 03:33:32 +09:00
spec_helper.rb Pass the vm host family while assembling it 2025-05-13 17:25:23 +03:00
thawed_mock.rb Update bin/monitor to export metrics to VictoriaMetrics 2025-05-09 18:26:44 +05:30
ubid_spec.rb Change rubocop TargetRubyVersion to 3.4 2025-04-26 06:51:19 +09:00