Support changing labels #201

Merged
wolfogre merged 31 commits from sillyguodong/act_runner:feature/declare_labels into main 2023-06-15 03:59:17 +00:00
Member
Implement proposal: https://github.com/go-gitea/gitea/issues/24540 Related: - Protocol: https://gitea.com/gitea/actions-proto-def/pulls/9 - Gitea side: https://github.com/go-gitea/gitea/pull/24806
sillyguodong added 10 commits 2023-05-19 08:29:56 +00:00
fix comment
Some checks failed
checks / check and test (pull_request) Failing after 39s
a20a89fb75
go mod
All checks were successful
checks / check and test (pull_request) Successful in 38s
44366109b2
test
Some checks failed
checks / check and test (pull_request) Failing after 37s
ca6b129163
fix
Some checks failed
checks / check and test (pull_request) Failing after 35s
0b38c4f6c7
sillyguodong added 1 commit 2023-05-19 08:31:52 +00:00
comment
Some checks failed
checks / check and test (pull_request) Failing after 35s
3c6d18a2b8
sillyguodong changed title from Support changing labels to WIP: Support changing labels 2023-05-19 08:43:19 +00:00
sillyguodong added 1 commit 2023-05-19 09:31:34 +00:00
Merge branch 'main' into feature/declare_labels
Some checks failed
checks / check and test (pull_request) Failing after 35s
8427d62126
sillyguodong added 1 commit 2023-05-20 12:24:19 +00:00
pass version when registering and declaring
Some checks failed
checks / check and test (pull_request) Failing after 36s
9a0d46fa66
sillyguodong added 1 commit 2023-05-22 04:21:10 +00:00
no pass version when new grpc client
Some checks failed
checks / check and test (pull_request) Failing after 49s
5d4e8cb73d
sillyguodong changed title from WIP: Support changing labels to Support changing labels 2023-06-05 10:05:38 +00:00
sillyguodong added 1 commit 2023-06-05 10:35:43 +00:00
fix log
Some checks failed
checks / check and test (pull_request) Failing after 48s
4dd6a5536d
sillyguodong added 1 commit 2023-06-06 02:07:03 +00:00
update go mod
All checks were successful
checks / check and test (pull_request) Successful in 1m25s
87f105a8a6
sillyguodong added 1 commit 2023-06-06 02:13:20 +00:00
Merge branch 'main' into feature/declare_labels
# Conflicts:
#	internal/pkg/config/config.go
All checks were successful
checks / check and test (pull_request) Successful in 41s
d0ec5b4dd3
sillyguodong added 1 commit 2023-06-06 03:03:51 +00:00
add version v prefix in makefile
All checks were successful
checks / check and test (pull_request) Successful in 40s
2efdf1dbb7
Owner

Release a new tag for actions-proto-go, please update.

Release a [new tag](https://gitea.com/gitea/actions-proto-go/releases/tag/v0.3.0) for actions-proto-go, please update.
sillyguodong added 1 commit 2023-06-06 03:45:34 +00:00
update go mod
All checks were successful
checks / check and test (pull_request) Successful in 1m19s
e89f91316c
wolfogre requested changes 2023-06-06 04:10:43 +00:00
@ -72,2 +78,4 @@
runner := run.NewRunner(cfg, reg, cli)
// declare the labels of the runner before fetching tasks
err = runner.Declare(ctx, ls.Names())
Owner

Not correct, should be:

  1. Parse labels from config.
  2. Invoke Declare
  3. If Declare return UNIMPLEMENTED (see https://grpc.github.io/grpc/core/md_doc_statuscodes.html), show warning logs and fallback to old logic, because the Gitea instance is an old version.
  4. If Declare return successfully, check if labels in config file and registration file are equal.
  5. SaveRegistration if necessary, and show info logs.
Not correct, should be: 1. Parse labels from config. 2. Invoke `Declare` 3. If `Declare` return `UNIMPLEMENTED` (see https://grpc.github.io/grpc/core/md_doc_statuscodes.html), show warning logs and fallback to old logic, because the Gitea instance is an old version. 4. If `Declare` return successfully, check if labels in config file and registration file are equal. 5. `SaveRegistration` if necessary, and show info logs.
sillyguodong marked this conversation as resolved
@ -46,6 +46,7 @@ func runRegister(ctx context.Context, regArgs *registerArgs, configFile *string)
log.Warnf("Runner in user-mode.")
}
log.Warnf("configFile: %s", *configFile)
Owner

Why Warn?

Why `Warn`?
sillyguodong marked this conversation as resolved
@ -39,9 +39,6 @@ func New(endpoint string, insecure bool, uuid, token, version string, opts ...co
if token != "" {
req.Header().Set(TokenHeader, token)
}
if version != "" {
Owner

Keep this, be compatibility with older Gitea instances.

Keep this, be compatibility with older Gitea instances.
sillyguodong marked this conversation as resolved
@ -28,1 +28,4 @@
fetch_interval: 2s
# The labels of a runner are used to determine which jobs the runner can run, and how to run them.
# Please enter sequences (equivalent to lists or arrays).
labels:
Owner

Not everyone knows YAML well enough to understand Please enter sequences (equivalent to lists or arrays).

Maybe:

-  # Please enter sequences (equivalent to lists or arrays).
+  # Like ["TODO", "TODO", "TODO"]
+  # If it's empty, ... TODO
-  labels:
+  labels: []
Not everyone knows YAML well enough to understand `Please enter sequences (equivalent to lists or arrays).` Maybe: ```diff - # Please enter sequences (equivalent to lists or arrays). + # Like ["TODO", "TODO", "TODO"] + # If it's empty, ... TODO - labels: + labels: [] ```
sillyguodong marked this conversation as resolved
sillyguodong added 1 commit 2023-06-06 08:57:44 +00:00
fix
Some checks failed
checks / check and test (pull_request) Failing after 35s
71a61d161b
sillyguodong added 1 commit 2023-06-06 09:17:09 +00:00
still pass version by request header
Some checks failed
checks / check and test (pull_request) Failing after 36s
e8873419aa
sillyguodong added 1 commit 2023-06-06 09:25:07 +00:00
vet
All checks were successful
checks / check and test (pull_request) Successful in 40s
8bbc2f22d5
sillyguodong added 1 commit 2023-06-07 06:02:19 +00:00
Merge branch 'main' into feature/declare_labels
All checks were successful
checks / check and test (pull_request) Successful in 1m28s
c9a8427124
wolfogre requested changes 2023-06-08 03:49:33 +00:00
@ -46,0 +48,4 @@
var overwrite bool
if len(cfg.Runner.Labels) > 0 {
// Determine if the labels in the `.runner` file are the same as the labels in config.
if isEqual := utils.AreStrSlicesElemsEqual(cfg.Runner.Labels, reg.Labels); !isEqual {
Owner

Why AreStrSlicesElemsEqual?

I think it's a good idea to keep exactly the same value in .runner and config file, even the order.

Why `AreStrSlicesElemsEqual`? I think it's a good idea to keep exactly the same value in `.runner` and config file, even the order.
sillyguodong marked this conversation as resolved
@ -41,3 +41,4 @@
}
// TODO: version will be removed from request header after Gitea 1.20 released.
if version != "" {
req.Header().Set(VersionHeader, version)
Owner

VersionHeader could be deprecated.

`VersionHeader` could be deprecated.
sillyguodong marked this conversation as resolved
@ -28,1 +28,4 @@
fetch_interval: 2s
# The labels of a runner are used to determine which jobs the runner can run, and how to run them.
# Like: ["macos-arm64:host", "ubuntu-latest:docker://node:16-bullseye", "ubuntu-22.04:docker://node:16-bullseye"]
# If it's empty when registering, will use default labels.
Owner

Incorrect.

-  # If it's empty when registering, will use default labels.
+  # If it's empty when registering, it will ask for inputting labels.
Incorrect. ```diff - # If it's empty when registering, will use default labels. + # If it's empty when registering, it will ask for inputting labels. ```
sillyguodong marked this conversation as resolved
@ -0,0 +6,4 @@
import "reflect"
// AreStrSlicesElemsEqual determines whether elements in two slices are equal (ignoring order).
func AreStrSlicesElemsEqual(s1, s2 []string) bool {
Owner

Incorrect.

Think about:

[a, b, b]
[a, a, b]

Maybe
477a1cc40e/modules/util/slice.go (L39)

But I don't think we really need this here.

Incorrect. Think about: ```text [a, b, b] [a, a, b] ``` Maybe https://github.com/go-gitea/gitea/blob/477a1cc40ebd3ecb116c632b0717bba748e914d2/modules/util/slice.go#L39 But I don't think we really need this here.
sillyguodong marked this conversation as resolved
sillyguodong added 1 commit 2023-06-08 07:30:10 +00:00
update
All checks were successful
checks / check and test (pull_request) Successful in 40s
f3209257ae
sillyguodong added 1 commit 2023-06-08 07:35:56 +00:00
comment
All checks were successful
checks / check and test (pull_request) Successful in 39s
1373c1e828
sillyguodong requested review from wolfogre 2023-06-08 08:16:00 +00:00
sillyguodong added 1 commit 2023-06-09 03:16:28 +00:00
do not exit if not specify labels in config
All checks were successful
checks / check and test (pull_request) Successful in 41s
489d8df450
wolfogre approved these changes 2023-06-09 03:27:50 +00:00
wolfogre added 1 commit 2023-06-09 03:28:18 +00:00
Merge branch 'main' into feature/declare_labels
All checks were successful
checks / check and test (pull_request) Successful in 38s
658513ab20
sillyguodong added 1 commit 2023-06-12 06:32:30 +00:00
Merge branch 'main' into feature/declare_labels
All checks were successful
checks / check and test (pull_request) Successful in 1m1s
7407e884df
sillyguodong added 1 commit 2023-06-12 07:00:51 +00:00
Merge branch 'main' into feature/declare_labels
All checks were successful
checks / check and test (pull_request) Successful in 54s
ad3ff08e26
Owner
~~Blocked by https://github.com/go-gitea/gitea/pull/24806~~
sillyguodong added 1 commit 2023-06-13 08:18:50 +00:00
adapt to older version Gitea
All checks were successful
checks / check and test (pull_request) Successful in 57s
f24147ce0f
Contributor

Stating here for the record:

If act_runner connect to an old version of Gitea instance, the feature would be disabled and warning would be logged, but runner can still run without the error.

Stating here for the record: If act_runner connect to an old version of Gitea instance, the feature would be disabled and warning would be logged, but runner can still run without the error.
Owner
https://github.com/go-gitea/gitea/pull/24806 is merged.
wolfogre added 1 commit 2023-06-15 03:32:17 +00:00
Merge branch 'main' into feature/declare_labels
All checks were successful
checks / check and test (pull_request) Successful in 59s
eb37630603
wolfogre merged commit 67b1363d25 into main 2023-06-15 03:59:17 +00:00
Sign in to join this conversation.
No description provided.