loading up the forgejo repo on tangled to test page performance
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge pull request '[BUG] Fix SourceHut Builds webhook with triggers field' (#3864) from oliverpool/forgejo:sourcehut_trigger into forgejo

Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/3864
Reviewed-by: Earl Warren <earl-warren@noreply.codeberg.org>

+61 -50
+1
release-notes/8.0.0/fix/3864.md
··· 1 + SourceHut Builds webhook would fail when the `triggers` field was used.
+6 -12
services/webhook/sourcehut/builds.go
··· 264 264 return []byte(msg), fmt.Errorf(msg+": %w", err) 265 265 } 266 266 defer r.Close() 267 + 268 + // reference: https://man.sr.ht/builds.sr.ht/manifest.md 267 269 var manifest struct { 268 - Image string `yaml:"image"` 269 - Arch string `yaml:"arch,omitempty"` 270 - Packages []string `yaml:"packages,omitempty"` 271 - Repositories map[string]string `yaml:"repositories,omitempty"` 272 - Artifacts []string `yaml:"artifacts,omitempty"` 273 - Shell bool `yaml:"shell,omitempty"` 274 - Sources []string `yaml:"sources"` 275 - Tasks []map[string]string `yaml:"tasks"` 276 - Triggers []string `yaml:"triggers,omitempty"` 277 - Environment map[string]string `yaml:"environment"` 278 - Secrets []string `yaml:"secrets,omitempty"` 279 - Oauth string `yaml:"oauth,omitempty"` 270 + Sources []string `yaml:"sources"` 271 + Environment map[string]string `yaml:"environment"` 272 + 273 + Rest map[string]yaml.Node `yaml:",inline"` 280 274 } 281 275 if err := yaml.NewDecoder(r).Decode(&manifest); err != nil { 282 276 msg := fmt.Sprintf("could not decode manifest %q", pc.meta.ManifestPath)
+49 -35
services/webhook/sourcehut/builds_test.go
··· 69 69 pc.meta.ManifestPath = "simple.yml" 70 70 pl, err := pc.Create(p) 71 71 require.NoError(t, err) 72 - assert.Equal(t, buildsVariables{ 73 - Manifest: `image: alpine/edge 74 - sources: 72 + 73 + assert.Equal(t, `sources: 75 74 - http://localhost:3000/testdata/repo.git#58771003157b81abc6bf41df0c5db4147a3e3c83 76 - tasks: 77 - - say-hello: | 78 - echo hello 79 - - say-world: echo world 80 75 environment: 81 76 BUILD_SUBMITTER: forgejo 82 77 BUILD_SUBMITTER_URL: https://example.forgejo.org/ 83 78 GIT_REF: refs/heads/test 84 - `, 79 + image: alpine/edge 80 + tasks: 81 + - say-hello: | 82 + echo hello 83 + - say-world: echo world 84 + `, pl.Variables.Manifest) 85 + assert.Equal(t, buildsVariables{ 86 + Manifest: pl.Variables.Manifest, // the manifest correctness is checked above, for nicer diff on error 85 87 Note: "branch test created", 86 88 Tags: []string{"testdata/repo", "branch/test", "simple.yml"}, 87 89 Secrets: true, ··· 100 102 pc.meta.ManifestPath = "simple.yml" 101 103 pl, err := pc.Create(p) 102 104 require.NoError(t, err) 103 - assert.Equal(t, buildsVariables{ 104 - Manifest: `image: alpine/edge 105 - sources: 105 + 106 + assert.Equal(t, `sources: 106 107 - http://localhost:3000/testdata/repo.git#58771003157b81abc6bf41df0c5db4147a3e3c83 108 + environment: 109 + BUILD_SUBMITTER: forgejo 110 + BUILD_SUBMITTER_URL: https://example.forgejo.org/ 111 + GIT_REF: refs/tags/v1.0.0 112 + image: alpine/edge 107 113 tasks: 108 114 - say-hello: | 109 115 echo hello 110 116 - say-world: echo world 111 - environment: 112 - BUILD_SUBMITTER: forgejo 113 - BUILD_SUBMITTER_URL: https://example.forgejo.org/ 114 - GIT_REF: refs/tags/v1.0.0 115 - `, 117 + `, pl.Variables.Manifest) 118 + assert.Equal(t, buildsVariables{ 119 + Manifest: pl.Variables.Manifest, // the manifest correctness is checked above, for nicer diff on error 116 120 Note: "tag v1.0.0 created", 117 121 Tags: []string{"testdata/repo", "tag/v1.0.0", "simple.yml"}, 118 122 Secrets: true, ··· 151 155 pl, err := pc.Push(p) 152 156 require.NoError(t, err) 153 157 154 - assert.Equal(t, buildsVariables{ 155 - Manifest: `image: alpine/edge 156 - sources: 158 + assert.Equal(t, `sources: 157 159 - http://localhost:3000/testdata/repo.git#58771003157b81abc6bf41df0c5db4147a3e3c83 158 - tasks: 159 - - say-hello: | 160 - echo hello 161 - - say-world: echo world 162 160 environment: 163 161 BUILD_SUBMITTER: forgejo 164 162 BUILD_SUBMITTER_URL: https://example.forgejo.org/ 165 163 GIT_REF: refs/heads/main 166 - `, 164 + image: alpine/edge 165 + tasks: 166 + - say-hello: | 167 + echo hello 168 + - say-world: echo world 169 + `, pl.Variables.Manifest) 170 + assert.Equal(t, buildsVariables{ 171 + Manifest: pl.Variables.Manifest, // the manifest correctness is checked above, for nicer diff on error 167 172 Note: "add simple", 168 173 Tags: []string{"testdata/repo", "branch/main", "simple.yml"}, 169 174 Secrets: true, ··· 175 180 p := &api.PushPayload{ 176 181 Ref: "refs/heads/main", 177 182 HeadCommit: &api.PayloadCommit{ 178 - ID: "69b217caa89166a02b8cd368b64fb83a44720e14", 183 + ID: "b0404943256a1f5a50c3726f4378756b4c1e5704", 179 184 Message: "replace simple with complex", 180 185 }, 181 186 Repo: repo, ··· 187 192 pl, err := pc.Push(p) 188 193 require.NoError(t, err) 189 194 190 - assert.Equal(t, buildsVariables{ 191 - Manifest: `image: archlinux 192 - packages: 193 - - nodejs 194 - - npm 195 - - rsync 196 - sources: 197 - - http://localhost:3000/testdata/repo.git#69b217caa89166a02b8cd368b64fb83a44720e14 198 - tasks: [] 195 + assert.Equal(t, `sources: 196 + - http://localhost:3000/testdata/repo.git#b0404943256a1f5a50c3726f4378756b4c1e5704 199 197 environment: 200 198 BUILD_SUBMITTER: forgejo 201 199 BUILD_SUBMITTER_URL: https://example.forgejo.org/ 202 200 GIT_REF: refs/heads/main 203 201 deploy: synapse@synapse-bt.org 202 + image: archlinux 203 + packages: 204 + - nodejs 205 + - npm 206 + - rsync 204 207 secrets: 205 208 - 7ebab768-e5e4-4c9d-ba57-ec41a72c5665 206 - `, 209 + tasks: [] 210 + triggers: 211 + - condition: failure 212 + action: email 213 + to: Jim Jimson <jim@example.org> 214 + # report back the status 215 + - condition: always 216 + action: webhook 217 + url: https://hook.example.org 218 + `, pl.Variables.Manifest) 219 + assert.Equal(t, buildsVariables{ 220 + Manifest: pl.Variables.Manifest, // the manifest correctness is checked above, for nicer diff on error 207 221 Note: "replace simple with complex", 208 222 Tags: []string{"testdata/repo", "branch/main", "complex.yaml"}, 209 223 Secrets: false,
services/webhook/sourcehut/testdata/repo.git/objects/01/16b5e2279b70e5f5b98240e8896331248f4463

This is a binary file and will not be displayed.

-1
services/webhook/sourcehut/testdata/repo.git/objects/56/f276169b9766f805e5198fe7fb6698153fdb03
··· 1 - x�NKj�0�Z�x�B��ɶ���z���Q�[FQ�?"=A3�Ѳmk#���*@��L3&�)��'D$�#�Β� 搊�Ѽ,#/��8�Ov��zIN<�u'��[;�J��~���{�#'�e;.x����輋#[K��[k�y���ASq\DA��kƵ�������؝~P�k���VO�
services/webhook/sourcehut/testdata/repo.git/objects/99/fb389b232e5497f0dcdb1c1065eac1d10d3794

This is a binary file and will not be displayed.

+4
services/webhook/sourcehut/testdata/repo.git/objects/a5/4082fdb8e55055382725f10a81bb4dc2b13029
··· 1 + xU��n�0 �w����k 2 + ��l�4�z�0�� ��%fm�~@��D����c<(�ŝ�% m�]�NjD��R� 3 + ��A��閌���9X�x����u�{��;N���ȅ�4(�Gy�:Q��O�?�/9 �lh�|�0�c���Όl8�*��$?��d�Ի��**��>7����ȖXom��UJItmKq���rh�8>��)ҺڋF�,����77,�8��� {:�0zZfy���a�) 4 + ��5�� ʴ�����狉7ΑL�ܯ�)z �yivoQ78J}�臤
services/webhook/sourcehut/testdata/repo.git/objects/b0/404943256a1f5a50c3726f4378756b4c1e5704

This is a binary file and will not be displayed.

services/webhook/sourcehut/testdata/repo.git/objects/bd/d74dba3f34542e480d56c2a91c9e2463180d3c

This is a binary file and will not be displayed.

services/webhook/sourcehut/testdata/repo.git/objects/c2/30778a03511f546f532e79c8c14917c260e750

This is a binary file and will not be displayed.

services/webhook/sourcehut/testdata/repo.git/objects/c9/fa8be8c6f230e9529f8e546a3e6a354cbaf313

This is a binary file and will not be displayed.

-1
services/webhook/sourcehut/testdata/repo.git/objects/cb/80b2628b69c86b6baea464e5f9fc28405fde4b
··· 1 - x=�Kn�0 D��)�`�k�@Pd�{P2���-AQ���] �Y��Ie�sm�KoD��)�����8�p gg44�l��FQ����F9�˜��V�,�[�U�Τ`~�[i�Vڕ� ��������4�+(��0Y)�$��"���Ԡl��Z-e��5��w�ԦʸN���Y�?V4�&���t����C9�=a���� �,P�
+1 -1
services/webhook/sourcehut/testdata/repo.git/refs/heads/main
··· 1 - 69b217caa89166a02b8cd368b64fb83a44720e14 1 + b0404943256a1f5a50c3726f4378756b4c1e5704