mirror of
https://code.forgejo.org/forgejo/runner.git
synced 2025-06-27 16:35:58 +00:00
chore: fix typos and add type checking to port/addr args (#576)
Hi! ~~ba2fc1273ce5cb04d96cfdbb47ebad929dcbd96f goes in tandem with https://code.forgejo.org/forgejo/act/pulls/135 and adapts to the API changes for `runner.Config.`~~ I dropped the act interface changes according to https://code.forgejo.org/forgejo/act/pulls/135#issuecomment-40695, but kept the CLI changes here - as they are not breaking here. Other three commits just fix up some typos around the tree - bit of a pet peeve of mine, sorry :^) Reviewed-on: https://code.forgejo.org/forgejo/runner/pulls/576 Reviewed-by: earl-warren <earl-warren@noreply.code.forgejo.org> Co-authored-by: Christoph Heiss <christoph@c8h4.io> Co-committed-by: Christoph Heiss <christoph@c8h4.io>
This commit is contained in:
parent
5a3d0bba9e
commit
efa324d16a
6 changed files with 23 additions and 24 deletions
8
Makefile
8
Makefile
|
@ -46,7 +46,7 @@ STORED_VERSION_FILE := VERSION
|
||||||
|
|
||||||
ifneq ($(DRONE_TAG),)
|
ifneq ($(DRONE_TAG),)
|
||||||
VERSION ?= $(subst v,,$(DRONE_TAG))
|
VERSION ?= $(subst v,,$(DRONE_TAG))
|
||||||
RELASE_VERSION ?= $(VERSION)
|
RELEASE_VERSION ?= $(VERSION)
|
||||||
else
|
else
|
||||||
ifneq ($(DRONE_BRANCH),)
|
ifneq ($(DRONE_BRANCH),)
|
||||||
VERSION ?= $(subst release/v,,$(DRONE_BRANCH))
|
VERSION ?= $(subst release/v,,$(DRONE_BRANCH))
|
||||||
|
@ -56,9 +56,9 @@ else
|
||||||
|
|
||||||
STORED_VERSION=$(shell cat $(STORED_VERSION_FILE) 2>/dev/null)
|
STORED_VERSION=$(shell cat $(STORED_VERSION_FILE) 2>/dev/null)
|
||||||
ifneq ($(STORED_VERSION),)
|
ifneq ($(STORED_VERSION),)
|
||||||
RELASE_VERSION ?= $(STORED_VERSION)
|
RELEASE_VERSION ?= $(STORED_VERSION)
|
||||||
else
|
else
|
||||||
RELASE_VERSION ?= $(shell git describe --tags --always | sed 's/-/+/' | sed 's/^v//')
|
RELEASE_VERSION ?= $(shell git describe --tags --always | sed 's/-/+/' | sed 's/^v//')
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
@ -66,7 +66,7 @@ GO_PACKAGES_TO_VET ?= $(filter-out gitea.com/gitea/act_runner/internal/pkg/clien
|
||||||
|
|
||||||
|
|
||||||
TAGS ?=
|
TAGS ?=
|
||||||
LDFLAGS ?= -X "gitea.com/gitea/act_runner/internal/pkg/ver.version=v$(RELASE_VERSION)"
|
LDFLAGS ?= -X "gitea.com/gitea/act_runner/internal/pkg/ver.version=v$(RELEASE_VERSION)"
|
||||||
|
|
||||||
all: build
|
all: build
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
**WARNING:** this is [alpha release quality](https://en.wikipedia.org/wiki/Software_release_life_cycle#Alpha) code and should not be considered secure enough to deploy in production.
|
**WARNING:** this is [alpha release quality](https://en.wikipedia.org/wiki/Software_release_life_cycle#Alpha) code and should not be considered secure enough to deploy in production.
|
||||||
|
|
||||||
A daemon that connects to a Forgejo instance and runs jobs for continous integration. The [installation and usage instructions](https://forgejo.org/docs/next/admin/actions/) are part of the Forgejo documentation.
|
A daemon that connects to a Forgejo instance and runs jobs for continuous integration. The [installation and usage instructions](https://forgejo.org/docs/next/admin/actions/) are part of the Forgejo documentation.
|
||||||
|
|
||||||
# Reporting bugs
|
# Reporting bugs
|
||||||
|
|
||||||
|
|
|
@ -36,7 +36,7 @@ Create a shared secret with:
|
||||||
openssl rand -hex 20
|
openssl rand -hex 20
|
||||||
```
|
```
|
||||||
|
|
||||||
Replace all occurences of {SHARED_SECRET} in
|
Replace all occurrences of {SHARED_SECRET} in
|
||||||
[compose-forgejo-and-runner.yml](compose-forgejo-and-runner.yml).
|
[compose-forgejo-and-runner.yml](compose-forgejo-and-runner.yml).
|
||||||
|
|
||||||
> **NOTE:** a token obtained from the Forgejo web interface cannot be used as a shared secret.
|
> **NOTE:** a token obtained from the Forgejo web interface cannot be used as a shared secret.
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
#
|
#
|
||||||
# openssl rand -hex 20
|
# openssl rand -hex 20
|
||||||
#
|
#
|
||||||
# Replace all occurences of {SHARED_SECRET} below with the output.
|
# Replace all occurrences of {SHARED_SECRET} below with the output.
|
||||||
#
|
#
|
||||||
# NOTE: a token obtained from the Forgejo web interface cannot be used
|
# NOTE: a token obtained from the Forgejo web interface cannot be used
|
||||||
# as a shared secret.
|
# as a shared secret.
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
# Secret data.
|
# Secret data.
|
||||||
# You will need to retrive this from the web UI, and your Forgejo instance must be running v1.21+
|
# You will need to retrieve this from the web UI, and your Forgejo instance must be running v1.21+
|
||||||
# Alternatively, create this with
|
# Alternatively, create this with
|
||||||
# kubectl create secret generic runner-secret --from-literal=token=your_offline_token_here
|
# kubectl create secret generic runner-secret --from-literal=token=your_offline_token_here
|
||||||
apiVersion: v1
|
apiVersion: v1
|
||||||
|
|
|
@ -7,6 +7,7 @@ package cmd
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"net"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
@ -50,8 +51,8 @@ type executeArgs struct {
|
||||||
containerCapDrop []string
|
containerCapDrop []string
|
||||||
containerOptions string
|
containerOptions string
|
||||||
artifactServerPath string
|
artifactServerPath string
|
||||||
artifactServerAddr string
|
artifactServerAddr net.IP
|
||||||
artifactServerPort string
|
artifactServerPort uint16
|
||||||
noSkipCheckout bool
|
noSkipCheckout bool
|
||||||
debug bool
|
debug bool
|
||||||
dryrun bool
|
dryrun bool
|
||||||
|
@ -256,7 +257,7 @@ func runExecList(ctx context.Context, planner model.WorkflowPlanner, execArgs *e
|
||||||
var filterEventName string
|
var filterEventName string
|
||||||
|
|
||||||
if len(execArgs.event) > 0 {
|
if len(execArgs.event) > 0 {
|
||||||
log.Infof("Using chosed event for filtering: %s", execArgs.event)
|
log.Infof("Using chosen event for filtering: %s", execArgs.event)
|
||||||
filterEventName = execArgs.event
|
filterEventName = execArgs.event
|
||||||
} else if execArgs.autodetectEvent {
|
} else if execArgs.autodetectEvent {
|
||||||
// collect all events from loaded workflows
|
// collect all events from loaded workflows
|
||||||
|
@ -316,7 +317,7 @@ func runExec(ctx context.Context, execArgs *executeArgs) func(cmd *cobra.Command
|
||||||
events := planner.GetEvents()
|
events := planner.GetEvents()
|
||||||
|
|
||||||
if len(execArgs.event) > 0 {
|
if len(execArgs.event) > 0 {
|
||||||
log.Infof("Using chosed event for filtering: %s", execArgs.event)
|
log.Infof("Using chosen event for filtering: %s", execArgs.event)
|
||||||
eventName = execArgs.event
|
eventName = execArgs.event
|
||||||
} else if len(events) == 1 && len(events[0]) > 0 {
|
} else if len(events) == 1 && len(events[0]) > 0 {
|
||||||
log.Infof("Using the only detected workflow event: %s", events[0])
|
log.Infof("Using the only detected workflow event: %s", events[0])
|
||||||
|
@ -359,13 +360,9 @@ func runExec(ctx context.Context, execArgs *executeArgs) func(cmd *cobra.Command
|
||||||
log.Infof("cache handler listens on: %v", handler.ExternalURL())
|
log.Infof("cache handler listens on: %v", handler.ExternalURL())
|
||||||
execArgs.cacheHandler = handler
|
execArgs.cacheHandler = handler
|
||||||
|
|
||||||
if len(execArgs.artifactServerAddr) == 0 {
|
if execArgs.artifactServerAddr == nil {
|
||||||
ip := common.GetOutboundIP()
|
|
||||||
if ip == nil {
|
|
||||||
return fmt.Errorf("unable to determine outbound IP address")
|
return fmt.Errorf("unable to determine outbound IP address")
|
||||||
}
|
}
|
||||||
execArgs.artifactServerAddr = ip.String()
|
|
||||||
}
|
|
||||||
|
|
||||||
if len(execArgs.artifactServerPath) == 0 {
|
if len(execArgs.artifactServerPath) == 0 {
|
||||||
tempDir, err := os.MkdirTemp("", "gitea-act-")
|
tempDir, err := os.MkdirTemp("", "gitea-act-")
|
||||||
|
@ -400,8 +397,8 @@ func runExec(ctx context.Context, execArgs *executeArgs) func(cmd *cobra.Command
|
||||||
ContainerOptions: execArgs.containerOptions,
|
ContainerOptions: execArgs.containerOptions,
|
||||||
AutoRemove: true,
|
AutoRemove: true,
|
||||||
ArtifactServerPath: execArgs.artifactServerPath,
|
ArtifactServerPath: execArgs.artifactServerPath,
|
||||||
ArtifactServerPort: execArgs.artifactServerPort,
|
ArtifactServerAddr: execArgs.artifactServerAddr.String(),
|
||||||
ArtifactServerAddr: execArgs.artifactServerAddr,
|
ArtifactServerPort: strconv.FormatUint(uint64(execArgs.artifactServerPort), 10),
|
||||||
NoSkipCheckout: execArgs.noSkipCheckout,
|
NoSkipCheckout: execArgs.noSkipCheckout,
|
||||||
// PresetGitHubContext: preset,
|
// PresetGitHubContext: preset,
|
||||||
// EventJSON: string(eventJSON),
|
// EventJSON: string(eventJSON),
|
||||||
|
@ -436,8 +433,10 @@ func runExec(ctx context.Context, execArgs *executeArgs) func(cmd *cobra.Command
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
artifactCancel := artifacts.Serve(ctx, execArgs.artifactServerPath, execArgs.artifactServerAddr, execArgs.artifactServerPort)
|
artifactCancel := artifacts.Serve(ctx, config.ArtifactServerPath, config.ArtifactServerAddr, config.ArtifactServerPort)
|
||||||
log.Debugf("artifacts server started at %s:%s", execArgs.artifactServerPath, execArgs.artifactServerPort)
|
log.Debugf("artifacts server started at http://%s",
|
||||||
|
net.JoinHostPort(config.ArtifactServerAddr, config.ArtifactServerPort),
|
||||||
|
)
|
||||||
|
|
||||||
ctx = common.WithDryrun(ctx, execArgs.dryrun)
|
ctx = common.WithDryrun(ctx, execArgs.dryrun)
|
||||||
executor := r.NewPlanExecutor(plan).Finally(func(ctx context.Context) error {
|
executor := r.NewPlanExecutor(plan).Finally(func(ctx context.Context) error {
|
||||||
|
@ -482,8 +481,8 @@ func loadExecCmd(ctx context.Context) *cobra.Command {
|
||||||
execCmd.Flags().StringArrayVarP(&execArg.containerCapDrop, "container-cap-drop", "", []string{}, "kernel capabilities to remove from the workflow containers (e.g. --container-cap-drop SYS_PTRACE)")
|
execCmd.Flags().StringArrayVarP(&execArg.containerCapDrop, "container-cap-drop", "", []string{}, "kernel capabilities to remove from the workflow containers (e.g. --container-cap-drop SYS_PTRACE)")
|
||||||
execCmd.Flags().StringVarP(&execArg.containerOptions, "container-opts", "", "", "container options")
|
execCmd.Flags().StringVarP(&execArg.containerOptions, "container-opts", "", "", "container options")
|
||||||
execCmd.PersistentFlags().StringVarP(&execArg.artifactServerPath, "artifact-server-path", "", ".", "Defines the path where the artifact server stores uploads and retrieves downloads from. If not specified the artifact server will not start.")
|
execCmd.PersistentFlags().StringVarP(&execArg.artifactServerPath, "artifact-server-path", "", ".", "Defines the path where the artifact server stores uploads and retrieves downloads from. If not specified the artifact server will not start.")
|
||||||
execCmd.PersistentFlags().StringVarP(&execArg.artifactServerAddr, "artifact-server-addr", "", "", "Defines the address where the artifact server listens")
|
execCmd.PersistentFlags().IPVarP(&execArg.artifactServerAddr, "artifact-server-addr", "", common.GetOutboundIP(), "Defines the address where the artifact server listens")
|
||||||
execCmd.PersistentFlags().StringVarP(&execArg.artifactServerPort, "artifact-server-port", "", "34567", "Defines the port where the artifact server listens (will only bind to localhost).")
|
execCmd.PersistentFlags().Uint16VarP(&execArg.artifactServerPort, "artifact-server-port", "", 34567, "Defines the port where the artifact server listens (will only bind to localhost).")
|
||||||
execCmd.PersistentFlags().StringVarP(&execArg.defaultActionsURL, "default-actions-url", "", "https://code.forgejo.org", "Defines the default base url of the action.")
|
execCmd.PersistentFlags().StringVarP(&execArg.defaultActionsURL, "default-actions-url", "", "https://code.forgejo.org", "Defines the default base url of the action.")
|
||||||
execCmd.PersistentFlags().BoolVarP(&execArg.noSkipCheckout, "no-skip-checkout", "", false, "Do not skip actions/checkout")
|
execCmd.PersistentFlags().BoolVarP(&execArg.noSkipCheckout, "no-skip-checkout", "", false, "Do not skip actions/checkout")
|
||||||
execCmd.PersistentFlags().BoolVarP(&execArg.debug, "debug", "d", false, "enable debug log")
|
execCmd.PersistentFlags().BoolVarP(&execArg.debug, "debug", "d", false, "enable debug log")
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue