2019-03-27 14:15:23 +03:00
module code . gitea . io / gitea
2024-09-10 05:23:07 +03:00
go 1.23
2019-03-27 14:15:23 +03:00
2024-09-17 22:35:59 +03:00
// rfc5280 said: "The serial number is an integer assigned by the CA to each certificate."
// But some CAs use negative serial number, just relax the check. related:
// Default TLS cert uses negative serial number #895 https://github.com/microsoft/mssql-docker/issues/895
godebug x509negativeserial = 1
2019-03-27 14:15:23 +03:00
require (
2024-03-17 18:40:05 +03:00
code . gitea . io / actions - proto - go v0 . 4.0
2023-10-13 19:11:15 +03:00
code . gitea . io / gitea - vet v0 . 2.3
2024-10-31 15:05:54 +03:00
code . gitea . io / sdk / gitea v0 . 19.0
2022-09-02 00:13:17 +03:00
codeberg . org / gusted / mcaptcha v0 . 0.0 - 20220723083913 - 4 f3072e1d570
2024-10-31 15:05:54 +03:00
connectrpc . com / connect v1 . 17.0
2024-05-02 17:09:38 +03:00
gitea . com / go - chi / binding v0 . 0.0 - 20240430071103 - 39 a851e106ed
2024-09-07 20:12:37 +03:00
gitea . com / go - chi / cache v0 . 2.1
2024-03-17 18:40:05 +03:00
gitea . com / go - chi / captcha v0 . 0.0 - 20240315150714 - fb487f629098
gitea . com / go - chi / session v0 . 0.0 - 20240316035857 - 16768 d98ec96
2022-09-02 00:13:17 +03:00
gitea . com / lunny / dingtalk_webhook v0 . 0.0 - 20171025031554 - e3534c89ef96
2023-08-16 15:02:40 +03:00
gitea . com / lunny / levelqueue v0 . 4.2 - 0.20230414023320 - 3 c0159fe0fe4
2024-09-08 01:05:18 +03:00
github . com / 42 wim / httpsig v1 . 2.2
2024-10-31 15:05:54 +03:00
github . com / 42 wim / sshsig v0 . 0.0 - 20240818000253 - e3a6333df815
github . com / Azure / azure - sdk - for - go / sdk / azcore v1 . 16.0
github . com / Azure / azure - sdk - for - go / sdk / storage / azblob v1 . 4.1
2023-05-03 00:40:46 +03:00
github . com / Azure / go - ntlmssp v0 . 0.0 - 20221128193559 - 754 e69321358
2024-04-28 02:21:33 +03:00
github . com / ProtonMail / go - crypto v1 . 0.0
2024-10-31 15:05:54 +03:00
github . com / PuerkitoBio / goquery v1 . 10.0
github . com / SaveTheRbtz / zstd - seekable - format - go / pkg v0 . 7.3
2024-06-04 08:34:34 +03:00
github . com / alecthomas / chroma / v2 v2 . 14.0
2024-10-31 15:05:54 +03:00
github . com / aws / aws - sdk - go v1 . 55.5
github . com / aws / aws - sdk - go - v2 / credentials v1 . 17.42
github . com / aws / aws - sdk - go - v2 / service / codecommit v1 . 27.3
2023-05-02 19:31:35 +03:00
github . com / blakesmith / ar v0 . 0.0 - 20190502131153 - 809 d4375e1fb
2024-08-02 22:32:31 +03:00
github . com / blevesearch / bleve / v2 v2 . 4.2
2024-10-31 15:05:54 +03:00
github . com / buildkite / terminal - to - html / v3 v3 . 16.3
github . com / caddyserver / certmagic v0 . 21.4
2024-09-27 17:27:37 +03:00
github . com / charmbracelet / git - lfs - transfer v0 . 2.0
2021-03-16 01:27:28 +03:00
github . com / chi - middleware / proxy v1 . 1.1
2023-01-14 18:57:10 +03:00
github . com / dimiro1 / reply v0 . 0.0 - 20200315094148 - d0136a4c9e21
2021-06-21 01:00:46 +03:00
github . com / djherbis / buffer v1 . 2.0
github . com / djherbis / nio / v3 v3 . 0.1
2023-02-01 21:30:39 +03:00
github . com / dsnet / compress v0 . 0.2 - 0.20210315054119 - f66993602bf5
2023-02-24 23:18:49 +03:00
github . com / dustin / go - humanize v1 . 0.1
2024-06-24 16:26:42 +03:00
github . com / editorconfig / editorconfig - core - go / v2 v2 . 6.2
2023-01-14 18:57:10 +03:00
github . com / emersion / go - imap v1 . 2.1
2022-05-10 13:32:42 +03:00
github . com / emirpasic / gods v1 . 18.1
2022-03-08 14:15:30 +03:00
github . com / ethantkoenig / rupture v1 . 0.1
2024-10-31 15:05:54 +03:00
github . com / felixge / fgprof v0 . 9.5
2023-12-19 04:18:42 +03:00
github . com / fsnotify / fsnotify v1 . 7.0
2024-06-24 16:26:42 +03:00
github . com / gliderlabs / ssh v0 . 3.7
2024-10-31 15:05:54 +03:00
github . com / go - ap / activitypub v0 . 0.0 - 20240910141749 - b4b8c8aa484c
2023-01-12 11:21:16 +03:00
github . com / go - ap / jsonld v0 . 0.0 - 20221030091449 - f2a191312c73
2024-10-31 15:05:54 +03:00
github . com / go - chi / chi / v5 v5 . 1.0
2022-05-10 13:32:42 +03:00
github . com / go - chi / cors v1 . 2.1
2023-12-19 04:18:42 +03:00
github . com / go - co - op / gocron v1 . 37.0
2024-10-19 15:51:55 +03:00
github . com / go - enry / go - enry / v2 v2 . 9.1
2024-10-31 15:05:54 +03:00
github . com / go - git / go - billy / v5 v5 . 6.0
2024-06-24 16:26:42 +03:00
github . com / go - git / go - git / v5 v5 . 12.0
2024-10-31 15:05:54 +03:00
github . com / go - ldap / ldap / v3 v3 . 4.8
Introduce globallock as distributed locks (#31908)
To help #31813, but do not replace it, since this PR just introduces the
new module but misses some work:
- New option in settings. `#31813` has done it.
- Use the locks in business logic. `#31813` has done it.
So I think the most efficient way is to merge this PR first (if it's
acceptable) and then finish #31813.
## Design principles
### Use spinlock even in memory implementation
In actual use cases, users may cancel requests. `sync.Mutex` will block
the goroutine until the lock is acquired even if the request is
canceled. And the spinlock is more suitable for this scenario since it's
possible to give up the lock acquisition.
Although the spinlock consumes more CPU resources, I think it's
acceptable in most cases.
### Do not expose the mutex to callers
If we expose the mutex to callers, it's possible for callers to reuse
the mutex, which causes more complexity.
For example:
```go
lock := GetLocker(key)
lock.Lock()
// ...
// even if the lock is unlocked, we cannot GC the lock,
// since the caller may still use it again.
lock.Unlock()
lock.Lock()
// ...
lock.Unlock()
// callers have to GC the lock manually.
RemoveLocker(key)
```
That's why
https://github.com/go-gitea/gitea/pull/31813#discussion_r1721200549
In this PR, we only expose `ReleaseFunc` to callers. So callers just
need to call `ReleaseFunc` to release the lock, and do not need to care
about the lock's lifecycle.
```go
_, release, err := locker.Lock(ctx, key)
if err != nil {
return err
}
// ...
release()
// if callers want to lock again, they have to re-acquire the lock.
_, release, err := locker.Lock(ctx, key)
// ...
```
In this way, it's also much easier for redis implementation to extend
the mutex automatically, so that callers do not need to care about the
lock's lifecycle. See also
https://github.com/go-gitea/gitea/pull/31813#discussion_r1722659743
### Use "release" instead of "unlock"
For "unlock", it has the meaning of "unlock an acquired lock". So it's
not acceptable to call "unlock" when failed to acquire the lock, or call
"unlock" multiple times. It causes more complexity for callers to decide
whether to call "unlock" or not.
So we use "release" instead of "unlock" to make it clear. Whether the
lock is acquired or not, callers can always call "release", and it's
also safe to call "release" multiple times.
But the code DO NOT expect callers to not call "release" after acquiring
the lock. If callers forget to call "release", it will cause resource
leak. That's why it's always safe to call "release" without extra
checks: to avoid callers to forget to call it.
### Acquired locks could be lost
Unlike `sync.Mutex` which will be locked forever once acquired until
calling `Unlock`, in the new module, the acquired lock could be lost.
For example, the caller has acquired the lock, and it holds the lock for
a long time since auto-extending is working for redis. However, it lost
the connection to the redis server, and it's impossible to extend the
lock anymore.
If the caller don't stop what it's doing, another instance which can
connect to the redis server could acquire the lock, and do the same
thing, which could cause data inconsistency.
So the caller should know what happened, the solution is to return a new
context which will be canceled if the lock is lost or released:
```go
ctx, release, err := locker.Lock(ctx, key)
if err != nil {
return err
}
defer release()
// ...
DoSomething(ctx)
// the lock is lost now, then ctx has been canceled.
// Failed, since ctx has been canceled.
DoSomethingElse(ctx)
```
### Multiple ways to use the lock
1. Regular way
```go
ctx, release, err := Lock(ctx, key)
if err != nil {
return err
}
defer release()
// ...
```
2. Early release
```go
ctx, release, err := Lock(ctx, key)
if err != nil {
return err
}
defer release()
// ...
// release the lock earlier and reset the context back
ctx = release()
// continue to do something else
// ...
```
3. Functional way
```go
if err := LockAndDo(ctx, key, func(ctx context.Context) error {
// ...
return nil
}); err != nil {
return err
}
```
2024-08-26 17:27:57 +03:00
github . com / go - redsync / redsync / v4 v4 . 13.0
2024-06-24 16:26:42 +03:00
github . com / go - sql - driver / mysql v1 . 8.1
github . com / go - swagger / go - swagger v0 . 31.0
github . com / go - testfixtures / testfixtures / v3 v3 . 11.0
2024-10-31 15:05:54 +03:00
github . com / go - webauthn / webauthn v0 . 11.2
2019-09-09 08:48:21 +03:00
github . com / gobwas / glob v0 . 2.3
2022-03-08 14:15:30 +03:00
github . com / gogs / chardet v0 . 0.0 - 20211120154057 - b7413eaefb8f
2021-02-01 07:49:25 +03:00
github . com / gogs / go - gogs - client v0 . 0.0 - 20210131175652 - 1 d7215cd8d85
2024-03-17 18:40:05 +03:00
github . com / golang - jwt / jwt / v5 v5 . 2.1
2024-04-28 08:20:23 +03:00
github . com / google / go - github / v61 v61 . 0.0
2024-10-01 22:25:08 +03:00
github . com / google / licenseclassifier / v2 v2 . 0.0
2024-10-31 15:05:54 +03:00
github . com / google / pprof v0 . 0.0 - 20241029153458 - d1b30febd7db
2024-03-08 06:19:35 +03:00
github . com / google / uuid v1 . 6.0
2024-06-18 11:05:28 +03:00
github . com / gorilla / feeds v1 . 2.0
2024-10-31 15:05:54 +03:00
github . com / gorilla / sessions v1 . 4.0
2024-05-02 17:43:23 +03:00
github . com / h2non / gock v1 . 2.0
2024-06-24 16:26:42 +03:00
github . com / hashicorp / go - version v1 . 7.0
2023-10-07 08:55:08 +03:00
github . com / hashicorp / golang - lru / v2 v2 . 0.7
2024-06-24 16:26:42 +03:00
github . com / huandu / xstrings v1 . 5.0
2023-05-05 12:17:19 +03:00
github . com / jaytaylor / html2text v0 . 0.0 - 20230321000545 - 74 c2419ad056
2024-10-31 15:05:54 +03:00
github . com / jhillyerd / enmime v1 . 3.0
2022-02-06 23:38:14 +03:00
github . com / json - iterator / go v1 . 1.12
2020-11-06 21:41:42 +03:00
github . com / kballard / go - shellquote v0 . 0.0 - 20180428030007 - 95032 a82bc51
2020-02-11 21:58:23 +03:00
github . com / keybase / go - crypto v0 . 0.0 - 20200123153347 - de78d2cb44f4
2024-10-31 15:05:54 +03:00
github . com / klauspost / compress v1 . 17.11
2024-06-24 16:26:42 +03:00
github . com / klauspost / cpuid / v2 v2 . 2.8
2023-05-05 12:17:19 +03:00
github . com / lib / pq v1 . 10.9
2024-06-24 16:26:42 +03:00
github . com / markbates / goth v1 . 80.0
2023-12-19 04:18:42 +03:00
github . com / mattn / go - isatty v0 . 0.20
2024-10-31 15:05:54 +03:00
github . com / mattn / go - sqlite3 v1 . 14.24
github . com / meilisearch / meilisearch - go v0 . 29.0
2022-03-08 14:15:30 +03:00
github . com / mholt / archiver / v3 v3 . 5.1
2024-10-31 15:05:54 +03:00
github . com / microcosm - cc / bluemonday v1 . 0.27
2024-06-24 16:26:42 +03:00
github . com / microsoft / go - mssqldb v1 . 7.2
2024-10-31 15:05:54 +03:00
github . com / minio / minio - go / v7 v7 . 0.80
2023-10-07 08:55:08 +03:00
github . com / msteinert / pam v1 . 2.0
2024-06-24 16:26:42 +03:00
github . com / nektos / act v0 . 2.63
2023-07-14 06:00:31 +03:00
github . com / niklasfasching / go - org v1 . 7.0
2022-05-10 13:32:42 +03:00
github . com / olivere / elastic / v7 v7 . 0.32
2023-02-06 13:07:09 +03:00
github . com / opencontainers / go - digest v1 . 0.0
2024-03-17 18:40:05 +03:00
github . com / opencontainers / image - spec v1 . 1.0
2020-04-03 22:29:12 +03:00
github . com / pkg / errors v0 . 9.1
2023-01-12 11:21:16 +03:00
github . com / pquerna / otp v1 . 4.0
2024-10-31 15:05:54 +03:00
github . com / prometheus / client_golang v1 . 20.5
2022-03-08 14:15:30 +03:00
github . com / quasoft / websspi v1 . 1.2
2024-10-31 15:05:54 +03:00
github . com / redis / go - redis / v9 v9 . 7.0
2023-08-24 06:06:51 +03:00
github . com / robfig / cron / v3 v3 . 0.1
2023-08-16 15:02:40 +03:00
github . com / santhosh - tekuri / jsonschema / v5 v5 . 3.1
2024-06-24 16:26:42 +03:00
github . com / sassoftware / go - rpmutils v0 . 4.0
github . com / sergi / go - diff v1 . 3.2 - 0.20230802210424 - 5 b0b94c5c0d3
2023-07-14 06:00:31 +03:00
github . com / shurcooL / vfsgen v0 . 0.0 - 20230704071429 - 0000 e147ea92
2024-03-17 18:40:05 +03:00
github . com / stretchr / testify v1 . 9.0
2020-09-28 00:09:46 +03:00
github . com / syndtr / goleveldb v1 . 0.0
2019-03-27 14:15:23 +03:00
github . com / tstranex / u2f v1 . 0.0
2024-06-24 16:26:42 +03:00
github . com / ulikunitz / xz v0 . 5.12
2024-10-31 15:05:54 +03:00
github . com / urfave / cli / v2 v2 . 27.5
github . com / xanzy / go - gitlab v0 . 112.0
2022-12-17 09:22:34 +03:00
github . com / xeipuuv / gojsonschema v1 . 2.0
2023-05-05 12:17:19 +03:00
github . com / yohcop / openid - go v1 . 0.1
2024-10-31 15:05:54 +03:00
github . com / yuin / goldmark v1 . 7.8
2023-08-16 15:02:40 +03:00
github . com / yuin / goldmark - highlighting / v2 v2 . 0.0 - 20230729083705 - 37449 abec8cc
2022-03-08 14:15:30 +03:00
github . com / yuin / goldmark - meta v1 . 1.0
2024-10-31 15:05:54 +03:00
golang . org / x / crypto v0 . 28.0
golang . org / x / image v0 . 21.0
golang . org / x / net v0 . 30.0
golang . org / x / oauth2 v0 . 23.0
2024-11-04 07:49:08 +03:00
golang . org / x / sync v0 . 8.0
2024-10-31 15:05:54 +03:00
golang . org / x / sys v0 . 26.0
golang . org / x / text v0 . 19.0
golang . org / x / tools v0 . 26.0
google . golang . org / grpc v1 . 67.1
google . golang . org / protobuf v1 . 35.1
2019-03-27 14:15:23 +03:00
gopkg . in / gomail . v2 v2 . 0.0 - 20160411212932 - 81 ebce5c23df
2022-09-02 00:13:17 +03:00
gopkg . in / ini . v1 v1 . 67.0
2022-09-13 19:33:37 +03:00
gopkg . in / yaml . v3 v3 . 0.1
2023-07-14 06:00:31 +03:00
mvdan . cc / xurls / v2 v2 . 5.0
2019-10-08 22:48:57 +03:00
strk . kbt . io / projects / go / libravatar v0 . 0.0 - 20191008002943 - 06 d1c002b251
2023-07-25 23:27:44 +03:00
xorm . io / builder v0 . 3.13
2024-07-15 00:15:59 +03:00
xorm . io / xorm v1 . 3.9
2019-03-27 14:15:23 +03:00
)
2020-09-06 03:44:34 +03:00
2022-03-16 07:08:31 +03:00
require (
2024-10-31 15:05:54 +03:00
cloud . google . com / go / compute / metadata v0 . 5.2 / / indirect
dario . cat / mergo v1 . 0.1 / / indirect
2024-03-17 18:40:05 +03:00
filippo . io / edwards25519 v1 . 1.0 / / indirect
2022-09-02 00:13:17 +03:00
git . sr . ht / ~ mariusor / go - xsd - duration v0 . 0.0 - 20220703122237 - 02 e73435a078 / / indirect
2024-10-31 15:05:54 +03:00
github . com / Azure / azure - sdk - for - go / sdk / internal v1 . 10.0 / / indirect
github . com / ClickHouse / ch - go v0 . 63.1 / / indirect
github . com / ClickHouse / clickhouse - go / v2 v2 . 24.0 / / indirect
github . com / DataDog / zstd v1 . 5.6 / / indirect
2022-09-02 00:13:17 +03:00
github . com / Masterminds / goutils v1 . 1.1 / / indirect
2024-10-31 15:05:54 +03:00
github . com / Masterminds / semver / v3 v3 . 3.0 / / indirect
github . com / Masterminds / sprig / v3 v3 . 3.0 / / indirect
2024-06-24 16:26:42 +03:00
github . com / Microsoft / go - winio v0 . 6.2 / / indirect
github . com / RoaringBitmap / roaring v1 . 9.4 / / indirect
2024-10-31 15:05:54 +03:00
github . com / andybalholm / brotli v1 . 1.1 / / indirect
2023-05-05 12:17:19 +03:00
github . com / andybalholm / cascadia v1 . 3.2 / / indirect
2022-03-16 07:08:31 +03:00
github . com / anmitsu / go - shlex v0 . 0.0 - 20200514113438 - 38 f4b401e2be / / indirect
2023-07-14 06:00:31 +03:00
github . com / asaskevich / govalidator v0 . 0.0 - 20230301143203 - a9d515a09cc2 / / indirect
2024-10-31 15:05:54 +03:00
github . com / aws / aws - sdk - go - v2 v1 . 32.3 / / indirect
github . com / aws / aws - sdk - go - v2 / internal / configsources v1 . 3.22 / / indirect
github . com / aws / aws - sdk - go - v2 / internal / endpoints / v2 v2 . 6.22 / / indirect
github . com / aws / smithy - go v1 . 22.0 / / indirect
2022-03-16 07:08:31 +03:00
github . com / aymerick / douceur v0 . 2.0 / / indirect
github . com / beorn7 / perks v1 . 0.1 / / indirect
2024-10-31 15:05:54 +03:00
github . com / bits - and - blooms / bitset v1 . 14.3 / / indirect
github . com / blevesearch / bleve_index_api v1 . 1.12 / / indirect
2024-03-17 18:40:05 +03:00
github . com / blevesearch / geo v0 . 1.20 / / indirect
2024-10-31 15:05:54 +03:00
github . com / blevesearch / go - faiss v1 . 0.23 / / indirect
2022-03-16 07:08:31 +03:00
github . com / blevesearch / go - porterstemmer v1 . 0.3 / / indirect
2022-05-10 13:32:42 +03:00
github . com / blevesearch / gtreap v0 . 1.1 / / indirect
2022-10-01 16:49:30 +03:00
github . com / blevesearch / mmap - go v1 . 0.4 / / indirect
2024-10-31 15:05:54 +03:00
github . com / blevesearch / scorch_segment_api / v2 v2 . 2.16 / / indirect
2023-01-12 11:21:16 +03:00
github . com / blevesearch / segment v0 . 9.1 / / indirect
2022-03-16 07:08:31 +03:00
github . com / blevesearch / snowballstem v0 . 9.0 / / indirect
2023-01-12 11:21:16 +03:00
github . com / blevesearch / upsidedown_store_api v1 . 0.2 / / indirect
2023-07-14 06:00:31 +03:00
github . com / blevesearch / vellum v1 . 0.10 / / indirect
2023-09-27 10:10:58 +03:00
github . com / blevesearch / zapx / v11 v11 . 3.10 / / indirect
github . com / blevesearch / zapx / v12 v12 . 3.10 / / indirect
github . com / blevesearch / zapx / v13 v13 . 3.10 / / indirect
github . com / blevesearch / zapx / v14 v14 . 3.10 / / indirect
2024-10-31 15:05:54 +03:00
github . com / blevesearch / zapx / v15 v15 . 3.16 / / indirect
github . com / blevesearch / zapx / v16 v16 . 1.7 / / indirect
github . com / boombuler / barcode v1 . 0.2 / / indirect
2023-10-13 19:11:15 +03:00
github . com / bradfitz / gomemcache v0 . 0.0 - 20230905024940 - 24 af94b03874 / / indirect
2024-06-24 16:26:42 +03:00
github . com / caddyserver / zerossl v0 . 1.3 / / indirect
2023-01-14 18:57:10 +03:00
github . com / cention - sany / utf7 v0 . 0.0 - 20170124080048 - 26 cad61bd60a / / indirect
2024-06-24 16:26:42 +03:00
github . com / cespare / xxhash / v2 v2 . 3.0 / / indirect
2024-10-31 15:05:54 +03:00
github . com / cloudflare / circl v1 . 5.0 / / indirect
2023-07-14 06:00:31 +03:00
github . com / couchbase / go - couchbase v0 . 1.1 / / indirect
2024-10-31 15:05:54 +03:00
github . com / couchbase / gomemcached v0 . 3.2 / / indirect
2023-07-14 06:00:31 +03:00
github . com / couchbase / goutils v0 . 1.2 / / indirect
2024-10-31 15:05:54 +03:00
github . com / cpuguy83 / go - md2man / v2 v2 . 0.5 / / indirect
github . com / cyphar / filepath - securejoin v0 . 3.4 / / indirect
2023-10-13 19:11:15 +03:00
github . com / davecgh / go - spew v1 . 1.2 - 0.20180830191138 - d8f796af33cc / / indirect
github . com / davidmz / go - pageant v1 . 0.2 / / indirect
2022-03-16 07:08:31 +03:00
github . com / dgryski / go - rendezvous v0 . 0.0 - 20200823014737 - 9 f7001d12a5f / / indirect
2024-10-31 15:05:54 +03:00
github . com / dlclark / regexp2 v1 . 11.4 / / indirect
github . com / emersion / go - sasl v0 . 0.0 - 20241020182733 - b788ff22d5a6 / / indirect
github . com / fatih / color v1 . 18.0 / / indirect
2023-12-19 04:18:42 +03:00
github . com / felixge / httpsnoop v1 . 0.4 / / indirect
2024-10-31 15:05:54 +03:00
github . com / fxamacker / cbor / v2 v2 . 7.0 / / indirect
2024-09-27 17:27:37 +03:00
github . com / git - lfs / pktline v0 . 0.0 - 20230103162542 - ca444d533ef1 / / indirect
2024-10-31 15:05:54 +03:00
github . com / go - ap / errors v0 . 0.0 - 20240910140019 - 1 e9d33cc1568 / / indirect
2024-06-24 16:26:42 +03:00
github . com / go - asn1 - ber / asn1 - ber v1 . 5.7 / / indirect
2022-03-16 07:08:31 +03:00
github . com / go - enry / go - oniguruma v1 . 2.1 / / indirect
2023-05-05 12:17:19 +03:00
github . com / go - faster / city v1 . 0.1 / / indirect
2023-12-19 04:18:42 +03:00
github . com / go - faster / errors v0 . 7.1 / / indirect
2024-09-08 01:05:18 +03:00
github . com / go - fed / httpsig v1 . 1.1 - 0.20201223112313 - 55836744818 e / / indirect
2023-07-14 06:00:31 +03:00
github . com / go - git / gcfg v1 . 5.1 - 0.20230307220236 - 3 a3c6141e376 / / indirect
2024-09-30 04:57:48 +03:00
github . com / go - ini / ini v1 . 67.0 / / indirect
2024-03-17 18:40:05 +03:00
github . com / go - openapi / analysis v0 . 23.0 / / indirect
github . com / go - openapi / errors v0 . 22.0 / / indirect
github . com / go - openapi / inflect v0 . 21.0 / / indirect
github . com / go - openapi / jsonpointer v0 . 21.0 / / indirect
github . com / go - openapi / jsonreference v0 . 21.0 / / indirect
github . com / go - openapi / loads v0 . 22.0 / / indirect
github . com / go - openapi / runtime v0 . 28.0 / / indirect
github . com / go - openapi / spec v0 . 21.0 / / indirect
github . com / go - openapi / strfmt v0 . 23.0 / / indirect
github . com / go - openapi / swag v0 . 23.0 / / indirect
github . com / go - openapi / validate v0 . 24.0 / / indirect
2024-10-31 15:05:54 +03:00
github . com / go - webauthn / x v0 . 1.15 / / indirect
2024-06-24 16:26:42 +03:00
github . com / goccy / go - json v0 . 10.3 / / indirect
2023-07-19 12:57:10 +03:00
github . com / golang - jwt / jwt / v4 v4 . 5.0 / / indirect
2022-03-16 07:08:31 +03:00
github . com / golang - sql / civil v0 . 0.0 - 20220223132316 - b832511892a9 / / indirect
2022-09-02 00:13:17 +03:00
github . com / golang - sql / sqlexp v0 . 1.0 / / indirect
2023-05-05 12:17:19 +03:00
github . com / golang / geo v0 . 0.0 - 20230421003525 - 6 adc56603217 / / indirect
2023-07-14 06:00:31 +03:00
github . com / golang / groupcache v0 . 0.0 - 20210331224755 - 41 bb18bfe9da / / indirect
2024-03-17 18:40:05 +03:00
github . com / golang / protobuf v1 . 5.4 / / indirect
2022-03-16 07:08:31 +03:00
github . com / golang / snappy v0 . 0.4 / / indirect
2024-10-31 15:05:54 +03:00
github . com / google / btree v1 . 1.3 / / indirect
2022-03-16 07:08:31 +03:00
github . com / google / go - querystring v1 . 1.0 / / indirect
2024-10-31 15:05:54 +03:00
github . com / google / go - tpm v0 . 9.1 / / indirect
2023-12-19 04:18:42 +03:00
github . com / gorilla / css v1 . 0.1 / / indirect
github . com / gorilla / handlers v1 . 5.2 / / indirect
github . com / gorilla / mux v1 . 8.1 / / indirect
github . com / gorilla / securecookie v1 . 1.2 / / indirect
2024-05-02 17:43:23 +03:00
github . com / h2non / parth v0 . 0.0 - 20190131123155 - b4df798d6542 / / indirect
Introduce globallock as distributed locks (#31908)
To help #31813, but do not replace it, since this PR just introduces the
new module but misses some work:
- New option in settings. `#31813` has done it.
- Use the locks in business logic. `#31813` has done it.
So I think the most efficient way is to merge this PR first (if it's
acceptable) and then finish #31813.
## Design principles
### Use spinlock even in memory implementation
In actual use cases, users may cancel requests. `sync.Mutex` will block
the goroutine until the lock is acquired even if the request is
canceled. And the spinlock is more suitable for this scenario since it's
possible to give up the lock acquisition.
Although the spinlock consumes more CPU resources, I think it's
acceptable in most cases.
### Do not expose the mutex to callers
If we expose the mutex to callers, it's possible for callers to reuse
the mutex, which causes more complexity.
For example:
```go
lock := GetLocker(key)
lock.Lock()
// ...
// even if the lock is unlocked, we cannot GC the lock,
// since the caller may still use it again.
lock.Unlock()
lock.Lock()
// ...
lock.Unlock()
// callers have to GC the lock manually.
RemoveLocker(key)
```
That's why
https://github.com/go-gitea/gitea/pull/31813#discussion_r1721200549
In this PR, we only expose `ReleaseFunc` to callers. So callers just
need to call `ReleaseFunc` to release the lock, and do not need to care
about the lock's lifecycle.
```go
_, release, err := locker.Lock(ctx, key)
if err != nil {
return err
}
// ...
release()
// if callers want to lock again, they have to re-acquire the lock.
_, release, err := locker.Lock(ctx, key)
// ...
```
In this way, it's also much easier for redis implementation to extend
the mutex automatically, so that callers do not need to care about the
lock's lifecycle. See also
https://github.com/go-gitea/gitea/pull/31813#discussion_r1722659743
### Use "release" instead of "unlock"
For "unlock", it has the meaning of "unlock an acquired lock". So it's
not acceptable to call "unlock" when failed to acquire the lock, or call
"unlock" multiple times. It causes more complexity for callers to decide
whether to call "unlock" or not.
So we use "release" instead of "unlock" to make it clear. Whether the
lock is acquired or not, callers can always call "release", and it's
also safe to call "release" multiple times.
But the code DO NOT expect callers to not call "release" after acquiring
the lock. If callers forget to call "release", it will cause resource
leak. That's why it's always safe to call "release" without extra
checks: to avoid callers to forget to call it.
### Acquired locks could be lost
Unlike `sync.Mutex` which will be locked forever once acquired until
calling `Unlock`, in the new module, the acquired lock could be lost.
For example, the caller has acquired the lock, and it holds the lock for
a long time since auto-extending is working for redis. However, it lost
the connection to the redis server, and it's impossible to extend the
lock anymore.
If the caller don't stop what it's doing, another instance which can
connect to the redis server could acquire the lock, and do the same
thing, which could cause data inconsistency.
So the caller should know what happened, the solution is to return a new
context which will be canceled if the lock is lost or released:
```go
ctx, release, err := locker.Lock(ctx, key)
if err != nil {
return err
}
defer release()
// ...
DoSomething(ctx)
// the lock is lost now, then ctx has been canceled.
// Failed, since ctx has been canceled.
DoSomethingElse(ctx)
```
### Multiple ways to use the lock
1. Regular way
```go
ctx, release, err := Lock(ctx, key)
if err != nil {
return err
}
defer release()
// ...
```
2. Early release
```go
ctx, release, err := Lock(ctx, key)
if err != nil {
return err
}
defer release()
// ...
// release the lock earlier and reset the context back
ctx = release()
// continue to do something else
// ...
```
3. Functional way
```go
if err := LockAndDo(ctx, key, func(ctx context.Context) error {
// ...
return nil
}); err != nil {
return err
}
```
2024-08-26 17:27:57 +03:00
github . com / hashicorp / errwrap v1 . 1.0 / / indirect
2022-03-16 07:08:31 +03:00
github . com / hashicorp / go - cleanhttp v0 . 5.2 / / indirect
Introduce globallock as distributed locks (#31908)
To help #31813, but do not replace it, since this PR just introduces the
new module but misses some work:
- New option in settings. `#31813` has done it.
- Use the locks in business logic. `#31813` has done it.
So I think the most efficient way is to merge this PR first (if it's
acceptable) and then finish #31813.
## Design principles
### Use spinlock even in memory implementation
In actual use cases, users may cancel requests. `sync.Mutex` will block
the goroutine until the lock is acquired even if the request is
canceled. And the spinlock is more suitable for this scenario since it's
possible to give up the lock acquisition.
Although the spinlock consumes more CPU resources, I think it's
acceptable in most cases.
### Do not expose the mutex to callers
If we expose the mutex to callers, it's possible for callers to reuse
the mutex, which causes more complexity.
For example:
```go
lock := GetLocker(key)
lock.Lock()
// ...
// even if the lock is unlocked, we cannot GC the lock,
// since the caller may still use it again.
lock.Unlock()
lock.Lock()
// ...
lock.Unlock()
// callers have to GC the lock manually.
RemoveLocker(key)
```
That's why
https://github.com/go-gitea/gitea/pull/31813#discussion_r1721200549
In this PR, we only expose `ReleaseFunc` to callers. So callers just
need to call `ReleaseFunc` to release the lock, and do not need to care
about the lock's lifecycle.
```go
_, release, err := locker.Lock(ctx, key)
if err != nil {
return err
}
// ...
release()
// if callers want to lock again, they have to re-acquire the lock.
_, release, err := locker.Lock(ctx, key)
// ...
```
In this way, it's also much easier for redis implementation to extend
the mutex automatically, so that callers do not need to care about the
lock's lifecycle. See also
https://github.com/go-gitea/gitea/pull/31813#discussion_r1722659743
### Use "release" instead of "unlock"
For "unlock", it has the meaning of "unlock an acquired lock". So it's
not acceptable to call "unlock" when failed to acquire the lock, or call
"unlock" multiple times. It causes more complexity for callers to decide
whether to call "unlock" or not.
So we use "release" instead of "unlock" to make it clear. Whether the
lock is acquired or not, callers can always call "release", and it's
also safe to call "release" multiple times.
But the code DO NOT expect callers to not call "release" after acquiring
the lock. If callers forget to call "release", it will cause resource
leak. That's why it's always safe to call "release" without extra
checks: to avoid callers to forget to call it.
### Acquired locks could be lost
Unlike `sync.Mutex` which will be locked forever once acquired until
calling `Unlock`, in the new module, the acquired lock could be lost.
For example, the caller has acquired the lock, and it holds the lock for
a long time since auto-extending is working for redis. However, it lost
the connection to the redis server, and it's impossible to extend the
lock anymore.
If the caller don't stop what it's doing, another instance which can
connect to the redis server could acquire the lock, and do the same
thing, which could cause data inconsistency.
So the caller should know what happened, the solution is to return a new
context which will be canceled if the lock is lost or released:
```go
ctx, release, err := locker.Lock(ctx, key)
if err != nil {
return err
}
defer release()
// ...
DoSomething(ctx)
// the lock is lost now, then ctx has been canceled.
// Failed, since ctx has been canceled.
DoSomethingElse(ctx)
```
### Multiple ways to use the lock
1. Regular way
```go
ctx, release, err := Lock(ctx, key)
if err != nil {
return err
}
defer release()
// ...
```
2. Early release
```go
ctx, release, err := Lock(ctx, key)
if err != nil {
return err
}
defer release()
// ...
// release the lock earlier and reset the context back
ctx = release()
// continue to do something else
// ...
```
3. Functional way
```go
if err := LockAndDo(ctx, key, func(ctx context.Context) error {
// ...
return nil
}); err != nil {
return err
}
```
2024-08-26 17:27:57 +03:00
github . com / hashicorp / go - multierror v1 . 1.1 / / indirect
2024-06-24 16:26:42 +03:00
github . com / hashicorp / go - retryablehttp v0 . 7.7 / / indirect
2022-03-16 07:08:31 +03:00
github . com / hashicorp / hcl v1 . 0.0 / / indirect
github . com / jbenet / go - context v0 . 0.0 - 20150711004518 - d14ea06fba99 / / indirect
2024-10-31 15:05:54 +03:00
github . com / jessevdk / go - flags v1 . 6.1 / / indirect
2022-03-16 07:08:31 +03:00
github . com / josharian / intern v1 . 0.0 / / indirect
2022-04-01 01:05:57 +03:00
github . com / kevinburke / ssh_config v1 . 2.0 / / indirect
2023-05-05 12:17:19 +03:00
github . com / klauspost / pgzip v1 . 2.6 / / indirect
2023-02-24 23:18:49 +03:00
github . com / kr / pretty v0 . 3.1 / / indirect
2022-03-16 07:08:31 +03:00
github . com / kr / text v0 . 2.0 / / indirect
2024-06-24 16:26:42 +03:00
github . com / libdns / libdns v0 . 2.2 / / indirect
2023-07-14 06:00:31 +03:00
github . com / magiconair / properties v1 . 8.7 / / indirect
2022-03-16 07:08:31 +03:00
github . com / mailru / easyjson v0 . 7.7 / / indirect
2023-07-14 06:00:31 +03:00
github . com / markbates / going v1 . 0.3 / / indirect
Implement actions (#21937)
Close #13539.
Co-authored by: @lunny @appleboy @fuxiaohei and others.
Related projects:
- https://gitea.com/gitea/actions-proto-def
- https://gitea.com/gitea/actions-proto-go
- https://gitea.com/gitea/act
- https://gitea.com/gitea/act_runner
### Summary
The target of this PR is to bring a basic implementation of "Actions",
an internal CI/CD system of Gitea. That means even though it has been
merged, the state of the feature is **EXPERIMENTAL**, and please note
that:
- It is disabled by default;
- It shouldn't be used in a production environment currently;
- It shouldn't be used in a public Gitea instance currently;
- Breaking changes may be made before it's stable.
**Please comment on #13539 if you have any different product design
ideas**, all decisions reached there will be adopted here. But in this
PR, we don't talk about **naming, feature-creep or alternatives**.
### ⚠️ Breaking
`gitea-actions` will become a reserved user name. If a user with the
name already exists in the database, it is recommended to rename it.
### Some important reviews
- What is `DEFAULT_ACTIONS_URL` in `app.ini` for?
- https://github.com/go-gitea/gitea/pull/21937#discussion_r1055954954
- Why the api for runners is not under the normal `/api/v1` prefix?
- https://github.com/go-gitea/gitea/pull/21937#discussion_r1061173592
- Why DBFS?
- https://github.com/go-gitea/gitea/pull/21937#discussion_r1061301178
- Why ignore events triggered by `gitea-actions` bot?
- https://github.com/go-gitea/gitea/pull/21937#discussion_r1063254103
- Why there's no permission control for actions?
- https://github.com/go-gitea/gitea/pull/21937#discussion_r1090229868
### What it looks like
<details>
#### Manage runners
<img width="1792" alt="image"
src="https://user-images.githubusercontent.com/9418365/205870657-c72f590e-2e08-4cd4-be7f-2e0abb299bbf.png">
#### List runs
<img width="1792" alt="image"
src="https://user-images.githubusercontent.com/9418365/205872794-50fde990-2b45-48c1-a178-908e4ec5b627.png">
#### View logs
<img width="1792" alt="image"
src="https://user-images.githubusercontent.com/9418365/205872501-9b7b9000-9542-4991-8f55-18ccdada77c3.png">
</details>
### How to try it
<details>
#### 1. Start Gitea
Clone this branch and [install from
source](https://docs.gitea.io/en-us/install-from-source).
Add additional configurations in `app.ini` to enable Actions:
```ini
[actions]
ENABLED = true
```
Start it.
If all is well, you'll see the management page of runners:
<img width="1792" alt="image"
src="https://user-images.githubusercontent.com/9418365/205877365-8e30a780-9b10-4154-b3e8-ee6c3cb35a59.png">
#### 2. Start runner
Clone the [act_runner](https://gitea.com/gitea/act_runner), and follow
the
[README](https://gitea.com/gitea/act_runner/src/branch/main/README.md)
to start it.
If all is well, you'll see a new runner has been added:
<img width="1792" alt="image"
src="https://user-images.githubusercontent.com/9418365/205878000-216f5937-e696-470d-b66c-8473987d91c3.png">
#### 3. Enable actions for a repo
Create a new repo or open an existing one, check the `Actions` checkbox
in settings and submit.
<img width="1792" alt="image"
src="https://user-images.githubusercontent.com/9418365/205879705-53e09208-73c0-4b3e-a123-2dcf9aba4b9c.png">
<img width="1792" alt="image"
src="https://user-images.githubusercontent.com/9418365/205879383-23f3d08f-1a85-41dd-a8b3-54e2ee6453e8.png">
If all is well, you'll see a new tab "Actions":
<img width="1792" alt="image"
src="https://user-images.githubusercontent.com/9418365/205881648-a8072d8c-5803-4d76-b8a8-9b2fb49516c1.png">
#### 4. Upload workflow files
Upload some workflow files to `.gitea/workflows/xxx.yaml`, you can
follow the [quickstart](https://docs.github.com/en/actions/quickstart)
of GitHub Actions. Yes, Gitea Actions is compatible with GitHub Actions
in most cases, you can use the same demo:
```yaml
name: GitHub Actions Demo
run-name: ${{ github.actor }} is testing out GitHub Actions 🚀
on: [push]
jobs:
Explore-GitHub-Actions:
runs-on: ubuntu-latest
steps:
- run: echo "🎉 The job was automatically triggered by a ${{ github.event_name }} event."
- run: echo "🐧 This job is now running on a ${{ runner.os }} server hosted by GitHub!"
- run: echo "🔎 The name of your branch is ${{ github.ref }} and your repository is ${{ github.repository }}."
- name: Check out repository code
uses: actions/checkout@v3
- run: echo "💡 The ${{ github.repository }} repository has been cloned to the runner."
- run: echo "🖥️ The workflow is now ready to test your code on the runner."
- name: List files in the repository
run: |
ls ${{ github.workspace }}
- run: echo "🍏 This job's status is ${{ job.status }}."
```
If all is well, you'll see a new run in `Actions` tab:
<img width="1792" alt="image"
src="https://user-images.githubusercontent.com/9418365/205884473-79a874bc-171b-4aaf-acd5-0241a45c3b53.png">
#### 5. Check the logs of jobs
Click a run and you'll see the logs:
<img width="1792" alt="image"
src="https://user-images.githubusercontent.com/9418365/205884800-994b0374-67f7-48ff-be9a-4c53f3141547.png">
#### 6. Go on
You can try more examples in [the
documents](https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions)
of GitHub Actions, then you might find a lot of bugs.
Come on, PRs are welcome.
</details>
See also: [Feature Preview: Gitea
Actions](https://blog.gitea.io/2022/12/feature-preview-gitea-actions/)
---------
Co-authored-by: a1012112796 <1012112796@qq.com>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: delvh <dev.lh@web.de>
Co-authored-by: ChristopherHX <christopher.homberger@web.de>
Co-authored-by: John Olheiser <john.olheiser@gmail.com>
2023-01-31 04:45:19 +03:00
github . com / mattn / go - colorable v0 . 1.13 / / indirect
2024-10-31 15:05:54 +03:00
github . com / mattn / go - runewidth v0 . 0.16 / / indirect
github . com / mholt / acmez / v2 v2 . 0.3 / / indirect
github . com / miekg / dns v1 . 1.62 / / indirect
2022-03-16 07:08:31 +03:00
github . com / minio / md5 - simd v1 . 1.2 / / indirect
2022-09-02 00:13:17 +03:00
github . com / mitchellh / copystructure v1 . 2.0 / / indirect
github . com / mitchellh / mapstructure v1 . 5.0 / / indirect
github . com / mitchellh / reflectwalk v1 . 0.2 / / indirect
2022-03-16 07:08:31 +03:00
github . com / modern - go / concurrent v0 . 0.0 - 20180306012644 - bacd9c7ef1dd / / indirect
github . com / modern - go / reflect2 v1 . 0.2 / / indirect
github . com / mrjones / oauth v0 . 0.0 - 20190623134757 - 126 b35219450 / / indirect
github . com / mschoch / smat v0 . 2.0 / / indirect
2024-09-10 05:23:07 +03:00
github . com / munnerz / goautoneg v0 . 0.0 - 20191010083416 - a7dc8b61c822 / / indirect
2022-03-16 07:08:31 +03:00
github . com / nwaples / rardecode v1 . 1.3 / / indirect
github . com / oklog / ulid v1 . 3.1 / / indirect
github . com / olekukonko / tablewriter v0 . 0.5 / / indirect
2023-04-14 01:41:04 +03:00
github . com / onsi / ginkgo v1 . 16.5 / / indirect
2024-03-08 06:19:35 +03:00
github . com / paulmach / orb v0 . 11.1 / / indirect
2024-10-31 15:05:54 +03:00
github . com / pelletier / go - toml / v2 v2 . 2.3 / / indirect
2024-01-23 08:40:00 +03:00
github . com / pierrec / lz4 / v4 v4 . 1.21 / / indirect
2023-05-05 12:17:19 +03:00
github . com / pjbgf / sha1cd v0 . 3.0 / / indirect
2023-10-13 19:11:15 +03:00
github . com / pmezard / go - difflib v1 . 0.1 - 0.20181226105442 - 5 d4384ee4fb2 / / indirect
2024-09-10 05:23:07 +03:00
github . com / prometheus / client_model v0 . 6.1 / / indirect
2024-10-31 15:05:54 +03:00
github . com / prometheus / common v0 . 60.1 / / indirect
2024-09-10 05:23:07 +03:00
github . com / prometheus / procfs v0 . 15.1 / / indirect
2024-10-31 15:05:54 +03:00
github . com / rhysd / actionlint v1 . 7.3 / / indirect
2024-03-17 18:40:05 +03:00
github . com / rivo / uniseg v0 . 4.7 / / indirect
2024-10-31 15:05:54 +03:00
github . com / rogpeppe / go - internal v1 . 13.1 / / indirect
2024-09-30 04:57:48 +03:00
github . com / rs / xid v1 . 6.0 / / indirect
2022-03-16 07:08:31 +03:00
github . com / russross / blackfriday / v2 v2 . 1.0 / / indirect
2024-10-31 15:05:54 +03:00
github . com / sagikazarmark / locafero v0 . 6.0 / / indirect
2023-10-13 19:11:15 +03:00
github . com / sagikazarmark / slog - shim v0 . 1.0 / / indirect
2023-05-05 12:17:19 +03:00
github . com / segmentio / asm v1 . 2.0 / / indirect
2024-06-24 16:26:42 +03:00
github . com / shopspring / decimal v1 . 4.0 / / indirect
2023-07-14 06:00:31 +03:00
github . com / shurcooL / httpfs v0 . 0.0 - 20230704072500 - f1e31cf0ba5c / / indirect
github . com / sirupsen / logrus v1 . 9.3 / / indirect
2024-10-31 15:05:54 +03:00
github . com / skeema / knownhosts v1 . 3.0 / / indirect
2023-10-13 19:11:15 +03:00
github . com / sourcegraph / conc v0 . 3.0 / / indirect
2023-12-19 04:18:42 +03:00
github . com / spf13 / afero v1 . 11.0 / / indirect
2024-10-31 15:05:54 +03:00
github . com / spf13 / cast v1 . 7.0 / / indirect
2022-03-16 07:08:31 +03:00
github . com / spf13 / pflag v1 . 0.5 / / indirect
2024-10-31 15:05:54 +03:00
github . com / spf13 / viper v1 . 19.0 / / indirect
2022-03-16 07:08:31 +03:00
github . com / ssor / bom v0 . 0.0 - 20170718123548 - 6386211 fdfcf / / indirect
2023-08-16 15:02:40 +03:00
github . com / subosito / gotenv v1 . 6.0 / / indirect
2022-03-16 07:08:31 +03:00
github . com / toqueteos / webbrowser v1 . 2.0 / / indirect
2022-04-01 19:34:57 +03:00
github . com / unknwon / com v1 . 0.1 / / indirect
2023-01-12 11:21:16 +03:00
github . com / valyala / fastjson v1 . 6.4 / / indirect
2022-03-16 07:08:31 +03:00
github . com / x448 / float16 v0 . 8.4 / / indirect
2023-01-12 11:21:16 +03:00
github . com / xanzy / ssh - agent v0 . 3.3 / / indirect
github . com / xeipuuv / gojsonpointer v0 . 0.0 - 20190905194746 - 02993 c407bfb / / indirect
2022-12-17 09:22:34 +03:00
github . com / xeipuuv / gojsonreference v0 . 0.0 - 20180127040603 - bd5ef7bd5415 / / indirect
2022-03-16 07:08:31 +03:00
github . com / xi2 / xz v0 . 0.0 - 20171230120015 - 48954 b6210f8 / / indirect
2024-06-24 16:26:42 +03:00
github . com / xrash / smetrics v0 . 0.0 - 20240521201337 - 686 a1a2994c1 / / indirect
2024-10-31 15:05:54 +03:00
github . com / zeebo / assert v1 . 3.0 / / indirect
github . com / zeebo / blake3 v0 . 2.4 / / indirect
go . etcd . io / bbolt v1 . 3.11 / / indirect
go . mongodb . org / mongo - driver v1 . 17.1 / / indirect
go . opentelemetry . io / otel v1 . 31.0 / / indirect
go . opentelemetry . io / otel / trace v1 . 31.0 / / indirect
2023-05-05 12:17:19 +03:00
go . uber . org / atomic v1 . 11.0 / / indirect
go . uber . org / multierr v1 . 11.0 / / indirect
2024-03-17 18:40:05 +03:00
go . uber . org / zap v1 . 27.0 / / indirect
2024-10-31 15:05:54 +03:00
golang . org / x / exp v0 . 0.0 - 20241009180824 - f66d83c29e7c / / indirect
golang . org / x / mod v0 . 21.0 / / indirect
golang . org / x / time v0 . 7.0 / / indirect
google . golang . org / genproto / googleapis / rpc v0 . 0.0 - 20241021214115 - 324 edc3d5d38 / / indirect
2022-03-16 07:08:31 +03:00
gopkg . in / alexcesaro / quotedprintable . v3 v3 . 0.0 - 20150716171945 - 2 caba252f4dc / / indirect
gopkg . in / warnings . v0 v0 . 1.2 / / indirect
2022-11-21 11:36:59 +03:00
gopkg . in / yaml . v2 v2 . 4.0 / / indirect
2022-03-16 07:08:31 +03:00
)
2021-04-23 03:08:53 +03:00
replace github . com / hashicorp / go - version = > github . com / 6543 / go - version v1 . 3.1
2021-08-03 21:32:01 +03:00
2022-01-07 05:33:17 +03:00
replace github . com / shurcooL / vfsgen = > github . com / lunny / vfsgen v0 . 0.0 - 20220105142115 - 2 c99e1ffdfa0
2022-01-14 18:03:31 +03:00
2024-10-07 06:50:38 +03:00
replace github . com / nektos / act = > gitea . com / gitea / act v0 . 261.3
Implement actions (#21937)
Close #13539.
Co-authored by: @lunny @appleboy @fuxiaohei and others.
Related projects:
- https://gitea.com/gitea/actions-proto-def
- https://gitea.com/gitea/actions-proto-go
- https://gitea.com/gitea/act
- https://gitea.com/gitea/act_runner
### Summary
The target of this PR is to bring a basic implementation of "Actions",
an internal CI/CD system of Gitea. That means even though it has been
merged, the state of the feature is **EXPERIMENTAL**, and please note
that:
- It is disabled by default;
- It shouldn't be used in a production environment currently;
- It shouldn't be used in a public Gitea instance currently;
- Breaking changes may be made before it's stable.
**Please comment on #13539 if you have any different product design
ideas**, all decisions reached there will be adopted here. But in this
PR, we don't talk about **naming, feature-creep or alternatives**.
### ⚠️ Breaking
`gitea-actions` will become a reserved user name. If a user with the
name already exists in the database, it is recommended to rename it.
### Some important reviews
- What is `DEFAULT_ACTIONS_URL` in `app.ini` for?
- https://github.com/go-gitea/gitea/pull/21937#discussion_r1055954954
- Why the api for runners is not under the normal `/api/v1` prefix?
- https://github.com/go-gitea/gitea/pull/21937#discussion_r1061173592
- Why DBFS?
- https://github.com/go-gitea/gitea/pull/21937#discussion_r1061301178
- Why ignore events triggered by `gitea-actions` bot?
- https://github.com/go-gitea/gitea/pull/21937#discussion_r1063254103
- Why there's no permission control for actions?
- https://github.com/go-gitea/gitea/pull/21937#discussion_r1090229868
### What it looks like
<details>
#### Manage runners
<img width="1792" alt="image"
src="https://user-images.githubusercontent.com/9418365/205870657-c72f590e-2e08-4cd4-be7f-2e0abb299bbf.png">
#### List runs
<img width="1792" alt="image"
src="https://user-images.githubusercontent.com/9418365/205872794-50fde990-2b45-48c1-a178-908e4ec5b627.png">
#### View logs
<img width="1792" alt="image"
src="https://user-images.githubusercontent.com/9418365/205872501-9b7b9000-9542-4991-8f55-18ccdada77c3.png">
</details>
### How to try it
<details>
#### 1. Start Gitea
Clone this branch and [install from
source](https://docs.gitea.io/en-us/install-from-source).
Add additional configurations in `app.ini` to enable Actions:
```ini
[actions]
ENABLED = true
```
Start it.
If all is well, you'll see the management page of runners:
<img width="1792" alt="image"
src="https://user-images.githubusercontent.com/9418365/205877365-8e30a780-9b10-4154-b3e8-ee6c3cb35a59.png">
#### 2. Start runner
Clone the [act_runner](https://gitea.com/gitea/act_runner), and follow
the
[README](https://gitea.com/gitea/act_runner/src/branch/main/README.md)
to start it.
If all is well, you'll see a new runner has been added:
<img width="1792" alt="image"
src="https://user-images.githubusercontent.com/9418365/205878000-216f5937-e696-470d-b66c-8473987d91c3.png">
#### 3. Enable actions for a repo
Create a new repo or open an existing one, check the `Actions` checkbox
in settings and submit.
<img width="1792" alt="image"
src="https://user-images.githubusercontent.com/9418365/205879705-53e09208-73c0-4b3e-a123-2dcf9aba4b9c.png">
<img width="1792" alt="image"
src="https://user-images.githubusercontent.com/9418365/205879383-23f3d08f-1a85-41dd-a8b3-54e2ee6453e8.png">
If all is well, you'll see a new tab "Actions":
<img width="1792" alt="image"
src="https://user-images.githubusercontent.com/9418365/205881648-a8072d8c-5803-4d76-b8a8-9b2fb49516c1.png">
#### 4. Upload workflow files
Upload some workflow files to `.gitea/workflows/xxx.yaml`, you can
follow the [quickstart](https://docs.github.com/en/actions/quickstart)
of GitHub Actions. Yes, Gitea Actions is compatible with GitHub Actions
in most cases, you can use the same demo:
```yaml
name: GitHub Actions Demo
run-name: ${{ github.actor }} is testing out GitHub Actions 🚀
on: [push]
jobs:
Explore-GitHub-Actions:
runs-on: ubuntu-latest
steps:
- run: echo "🎉 The job was automatically triggered by a ${{ github.event_name }} event."
- run: echo "🐧 This job is now running on a ${{ runner.os }} server hosted by GitHub!"
- run: echo "🔎 The name of your branch is ${{ github.ref }} and your repository is ${{ github.repository }}."
- name: Check out repository code
uses: actions/checkout@v3
- run: echo "💡 The ${{ github.repository }} repository has been cloned to the runner."
- run: echo "🖥️ The workflow is now ready to test your code on the runner."
- name: List files in the repository
run: |
ls ${{ github.workspace }}
- run: echo "🍏 This job's status is ${{ job.status }}."
```
If all is well, you'll see a new run in `Actions` tab:
<img width="1792" alt="image"
src="https://user-images.githubusercontent.com/9418365/205884473-79a874bc-171b-4aaf-acd5-0241a45c3b53.png">
#### 5. Check the logs of jobs
Click a run and you'll see the logs:
<img width="1792" alt="image"
src="https://user-images.githubusercontent.com/9418365/205884800-994b0374-67f7-48ff-be9a-4c53f3141547.png">
#### 6. Go on
You can try more examples in [the
documents](https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions)
of GitHub Actions, then you might find a lot of bugs.
Come on, PRs are welcome.
</details>
See also: [Feature Preview: Gitea
Actions](https://blog.gitea.io/2022/12/feature-preview-gitea-actions/)
---------
Co-authored-by: a1012112796 <1012112796@qq.com>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: delvh <dev.lh@web.de>
Co-authored-by: ChristopherHX <christopher.homberger@web.de>
Co-authored-by: John Olheiser <john.olheiser@gmail.com>
2023-01-31 04:45:19 +03:00
2024-09-27 17:27:37 +03:00
replace github . com / charmbracelet / git - lfs - transfer = > gitea . com / gitea / git - lfs - transfer v0 . 2.0
2024-06-06 06:37:08 +03:00
// TODO: This could be removed after https://github.com/mholt/archiver/pull/396 merged
replace github . com / mholt / archiver / v3 = > github . com / anchore / archiver / v3 v3 . 5.2
2022-01-18 14:04:24 +03:00
exclude github . com / gofrs / uuid v3 . 2.0 + incompatible
exclude github . com / gofrs / uuid v4 . 0.0 + incompatible
exclude github . com / goccy / go - json v0 . 4.11
2023-01-09 09:00:10 +03:00
exclude github . com / satori / go . uuid v1 . 2.0