Skip to content

Commit 392fa48

Browse files
committed
Merge branch 'main' into add-issue-planned-time
2 parents bf7fcba + d477dd5 commit 392fa48

File tree

178 files changed

+4742
-2162
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

178 files changed

+4742
-2162
lines changed

.eslintrc.yaml

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,6 @@ rules:
224224
"@typescript-eslint/await-thenable": [2]
225225
"@typescript-eslint/ban-ts-comment": [2, {'ts-expect-error': false, 'ts-ignore': true, 'ts-nocheck': false, 'ts-check': false}]
226226
"@typescript-eslint/ban-tslint-comment": [0]
227-
"@typescript-eslint/ban-types": [2, {extendDefaults: true, types: {Function: false}}]
228227
"@typescript-eslint/class-literal-property-style": [0]
229228
"@typescript-eslint/class-methods-use-this": [0]
230229
"@typescript-eslint/consistent-generic-constructors": [0]
@@ -255,6 +254,7 @@ rules:
255254
"@typescript-eslint/no-dynamic-delete": [0]
256255
"@typescript-eslint/no-empty-function": [0]
257256
"@typescript-eslint/no-empty-interface": [0]
257+
"@typescript-eslint/no-empty-object-type": [2]
258258
"@typescript-eslint/no-explicit-any": [0]
259259
"@typescript-eslint/no-extra-non-null-assertion": [2]
260260
"@typescript-eslint/no-extraneous-class": [0]
@@ -266,7 +266,7 @@ rules:
266266
"@typescript-eslint/no-invalid-this": [0]
267267
"@typescript-eslint/no-invalid-void-type": [0]
268268
"@typescript-eslint/no-loop-func": [0]
269-
"@typescript-eslint/no-loss-of-precision": [2]
269+
"@typescript-eslint/no-loss-of-precision": [0]
270270
"@typescript-eslint/no-magic-numbers": [0]
271271
"@typescript-eslint/no-meaningless-void-operator": [0]
272272
"@typescript-eslint/no-misused-new": [2]
@@ -278,8 +278,9 @@ rules:
278278
"@typescript-eslint/no-non-null-assertion": [0]
279279
"@typescript-eslint/no-redeclare": [0]
280280
"@typescript-eslint/no-redundant-type-constituents": [2]
281-
"@typescript-eslint/no-require-imports": [0]
281+
"@typescript-eslint/no-require-imports": [2]
282282
"@typescript-eslint/no-restricted-imports": [0]
283+
"@typescript-eslint/no-restricted-types": [0]
283284
"@typescript-eslint/no-shadow": [0]
284285
"@typescript-eslint/no-this-alias": [0] # handled by unicorn/no-this-assignment
285286
"@typescript-eslint/no-unnecessary-boolean-literal-compare": [0]
@@ -294,6 +295,7 @@ rules:
294295
"@typescript-eslint/no-unsafe-call": [0]
295296
"@typescript-eslint/no-unsafe-declaration-merging": [2]
296297
"@typescript-eslint/no-unsafe-enum-comparison": [2]
298+
"@typescript-eslint/no-unsafe-function-type": [2]
297299
"@typescript-eslint/no-unsafe-member-access": [0]
298300
"@typescript-eslint/no-unsafe-return": [0]
299301
"@typescript-eslint/no-unsafe-unary-minus": [2]
@@ -302,7 +304,7 @@ rules:
302304
"@typescript-eslint/no-use-before-define": [0]
303305
"@typescript-eslint/no-useless-constructor": [0]
304306
"@typescript-eslint/no-useless-empty-export": [0]
305-
"@typescript-eslint/no-var-requires": [2]
307+
"@typescript-eslint/no-wrapper-object-types": [2]
306308
"@typescript-eslint/non-nullable-type-assertion-style": [0]
307309
"@typescript-eslint/only-throw-error": [2]
308310
"@typescript-eslint/parameter-properties": [0]
@@ -334,7 +336,7 @@ rules:
334336
"@typescript-eslint/switch-exhaustiveness-check": [0]
335337
"@typescript-eslint/triple-slash-reference": [2]
336338
"@typescript-eslint/typedef": [0]
337-
"@typescript-eslint/unbound-method": [2]
339+
"@typescript-eslint/unbound-method": [0] # too many false-positives
338340
"@typescript-eslint/unified-signatures": [2]
339341
accessor-pairs: [2]
340342
array-callback-return: [2, {checkForEach: true}]
@@ -599,7 +601,7 @@ rules:
599601
no-lone-blocks: [2]
600602
no-lonely-if: [0]
601603
no-loop-func: [0]
602-
no-loss-of-precision: [0] # handled by @typescript-eslint/no-loss-of-precision
604+
no-loss-of-precision: [2]
603605
no-magic-numbers: [0]
604606
no-misleading-character-class: [2]
605607
no-multi-assign: [0]
@@ -843,6 +845,7 @@ rules:
843845
unicorn/no-invalid-fetch-options: [2]
844846
unicorn/no-invalid-remove-event-listener: [2]
845847
unicorn/no-keyword-prefix: [0]
848+
unicorn/no-length-as-slice-end: [2]
846849
unicorn/no-lonely-if: [2]
847850
unicorn/no-magic-array-flat-depth: [0]
848851
unicorn/no-negated-condition: [0]

.github/labeler.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,3 +75,8 @@ modifies/js:
7575
- any-glob-to-any-file:
7676
- "**/*.js"
7777
- "**/*.vue"
78+
79+
docs-update-needed:
80+
- changed-files:
81+
- any-glob-to-any-file:
82+
- "custom/conf/app.example.ini"

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ TAGS ?=
137137
TAGS_SPLIT := $(subst $(COMMA), ,$(TAGS))
138138
TAGS_EVIDENCE := $(MAKE_EVIDENCE_DIR)/tags
139139

140-
TEST_TAGS ?= sqlite sqlite_unlock_notify
140+
TEST_TAGS ?= $(TAGS_SPLIT) sqlite sqlite_unlock_notify
141141

142142
TAR_EXCLUDES := .git data indexers queues log node_modules $(EXECUTABLE) $(FOMANTIC_WORK_DIR)/node_modules $(DIST) $(MAKE_EVIDENCE_DIR) $(AIR_TMP_DIR) $(GO_LICENSE_TMP_DIR)
143143

assets/go-licenses.json

Lines changed: 10 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

custom/conf/app.example.ini

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2555,7 +2555,8 @@ LEVEL = Info
25552555
;LIMIT_SIZE_SWIFT = -1
25562556
;; Maximum size of a Vagrant upload (`-1` means no limits, format `1000`, `1 MB`, `1 GiB`)
25572557
;LIMIT_SIZE_VAGRANT = -1
2558-
2558+
;; Enable RPM re-signing by default. (It will overwrite the old signature ,using v4 format, not compatible with CentOS 6 or older)
2559+
;DEFAULT_RPM_SIGN_ENABLED = false
25592560
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
25602561
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
25612562
;; default storage for attachments, lfs and avatars
@@ -2684,6 +2685,14 @@ LEVEL = Info
26842685
;;
26852686
;; Default platform to get action plugins, `github` for `https://github.com`, `self` for the current Gitea instance.
26862687
;DEFAULT_ACTIONS_URL = github
2688+
;; Logs retention time in days. Old logs will be deleted after this period.
2689+
;LOG_RETENTION_DAYS = 365
2690+
;; Log compression type, `none` for no compression, `zstd` for zstd compression.
2691+
;; Other compression types like `gzip` are NOT supported, since seekable stream is required for log view.
2692+
;; It's always recommended to use compression when using local disk as log storage if CPU or memory is not a bottleneck.
2693+
;; And for object storage services like S3, which is billed for requests, it would cause extra 2 times of get requests for each log view.
2694+
;; But it will save storage space and network bandwidth, so it's still recommended to use compression.
2695+
;LOG_COMPRESSION = none
26872696
;; Default artifact retention time in days. Artifacts could have their own retention periods by setting the `retention-days` option in `actions/upload-artifact` step.
26882697
;ARTIFACT_RETENTION_DAYS = 90
26892698
;; Timeout to stop the task which have running status, but haven't been updated for a long time

go.mod

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,10 @@ require (
2020
github.com/Azure/go-ntlmssp v0.0.0-20221128193559-754e69321358
2121
github.com/ProtonMail/go-crypto v1.0.0
2222
github.com/PuerkitoBio/goquery v1.9.2
23+
github.com/SaveTheRbtz/zstd-seekable-format-go/pkg v0.7.2
2324
github.com/alecthomas/chroma/v2 v2.14.0
2425
github.com/blakesmith/ar v0.0.0-20190502131153-809d4375e1fb
25-
github.com/blevesearch/bleve/v2 v2.4.0
26+
github.com/blevesearch/bleve/v2 v2.4.2
2627
github.com/buildkite/terminal-to-html/v3 v3.12.1
2728
github.com/caddyserver/certmagic v0.21.3
2829
github.com/chi-middleware/proxy v1.1.1
@@ -147,13 +148,13 @@ require (
147148
github.com/aymerick/douceur v0.2.0 // indirect
148149
github.com/beorn7/perks v1.0.1 // indirect
149150
github.com/bits-and-blooms/bitset v1.13.0 // indirect
150-
github.com/blevesearch/bleve_index_api v1.1.9 // indirect
151+
github.com/blevesearch/bleve_index_api v1.1.10 // indirect
151152
github.com/blevesearch/geo v0.1.20 // indirect
152-
github.com/blevesearch/go-faiss v1.0.19 // indirect
153+
github.com/blevesearch/go-faiss v1.0.20 // indirect
153154
github.com/blevesearch/go-porterstemmer v1.0.3 // indirect
154155
github.com/blevesearch/gtreap v0.1.1 // indirect
155156
github.com/blevesearch/mmap-go v1.0.4 // indirect
156-
github.com/blevesearch/scorch_segment_api/v2 v2.2.14 // indirect
157+
github.com/blevesearch/scorch_segment_api/v2 v2.2.15 // indirect
157158
github.com/blevesearch/segment v0.9.1 // indirect
158159
github.com/blevesearch/snowballstem v0.9.0 // indirect
159160
github.com/blevesearch/upsidedown_store_api v1.0.2 // indirect
@@ -163,7 +164,7 @@ require (
163164
github.com/blevesearch/zapx/v13 v13.3.10 // indirect
164165
github.com/blevesearch/zapx/v14 v14.3.10 // indirect
165166
github.com/blevesearch/zapx/v15 v15.3.13 // indirect
166-
github.com/blevesearch/zapx/v16 v16.1.4 // indirect
167+
github.com/blevesearch/zapx/v16 v16.1.5 // indirect
167168
github.com/boombuler/barcode v1.0.1 // indirect
168169
github.com/bradfitz/gomemcache v0.0.0-20230905024940-24af94b03874 // indirect
169170
github.com/caddyserver/zerossl v0.1.3 // indirect
@@ -209,6 +210,7 @@ require (
209210
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
210211
github.com/golang/protobuf v1.5.4 // indirect
211212
github.com/golang/snappy v0.0.4 // indirect
213+
github.com/google/btree v1.1.2 // indirect
212214
github.com/google/go-querystring v1.1.0 // indirect
213215
github.com/google/go-tpm v0.9.0 // indirect
214216
github.com/gorilla/css v1.0.1 // indirect

go.sum

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,8 @@ github.com/RoaringBitmap/roaring v0.4.23/go.mod h1:D0gp8kJQgE1A4LQ5wFLggQEyvDi06
8080
github.com/RoaringBitmap/roaring v0.7.1/go.mod h1:jdT9ykXwHFNdJbEtxePexlFYH9LXucApeS0/+/g+p1I=
8181
github.com/RoaringBitmap/roaring v1.9.4 h1:yhEIoH4YezLYT04s1nHehNO64EKFTop/wBhxv2QzDdQ=
8282
github.com/RoaringBitmap/roaring v1.9.4/go.mod h1:6AXUsoIEzDTFFQCe1RbGA6uFONMhvejWj5rqITANK90=
83+
github.com/SaveTheRbtz/zstd-seekable-format-go/pkg v0.7.2 h1:cSXom2MoKJ9KPPw29RoZtHvUETY4F4n/kXl8m9btnQ0=
84+
github.com/SaveTheRbtz/zstd-seekable-format-go/pkg v0.7.2/go.mod h1:JitQWJ8JuV4Y87l8VsHiiwhb3cgdyn68mX40s7NT6PA=
8385
github.com/alecthomas/assert/v2 v2.7.0 h1:QtqSACNS3tF7oasA8CU6A6sXZSBDqnm7RfpLl9bZqbE=
8486
github.com/alecthomas/assert/v2 v2.7.0/go.mod h1:Bze95FyfUr7x34QZrjL+XP+0qgp/zg8yS+TtBj1WA3k=
8587
github.com/alecthomas/chroma/v2 v2.2.0/go.mod h1:vf4zrexSH54oEjJ7EdB65tGNHmH3pGZmVkgTP5RHvAs=
@@ -117,15 +119,15 @@ github.com/bits-and-blooms/bitset v1.13.0/go.mod h1:7hO7Gc7Pp1vODcmWvKMRA9BNmbv6
117119
github.com/blakesmith/ar v0.0.0-20190502131153-809d4375e1fb h1:m935MPodAbYS46DG4pJSv7WO+VECIWUQ7OJYSoTrMh4=
118120
github.com/blakesmith/ar v0.0.0-20190502131153-809d4375e1fb/go.mod h1:PkYb9DJNAwrSvRx5DYA+gUcOIgTGVMNkfSCbZM8cWpI=
119121
github.com/blevesearch/bleve/v2 v2.0.5/go.mod h1:ZjWibgnbRX33c+vBRgla9QhPb4QOjD6fdVJ+R1Bk8LM=
120-
github.com/blevesearch/bleve/v2 v2.4.0 h1:2xyg+Wv60CFHYccXc+moGxbL+8QKT/dZK09AewHgKsg=
121-
github.com/blevesearch/bleve/v2 v2.4.0/go.mod h1:IhQHoFAbHgWKYavb9rQgQEJJVMuY99cKdQ0wPpst2aY=
122+
github.com/blevesearch/bleve/v2 v2.4.2 h1:NooYP1mb3c0StkiY9/xviiq2LGSaE8BQBCc/pirMx0U=
123+
github.com/blevesearch/bleve/v2 v2.4.2/go.mod h1:ATNKj7Yl2oJv/lGuF4kx39bST2dveX6w0th2FFYLkc8=
122124
github.com/blevesearch/bleve_index_api v1.0.0/go.mod h1:fiwKS0xLEm+gBRgv5mumf0dhgFr2mDgZah1pqv1c1M4=
123-
github.com/blevesearch/bleve_index_api v1.1.9 h1:Cpq0Lp3As0Gfk3+PmcoNDRKeI50C5yuFNpj0YlN/bOE=
124-
github.com/blevesearch/bleve_index_api v1.1.9/go.mod h1:PbcwjIcRmjhGbkS/lJCpfgVSMROV6TRubGGAODaK1W8=
125+
github.com/blevesearch/bleve_index_api v1.1.10 h1:PDLFhVjrjQWr6jCuU7TwlmByQVCSEURADHdCqVS9+g0=
126+
github.com/blevesearch/bleve_index_api v1.1.10/go.mod h1:PbcwjIcRmjhGbkS/lJCpfgVSMROV6TRubGGAODaK1W8=
125127
github.com/blevesearch/geo v0.1.20 h1:paaSpu2Ewh/tn5DKn/FB5SzvH0EWupxHEIwbCk/QPqM=
126128
github.com/blevesearch/geo v0.1.20/go.mod h1:DVG2QjwHNMFmjo+ZgzrIq2sfCh6rIHzy9d9d0B59I6w=
127-
github.com/blevesearch/go-faiss v1.0.19 h1:UKoP8hS7DVsVSRRloNJb4qPfe2UQ99pP4D3oXd23g2A=
128-
github.com/blevesearch/go-faiss v1.0.19/go.mod h1:jrxHrbl42X/RnDPI+wBoZU8joxxuRwedrxqswQ3xfU8=
129+
github.com/blevesearch/go-faiss v1.0.20 h1:AIkdTQFWuZ5LQmKQSebgMR4RynGNw8ZseJXaan5kvtI=
130+
github.com/blevesearch/go-faiss v1.0.20/go.mod h1:jrxHrbl42X/RnDPI+wBoZU8joxxuRwedrxqswQ3xfU8=
129131
github.com/blevesearch/go-porterstemmer v1.0.3 h1:GtmsqID0aZdCSNiY8SkuPJ12pD4jI+DdXTAn4YRcHCo=
130132
github.com/blevesearch/go-porterstemmer v1.0.3/go.mod h1:angGc5Ht+k2xhJdZi511LtmxuEf0OVpvUUNrwmM1P7M=
131133
github.com/blevesearch/gtreap v0.1.1 h1:2JWigFrzDMR+42WGIN/V2p0cUvn4UP3C4Q5nmaZGW8Y=
@@ -134,8 +136,8 @@ github.com/blevesearch/mmap-go v1.0.2/go.mod h1:ol2qBqYaOUsGdm7aRMRrYGgPvnwLe6Y+
134136
github.com/blevesearch/mmap-go v1.0.4 h1:OVhDhT5B/M1HNPpYPBKIEJaD0F3Si+CrEKULGCDPWmc=
135137
github.com/blevesearch/mmap-go v1.0.4/go.mod h1:EWmEAOmdAS9z/pi/+Toxu99DnsbhG1TIxUoRmJw/pSs=
136138
github.com/blevesearch/scorch_segment_api/v2 v2.0.1/go.mod h1:lq7yK2jQy1yQjtjTfU931aVqz7pYxEudHaDwOt1tXfU=
137-
github.com/blevesearch/scorch_segment_api/v2 v2.2.14 h1:fgMLMpGWR7u2TdRm7XSZVWhPvMAcdYHh25Lq1fQ6Fjo=
138-
github.com/blevesearch/scorch_segment_api/v2 v2.2.14/go.mod h1:B7+a7vfpY4NsjuTkpv/eY7RZ91Xr90VaJzT2t7upZN8=
139+
github.com/blevesearch/scorch_segment_api/v2 v2.2.15 h1:prV17iU/o+A8FiZi9MXmqbagd8I0bCqM7OKUYPbnb5Y=
140+
github.com/blevesearch/scorch_segment_api/v2 v2.2.15/go.mod h1:db0cmP03bPNadXrCDuVkKLV6ywFSiRgPFT1YVrestBc=
139141
github.com/blevesearch/segment v0.9.0/go.mod h1:9PfHYUdQCgHktBgvtUOF4x+pc4/l8rdH0u5spnW85UQ=
140142
github.com/blevesearch/segment v0.9.1 h1:+dThDy+Lvgj5JMxhmOVlgFfkUtZV2kw49xax4+jTfSU=
141143
github.com/blevesearch/segment v0.9.1/go.mod h1:zN21iLm7+GnBHWTao9I+Au/7MBiL8pPFtJBJTsk6kQw=
@@ -163,8 +165,8 @@ github.com/blevesearch/zapx/v14 v14.3.10/go.mod h1:qqyuR0u230jN1yMmE4FIAuCxmahRQ
163165
github.com/blevesearch/zapx/v15 v15.2.0/go.mod h1:MmQceLpWfME4n1WrBFIwplhWmaQbQqLQARpaKUEOs/A=
164166
github.com/blevesearch/zapx/v15 v15.3.13 h1:6EkfaZiPlAxqXz0neniq35my6S48QI94W/wyhnpDHHQ=
165167
github.com/blevesearch/zapx/v15 v15.3.13/go.mod h1:Turk/TNRKj9es7ZpKK95PS7f6D44Y7fAFy8F4LXQtGg=
166-
github.com/blevesearch/zapx/v16 v16.1.4 h1:TBQfG77g2UUXwfjOVcEtB9pXkg6JBmGXkeZKI67+TiA=
167-
github.com/blevesearch/zapx/v16 v16.1.4/go.mod h1:+Q+Z89Iv7ewhdX2jyE6Qs/RUnN4tZuokaQ0xvTaFmx8=
168+
github.com/blevesearch/zapx/v16 v16.1.5 h1:b0sMcarqNFxuXvjoXsF8WtwVahnxyhEvBSRJi/AUHjU=
169+
github.com/blevesearch/zapx/v16 v16.1.5/go.mod h1:J4mSF39w1QELc11EWRSBFkPeZuO7r/NPKkHzDCoiaI8=
168170
github.com/boombuler/barcode v1.0.1-0.20190219062509-6c824513bacc/go.mod h1:paBWMcWSl3LHKBqUq+rly7CNSldXjb2rDl3JlRe0mD8=
169171
github.com/boombuler/barcode v1.0.1 h1:NDBbPmhS+EqABEs5Kg3n/5ZNjy73Pz7SIV+KCeqyXcs=
170172
github.com/boombuler/barcode v1.0.1/go.mod h1:paBWMcWSl3LHKBqUq+rly7CNSldXjb2rDl3JlRe0mD8=
@@ -395,6 +397,8 @@ github.com/golang/snappy v0.0.1/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEW
395397
github.com/golang/snappy v0.0.2/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q=
396398
github.com/golang/snappy v0.0.4 h1:yAGX7huGHXlcLOEtBnF4w7FQwA26wojNCwOYAEhLjQM=
397399
github.com/golang/snappy v0.0.4/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q=
400+
github.com/google/btree v1.1.2 h1:xf4v41cLI2Z6FxbKm+8Bu+m8ifhj15JuZ9sa0jZCMUU=
401+
github.com/google/btree v1.1.2/go.mod h1:qOPhT0dTNdNzV6Z/lhRX0YXUafgPLFUh+gZMl761Gm4=
398402
github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
399403
github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
400404
github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=

models/actions/run.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -361,6 +361,19 @@ func GetRunByIndex(ctx context.Context, repoID, index int64) (*ActionRun, error)
361361
return run, nil
362362
}
363363

364+
func GetLatestRun(ctx context.Context, repoID int64) (*ActionRun, error) {
365+
run := &ActionRun{
366+
RepoID: repoID,
367+
}
368+
has, err := db.GetEngine(ctx).Where("repo_id=?", repoID).Desc("index").Get(run)
369+
if err != nil {
370+
return nil, err
371+
} else if !has {
372+
return nil, fmt.Errorf("latest run with repo_id %d: %w", repoID, util.ErrNotExist)
373+
}
374+
return run, nil
375+
}
376+
364377
func GetWorkflowLatestRun(ctx context.Context, repoID int64, workflowFile, branch, event string) (*ActionRun, error) {
365378
var run ActionRun
366379
q := db.GetEngine(ctx).Where("repo_id=?", repoID).

models/actions/task.go

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ type ActionTask struct {
3535
RunnerID int64 `xorm:"index"`
3636
Status Status `xorm:"index"`
3737
Started timeutil.TimeStamp `xorm:"index"`
38-
Stopped timeutil.TimeStamp
38+
Stopped timeutil.TimeStamp `xorm:"index(stopped_log_expired)"`
3939

4040
RepoID int64 `xorm:"index"`
4141
OwnerID int64 `xorm:"index"`
@@ -51,8 +51,8 @@ type ActionTask struct {
5151
LogInStorage bool // read log from database or from storage
5252
LogLength int64 // lines count
5353
LogSize int64 // blob size
54-
LogIndexes LogIndexes `xorm:"LONGBLOB"` // line number to offset
55-
LogExpired bool // files that are too old will be deleted
54+
LogIndexes LogIndexes `xorm:"LONGBLOB"` // line number to offset
55+
LogExpired bool `xorm:"index(stopped_log_expired)"` // files that are too old will be deleted
5656

5757
Created timeutil.TimeStamp `xorm:"created"`
5858
Updated timeutil.TimeStamp `xorm:"updated index"`
@@ -470,6 +470,16 @@ func StopTask(ctx context.Context, taskID int64, status Status) error {
470470
return nil
471471
}
472472

473+
func FindOldTasksToExpire(ctx context.Context, olderThan timeutil.TimeStamp, limit int) ([]*ActionTask, error) {
474+
e := db.GetEngine(ctx)
475+
476+
tasks := make([]*ActionTask, 0, limit)
477+
// Check "stopped > 0" to avoid deleting tasks that are still running
478+
return tasks, e.Where("stopped > 0 AND stopped < ? AND log_expired = ?", olderThan, false).
479+
Limit(limit).
480+
Find(&tasks)
481+
}
482+
473483
func isSubset(set, subset []string) bool {
474484
m := make(container.Set[string], len(set))
475485
for _, v := range set {
@@ -492,7 +502,13 @@ func convertTimestamp(timestamp *timestamppb.Timestamp) timeutil.TimeStamp {
492502
}
493503

494504
func logFileName(repoFullName string, taskID int64) string {
495-
return fmt.Sprintf("%s/%02x/%d.log", repoFullName, taskID%256, taskID)
505+
ret := fmt.Sprintf("%s/%02x/%d.log", repoFullName, taskID%256, taskID)
506+
507+
if setting.Actions.LogCompression.IsZstd() {
508+
ret += ".zst"
509+
}
510+
511+
return ret
496512
}
497513

498514
func getTaskIDFromCache(token string) int64 {

models/asymkey/ssh_key.go

Lines changed: 7 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -229,35 +229,26 @@ func UpdatePublicKeyUpdated(ctx context.Context, id int64) error {
229229

230230
// PublicKeysAreExternallyManaged returns whether the provided KeyID represents an externally managed Key
231231
func PublicKeysAreExternallyManaged(ctx context.Context, keys []*PublicKey) ([]bool, error) {
232-
sources := make([]*auth.Source, 0, 5)
232+
sourceCache := make(map[int64]*auth.Source, len(keys))
233233
externals := make([]bool, len(keys))
234-
keyloop:
234+
235235
for i, key := range keys {
236236
if key.LoginSourceID == 0 {
237237
externals[i] = false
238-
continue keyloop
239-
}
240-
241-
var source *auth.Source
242-
243-
sourceloop:
244-
for _, s := range sources {
245-
if s.ID == key.LoginSourceID {
246-
source = s
247-
break sourceloop
248-
}
238+
continue
249239
}
250240

251-
if source == nil {
241+
source, ok := sourceCache[key.LoginSourceID]
242+
if !ok {
252243
var err error
253244
source, err = auth.GetSourceByID(ctx, key.LoginSourceID)
254245
if err != nil {
255246
if auth.IsErrSourceNotExist(err) {
256247
externals[i] = false
257-
sources[i] = &auth.Source{
248+
sourceCache[key.LoginSourceID] = &auth.Source{
258249
ID: key.LoginSourceID,
259250
}
260-
continue keyloop
251+
continue
261252
}
262253
return nil, err
263254
}

0 commit comments

Comments
 (0)