WIP: Add a PeekTask endpoint to the actions API #5849

Closed
wetneb wants to merge 1 commit from wetneb/forgejo:5847-PeekTask-API into forgejo
Member

This lets a runner check if a task is available for it, without getting the task assigned to it immediately.

For #5847. So far just an untested proof of concept.

Problems

This area of the code doesn't seem covered by tests much so it's unclear to me how to set them up. If people have pointers to tests to take inspiration from, I'd be very grateful.

Also, this new PeekTask API is reusing the protobuf request/responses from the FetchTask endpoint. Is that fine? Intuitively, the response at least ought to be separate, because we shouldn't return a task, but rather a boolean indicating if a task is available, or even better, the number of pending tasks (so that one can scale a pool of runners dynamically), as suggested by @dcz_pf. But it seems to me that the protobuf declarations are not part of this code base, so it would be harder to modify them as things stand. Alternatively, we could make separate Protobuf declarations in the forgejo repository only for this API endpoint, without forking the others.

Also, I couldn't figure out how to specify that PeekTask expects GET requests, compared to FetchTask which should be called with POST requests only (I think?)

Checklist

Tests

  • I added test coverage for Go changes...
    • in their respective *_test.go for unit tests.
    • in the tests/integration directory if it involves interactions with a live Forgejo server.
  • I added test coverage for JavaScript changes...

Documentation

  • I created a pull request to the documentation to explain to Forgejo users how to use this change.
  • I did not document these changes and I do not expect someone else to do it.

Release notes

  • I do not want this change to show in the release notes.
  • I want the title to show in the release notes with a link to this pull request.
  • I want the content of the release-notes/<pull request number>.md to be be used for the release notes instead of the title.
This lets a runner check if a task is available for it, without getting the task assigned to it immediately. For #5847. So far just an untested proof of concept. ## Problems This area of the code doesn't seem covered by tests much so it's unclear to me how to set them up. If people have pointers to tests to take inspiration from, I'd be very grateful. Also, this new `PeekTask` API is reusing the protobuf request/responses from the `FetchTask` endpoint. Is that fine? Intuitively, the response at least ought to be separate, because we shouldn't return a task, but rather a boolean indicating if a task is available, or even better, the number of pending tasks (so that one can scale a pool of runners dynamically), as [suggested](https://codeberg.org/dcz_pf/ci_fetcher) by @dcz_pf. But it seems to me that the protobuf declarations are not part of this code base, so it would be harder to modify them as things stand. Alternatively, we could make separate Protobuf declarations in the forgejo repository only for this API endpoint, without forking the others. Also, I couldn't figure out how to specify that `PeekTask` expects GET requests, compared to `FetchTask` which should be called with POST requests only (I think?) ## Checklist ### Tests - I added test coverage for Go changes... - [ ] in their respective `*_test.go` for unit tests. - [ ] in the `tests/integration` directory if it involves interactions with a live Forgejo server. - I added test coverage for JavaScript changes... - [ ] in `web_src/js/*.test.js` if it can be unit tested. - [ ] in `tests/e2e/*.test.e2e.js` if it requires interactions with a live Forgejo server (see also the [developer guide for JavaScript testing](https://codeberg.org/forgejo/forgejo/src/branch/forgejo/tests/e2e/README.md#end-to-end-tests)). ### Documentation - [ ] I created a pull request [to the documentation](https://codeberg.org/forgejo/docs) to explain to Forgejo users how to use this change. - [ ] I did not document these changes and I do not expect someone else to do it. ### Release notes - [ ] I do not want this change to show in the release notes. - [ ] I want the title to show in the release notes with a link to this pull request. - [ ] I want the content of the `release-notes/<pull request number>.md` to be be used for the release notes instead of the title.
Contributor

Please rebase your pull request or merge the latest target branch. It is necessary for the tests to not be skipped. A change in how the CI is run was done 12 hours ago and the requirement it imposes on open pull requests was overlooked. Sorry for the inconvenience.

Please rebase your pull request or merge the latest target branch. It is necessary for the tests to not be skipped. A change in how the CI is run was done 12 hours ago and the requirement it imposes on open pull requests was overlooked. Sorry for the inconvenience.
wetneb force-pushed 5847-PeekTask-API from 4f6cebaecc
All checks were successful
/ backporting (pull_request_target) Has been skipped
testing / frontend-checks (pull_request) Successful in 1m32s
/ info (pull_request_target) Successful in 3s
/ cascade (pull_request_target) Has been skipped
testing / backend-checks (pull_request) Successful in 2m59s
testing / test-e2e (pull_request) Successful in 2m2s
testing / test-unit (pull_request) Successful in 5m14s
testing / test-remote-cacher (map[image:docker.io/bitnami/redis:7.2 port:6379]) (pull_request) Successful in 1m39s
testing / test-remote-cacher (map[image:docker.io/bitnami/valkey:7.2 port:6379]) (pull_request) Successful in 1m56s
testing / test-remote-cacher (map[image:ghcr.io/microsoft/garnet-alpine:1.0.14 port:6379]) (pull_request) Successful in 1m55s
testing / test-remote-cacher (map[image:registry.redict.io/redict:7.3.0-scratch port:6379]) (pull_request) Successful in 1m49s
testing / test-mysql (pull_request) Successful in 22m1s
testing / test-sqlite (pull_request) Successful in 22m16s
/ release-notes (pull_request_target) Has been skipped
testing / test-pgsql (pull_request) Successful in 27m7s
testing / security-check (pull_request) Successful in 1m22s
to 9c99755dcf
Some checks failed
/ release-notes (pull_request_target) Has been skipped
testing / frontend-checks (pull_request) Successful in 1m10s
testing / backend-checks (pull_request) Successful in 2m35s
testing / test-e2e (pull_request) Successful in 2m25s
testing / test-unit (pull_request) Successful in 4m28s
testing / test-remote-cacher (map[image:docker.io/bitnami/redis:7.2 port:6379]) (pull_request) Successful in 1m52s
testing / test-remote-cacher (map[image:docker.io/bitnami/valkey:7.2 port:6379]) (pull_request) Successful in 2m48s
testing / test-remote-cacher (map[image:ghcr.io/microsoft/garnet-alpine:1.0.14 port:6379]) (pull_request) Successful in 2m25s
testing / test-remote-cacher (map[image:registry.redict.io/redict:7.3.0-scratch port:6379]) (pull_request) Successful in 2m19s
testing / test-mysql (pull_request) Successful in 21m34s
testing / test-sqlite (pull_request) Successful in 21m59s
testing / test-pgsql (pull_request) Successful in 24m32s
testing / security-check (pull_request) Successful in 55s
requirements / merge-conditions (pull_request) Failing after 2s
issue-labels / cascade (pull_request_target) Has been skipped
issue-labels / release-notes (pull_request_target) Has been skipped
issue-labels / backporting (pull_request_target) Has been skipped
milestone / set (pull_request_target) Has been skipped
2024-11-14 08:19:06 +01:00
Compare
Contributor

This pull request contains good code but it has not seen any activity in a long time. In order to unclutter the queue and help reviewers focus on those that are actively worked on, it is now closed. Feel free to re-open it as soon as you want. It is also marked with the label valuable code so it can conveniently be found later and not confused with pull requests closed for other reasons.

This pull request contains good code but it has not seen any activity in a long time. In order to unclutter the queue and help reviewers focus on those that are actively worked on, it is now closed. Feel free to re-open it as soon as you want. It is also marked with the label `valuable code` so it can conveniently be found later and not confused with pull requests closed for other reasons.
earl-warren closed this pull request 2025-02-02 12:36:44 +01:00
Some checks failed
/ release-notes (pull_request_target) Has been skipped
testing / frontend-checks (pull_request) Successful in 1m10s
Required
Details
testing / backend-checks (pull_request) Successful in 2m35s
Required
Details
testing / test-e2e (pull_request) Successful in 2m25s
testing / test-unit (pull_request) Successful in 4m28s
Required
Details
testing / test-remote-cacher (map[image:docker.io/bitnami/redis:7.2 port:6379]) (pull_request) Successful in 1m52s
testing / test-remote-cacher (map[image:docker.io/bitnami/valkey:7.2 port:6379]) (pull_request) Successful in 2m48s
testing / test-remote-cacher (map[image:ghcr.io/microsoft/garnet-alpine:1.0.14 port:6379]) (pull_request) Successful in 2m25s
testing / test-remote-cacher (map[image:registry.redict.io/redict:7.3.0-scratch port:6379]) (pull_request) Successful in 2m19s
testing / test-mysql (pull_request) Successful in 21m34s
Required
Details
testing / test-sqlite (pull_request) Successful in 21m59s
Required
Details
testing / test-pgsql (pull_request) Successful in 24m32s
Required
Details
testing / security-check (pull_request) Successful in 55s
requirements / merge-conditions (pull_request) Failing after 2s
issue-labels / cascade (pull_request_target) Has been skipped
issue-labels / release-notes (pull_request_target) Has been skipped
issue-labels / backporting (pull_request_target) Has been skipped
milestone / set (pull_request_target) Has been skipped

Pull request closed

Sign in to join this conversation.
No reviewers
No labels
arch
riscv64
backport/v1.19
backport/v1.20
backport/v1.21/forgejo
backport/v10.0/forgejo
backport/v11.0/forgejo
backport/v12.0/forgejo
backport/v13.0/forgejo
backport/v14.0/forgejo
backport/v15.0/forgejo
backport/v7.0/forgejo
backport/v8.0/forgejo
backport/v9.0/forgejo
breaking
bug
bug
confirmed
bug
duplicate
bug
needs-more-info
bug
new-report
bug
reported-upstream
code/actions
code/api
code/auth
code/auth/faidp
code/auth/farp
code/email
code/federation
code/git
code/migrations
code/packages
code/wiki
database
MySQL
database
PostgreSQL
database
SQLite
dependency-upgrade
dependency
certmagic
dependency
chart.js
dependency
Chi
dependency
Chroma
dependency
citation.js
dependency
codespell
dependency
css-loader
dependency
devcontainers
dependency
dropzone
dependency
editorconfig-checker
dependency
elasticsearch
dependency
enmime
dependency
F3
dependency
ForgeFed
dependency
garage
dependency
Git
dependency
git-backporting
dependency
Gitea
dependency
gitignore
dependency
go-ap
dependency
go-enry
dependency
go-gitlab
dependency
Go-org
dependency
go-rpmutils
dependency
go-sql-driver mysql
dependency
go-swagger
dependency
go-version
dependency
go-webauthn
dependency
gocron
dependency
Golang
dependency
goldmark
dependency
goquery
dependency
Goth
dependency
grpc-go
dependency
happy-dom
dependency
Helm
dependency
image-spec
dependency
jsonschema
dependency
KaTeX
dependency
lint
dependency
MariaDB
dependency
Mermaid
dependency
minio-go
dependency
misspell
dependency
Monaco
dependency
PDFobject
dependency
playwright
dependency
postcss
dependency
postcss-plugins
dependency
pprof
dependency
prometheus client_golang
dependency
protobuf
dependency
relative-time-element
dependency
renovate
dependency
reply
dependency
ssh
dependency
swagger-ui
dependency
tailwind
dependency
temporal-polyfill
dependency
terminal-to-html
dependency
tests-only
dependency
text-expander-element
dependency
urfave
dependency
vfsgen
dependency
vite
dependency
Woodpecker CI
dependency
x tools
dependency
XORM
Discussion
duplicate
enhancement/feature
forgejo/accessibility
forgejo/branding
forgejo/ci
forgejo/commit-graph
forgejo/documentation
forgejo/furnace cleanup
forgejo/i18n
forgejo/interop
forgejo/moderation
forgejo/privacy
forgejo/release
forgejo/scaling
forgejo/security
forgejo/ui
Gain
High
Gain
Nice to have
Gain
Undefined
Gain
Very High
good first issue
i18n/backport-stable
impact
large
impact
medium
impact
small
impact
unknown
Incompatible license
issue
closed
issue
do-not-exist-yet
issue
open
manual test
Manually tested during feature freeze
OS
FreeBSD
OS
Linux
OS
macOS
OS
Windows
problem
QA
regression
release blocker
Release Cycle
Feature Freeze
release-blocker
v7.0
release-blocker
v7.0.1
release-blocker
v7.0.2
release-blocker
v7.0.3
release-blocker
v7.0.4
release-blocker
v8.0.0
release-blocker/v9.0.0
run-all-playwright-tests
run-end-to-end-tests
test
manual
test
needed
test
needs-help
test
not-needed
test
present
untested
User research - time-tracker
valuable code
worth a release-note
User research - Accessibility
User research - Blocked
User research - Community
User research - Config (instance)
User research - Errors
User research - Filters
User research - Future backlog
User research - Git workflow
User research - Labels
User research - Moderation
User research - Needs input
User research - Notifications/Dashboard
User research - Rendering
User research - Repo creation
User research - Repo units
User research - Security
User research - Settings (in-app)
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
forgejo/forgejo!5849
No description provided.