From 4e5bf595794657c80dc71aab5b3884b327110cae Mon Sep 17 00:00:00 2001 From: Earl Warren Date: Mon, 3 Jul 2023 09:45:12 +0200 Subject: [PATCH] [CI] DEFAULT_ACTIONS_URL = https://code.forgejo.org [CI] Revert "Restrict `[actions].DEFAULT_ACTIONS_URL` to only `github` or `self` (#25581)" This reverts commit 67bd9d4f1eedb4728031504d0dd09d014c0f3e6f. (cherry picked from commit 0547e94023a545fafe82e280dd809e7efd6d86e2) (cherry picked from commit d21ad654ad0abc243913532326e916899b0e387c) (cherry picked from commit b905e9d8386c58206234a417769cc17b3be34b62) (cherry picked from commit 251a5bf235b1723bc2bc324f9e8c03a8668bb5ae) (cherry picked from commit b370e4769423bec92b0f265f3e3b2b683640024d) (cherry picked from commit 2cc28d078507027749c14a5448e949ab54b79c66) (cherry picked from commit ed870a39e98fbb69c435a3a3ef0434fe6163ebe7) (cherry picked from commit 7bb0c4654ecbbd2feee2c74034c1e2cdca0d6828) (cherry picked from commit bab1f552c385e3c7d0faa33d28fb8087780ea834) Conflicts: custom/conf/app.example.ini modules/setting/actions.go https://codeberg.org/forgejo/forgejo/pulls/1413 [CI] DEFAULT_ACTIONS_URL = https://codeberg.org (cherry picked from commit 52b364ddbd9ac82b9e6f9c1767db2d6b36165011) (cherry picked from commit 99887cd5673f6da49664b590ad60c83fdbe25a4a) (cherry picked from commit cd5788782aa5c2ee8baecd57ca1e7882f0854453) (cherry picked from commit 71c698a704d307c568f247710550d48f27cca4ce) (cherry picked from commit 71386241dd741a4fa0b67d59a07d84ac31e0b870) (cherry picked from commit b7ab05aeac12c44acd117d5a4e8d7b4da2ba4aa7) (cherry picked from commit e78b9ca59c0af867f94d9c9bfae48f8cc9381224) (cherry picked from commit edb3adf4606af94ed0ab0bd844ef626a39a99297) (cherry picked from commit 3e400881975340be9148c4549a744395a6dac665) [BRANDING] DEFAULT_ACTIONS_URL = https://code.forgejo.org (cherry picked from commit d0e4512c902dec669da36a055a2ea54adb107e0f) (cherry picked from commit 8ba6e047095e9ecb107d77361664fa83b03ddaa2) (cherry picked from commit 63490810449b4189ed8538a22182fde1bc89c057) (cherry picked from commit e06bd444951d1fd94a71ce3d591a8f397f456363) (cherry picked from commit d58219d8e13f0b4007108d78f8f6f96a1d842c2c) (cherry picked from commit 052f2c2aa45ae1aa1d59aaf713db4f771f62773b) (cherry picked from commit 29dc39538631f65eaaf5dcc4eeb747fbc68d7498) (cherry picked from commit 9eef3f59f3a1347ccc7d6d3704c9f5b40a3b6555) (cherry picked from commit d650391fedd5b2cac313e29d51cc8689d885a594) (cherry picked from commit c2e6e8c55d955f1e2b781c983f05319dddcc4386) (cherry picked from commit e28a47741dc668421989b6b2310365a6611b23b7) [CI] DEFAULT_ACTIONS_URL support for self & github (squash) Refs: https://codeberg.org/forgejo/forgejo/issues/1062 (cherry picked from commit 74cc25376ecd1dbab57abffe286ae1f918057cfd) (cherry picked from commit 405430708ffbebcfd2cefdcdfd24a540985b817c) (cherry picked from commit 0274a6dee7f383bcd6b65b995b991b5ab0ee635a) (cherry picked from commit be5cda0fd03b265367c551aefed83456be257075) (cherry picked from commit d27474849fc4dd4ec958c04b7be06eced8b74d6e) (cherry picked from commit 4a5e9e2d81f89b5c9e6782d1c24880d62f802d7f) (cherry picked from commit 65b31906b27c7a6ecaecf74af748e046c51aa7a8) (cherry picked from commit 13cf0b0963bb110db7229dc5cd4d202e7dec11fb) Conflicts: custom/conf/app.example.ini modules/setting/actions.go https://codeberg.org/forgejo/forgejo/pulls/1413 (cherry picked from commit 49529badce0a43a07a786b22e2a8705a6a1dbe63) Conflicts: custom/conf/app.example.ini docs/content/administration/config-cheat-sheet.en-us.md modules/setting/actions.go https://codeberg.org/forgejo/forgejo/pulls/1460 (cherry picked from commit 00327b9b1f8512ddb93a07b57fcaee53b701478b) (cherry picked from commit 3b322e43d5695d540a52259abdde74505241dda9) (cherry picked from commit 492cc5205908263a2733ba06a6562237406d4c11) Conflicts: modules/setting/actions.go https://codeberg.org/forgejo/forgejo/pulls/1573 (cherry picked from commit 9027b655df24bf47f49cc25d3547b6e49f66dde5) (cherry picked from commit 47643830286025dbff1538e9a6ffc23b05ea3e4b) (cherry picked from commit fbb00fd1cf9ecf30292aa3053f41076d7bb9027e) (cherry picked from commit 417cd6c801bb14b38f672fea3371486c12636ebf) (cherry picked from commit 6b70773ad817f6f3958e958a58c3d918e7d7f00e) (cherry picked from commit 9ba069327d0c5179bdae7e22ca580f3c460e9ac1) Conflicts: modules/setting/actions.go https://codeberg.org/forgejo/forgejo/pulls/1827 (cherry picked from commit 727edf19ee48648d1464f3bb38f85d82900870fa) (cherry picked from commit 689326ce2093701e57371759eda23ed9b7781286) (cherry picked from commit 745d60aec426e40a8ac98199e5f342113b39b871) (cherry picked from commit cb4ae4582c24552167e692871e697cc02384c054) (cherry picked from commit 48d5ffe1c0345f612e96acb2459c80431fa94993) Conflicts: custom/conf/app.example.ini https://codeberg.org/forgejo/forgejo/pulls/2068 (cherry picked from commit bbd4725bfdd82aa801ec0541c7dbdef9b39dcb1d) (cherry picked from commit 04eda91d10889febaee3f1b824defb2c0c9fb493) (cherry picked from commit d3621e46349645ad5e194ba6a21d4f607c403c8c) (cherry picked from commit 08da63cc4daacabf53ed18f4e521375b49bea8fe) (cherry picked from commit dc6d291b7127e92ae05bb51c6ae018734fbc3fc7) --- custom/conf/app.example.ini | 7 +++---- modules/setting/actions.go | 29 +++++------------------------ modules/setting/actions_test.go | 31 ++++--------------------------- 3 files changed, 12 insertions(+), 55 deletions(-) diff --git a/custom/conf/app.example.ini b/custom/conf/app.example.ini index 363bbcb151..3fb8456f2a 100644 --- a/custom/conf/app.example.ini +++ b/custom/conf/app.example.ini @@ -2582,10 +2582,9 @@ LEVEL = Info ; [actions] ;; Enable/Disable actions capabilities ;ENABLED = true -;; -;; Default platform to get action plugins, `github` for `https://github.com`, `self` for the current Gitea instance. -;DEFAULT_ACTIONS_URL = github -;; Default artifact retention time in days. Artifacts could have their own retention periods by setting the `retention-days` option in `actions/upload-artifact` step. +;; Default address to get action plugins, e.g. the default value means downloading from "https://code.forgejo.org/actions/checkout" for "uses: actions/checkout@v3" +;DEFAULT_ACTIONS_URL = https://code.forgejo.org +;; Default artifact retention time in days, default is 90 days ;ARTIFACT_RETENTION_DAYS = 90 ;; Timeout to stop the task which have running status, but haven't been updated for a long time ;ZOMBIE_TASK_TIMEOUT = 10m diff --git a/modules/setting/actions.go b/modules/setting/actions.go index 9fd484c3b8..e9b735dae8 100644 --- a/modules/setting/actions.go +++ b/modules/setting/actions.go @@ -7,8 +7,6 @@ import ( "fmt" "strings" "time" - - "code.gitea.io/gitea/modules/log" ) // Actions settings @@ -25,7 +23,7 @@ var ( SkipWorkflowStrings []string `ìni:"SKIP_WORKFLOW_STRINGS"` }{ Enabled: true, - DefaultActionsURL: defaultActionsURLGitHub, + DefaultActionsURL: defaultActionsURLForgejo, SkipWorkflowStrings: []string{"[skip ci]", "[ci skip]", "[no ci]", "[skip actions]", "[actions skip]"}, } ) @@ -39,18 +37,14 @@ func (url defaultActionsURL) URL() string { case defaultActionsURLSelf: return strings.TrimSuffix(AppURL, "/") default: - // This should never happen, but just in case, use GitHub as fallback - return "https://github.com" + return string(url) } } const ( - defaultActionsURLGitHub = "github" // https://github.com - defaultActionsURLSelf = "self" // the root URL of the self-hosted Gitea instance - // DefaultActionsURL only supports GitHub and the self-hosted Gitea. - // It's intentionally not supported more, so please be cautious before adding more like "gitea" or "gitlab". - // If you get some trouble with `uses: username/action_name@version` in your workflow, - // please consider to use `uses: https://the_url_you_want_to_use/username/action_name@version` instead. + defaultActionsURLForgejo = "https://code.forgejo.org" + defaultActionsURLGitHub = "github" // https://github.com + defaultActionsURLSelf = "self" // the root URL of the self-hosted instance ) func loadActionsFrom(rootCfg ConfigProvider) error { @@ -60,19 +54,6 @@ func loadActionsFrom(rootCfg ConfigProvider) error { return fmt.Errorf("failed to map Actions settings: %v", err) } - if urls := string(Actions.DefaultActionsURL); urls != defaultActionsURLGitHub && urls != defaultActionsURLSelf { - url := strings.Split(urls, ",")[0] - if strings.HasPrefix(url, "https://") || strings.HasPrefix(url, "http://") { - log.Error("[actions] DEFAULT_ACTIONS_URL does not support %q as custom URL any longer, fallback to %q", - urls, - defaultActionsURLGitHub, - ) - Actions.DefaultActionsURL = defaultActionsURLGitHub - } else { - return fmt.Errorf("unsupported [actions] DEFAULT_ACTIONS_URL: %q", urls) - } - } - // don't support to read configuration from [actions] Actions.LogStorage, err = getStorage(rootCfg, "actions_log", "", nil) if err != nil { diff --git a/modules/setting/actions_test.go b/modules/setting/actions_test.go index 3645a3f5da..01f5bf74a5 100644 --- a/modules/setting/actions_test.go +++ b/modules/setting/actions_test.go @@ -110,7 +110,6 @@ func Test_getDefaultActionsURLForActions(t *testing.T) { tests := []struct { name string iniStr string - wantErr assert.ErrorAssertionFunc wantURL string }{ { @@ -118,8 +117,7 @@ func Test_getDefaultActionsURLForActions(t *testing.T) { iniStr: ` [actions] `, - wantErr: assert.NoError, - wantURL: "https://github.com", + wantURL: "https://code.forgejo.org", }, { name: "github", @@ -127,7 +125,6 @@ func Test_getDefaultActionsURLForActions(t *testing.T) { [actions] DEFAULT_ACTIONS_URL = github `, - wantErr: assert.NoError, wantURL: "https://github.com", }, { @@ -136,35 +133,15 @@ DEFAULT_ACTIONS_URL = github [actions] DEFAULT_ACTIONS_URL = self `, - wantErr: assert.NoError, wantURL: "http://test_get_default_actions_url_for_actions:3000", }, - { - name: "custom url", - iniStr: ` -[actions] -DEFAULT_ACTIONS_URL = https://gitea.com -`, - wantErr: assert.NoError, - wantURL: "https://github.com", - }, { name: "custom urls", iniStr: ` [actions] -DEFAULT_ACTIONS_URL = https://gitea.com,https://github.com +DEFAULT_ACTIONS_URL = https://example.com `, - wantErr: assert.NoError, - wantURL: "https://github.com", - }, - { - name: "invalid", - iniStr: ` -[actions] -DEFAULT_ACTIONS_URL = gitea -`, - wantErr: assert.Error, - wantURL: "https://github.com", + wantURL: "https://example.com", }, } @@ -172,7 +149,7 @@ DEFAULT_ACTIONS_URL = gitea t.Run(tt.name, func(t *testing.T) { cfg, err := NewConfigProviderFromData(tt.iniStr) require.NoError(t, err) - if !tt.wantErr(t, loadActionsFrom(cfg)) { + if !assert.NoError(t, loadActionsFrom(cfg)) { return } assert.EqualValues(t, tt.wantURL, Actions.DefaultActionsURL.URL())