Merge branch 'main' into pacman-packages

This commit is contained in:
silverwind 2023-07-25 00:02:26 +02:00 committed by GitHub
commit 672b00b542
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 84 additions and 56 deletions

View File

@ -110,9 +110,9 @@ Note that the repository may still use instance-level or organization-level runn
The level of the runner determines where to obtain the registration token. The level of the runner determines where to obtain the registration token.
- Instance level: The admin settings page, like `<your_gitea.com>/admin/runners`. - Instance level: The admin settings page, like `<your_gitea.com>/admin/actions/runners`.
- Organization level: The organization settings page, like `<your_gitea.com>/<org>/settings/runners`. - Organization level: The organization settings page, like `<your_gitea.com>/<org>/settings/actions/runners`.
- Repository level: The repository settings page, like `<your_gitea.com>/<owner>/<repo>/settings/runners`. - Repository level: The repository settings page, like `<your_gitea.com>/<owner>/<repo>/settings/actions/runners`.
If you cannot see the settings page, please make sure that you have the right permissions and that Actions have been enabled. If you cannot see the settings page, please make sure that you have the right permissions and that Actions have been enabled.

View File

@ -109,9 +109,9 @@ docker run -v $(pwd)/config.yaml:/config.yaml -e CONFIG_FILE=/config.yaml ...
Runner级别决定了从哪里获取注册令牌。 Runner级别决定了从哪里获取注册令牌。
- 实例级别:管理员设置页面,例如 `<your_gitea.com>/admin/runners`。 - 实例级别:管理员设置页面,例如 `<your_gitea.com>/admin/actions/runners`。
- 组织级别:组织设置页面,例如 `<your_gitea.com>/<org>/settings/runners`。 - 组织级别:组织设置页面,例如 `<your_gitea.com>/<org>/settings/actions/runners`。
- 存储库级别:存储库设置页面,例如 `<your_gitea.com>/<owner>/<repo>/settings/runners`。 - 存储库级别:存储库设置页面,例如 `<your_gitea.com>/<owner>/<repo>/settings/actions/runners`。
如果您无法看到设置页面,请确保您具有正确的权限并且已启用 Actions。 如果您无法看到设置页面,请确保您具有正确的权限并且已启用 Actions。

View File

@ -66,7 +66,11 @@ If you are unsure which address to use, the LAN address is usually the right cho
`token` is used for authentication and identification, such as `P2U1U0oB4XaRCi8azcngmPCLbRpUGapalhmddh23`. `token` is used for authentication and identification, such as `P2U1U0oB4XaRCi8azcngmPCLbRpUGapalhmddh23`.
It is one-time use only and cannot be used to register multiple runners. It is one-time use only and cannot be used to register multiple runners.
You can obtain tokens from `<your_gitea.com>/admin/runners`. You can obtain different levels of 'tokens' from the following places to create the corresponding level of' runners':
- Instance level: The admin settings page, like `<your_gitea.com>/admin/actions/runners`.
- Organization level: The organization settings page, like `<your_gitea.com>/<org>/settings/actions/runners`.
- Repository level: The repository settings page, like `<your_gitea.com>/<owner>/<repo>/settings/actions/runners`.
![register runner](/images/usage/actions/register-runner.png) ![register runner](/images/usage/actions/register-runner.png)

View File

@ -66,7 +66,11 @@ Runner和Job容器由Runner启动以执行Job将连接到此地址。
`token` 用于身份验证和标识,例如 `P2U1U0oB4XaRCi8azcngmPCLbRpUGapalhmddh23` `token` 用于身份验证和标识,例如 `P2U1U0oB4XaRCi8azcngmPCLbRpUGapalhmddh23`
它只能使用一次并且不能用于注册多个Runner。 它只能使用一次并且不能用于注册多个Runner。
您可以从 `<your_gitea.com>/admin/runners` 获取令牌。 您可以从以下位置获取不同级别的`token`,从而创建出相应级别的`runner`
- 实例级别:管理员设置页面,例如 `<your_gitea.com>/admin/actions/runners`
- 组织级别:组织设置页面,例如 `<your_gitea.com>/<org>/settings/actions/runners`
- 存储库级别:存储库设置页面,例如 `<your_gitea.com>/<owner>/<repo>/settings/actions/runners`
![register runner](/images/usage/actions/register-runner.png) ![register runner](/images/usage/actions/register-runner.png)

View File

@ -18,7 +18,7 @@ menu:
# Secrets # Secrets
Secrets allow you to store sensitive information in your user, organization or repository. Secrets allow you to store sensitive information in your user, organization or repository.
Secrets are available on Gitea 1.19+ and are only visible in 1.20+ when ACTIONS are enabled Secrets are available on Gitea 1.19+ and are only visible in 1.20+ when ACTIONS are enabled.
# Naming your secrets # Naming your secrets

View File

@ -80,7 +80,9 @@ func ParsePackage(r io.Reader) (*Package, error) {
if strings.HasPrefix(hd.Name, controlTar) { if strings.HasPrefix(hd.Name, controlTar) {
var inner io.Reader var inner io.Reader
switch hd.Name[len(controlTar):] { // https://man7.org/linux/man-pages/man5/deb-split.5.html#FORMAT
// The file names might contain a trailing slash (since dpkg 1.15.6).
switch strings.TrimSuffix(hd.Name[len(controlTar):], "/") {
case "": case "":
inner = arr inner = arr
case ".gz": case ".gz":

View File

@ -69,59 +69,73 @@ func TestParsePackage(t *testing.T) {
tw.Write([]byte("Package: gitea\nVersion: 1.0.0\nArchitecture: amd64\n")) tw.Write([]byte("Package: gitea\nVersion: 1.0.0\nArchitecture: amd64\n"))
tw.Close() tw.Close()
t.Run("None", func(t *testing.T) { cases := []struct {
data := createArchive(map[string][]byte{"control.tar": buf.Bytes()}) Extension string
WriterFactory func(io.Writer) io.WriteCloser
}{
{
Extension: "",
WriterFactory: func(w io.Writer) io.WriteCloser {
return nopCloser{w}
},
},
{
Extension: ".gz",
WriterFactory: func(w io.Writer) io.WriteCloser {
return gzip.NewWriter(w)
},
},
{
Extension: ".xz",
WriterFactory: func(w io.Writer) io.WriteCloser {
xw, _ := xz.NewWriter(w)
return xw
},
},
{
Extension: ".zst",
WriterFactory: func(w io.Writer) io.WriteCloser {
zw, _ := zstd.NewWriter(w)
return zw
},
},
}
p, err := ParsePackage(data) for _, c := range cases {
assert.NotNil(t, p) t.Run(c.Extension, func(t *testing.T) {
assert.NoError(t, err) var cbuf bytes.Buffer
assert.Equal(t, "gitea", p.Name) w := c.WriterFactory(&cbuf)
}) w.Write(buf.Bytes())
w.Close()
t.Run("gz", func(t *testing.T) { data := createArchive(map[string][]byte{"control.tar" + c.Extension: cbuf.Bytes()})
var zbuf bytes.Buffer
zw := gzip.NewWriter(&zbuf)
zw.Write(buf.Bytes())
zw.Close()
data := createArchive(map[string][]byte{"control.tar.gz": zbuf.Bytes()}) p, err := ParsePackage(data)
assert.NotNil(t, p)
assert.NoError(t, err)
assert.Equal(t, "gitea", p.Name)
p, err := ParsePackage(data) t.Run("TrailingSlash", func(t *testing.T) {
assert.NotNil(t, p) data := createArchive(map[string][]byte{"control.tar" + c.Extension + "/": cbuf.Bytes()})
assert.NoError(t, err)
assert.Equal(t, "gitea", p.Name)
})
t.Run("xz", func(t *testing.T) { p, err := ParsePackage(data)
var xbuf bytes.Buffer assert.NotNil(t, p)
xw, _ := xz.NewWriter(&xbuf) assert.NoError(t, err)
xw.Write(buf.Bytes()) assert.Equal(t, "gitea", p.Name)
xw.Close() })
})
data := createArchive(map[string][]byte{"control.tar.xz": xbuf.Bytes()}) }
p, err := ParsePackage(data)
assert.NotNil(t, p)
assert.NoError(t, err)
assert.Equal(t, "gitea", p.Name)
})
t.Run("zst", func(t *testing.T) {
var zbuf bytes.Buffer
zw, _ := zstd.NewWriter(&zbuf)
zw.Write(buf.Bytes())
zw.Close()
data := createArchive(map[string][]byte{"control.tar.zst": zbuf.Bytes()})
p, err := ParsePackage(data)
assert.NotNil(t, p)
assert.NoError(t, err)
assert.Equal(t, "gitea", p.Name)
})
}) })
} }
type nopCloser struct {
io.Writer
}
func (nopCloser) Close() error {
return nil
}
func TestParseControlFile(t *testing.T) { func TestParseControlFile(t *testing.T) {
buildContent := func(name, version, architecture string) *bytes.Buffer { buildContent := func(name, version, architecture string) *bytes.Buffer {
var buf bytes.Buffer var buf bytes.Buffer

View File

@ -187,7 +187,7 @@ func UploadPackageFile(ctx *context.Context) {
) )
if err != nil { if err != nil {
switch err { switch err {
case packages_model.ErrDuplicatePackageVersion: case packages_model.ErrDuplicatePackageVersion, packages_model.ErrDuplicatePackageFile:
apiError(ctx, http.StatusBadRequest, err) apiError(ctx, http.StatusBadRequest, err)
case packages_service.ErrQuotaTotalCount, packages_service.ErrQuotaTypeSize, packages_service.ErrQuotaTotalSize: case packages_service.ErrQuotaTotalCount, packages_service.ErrQuotaTypeSize, packages_service.ErrQuotaTotalSize:
apiError(ctx, http.StatusForbidden, err) apiError(ctx, http.StatusForbidden, err)

View File

@ -144,6 +144,10 @@ func TestPackageDebian(t *testing.T) {
} }
return seen return seen
}) })
req = NewRequestWithBody(t, "PUT", uploadURL, createArchive(packageName, packageVersion, architecture))
AddBasicAuthHeader(req, user.Name)
MakeRequest(t, req, http.StatusBadRequest)
}) })
t.Run("Download", func(t *testing.T) { t.Run("Download", func(t *testing.T) {