diff --git a/.github/workflows/dev_auto-pr-author-assign.yml b/.github/workflows/dev_auto-pr-author-assign.yml index a37b1ef4b..6a44efe56 100644 --- a/.github/workflows/dev_auto-pr-author-assign.yml +++ b/.github/workflows/dev_auto-pr-author-assign.yml @@ -1,3 +1,17 @@ +# Copyright 2024 Flant JSC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + # .github/workflows/auto-author-assign.yml name: Auto Author Assign diff --git a/.github/workflows/dev_build_precache.yml b/.github/workflows/dev_build_precache.yml index 14bfbff51..4a4ec2540 100644 --- a/.github/workflows/dev_build_precache.yml +++ b/.github/workflows/dev_build_precache.yml @@ -1,3 +1,17 @@ +# Copyright 2024 Flant JSC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + name: Build main, pre-alpha every 8 hours for dev env: MODULES_REGISTRY: ${{ vars.DEV_REGISTRY }} diff --git a/.github/workflows/dev_module_build-and-registration.yml b/.github/workflows/dev_module_build-and-registration.yml index 6387a501a..76c706fc6 100644 --- a/.github/workflows/dev_module_build-and-registration.yml +++ b/.github/workflows/dev_module_build-and-registration.yml @@ -1,3 +1,17 @@ +# Copyright 2024 Flant JSC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + name: Deploy Dev env: diff --git a/.github/workflows/dev_module_build-on-self-hosted-runner.yml b/.github/workflows/dev_module_build-on-self-hosted-runner.yml index 9829dff4e..61cb6cdd7 100644 --- a/.github/workflows/dev_module_build-on-self-hosted-runner.yml +++ b/.github/workflows/dev_module_build-on-self-hosted-runner.yml @@ -1,3 +1,17 @@ +# Copyright 2024 Flant JSC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + name: Build and push for dev (Self-hosted) env: diff --git a/.github/workflows/dev_module_build.yml b/.github/workflows/dev_module_build.yml index e7c3276fd..4c709083f 100644 --- a/.github/workflows/dev_module_build.yml +++ b/.github/workflows/dev_module_build.yml @@ -1,3 +1,17 @@ +# Copyright 2024 Flant JSC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + name: Build and push for dev env: diff --git a/.github/workflows/dev_registry-cleanup.yml b/.github/workflows/dev_registry-cleanup.yml index ab46c32d1..b5c150f65 100644 --- a/.github/workflows/dev_registry-cleanup.yml +++ b/.github/workflows/dev_registry-cleanup.yml @@ -1,3 +1,17 @@ +# Copyright 2024 Flant JSC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + name: Cleanup dev registries env: diff --git a/.github/workflows/release_module_build-and-registration.yml b/.github/workflows/release_module_build-and-registration.yml index fdb96f196..353cfe228 100644 --- a/.github/workflows/release_module_build-and-registration.yml +++ b/.github/workflows/release_module_build-and-registration.yml @@ -1,3 +1,17 @@ +# Copyright 2024 Flant JSC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + name: Build and push for prod env: diff --git a/.github/workflows/release_module_release-channels.yml b/.github/workflows/release_module_release-channels.yml index 3096e81c9..381248767 100644 --- a/.github/workflows/release_module_release-channels.yml +++ b/.github/workflows/release_module_release-channels.yml @@ -1,3 +1,17 @@ +# Copyright 2024 Flant JSC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + name: Deploy Prod env: diff --git a/.github/workflows/release_release-please.yml b/.github/workflows/release_release-please.yml index 91dee5f72..f45e94b1d 100644 --- a/.github/workflows/release_release-please.yml +++ b/.github/workflows/release_release-please.yml @@ -1,3 +1,17 @@ +# Copyright 2024 Flant JSC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + name: Release please on: diff --git a/tools/addlicense/addlicense_test.go b/tools/addlicense/addlicense_test.go index a8d52ee85..8a29c8eb0 100644 --- a/tools/addlicense/addlicense_test.go +++ b/tools/addlicense/addlicense_test.go @@ -222,3 +222,75 @@ print("Hello") }) } } + +func Test_FilesPathWithExtensionRe(t *testing.T) { + filePathCases := []struct { + title string + filePath string + }{ + { + title: "Path .github with yaml extension", + filePath: "./.github/workflows/build.yaml", + }, + { + title: "Path with /some/folder/.github yaml extension", + filePath: "/some/folder/.github/workflows/build.yaml", + }, + { + title: "Path with ./.github yml extension", + filePath: "./.github/workflows/build.yml", + }, + { + title: "Path with sh extension", + filePath: "./run.sh", + }, + { + title: "Path with py extension", + filePath: "./scripts/run.py", + }, + { + title: "Path with go extension", + filePath: "./cmds/run.go", + }, + } + + for _, c := range filePathCases { + t.Run(c.title, func(t *testing.T) { + resFilePathMatch := fileToCheckRe.MatchString(c.filePath) + require.True(t, resFilePathMatch) + + // Copyright is maintained for files with an extension + license := getLicenseForFile(c.filePath) + require.NotEmpty(t, license) + require.True(t, CELicenseRe.MatchString(license)) + }) + } +} + +func Test_FilesPathNoExtensionRe(t *testing.T) { + filePathCases := []struct { + title string + filePath string + }{ + { + title: "Path with no extension", + filePath: "./cmds/enable", + }, + { + title: "Path with no extension root dir", + filePath: "/enable", + }, + } + + for _, c := range filePathCases { + t.Run(c.title, func(t *testing.T) { + resFilePathMatch := fileToCheckRe.MatchString(c.filePath) + require.True(t, resFilePathMatch) + + // Copyright is not maintained for files without an extension + license := getLicenseForFile(c.filePath) + require.Empty(t, license) + require.False(t, CELicenseRe.MatchString(license)) + }) + } +} diff --git a/tools/addlicense/utils.go b/tools/addlicense/utils.go index ddbc75629..4929122bd 100644 --- a/tools/addlicense/utils.go +++ b/tools/addlicense/utils.go @@ -42,7 +42,7 @@ func getLicenseForFile(filePath string) string { switch filepath.Ext(filePath) { case ".go": return goLicense - case ".py", ".sh", ".bash", ".zsh": + case ".py", ".sh", ".bash", ".zsh", ".yaml", ".yml": return bashPythonLicense default: return "" diff --git a/tools/addlicense/variables.go b/tools/addlicense/variables.go index 1f261251a..ba8109f80 100644 --- a/tools/addlicense/variables.go +++ b/tools/addlicense/variables.go @@ -47,7 +47,7 @@ var ( // - Ends with .go, .sh, .py // - Is inside a .github directory: scripts, workflows, or workflow_templates subdirectories, // and ends with .js, .yml, .yaml, or .sh -var fileToCheckRe = regexp.MustCompile(`\.go$|/[^/.]+$|\.sh$|\.py$|^\.github/(scripts|workflows|workflow_templates)/.+\.(js|yml|yaml|sh)$`) +var fileToCheckRe = regexp.MustCompile(`\.go$|/[^/.]+$|\.sh$|\.py$|\.github/(scripts|workflows|workflow_templates)/.+\.(js|yml|yaml|sh)$`) // fileToSkipRe matches filenames that will be skipped for adding license, meet the following conditions: // - Directories .github/CODEOWNERS, /docs/