From 97dc52416109de9288bbd4051a1754748078fd02 Mon Sep 17 00:00:00 2001 From: vdaas-ci <57942646+vdaas-ci@users.noreply.github.com> Date: Wed, 11 Sep 2024 12:24:06 +0900 Subject: [PATCH 1/2] automatically generate workflows (#2595) (#2603) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * chore: add an actions/gen folder to hack * feat: add a generator of docker image building workflows --------- Co-authored-by: Shunya Morihira (森平 隼矢) <105629359+smorihira@users.noreply.github.com> Co-authored-by: Hiroto Funakoshi Co-authored-by: Kiichiro YUKAWA --- .../workflows/dockers-agent-faiss-image.yaml | 82 ++ .../workflows/dockers-agent-faiss-image.yml | 69 -- .github/workflows/dockers-agent-image.yaml | 84 ++ .github/workflows/dockers-agent-image.yml | 65 -- .../workflows/dockers-agent-ngt-image.yaml | 80 ++ .github/workflows/dockers-agent-ngt-image.yml | 69 -- .../dockers-agent-sidecar-image.yaml | 80 ++ .../workflows/dockers-agent-sidecar-image.yml | 67 -- .../dockers-benchmark-job-image.yaml | 80 ++ .../workflows/dockers-benchmark-job-image.yml | 65 -- .../dockers-benchmark-operator-image.yaml | 87 ++- .github/workflows/dockers-binfmt-image.yaml | 63 +- .../workflows/dockers-buildbase-image.yaml | 77 ++ .github/workflows/dockers-buildbase-image.yml | 48 -- .github/workflows/dockers-buildkit-image.yaml | 63 +- .../dockers-buildkit-syft-scanner-image.yaml | 63 +- .../workflows/dockers-ci-container-image.yaml | 65 ++ .../workflows/dockers-ci-container-image.yml | 54 -- .../dockers-dev-container-image.yaml | 64 ++ .../workflows/dockers-dev-container-image.yml | 49 -- .../dockers-discoverer-k8s-image.yaml | 76 ++ .../dockers-discoverer-k8s-image.yml | 63 -- .../dockers-gateway-filter-image.yaml | 80 ++ .../dockers-gateway-filter-image.yml | 69 -- .../workflows/dockers-gateway-lb-image.yaml | 80 ++ .../workflows/dockers-gateway-lb-image.yml | 69 -- .../dockers-gateway-mirror-image.yaml | 85 +- .../dockers-helm-operator-image.yaml | 72 ++ .../workflows/dockers-helm-operator-image.yml | 59 -- .../dockers-index-correction-image.yaml | 78 ++ .../workflows/dockers-index-correction.yml | 63 -- .../dockers-index-creation-image.yaml | 78 ++ .github/workflows/dockers-index-creation.yml | 63 -- .../dockers-index-operator-image.yaml | 76 ++ .github/workflows/dockers-index-operator.yml | 63 -- .../workflows/dockers-index-save-image.yaml | 78 ++ .github/workflows/dockers-index-save.yml | 63 -- .github/workflows/dockers-loadtest-image.yaml | 79 ++ .github/workflows/dockers-loadtest-image.yml | 66 -- .../dockers-manager-index-image.yaml | 78 ++ .../workflows/dockers-manager-index-image.yml | 65 -- .../dockers-readreplica-rotate-image.yaml | 76 ++ .../workflows/dockers-readreplica-rotate.yml | 63 -- Makefile | 5 + Makefile.d/functions.mk | 17 + hack/actions/gen/main.go | 733 ++++++++++++++++++ 46 files changed, 2456 insertions(+), 1315 deletions(-) create mode 100755 .github/workflows/dockers-agent-faiss-image.yaml delete mode 100644 .github/workflows/dockers-agent-faiss-image.yml create mode 100755 .github/workflows/dockers-agent-image.yaml delete mode 100644 .github/workflows/dockers-agent-image.yml create mode 100755 .github/workflows/dockers-agent-ngt-image.yaml delete mode 100644 .github/workflows/dockers-agent-ngt-image.yml create mode 100755 .github/workflows/dockers-agent-sidecar-image.yaml delete mode 100644 .github/workflows/dockers-agent-sidecar-image.yml create mode 100755 .github/workflows/dockers-benchmark-job-image.yaml delete mode 100644 .github/workflows/dockers-benchmark-job-image.yml mode change 100644 => 100755 .github/workflows/dockers-benchmark-operator-image.yaml mode change 100644 => 100755 .github/workflows/dockers-binfmt-image.yaml create mode 100755 .github/workflows/dockers-buildbase-image.yaml delete mode 100644 .github/workflows/dockers-buildbase-image.yml mode change 100644 => 100755 .github/workflows/dockers-buildkit-image.yaml mode change 100644 => 100755 .github/workflows/dockers-buildkit-syft-scanner-image.yaml create mode 100755 .github/workflows/dockers-ci-container-image.yaml delete mode 100644 .github/workflows/dockers-ci-container-image.yml create mode 100755 .github/workflows/dockers-dev-container-image.yaml delete mode 100644 .github/workflows/dockers-dev-container-image.yml create mode 100755 .github/workflows/dockers-discoverer-k8s-image.yaml delete mode 100644 .github/workflows/dockers-discoverer-k8s-image.yml create mode 100755 .github/workflows/dockers-gateway-filter-image.yaml delete mode 100644 .github/workflows/dockers-gateway-filter-image.yml create mode 100755 .github/workflows/dockers-gateway-lb-image.yaml delete mode 100644 .github/workflows/dockers-gateway-lb-image.yml mode change 100644 => 100755 .github/workflows/dockers-gateway-mirror-image.yaml create mode 100755 .github/workflows/dockers-helm-operator-image.yaml delete mode 100644 .github/workflows/dockers-helm-operator-image.yml create mode 100755 .github/workflows/dockers-index-correction-image.yaml delete mode 100644 .github/workflows/dockers-index-correction.yml create mode 100755 .github/workflows/dockers-index-creation-image.yaml delete mode 100644 .github/workflows/dockers-index-creation.yml create mode 100755 .github/workflows/dockers-index-operator-image.yaml delete mode 100644 .github/workflows/dockers-index-operator.yml create mode 100755 .github/workflows/dockers-index-save-image.yaml delete mode 100644 .github/workflows/dockers-index-save.yml create mode 100755 .github/workflows/dockers-loadtest-image.yaml delete mode 100644 .github/workflows/dockers-loadtest-image.yml create mode 100755 .github/workflows/dockers-manager-index-image.yaml delete mode 100644 .github/workflows/dockers-manager-index-image.yml create mode 100755 .github/workflows/dockers-readreplica-rotate-image.yaml delete mode 100644 .github/workflows/dockers-readreplica-rotate.yml create mode 100644 hack/actions/gen/main.go diff --git a/.github/workflows/dockers-agent-faiss-image.yaml b/.github/workflows/dockers-agent-faiss-image.yaml new file mode 100755 index 0000000000..bda1be82ae --- /dev/null +++ b/.github/workflows/dockers-agent-faiss-image.yaml @@ -0,0 +1,82 @@ +# +# Copyright (C) 2019-2024 vdaas.org vald team +# +# 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 +# +# https://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. +# +# DO_NOT_EDIT this workflow file is generated by https://github.com/vdaas/vald/blob/main/hack/actions/gen/main.go +name: 'Build docker image: agent-faiss' +on: + push: + branches: + - main + - release/v*.* + - '!release/v*.*.*' + tags: + - '*.*.*' + - v*.*.* + - '*.*.*-*' + - v*.*.*-* + pull_request: + paths: + - hack/docker/gen/main.go + - dockers/agent/core/faiss/Dockerfile + - hack/actions/gen/main.go + - .github/workflows/dockers-agent-faiss-image.yaml + - .github/actions/docker-build/action.yaml + - .github/workflows/_docker-image.yaml + - cmd/agent/core/faiss/** + - pkg/agent/core/faiss/** + - pkg/agent/internal/** + - apis/grpc/** + - apis/proto/** + - go.mod + - go.sum + - versions/GO_VERSION + - internal/** + - '!internal/**/*_test.go' + - '!internal/**/*_mock.go' + - '!internal/db/**' + - '!internal/k8s/**' + - versions/FAISS_VERSION + - Makefile + - Makefile.d/** + pull_request_target: + paths: + - hack/docker/gen/main.go + - dockers/agent/core/faiss/Dockerfile + - hack/actions/gen/main.go + - .github/workflows/dockers-agent-faiss-image.yaml + - .github/actions/docker-build/action.yaml + - .github/workflows/_docker-image.yaml + - cmd/agent/core/faiss/** + - pkg/agent/core/faiss/** + - pkg/agent/internal/** + - apis/grpc/** + - apis/proto/** + - go.mod + - go.sum + - versions/GO_VERSION + - internal/** + - '!internal/**/*_test.go' + - '!internal/**/*_mock.go' + - '!internal/db/**' + - '!internal/k8s/**' + - versions/FAISS_VERSION + - Makefile + - Makefile.d/** +jobs: + build: + uses: ./.github/workflows/_docker-image.yaml + with: + target: agent-faiss + secrets: inherit diff --git a/.github/workflows/dockers-agent-faiss-image.yml b/.github/workflows/dockers-agent-faiss-image.yml deleted file mode 100644 index d623609a56..0000000000 --- a/.github/workflows/dockers-agent-faiss-image.yml +++ /dev/null @@ -1,69 +0,0 @@ -# -# Copyright (C) 2019-2024 vdaas.org vald team -# -# 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 -# -# https://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 docker image: agent-faiss" -on: - push: - branches: - - "main" - - "release/v*.*" - - "!release/v*.*.*" - tags: - - "*.*.*" - - "v*.*.*" - - "*.*.*-*" - - "v*.*.*-*" - pull_request: - paths: - - "!internal/**/*_test.go" - - "!internal/db/**" - - "!internal/k8s/**" - - ".github/actions/docker-build/action.yaml" - - ".github/workflows/_docker-image.yaml" - - ".github/workflows/dockers-agent-faiss-image.yml" - - "Makefile" - - "apis/grpc/**" - - "cmd/agent/core/faiss/**" - - "dockers/agent/core/faiss/Dockerfile" - - "go.mod" - - "go.sum" - - "internal/**" - - "pkg/agent/core/faiss/**" - - "versions/FAISS_VERSION" - - "versions/GO_VERSION" - pull_request_target: - paths: - - "!internal/**/*_test.go" - - "!internal/db/**" - - "!internal/k8s/**" - - ".github/actions/docker-build/action.yaml" - - ".github/workflows/_docker-image.yaml" - - ".github/workflows/dockers-agent-faiss-image.yml" - - "Makefile" - - "apis/grpc/**" - - "cmd/agent/core/faiss/**" - - "dockers/agent/core/faiss/Dockerfile" - - "go.mod" - - "go.sum" - - "internal/**" - - "pkg/agent/core/faiss/**" - - "versions/FAISS_VERSION" - - "versions/GO_VERSION" -jobs: - build: - uses: ./.github/workflows/_docker-image.yaml - with: - target: agent-faiss - secrets: inherit diff --git a/.github/workflows/dockers-agent-image.yaml b/.github/workflows/dockers-agent-image.yaml new file mode 100755 index 0000000000..d6665fe250 --- /dev/null +++ b/.github/workflows/dockers-agent-image.yaml @@ -0,0 +1,84 @@ +# +# Copyright (C) 2019-2024 vdaas.org vald team +# +# 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 +# +# https://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. +# +# DO_NOT_EDIT this workflow file is generated by https://github.com/vdaas/vald/blob/main/hack/actions/gen/main.go +name: 'Build docker image: agent' +on: + push: + branches: + - main + - release/v*.* + - '!release/v*.*.*' + tags: + - '*.*.*' + - v*.*.* + - '*.*.*-*' + - v*.*.*-* + pull_request: + paths: + - hack/docker/gen/main.go + - dockers/agent/core/agent/Dockerfile + - hack/actions/gen/main.go + - .github/workflows/dockers-agent-image.yaml + - .github/actions/docker-build/action.yaml + - .github/workflows/_docker-image.yaml + - cmd/agent/core/agent/** + - pkg/agent/core/agent/** + - apis/grpc/** + - apis/proto/** + - rust/Cargo.lock + - rust/Cargo.toml + - rust/bin/agent + - rust/libs/ngt-rs/** + - rust/libs/ngt/** + - rust/libs/proto/** + - versions/RUST_VERSION + - versions/FAISS_VERSION + - versions/NGT_VERSION + - versions/FAISS_VERSION + - versions/NGT_VERSION + - Makefile + - Makefile.d/** + pull_request_target: + paths: + - hack/docker/gen/main.go + - dockers/agent/core/agent/Dockerfile + - hack/actions/gen/main.go + - .github/workflows/dockers-agent-image.yaml + - .github/actions/docker-build/action.yaml + - .github/workflows/_docker-image.yaml + - cmd/agent/core/agent/** + - pkg/agent/core/agent/** + - apis/grpc/** + - apis/proto/** + - rust/Cargo.lock + - rust/Cargo.toml + - rust/bin/agent + - rust/libs/ngt-rs/** + - rust/libs/ngt/** + - rust/libs/proto/** + - versions/RUST_VERSION + - versions/FAISS_VERSION + - versions/NGT_VERSION + - versions/FAISS_VERSION + - versions/NGT_VERSION + - Makefile + - Makefile.d/** +jobs: + build: + uses: ./.github/workflows/_docker-image.yaml + with: + target: agent + secrets: inherit diff --git a/.github/workflows/dockers-agent-image.yml b/.github/workflows/dockers-agent-image.yml deleted file mode 100644 index 0aa4f2e98c..0000000000 --- a/.github/workflows/dockers-agent-image.yml +++ /dev/null @@ -1,65 +0,0 @@ -# -# Copyright (C) 2019-2024 vdaas.org vald team -# -# 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 -# -# https://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 docker image: agent" -on: - push: - branches: - - "main" - - "release/v*.*" - - "!release/v*.*.*" - tags: - - "*.*.*" - - "v*.*.*" - - "*.*.*-*" - - "v*.*.*-*" - pull_request: - paths: - - ".github/actions/docker-build/action.yaml" - - ".github/workflows/_docker-image.yaml" - - ".github/workflows/dockers-agent-image.yml" - - "Makefile" - - "dockers/agent/core/agent/Dockerfile" - - "rust/Cargo.lock" - - "rust/Cargo.toml" - - "rust/bin/agent/**" - - "rust/libs/ngt-rs/**" - - "rust/libs/ngt/**" - - "rust/libs/proto/**" - - "versions/FAISS_VERSION" - - "versions/NGT_VERSION" - - "versions/RUST_VERSION" - pull_request_target: - paths: - - ".github/actions/docker-build/action.yaml" - - ".github/workflows/_docker-image.yaml" - - ".github/workflows/dockers-agent-image.yml" - - "Makefile" - - "dockers/agent/core/agent/Dockerfile" - - "rust/Cargo.lock" - - "rust/Cargo.toml" - - "rust/bin/agent/**" - - "rust/libs/ngt-rs/**" - - "rust/libs/ngt/**" - - "rust/libs/proto/**" - - "versions/FAISS_VERSION" - - "versions/NGT_VERSION" - - "versions/RUST_VERSION" -jobs: - build: - uses: ./.github/workflows/_docker-image.yaml - with: - target: agent - secrets: inherit diff --git a/.github/workflows/dockers-agent-ngt-image.yaml b/.github/workflows/dockers-agent-ngt-image.yaml new file mode 100755 index 0000000000..e2587cc568 --- /dev/null +++ b/.github/workflows/dockers-agent-ngt-image.yaml @@ -0,0 +1,80 @@ +# +# Copyright (C) 2019-2024 vdaas.org vald team +# +# 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 +# +# https://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. +# +# DO_NOT_EDIT this workflow file is generated by https://github.com/vdaas/vald/blob/main/hack/actions/gen/main.go +name: 'Build docker image: agent-ngt' +on: + push: + branches: + - main + - release/v*.* + - '!release/v*.*.*' + tags: + - '*.*.*' + - v*.*.* + - '*.*.*-*' + - v*.*.*-* + pull_request: + paths: + - hack/docker/gen/main.go + - dockers/agent/core/ngt/Dockerfile + - hack/actions/gen/main.go + - .github/workflows/dockers-agent-ngt-image.yaml + - .github/actions/docker-build/action.yaml + - .github/workflows/_docker-image.yaml + - cmd/agent/core/ngt/** + - pkg/agent/core/ngt/** + - pkg/agent/internal/** + - apis/grpc/** + - apis/proto/** + - go.mod + - go.sum + - versions/GO_VERSION + - internal/** + - '!internal/**/*_test.go' + - '!internal/**/*_mock.go' + - '!internal/db/**' + - versions/NGT_VERSION + - Makefile + - Makefile.d/** + pull_request_target: + paths: + - hack/docker/gen/main.go + - dockers/agent/core/ngt/Dockerfile + - hack/actions/gen/main.go + - .github/workflows/dockers-agent-ngt-image.yaml + - .github/actions/docker-build/action.yaml + - .github/workflows/_docker-image.yaml + - cmd/agent/core/ngt/** + - pkg/agent/core/ngt/** + - pkg/agent/internal/** + - apis/grpc/** + - apis/proto/** + - go.mod + - go.sum + - versions/GO_VERSION + - internal/** + - '!internal/**/*_test.go' + - '!internal/**/*_mock.go' + - '!internal/db/**' + - versions/NGT_VERSION + - Makefile + - Makefile.d/** +jobs: + build: + uses: ./.github/workflows/_docker-image.yaml + with: + target: agent-ngt + secrets: inherit diff --git a/.github/workflows/dockers-agent-ngt-image.yml b/.github/workflows/dockers-agent-ngt-image.yml deleted file mode 100644 index 3f8ff939bc..0000000000 --- a/.github/workflows/dockers-agent-ngt-image.yml +++ /dev/null @@ -1,69 +0,0 @@ -# -# Copyright (C) 2019-2024 vdaas.org vald team -# -# 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 -# -# https://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 docker image: agent-ngt" -on: - push: - branches: - - "main" - - "release/v*.*" - - "!release/v*.*.*" - tags: - - "*.*.*" - - "v*.*.*" - - "*.*.*-*" - - "v*.*.*-*" - pull_request: - paths: - - "!internal/**/*_test.go" - - "!internal/db/**" - - "!internal/k8s/**" - - ".github/actions/docker-build/action.yaml" - - ".github/workflows/_docker-image.yaml" - - ".github/workflows/dockers-agent-ngt-image.yml" - - "Makefile" - - "apis/grpc/**" - - "cmd/agent/core/ngt/**" - - "dockers/agent/core/ngt/Dockerfile" - - "go.mod" - - "go.sum" - - "internal/**" - - "pkg/agent/core/ngt/**" - - "versions/NGT_VERSION" - - "versions/GO_VERSION" - pull_request_target: - paths: - - "!internal/**/*_test.go" - - "!internal/db/**" - - "!internal/k8s/**" - - ".github/actions/docker-build/action.yaml" - - ".github/workflows/_docker-image.yaml" - - ".github/workflows/dockers-agent-ngt-image.yml" - - "Makefile" - - "apis/grpc/**" - - "cmd/agent/core/ngt/**" - - "dockers/agent/core/ngt/Dockerfile" - - "go.mod" - - "go.sum" - - "internal/**" - - "pkg/agent/core/ngt/**" - - "versions/NGT_VERSION" - - "versions/GO_VERSION" -jobs: - build: - uses: ./.github/workflows/_docker-image.yaml - with: - target: agent-ngt - secrets: inherit diff --git a/.github/workflows/dockers-agent-sidecar-image.yaml b/.github/workflows/dockers-agent-sidecar-image.yaml new file mode 100755 index 0000000000..78456cab05 --- /dev/null +++ b/.github/workflows/dockers-agent-sidecar-image.yaml @@ -0,0 +1,80 @@ +# +# Copyright (C) 2019-2024 vdaas.org vald team +# +# 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 +# +# https://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. +# +# DO_NOT_EDIT this workflow file is generated by https://github.com/vdaas/vald/blob/main/hack/actions/gen/main.go +name: 'Build docker image: agent-sidecar' +on: + push: + branches: + - main + - release/v*.* + - '!release/v*.*.*' + tags: + - '*.*.*' + - v*.*.* + - '*.*.*-*' + - v*.*.*-* + pull_request: + paths: + - hack/docker/gen/main.go + - dockers/agent/sidecar/Dockerfile + - hack/actions/gen/main.go + - .github/workflows/dockers-agent-sidecar-image.yaml + - .github/actions/docker-build/action.yaml + - .github/workflows/_docker-image.yaml + - cmd/agent/sidecar/** + - pkg/agent/sidecar/** + - apis/grpc/** + - apis/proto/** + - go.mod + - go.sum + - versions/GO_VERSION + - internal/** + - '!internal/**/*_test.go' + - '!internal/**/*_mock.go' + - '!internal/db/**' + - '!internal/k8s/**' + - internal/db/storage/blob/** + - Makefile + - Makefile.d/** + pull_request_target: + paths: + - hack/docker/gen/main.go + - dockers/agent/sidecar/Dockerfile + - hack/actions/gen/main.go + - .github/workflows/dockers-agent-sidecar-image.yaml + - .github/actions/docker-build/action.yaml + - .github/workflows/_docker-image.yaml + - cmd/agent/sidecar/** + - pkg/agent/sidecar/** + - apis/grpc/** + - apis/proto/** + - go.mod + - go.sum + - versions/GO_VERSION + - internal/** + - '!internal/**/*_test.go' + - '!internal/**/*_mock.go' + - '!internal/db/**' + - '!internal/k8s/**' + - internal/db/storage/blob/** + - Makefile + - Makefile.d/** +jobs: + build: + uses: ./.github/workflows/_docker-image.yaml + with: + target: agent-sidecar + secrets: inherit diff --git a/.github/workflows/dockers-agent-sidecar-image.yml b/.github/workflows/dockers-agent-sidecar-image.yml deleted file mode 100644 index 38ae9eeb3a..0000000000 --- a/.github/workflows/dockers-agent-sidecar-image.yml +++ /dev/null @@ -1,67 +0,0 @@ -# -# Copyright (C) 2019-2024 vdaas.org vald team -# -# 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 -# -# https://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 docker image: agent-sidecar" -on: - push: - branches: - - "main" - - "release/v*.*" - - "!release/v*.*.*" - tags: - - "*.*.*" - - "v*.*.*" - - "*.*.*-*" - - "v*.*.*-*" - pull_request: - paths: - - ".github/actions/docker-build/action.yaml" - - ".github/workflows/_docker-image.yaml" - - ".github/workflows/dockers-agent-sidecar-image.yml" - - "go.mod" - - "go.sum" - - "internal/**" - - "!internal/**/*_test.go" - - "!internal/db/**" - - "internal/db/storage/blob/**" - - "!internal/k8s/**" - - "apis/grpc/**" - - "pkg/agent/sidecar/**" - - "cmd/agent/sidecar/**" - - "dockers/agent/sidecar/Dockerfile" - - "versions/GO_VERSION" - pull_request_target: - paths: - - ".github/actions/docker-build/action.yaml" - - ".github/workflows/_docker-image.yaml" - - ".github/workflows/dockers-agent-sidecar-image.yml" - - "go.mod" - - "go.sum" - - "internal/**" - - "!internal/**/*_test.go" - - "!internal/db/**" - - "internal/db/storage/blob/**" - - "!internal/k8s/**" - - "apis/grpc/**" - - "pkg/agent/sidecar/**" - - "cmd/agent/sidecar/**" - - "dockers/agent/sidecar/Dockerfile" - - "versions/GO_VERSION" -jobs: - build: - uses: ./.github/workflows/_docker-image.yaml - with: - target: agent-sidecar - secrets: inherit diff --git a/.github/workflows/dockers-benchmark-job-image.yaml b/.github/workflows/dockers-benchmark-job-image.yaml new file mode 100755 index 0000000000..6ff59e9816 --- /dev/null +++ b/.github/workflows/dockers-benchmark-job-image.yaml @@ -0,0 +1,80 @@ +# +# Copyright (C) 2019-2024 vdaas.org vald team +# +# 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 +# +# https://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. +# +# DO_NOT_EDIT this workflow file is generated by https://github.com/vdaas/vald/blob/main/hack/actions/gen/main.go +name: 'Build docker image: benchmark-job' +on: + push: + branches: + - main + - release/v*.* + - '!release/v*.*.*' + tags: + - '*.*.*' + - v*.*.* + - '*.*.*-*' + - v*.*.*-* + pull_request: + paths: + - hack/docker/gen/main.go + - dockers/tools/benchmark/job/Dockerfile + - hack/actions/gen/main.go + - .github/workflows/dockers-benchmark-job-image.yaml + - .github/actions/docker-build/action.yaml + - .github/workflows/_docker-image.yaml + - cmd/tools/benchmark/job/** + - pkg/tools/benchmark/job/** + - cmd/tools/benchmark/operators/** + - pkg/tools/benchmark/operators/** + - apis/grpc/** + - apis/proto/** + - go.mod + - go.sum + - versions/GO_VERSION + - internal/** + - '!internal/**/*_test.go' + - '!internal/**/*_mock.go' + - '!internal/db/**' + - Makefile + - Makefile.d/** + pull_request_target: + paths: + - hack/docker/gen/main.go + - dockers/tools/benchmark/job/Dockerfile + - hack/actions/gen/main.go + - .github/workflows/dockers-benchmark-job-image.yaml + - .github/actions/docker-build/action.yaml + - .github/workflows/_docker-image.yaml + - cmd/tools/benchmark/job/** + - pkg/tools/benchmark/job/** + - cmd/tools/benchmark/operators/** + - pkg/tools/benchmark/operators/** + - apis/grpc/** + - apis/proto/** + - go.mod + - go.sum + - versions/GO_VERSION + - internal/** + - '!internal/**/*_test.go' + - '!internal/**/*_mock.go' + - '!internal/db/**' + - Makefile + - Makefile.d/** +jobs: + build: + uses: ./.github/workflows/_docker-image.yaml + with: + target: benchmark-job + secrets: inherit diff --git a/.github/workflows/dockers-benchmark-job-image.yml b/.github/workflows/dockers-benchmark-job-image.yml deleted file mode 100644 index 2d59b4356c..0000000000 --- a/.github/workflows/dockers-benchmark-job-image.yml +++ /dev/null @@ -1,65 +0,0 @@ -# -# Copyright (C) 2019-2024 vdaas.org vald team -# -# 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 -# -# https://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 docker image: benchmark-job" -on: - push: - branches: - - main - tags: - - "*.*.*" - - "v*.*.*" - - "*.*.*-*" - - "v*.*.*-*" - pull_request: - paths: - - ".github/actions/docker-build/action.yaml" - - ".github/workflows/_docker-image.yaml" - - ".github/workflows/dockers-benchmak-job-image.yml" - - "go.mod" - - "go.sum" - - "internal/**" - - "!internal/**/*_test.go" - - "!internal/db/**" - - "apis/grpc/**" - - "pkg/tools/benchmark/operator/**" - - "cmd/tools/benchmark/operator/**" - - "pkg/tools/benchmark/job/**" - - "cmd/tools/benchmark/job/**" - - "dockers/tools/benchmark/job/Dockerfile" - - "versions/GO_VERSION" - pull_request_target: - paths: - - ".github/actions/docker-build/action.yaml" - - ".github/workflows/_docker-image.yaml" - - ".github/workflows/dockers-benchmak-job-image.yml" - - "go.mod" - - "go.sum" - - "internal/**" - - "!internal/**/*_test.go" - - "!internal/db/**" - - "apis/grpc/**" - - "pkg/tools/benchmark/operator/**" - - "cmd/tools/benchmark/operator/**" - - "pkg/tools/benchmark/job/**" - - "cmd/tools/benchmark/job/**" - - "dockers/tools/benchmark/job/Dockerfile" - - "versions/GO_VERSION" -jobs: - build: - uses: ./.github/workflows/_docker-image.yaml - with: - target: benchmark-job - secrets: inherit diff --git a/.github/workflows/dockers-benchmark-operator-image.yaml b/.github/workflows/dockers-benchmark-operator-image.yaml old mode 100644 new mode 100755 index 2cc23d85b3..31c0f0f341 --- a/.github/workflows/dockers-benchmark-operator-image.yaml +++ b/.github/workflows/dockers-benchmark-operator-image.yaml @@ -13,50 +13,65 @@ # See the License for the specific language governing permissions and # limitations under the License. # -name: "Build docker image: benchmark-operator" +# DO_NOT_EDIT this workflow file is generated by https://github.com/vdaas/vald/blob/main/hack/actions/gen/main.go +name: 'Build docker image: benchmark-operator' on: push: branches: - - main + - main + - release/v*.* + - '!release/v*.*.*' tags: - - "*.*.*" - - "v*.*.*" - - "*.*.*-*" - - "v*.*.*-*" + - '*.*.*' + - v*.*.* + - '*.*.*-*' + - v*.*.*-* pull_request: paths: - - ".github/actions/docker-build/action.yaml" - - ".github/workflows/_docker-image.yaml" - - ".github/workflows/dockers-benchmak-operator-image.yml" - - "go.mod" - - "go.sum" - - "internal/**" - - "!internal/**/*_test.go" - - "!internal/db/**" - - "apis/grpc/**" - - "pkg/tools/benchmark/operator/**" - - "cmd/tools/benchmark/operator/**" - - "pkg/tools/benchmark/job/**" - - "cmd/tools/benchmark/job/**" - - "dockers/tools/benchmark/operator/Dockerfile" - - "versions/GO_VERSION" + - hack/docker/gen/main.go + - dockers/tools/benchmark/operator/Dockerfile + - hack/actions/gen/main.go + - .github/workflows/dockers-benchmark-operator-image.yaml + - .github/actions/docker-build/action.yaml + - .github/workflows/_docker-image.yaml + - cmd/tools/benchmark/operator/** + - pkg/tools/benchmark/operator/** + - cmd/tools/benchmark/jobs/** + - pkg/tools/benchmark/jobs/** + - apis/grpc/** + - apis/proto/** + - go.mod + - go.sum + - versions/GO_VERSION + - internal/** + - '!internal/**/*_test.go' + - '!internal/**/*_mock.go' + - '!internal/db/**' + - Makefile + - Makefile.d/** pull_request_target: paths: - - ".github/actions/docker-build/action.yaml" - - ".github/workflows/_docker-image.yaml" - - ".github/workflows/dockers-benchmak-operator-image.yml" - - "go.mod" - - "go.sum" - - "internal/**" - - "!internal/**/*_test.go" - - "!internal/db/**" - - "apis/grpc/**" - - "pkg/tools/benchmark/operator/**" - - "cmd/tools/benchmark/operator/**" - - "pkg/tools/benchmark/job/**" - - "cmd/tools/benchmark/job/**" - - "dockers/tools/benchmark/operator/Dockerfile" - - "versions/GO_VERSION" + - hack/docker/gen/main.go + - dockers/tools/benchmark/operator/Dockerfile + - hack/actions/gen/main.go + - .github/workflows/dockers-benchmark-operator-image.yaml + - .github/actions/docker-build/action.yaml + - .github/workflows/_docker-image.yaml + - cmd/tools/benchmark/operator/** + - pkg/tools/benchmark/operator/** + - cmd/tools/benchmark/jobs/** + - pkg/tools/benchmark/jobs/** + - apis/grpc/** + - apis/proto/** + - go.mod + - go.sum + - versions/GO_VERSION + - internal/** + - '!internal/**/*_test.go' + - '!internal/**/*_mock.go' + - '!internal/db/**' + - Makefile + - Makefile.d/** jobs: build: uses: ./.github/workflows/_docker-image.yaml diff --git a/.github/workflows/dockers-binfmt-image.yaml b/.github/workflows/dockers-binfmt-image.yaml old mode 100644 new mode 100755 index 9a5d961c9d..4689f56333 --- a/.github/workflows/dockers-binfmt-image.yaml +++ b/.github/workflows/dockers-binfmt-image.yaml @@ -13,32 +13,61 @@ # See the License for the specific language governing permissions and # limitations under the License. # -name: "Build docker image: binfmt" +# DO_NOT_EDIT this workflow file is generated by https://github.com/vdaas/vald/blob/main/hack/actions/gen/main.go +name: 'Build docker image: binfmt' on: schedule: - - cron: "0 * * * *" + - cron: 0 * * * * push: branches: - - "main" - - "release/v*.*" - - "!release/v*.*.*" + - main + - release/v*.* + - '!release/v*.*.*' tags: - - "*.*.*" - - "v*.*.*" - - "*.*.*-*" - - "v*.*.*-*" + - '*.*.*' + - v*.*.* + - '*.*.*-*' + - v*.*.*-* pull_request: paths: - - ".github/actions/docker-build/action.yaml" - - ".github/workflows/_docker-image.yaml" - - ".github/workflows/dockers-binfmt-image.yml" - - "dockers/binfmt/Dockerfile" + - hack/docker/gen/main.go + - dockers/binfmt/Dockerfile + - hack/actions/gen/main.go + - .github/workflows/dockers-binfmt-image.yaml + - .github/actions/docker-build/action.yaml + - .github/workflows/_docker-image.yaml + - cmd/binfmt/** + - pkg/binfmt/** + - apis/grpc/** + - apis/proto/** + - go.mod + - go.sum + - versions/GO_VERSION + - internal/** + - '!internal/**/*_test.go' + - '!internal/**/*_mock.go' + - '!internal/db/**' + - '!internal/k8s/**' pull_request_target: paths: - - ".github/actions/docker-build/action.yaml" - - ".github/workflows/_docker-image.yaml" - - ".github/workflows/dockers-binfmt-image.yml" - - "dockers/binfmt/Dockerfile" + - hack/docker/gen/main.go + - dockers/binfmt/Dockerfile + - hack/actions/gen/main.go + - .github/workflows/dockers-binfmt-image.yaml + - .github/actions/docker-build/action.yaml + - .github/workflows/_docker-image.yaml + - cmd/binfmt/** + - pkg/binfmt/** + - apis/grpc/** + - apis/proto/** + - go.mod + - go.sum + - versions/GO_VERSION + - internal/** + - '!internal/**/*_test.go' + - '!internal/**/*_mock.go' + - '!internal/db/**' + - '!internal/k8s/**' jobs: build: uses: ./.github/workflows/_docker-image.yaml diff --git a/.github/workflows/dockers-buildbase-image.yaml b/.github/workflows/dockers-buildbase-image.yaml new file mode 100755 index 0000000000..5117c243fc --- /dev/null +++ b/.github/workflows/dockers-buildbase-image.yaml @@ -0,0 +1,77 @@ +# +# Copyright (C) 2019-2024 vdaas.org vald team +# +# 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 +# +# https://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. +# +# DO_NOT_EDIT this workflow file is generated by https://github.com/vdaas/vald/blob/main/hack/actions/gen/main.go +name: 'Build docker image: buildbase' +on: + schedule: + - cron: 0 * * * * + push: + branches: + - main + - release/v*.* + - '!release/v*.*.*' + tags: + - '*.*.*' + - v*.*.* + - '*.*.*-*' + - v*.*.*-* + pull_request: + paths: + - hack/docker/gen/main.go + - dockers/buildbase/Dockerfile + - hack/actions/gen/main.go + - .github/workflows/dockers-buildbase-image.yaml + - .github/actions/docker-build/action.yaml + - .github/workflows/_docker-image.yaml + - cmd/buildbase/** + - pkg/buildbase/** + - apis/grpc/** + - apis/proto/** + - go.mod + - go.sum + - versions/GO_VERSION + - internal/** + - '!internal/**/*_test.go' + - '!internal/**/*_mock.go' + - '!internal/db/**' + - '!internal/k8s/**' + pull_request_target: + paths: + - hack/docker/gen/main.go + - dockers/buildbase/Dockerfile + - hack/actions/gen/main.go + - .github/workflows/dockers-buildbase-image.yaml + - .github/actions/docker-build/action.yaml + - .github/workflows/_docker-image.yaml + - cmd/buildbase/** + - pkg/buildbase/** + - apis/grpc/** + - apis/proto/** + - go.mod + - go.sum + - versions/GO_VERSION + - internal/** + - '!internal/**/*_test.go' + - '!internal/**/*_mock.go' + - '!internal/db/**' + - '!internal/k8s/**' +jobs: + build: + uses: ./.github/workflows/_docker-image.yaml + with: + target: buildbase + platforms: linux/amd64,linux/arm64 + secrets: inherit diff --git a/.github/workflows/dockers-buildbase-image.yml b/.github/workflows/dockers-buildbase-image.yml deleted file mode 100644 index 6819dd7618..0000000000 --- a/.github/workflows/dockers-buildbase-image.yml +++ /dev/null @@ -1,48 +0,0 @@ -# -# Copyright (C) 2019-2024 vdaas.org vald team -# -# 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 -# -# https://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 docker image: buildbase" -on: - schedule: - - cron: "0 * * * *" - push: - branches: - - "main" - - "release/v*.*" - - "!release/v*.*.*" - tags: - - "*.*.*" - - "v*.*.*" - - "*.*.*-*" - - "v*.*.*-*" - pull_request: - paths: - - ".github/actions/docker-build/action.yaml" - - ".github/workflows/_docker-image.yaml" - - ".github/workflows/dockers-buildbase-image.yml" - - "dockers/buildbase/Dockerfile" - pull_request_target: - paths: - - ".github/actions/docker-build/action.yaml" - - ".github/workflows/_docker-image.yaml" - - ".github/workflows/dockers-buildbase-image.yml" - - "dockers/buildbase/Dockerfile" -jobs: - build: - uses: ./.github/workflows/_docker-image.yaml - with: - target: buildbase - platforms: linux/amd64,linux/arm64 - secrets: inherit diff --git a/.github/workflows/dockers-buildkit-image.yaml b/.github/workflows/dockers-buildkit-image.yaml old mode 100644 new mode 100755 index 8b202e1355..df7d955c0f --- a/.github/workflows/dockers-buildkit-image.yaml +++ b/.github/workflows/dockers-buildkit-image.yaml @@ -13,32 +13,61 @@ # See the License for the specific language governing permissions and # limitations under the License. # -name: "Build docker image: buildkit" +# DO_NOT_EDIT this workflow file is generated by https://github.com/vdaas/vald/blob/main/hack/actions/gen/main.go +name: 'Build docker image: buildkit' on: schedule: - - cron: "0 * * * *" + - cron: 0 * * * * push: branches: - - "main" - - "release/v*.*" - - "!release/v*.*.*" + - main + - release/v*.* + - '!release/v*.*.*' tags: - - "*.*.*" - - "v*.*.*" - - "*.*.*-*" - - "v*.*.*-*" + - '*.*.*' + - v*.*.* + - '*.*.*-*' + - v*.*.*-* pull_request: paths: - - ".github/actions/docker-build/action.yaml" - - ".github/workflows/_docker-image.yaml" - - ".github/workflows/dockers-buildkit-image.yml" - - "dockers/buildkit/Dockerfile" + - hack/docker/gen/main.go + - dockers/buildkit/Dockerfile + - hack/actions/gen/main.go + - .github/workflows/dockers-buildkit-image.yaml + - .github/actions/docker-build/action.yaml + - .github/workflows/_docker-image.yaml + - cmd/buildkit/** + - pkg/buildkit/** + - apis/grpc/** + - apis/proto/** + - go.mod + - go.sum + - versions/GO_VERSION + - internal/** + - '!internal/**/*_test.go' + - '!internal/**/*_mock.go' + - '!internal/db/**' + - '!internal/k8s/**' pull_request_target: paths: - - ".github/actions/docker-build/action.yaml" - - ".github/workflows/_docker-image.yaml" - - ".github/workflows/dockers-buildkit-image.yml" - - "dockers/buildkit/Dockerfile" + - hack/docker/gen/main.go + - dockers/buildkit/Dockerfile + - hack/actions/gen/main.go + - .github/workflows/dockers-buildkit-image.yaml + - .github/actions/docker-build/action.yaml + - .github/workflows/_docker-image.yaml + - cmd/buildkit/** + - pkg/buildkit/** + - apis/grpc/** + - apis/proto/** + - go.mod + - go.sum + - versions/GO_VERSION + - internal/** + - '!internal/**/*_test.go' + - '!internal/**/*_mock.go' + - '!internal/db/**' + - '!internal/k8s/**' jobs: build: uses: ./.github/workflows/_docker-image.yaml diff --git a/.github/workflows/dockers-buildkit-syft-scanner-image.yaml b/.github/workflows/dockers-buildkit-syft-scanner-image.yaml old mode 100644 new mode 100755 index 0476cfdfb9..b74ee0acfb --- a/.github/workflows/dockers-buildkit-syft-scanner-image.yaml +++ b/.github/workflows/dockers-buildkit-syft-scanner-image.yaml @@ -13,32 +13,61 @@ # See the License for the specific language governing permissions and # limitations under the License. # -name: "Build docker image: buildkit-syft-scanner" +# DO_NOT_EDIT this workflow file is generated by https://github.com/vdaas/vald/blob/main/hack/actions/gen/main.go +name: 'Build docker image: buildkit-syft-scanner' on: schedule: - - cron: "0 * * * *" + - cron: 0 * * * * push: branches: - - "main" - - "release/v*.*" - - "!release/v*.*.*" + - main + - release/v*.* + - '!release/v*.*.*' tags: - - "*.*.*" - - "v*.*.*" - - "*.*.*-*" - - "v*.*.*-*" + - '*.*.*' + - v*.*.* + - '*.*.*-*' + - v*.*.*-* pull_request: paths: - - ".github/actions/docker-build/action.yaml" - - ".github/workflows/_docker-image.yaml" - - ".github/workflows/dockers-buildkit-syft-scanner-image.yml" - - "dockers/buildkit/syft/scanner/Dockerfile" + - hack/docker/gen/main.go + - dockers/buildkit/syft/scanner/Dockerfile + - hack/actions/gen/main.go + - .github/workflows/dockers-buildkit-syft-scanner-image.yaml + - .github/actions/docker-build/action.yaml + - .github/workflows/_docker-image.yaml + - cmd/buildkit/syft/scanner/** + - pkg/buildkit/syft/scanner/** + - apis/grpc/** + - apis/proto/** + - go.mod + - go.sum + - versions/GO_VERSION + - internal/** + - '!internal/**/*_test.go' + - '!internal/**/*_mock.go' + - '!internal/db/**' + - '!internal/k8s/**' pull_request_target: paths: - - ".github/actions/docker-build/action.yaml" - - ".github/workflows/_docker-image.yaml" - - ".github/workflows/dockers-buildkit-syft-scanner-image.yml" - - "dockers/buildkit/syft/scanner/Dockerfile" + - hack/docker/gen/main.go + - dockers/buildkit/syft/scanner/Dockerfile + - hack/actions/gen/main.go + - .github/workflows/dockers-buildkit-syft-scanner-image.yaml + - .github/actions/docker-build/action.yaml + - .github/workflows/_docker-image.yaml + - cmd/buildkit/syft/scanner/** + - pkg/buildkit/syft/scanner/** + - apis/grpc/** + - apis/proto/** + - go.mod + - go.sum + - versions/GO_VERSION + - internal/** + - '!internal/**/*_test.go' + - '!internal/**/*_mock.go' + - '!internal/db/**' + - '!internal/k8s/**' jobs: build: uses: ./.github/workflows/_docker-image.yaml diff --git a/.github/workflows/dockers-ci-container-image.yaml b/.github/workflows/dockers-ci-container-image.yaml new file mode 100755 index 0000000000..fa6ffb3943 --- /dev/null +++ b/.github/workflows/dockers-ci-container-image.yaml @@ -0,0 +1,65 @@ +# +# Copyright (C) 2019-2024 vdaas.org vald team +# +# 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 +# +# https://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. +# +# DO_NOT_EDIT this workflow file is generated by https://github.com/vdaas/vald/blob/main/hack/actions/gen/main.go +name: 'Build docker image: ci-container' +on: + push: + branches: + - main + - release/v*.* + - '!release/v*.*.*' + tags: + - '*.*.*' + - v*.*.* + - '*.*.*-*' + - v*.*.*-* + pull_request: + paths: + - hack/docker/gen/main.go + - dockers/ci/base/Dockerfile + - hack/actions/gen/main.go + - .github/workflows/dockers-ci-container-image.yaml + - .github/actions/docker-build/action.yaml + - .github/workflows/_docker-image.yaml + - cmd/ci/base/** + - pkg/ci/base/** + - apis/grpc/** + - apis/proto/** + - hack/** + - Makefile + - Makefile.d/** + pull_request_target: + paths: + - hack/docker/gen/main.go + - dockers/ci/base/Dockerfile + - hack/actions/gen/main.go + - .github/workflows/dockers-ci-container-image.yaml + - .github/actions/docker-build/action.yaml + - .github/workflows/_docker-image.yaml + - cmd/ci/base/** + - pkg/ci/base/** + - apis/grpc/** + - apis/proto/** + - hack/** + - Makefile + - Makefile.d/** +jobs: + build: + uses: ./.github/workflows/_docker-image.yaml + with: + target: ci-container + platforms: linux/amd64 + secrets: inherit diff --git a/.github/workflows/dockers-ci-container-image.yml b/.github/workflows/dockers-ci-container-image.yml deleted file mode 100644 index 2e0b034768..0000000000 --- a/.github/workflows/dockers-ci-container-image.yml +++ /dev/null @@ -1,54 +0,0 @@ -# -# Copyright (C) 2019-2024 vdaas.org vald team -# -# 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 -# -# https://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 docker image: ci-container" -on: - push: - branches: - - "main" - - "release/v*.*" - - "!release/v*.*.*" - tags: - - "*.*.*" - - "v*.*.*" - - "*.*.*-*" - - "v*.*.*-*" - pull_request: - paths: - - ".github/actions/docker-build/action.yaml" - - ".github/workflows/_docker-image.yaml" - - ".github/workflows/dockers-ci-container-image.yml" - - "dockers/ci/**" - - "Makefile" - - "Makefile.d/**" - - "versions/GO_VERSION" - - "versions/NGT_VERSION" - pull_request_target: - paths: - - ".github/actions/docker-build/action.yaml" - - ".github/workflows/_docker-image.yaml" - - ".github/workflows/dockers-ci-container-image.yml" - - "dockers/ci/**" - - "Makefile" - - "Makefile.d/**" - - "versions/GO_VERSION" - - "versions/NGT_VERSION" -jobs: - build: - uses: ./.github/workflows/_docker-image.yaml - with: - target: ci-container - platforms: linux/amd64 - secrets: inherit diff --git a/.github/workflows/dockers-dev-container-image.yaml b/.github/workflows/dockers-dev-container-image.yaml new file mode 100755 index 0000000000..ee83a872c4 --- /dev/null +++ b/.github/workflows/dockers-dev-container-image.yaml @@ -0,0 +1,64 @@ +# +# Copyright (C) 2019-2024 vdaas.org vald team +# +# 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 +# +# https://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. +# +# DO_NOT_EDIT this workflow file is generated by https://github.com/vdaas/vald/blob/main/hack/actions/gen/main.go +name: 'Build docker image: dev-container' +on: + push: + branches: + - main + - release/v*.* + - '!release/v*.*.*' + tags: + - '*.*.*' + - v*.*.* + - '*.*.*-*' + - v*.*.*-* + pull_request: + paths: + - hack/docker/gen/main.go + - dockers/dev/Dockerfile + - hack/actions/gen/main.go + - .github/workflows/dockers-dev-container-image.yaml + - .github/actions/docker-build/action.yaml + - .github/workflows/_docker-image.yaml + - cmd/dev/** + - pkg/dev/** + - apis/grpc/** + - apis/proto/** + - hack/** + - Makefile + - Makefile.d/** + pull_request_target: + paths: + - hack/docker/gen/main.go + - dockers/dev/Dockerfile + - hack/actions/gen/main.go + - .github/workflows/dockers-dev-container-image.yaml + - .github/actions/docker-build/action.yaml + - .github/workflows/_docker-image.yaml + - cmd/dev/** + - pkg/dev/** + - apis/grpc/** + - apis/proto/** + - hack/** + - Makefile + - Makefile.d/** +jobs: + build: + uses: ./.github/workflows/_docker-image.yaml + with: + target: dev-container + secrets: inherit diff --git a/.github/workflows/dockers-dev-container-image.yml b/.github/workflows/dockers-dev-container-image.yml deleted file mode 100644 index f9eae6c6ae..0000000000 --- a/.github/workflows/dockers-dev-container-image.yml +++ /dev/null @@ -1,49 +0,0 @@ -# -# Copyright (C) 2019-2024 vdaas.org vald team -# -# 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 -# -# https://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 docker image: dev-container" -on: - push: - branches: - - "main" - - "release/v*.*" - - "!release/v*.*.*" - pull_request: - paths: - - ".github/actions/docker-build/action.yaml" - - ".github/workflows/_docker-image.yaml" - - ".github/workflows/dockers-dev-container-image.yml" - - "dockers/dev/**" - - "Makefile" - - "Makefile.d/**" - - "versions/GO_VERSION" - - "versions/NGT_VERSION" - pull_request_target: - paths: - - ".github/actions/docker-build/action.yaml" - - ".github/workflows/_docker-image.yaml" - - ".github/workflows/dockers-dev-container-image.yml" - - "dockers/dev/**" - - "Makefile" - - "Makefile.d/**" - - "versions/GO_VERSION" - - "versions/NGT_VERSION" -jobs: - build: - uses: ./.github/workflows/_docker-image.yaml - with: - target: dev-container - platforms: linux/amd64 - secrets: inherit diff --git a/.github/workflows/dockers-discoverer-k8s-image.yaml b/.github/workflows/dockers-discoverer-k8s-image.yaml new file mode 100755 index 0000000000..e0fea36ae9 --- /dev/null +++ b/.github/workflows/dockers-discoverer-k8s-image.yaml @@ -0,0 +1,76 @@ +# +# Copyright (C) 2019-2024 vdaas.org vald team +# +# 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 +# +# https://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. +# +# DO_NOT_EDIT this workflow file is generated by https://github.com/vdaas/vald/blob/main/hack/actions/gen/main.go +name: 'Build docker image: discoverer-k8s' +on: + push: + branches: + - main + - release/v*.* + - '!release/v*.*.*' + tags: + - '*.*.*' + - v*.*.* + - '*.*.*-*' + - v*.*.*-* + pull_request: + paths: + - hack/docker/gen/main.go + - dockers/discoverer/k8s/Dockerfile + - hack/actions/gen/main.go + - .github/workflows/dockers-discoverer-k8s-image.yaml + - .github/actions/docker-build/action.yaml + - .github/workflows/_docker-image.yaml + - cmd/discoverer/k8s/** + - pkg/discoverer/k8s/** + - apis/grpc/** + - apis/proto/** + - go.mod + - go.sum + - versions/GO_VERSION + - internal/** + - '!internal/**/*_test.go' + - '!internal/**/*_mock.go' + - '!internal/db/**' + - Makefile + - Makefile.d/** + pull_request_target: + paths: + - hack/docker/gen/main.go + - dockers/discoverer/k8s/Dockerfile + - hack/actions/gen/main.go + - .github/workflows/dockers-discoverer-k8s-image.yaml + - .github/actions/docker-build/action.yaml + - .github/workflows/_docker-image.yaml + - cmd/discoverer/k8s/** + - pkg/discoverer/k8s/** + - apis/grpc/** + - apis/proto/** + - go.mod + - go.sum + - versions/GO_VERSION + - internal/** + - '!internal/**/*_test.go' + - '!internal/**/*_mock.go' + - '!internal/db/**' + - Makefile + - Makefile.d/** +jobs: + build: + uses: ./.github/workflows/_docker-image.yaml + with: + target: discoverer-k8s + secrets: inherit diff --git a/.github/workflows/dockers-discoverer-k8s-image.yml b/.github/workflows/dockers-discoverer-k8s-image.yml deleted file mode 100644 index 6612d9cf2d..0000000000 --- a/.github/workflows/dockers-discoverer-k8s-image.yml +++ /dev/null @@ -1,63 +0,0 @@ -# -# Copyright (C) 2019-2024 vdaas.org vald team -# -# 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 -# -# https://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 docker image: discoverer-k8s" -on: - push: - branches: - - "main" - - "release/v*.*" - - "!release/v*.*.*" - tags: - - "*.*.*" - - "v*.*.*" - - "*.*.*-*" - - "v*.*.*-*" - pull_request: - paths: - - ".github/actions/docker-build/action.yaml" - - ".github/workflows/_docker-image.yaml" - - ".github/workflows/dockers-discoverer-k8s-image.yml" - - "go.mod" - - "go.sum" - - "internal/**" - - "!internal/**/*_test.go" - - "!internal/db/**" - - "apis/grpc/**" - - "pkg/discoverer/k8s/**" - - "cmd/discoverer/k8s/**" - - "dockers/discoverer/k8s/Dockerfile" - - "versions/GO_VERSION" - pull_request_target: - paths: - - ".github/actions/docker-build/action.yaml" - - ".github/workflows/_docker-image.yaml" - - ".github/workflows/dockers-discoverer-k8s-image.yml" - - "go.mod" - - "go.sum" - - "internal/**" - - "!internal/**/*_test.go" - - "!internal/db/**" - - "apis/grpc/**" - - "pkg/discoverer/k8s/**" - - "cmd/discoverer/k8s/**" - - "dockers/discoverer/k8s/Dockerfile" - - "versions/GO_VERSION" -jobs: - build: - uses: ./.github/workflows/_docker-image.yaml - with: - target: discoverer-k8s - secrets: inherit diff --git a/.github/workflows/dockers-gateway-filter-image.yaml b/.github/workflows/dockers-gateway-filter-image.yaml new file mode 100755 index 0000000000..185821dfd2 --- /dev/null +++ b/.github/workflows/dockers-gateway-filter-image.yaml @@ -0,0 +1,80 @@ +# +# Copyright (C) 2019-2024 vdaas.org vald team +# +# 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 +# +# https://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. +# +# DO_NOT_EDIT this workflow file is generated by https://github.com/vdaas/vald/blob/main/hack/actions/gen/main.go +name: 'Build docker image: gateway-filter' +on: + push: + branches: + - main + - release/v*.* + - '!release/v*.*.*' + tags: + - '*.*.*' + - v*.*.* + - '*.*.*-*' + - v*.*.*-* + pull_request: + paths: + - hack/docker/gen/main.go + - dockers/gateway/filter/Dockerfile + - hack/actions/gen/main.go + - .github/workflows/dockers-gateway-filter-image.yaml + - .github/actions/docker-build/action.yaml + - .github/workflows/_docker-image.yaml + - cmd/gateway/filter/** + - pkg/gateway/filter/** + - pkg/gateway/internal/** + - apis/grpc/** + - apis/proto/** + - go.mod + - go.sum + - versions/GO_VERSION + - internal/** + - '!internal/**/*_test.go' + - '!internal/**/*_mock.go' + - '!internal/db/**' + - '!internal/k8s/**' + - Makefile + - Makefile.d/** + pull_request_target: + paths: + - hack/docker/gen/main.go + - dockers/gateway/filter/Dockerfile + - hack/actions/gen/main.go + - .github/workflows/dockers-gateway-filter-image.yaml + - .github/actions/docker-build/action.yaml + - .github/workflows/_docker-image.yaml + - cmd/gateway/filter/** + - pkg/gateway/filter/** + - pkg/gateway/internal/** + - apis/grpc/** + - apis/proto/** + - go.mod + - go.sum + - versions/GO_VERSION + - internal/** + - '!internal/**/*_test.go' + - '!internal/**/*_mock.go' + - '!internal/db/**' + - '!internal/k8s/**' + - Makefile + - Makefile.d/** +jobs: + build: + uses: ./.github/workflows/_docker-image.yaml + with: + target: gateway-filter + secrets: inherit diff --git a/.github/workflows/dockers-gateway-filter-image.yml b/.github/workflows/dockers-gateway-filter-image.yml deleted file mode 100644 index 94d9754912..0000000000 --- a/.github/workflows/dockers-gateway-filter-image.yml +++ /dev/null @@ -1,69 +0,0 @@ -# -# Copyright (C) 2019-2024 vdaas.org vald team -# -# 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 -# -# https://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 docker image: gateway-filter" -on: - push: - branches: - - "main" - - "release/v*.*" - - "!release/v*.*.*" - tags: - - "*.*.*" - - "v*.*.*" - - "*.*.*-*" - - "v*.*.*-*" - pull_request: - paths: - - ".github/actions/docker-build/action.yaml" - - ".github/workflows/_docker-image.yaml" - - ".github/workflows/dockers-gateway-filter-image.yml" - - "go.mod" - - "go.sum" - - "internal/**" - - "!internal/**/*_test.go" - - "!internal/**/*_mock.go" - - "!internal/db/**" - - "!internal/k8s/**" - - "apis/grpc/**" - - "pkg/gateway/filter/**" - - "cmd/gateway/filter/**" - - "pkg/gateway/internal/**" - - "dockers/gateway/filter/Dockerfile" - - "versions/GO_VERSION" - pull_request_target: - paths: - - ".github/actions/docker-build/action.yaml" - - ".github/workflows/_docker-image.yaml" - - ".github/workflows/dockers-gateway-filter-image.yml" - - "go.mod" - - "go.sum" - - "internal/**" - - "!internal/**/*_test.go" - - "!internal/**/*_mock.go" - - "!internal/db/**" - - "!internal/k8s/**" - - "apis/grpc/**" - - "pkg/gateway/filter/**" - - "cmd/gateway/filter/**" - - "pkg/gateway/internal/**" - - "dockers/gateway/filter/Dockerfile" - - "versions/GO_VERSION" -jobs: - build: - uses: ./.github/workflows/_docker-image.yaml - with: - target: gateway-filter - secrets: inherit diff --git a/.github/workflows/dockers-gateway-lb-image.yaml b/.github/workflows/dockers-gateway-lb-image.yaml new file mode 100755 index 0000000000..ffbe94fd42 --- /dev/null +++ b/.github/workflows/dockers-gateway-lb-image.yaml @@ -0,0 +1,80 @@ +# +# Copyright (C) 2019-2024 vdaas.org vald team +# +# 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 +# +# https://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. +# +# DO_NOT_EDIT this workflow file is generated by https://github.com/vdaas/vald/blob/main/hack/actions/gen/main.go +name: 'Build docker image: gateway-lb' +on: + push: + branches: + - main + - release/v*.* + - '!release/v*.*.*' + tags: + - '*.*.*' + - v*.*.* + - '*.*.*-*' + - v*.*.*-* + pull_request: + paths: + - hack/docker/gen/main.go + - dockers/gateway/lb/Dockerfile + - hack/actions/gen/main.go + - .github/workflows/dockers-gateway-lb-image.yaml + - .github/actions/docker-build/action.yaml + - .github/workflows/_docker-image.yaml + - cmd/gateway/lb/** + - pkg/gateway/lb/** + - pkg/gateway/internal/** + - apis/grpc/** + - apis/proto/** + - go.mod + - go.sum + - versions/GO_VERSION + - internal/** + - '!internal/**/*_test.go' + - '!internal/**/*_mock.go' + - '!internal/db/**' + - '!internal/k8s/**' + - Makefile + - Makefile.d/** + pull_request_target: + paths: + - hack/docker/gen/main.go + - dockers/gateway/lb/Dockerfile + - hack/actions/gen/main.go + - .github/workflows/dockers-gateway-lb-image.yaml + - .github/actions/docker-build/action.yaml + - .github/workflows/_docker-image.yaml + - cmd/gateway/lb/** + - pkg/gateway/lb/** + - pkg/gateway/internal/** + - apis/grpc/** + - apis/proto/** + - go.mod + - go.sum + - versions/GO_VERSION + - internal/** + - '!internal/**/*_test.go' + - '!internal/**/*_mock.go' + - '!internal/db/**' + - '!internal/k8s/**' + - Makefile + - Makefile.d/** +jobs: + build: + uses: ./.github/workflows/_docker-image.yaml + with: + target: gateway-lb + secrets: inherit diff --git a/.github/workflows/dockers-gateway-lb-image.yml b/.github/workflows/dockers-gateway-lb-image.yml deleted file mode 100644 index a438eb29bf..0000000000 --- a/.github/workflows/dockers-gateway-lb-image.yml +++ /dev/null @@ -1,69 +0,0 @@ -# -# Copyright (C) 2019-2024 vdaas.org vald team -# -# 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 -# -# https://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 docker image: gateway-lb" -on: - push: - branches: - - "main" - - "release/v*.*" - - "!release/v*.*.*" - tags: - - "*.*.*" - - "v*.*.*" - - "*.*.*-*" - - "v*.*.*-*" - pull_request: - paths: - - ".github/actions/docker-build/action.yaml" - - ".github/workflows/_docker-image.yaml" - - ".github/workflows/dockers-gateway-lb-image.yml" - - "go.mod" - - "go.sum" - - "internal/**" - - "!internal/**/*_test.go" - - "!internal/**/*_mock.go" - - "!internal/db/**" - - "!internal/k8s/**" - - "apis/grpc/**" - - "pkg/gateway/lb/**" - - "cmd/gateway/lb/**" - - "pkg/gateway/internal/**" - - "dockers/gateway/lb/Dockerfile" - - "versions/GO_VERSION" - pull_request_target: - paths: - - ".github/actions/docker-build/action.yaml" - - ".github/workflows/_docker-image.yaml" - - ".github/workflows/dockers-gateway-lb-image.yml" - - "go.mod" - - "go.sum" - - "internal/**" - - "!internal/**/*_test.go" - - "!internal/**/*_mock.go" - - "!internal/db/**" - - "!internal/k8s/**" - - "apis/grpc/**" - - "pkg/gateway/lb/**" - - "cmd/gateway/lb/**" - - "pkg/gateway/internal/**" - - "dockers/gateway/lb/Dockerfile" - - "versions/GO_VERSION" -jobs: - build: - uses: ./.github/workflows/_docker-image.yaml - with: - target: gateway-lb - secrets: inherit diff --git a/.github/workflows/dockers-gateway-mirror-image.yaml b/.github/workflows/dockers-gateway-mirror-image.yaml old mode 100644 new mode 100755 index aeddaa45f0..29e2f55f35 --- a/.github/workflows/dockers-gateway-mirror-image.yaml +++ b/.github/workflows/dockers-gateway-mirror-image.yaml @@ -13,50 +13,63 @@ # See the License for the specific language governing permissions and # limitations under the License. # -name: "Build docker image: gateway-mirror" +# DO_NOT_EDIT this workflow file is generated by https://github.com/vdaas/vald/blob/main/hack/actions/gen/main.go +name: 'Build docker image: gateway-mirror' on: push: branches: - - main + - main + - release/v*.* + - '!release/v*.*.*' tags: - - "*.*.*" - - "v*.*.*" - - "*.*.*-*" - - "v*.*.*-*" + - '*.*.*' + - v*.*.* + - '*.*.*-*' + - v*.*.*-* pull_request: paths: - - ".github/actions/docker-build/action.yaml" - - ".github/workflows/dockers-gateway-mirror-image.yml" - - "go.mod" - - "go.sum" - - "internal/**" - - "!internal/**/*_test.go" - - "!internal/**/*_mock.go" - - "!internal/db/**" - - "!internal/k8s/**" - - "apis/grpc/**" - - "pkg/gateway/mirror/**" - - "cmd/gateway/mirror/**" - - "pkg/gateway/internal/**" - - "dockers/gateway/mirror/Dockerfile" - - "versions/GO_VERSION" + - hack/docker/gen/main.go + - dockers/gateway/mirror/Dockerfile + - hack/actions/gen/main.go + - .github/workflows/dockers-gateway-mirror-image.yaml + - .github/actions/docker-build/action.yaml + - .github/workflows/_docker-image.yaml + - cmd/gateway/mirror/** + - pkg/gateway/mirror/** + - pkg/gateway/internal/** + - apis/grpc/** + - apis/proto/** + - go.mod + - go.sum + - versions/GO_VERSION + - internal/** + - '!internal/**/*_test.go' + - '!internal/**/*_mock.go' + - '!internal/db/**' + - Makefile + - Makefile.d/** pull_request_target: paths: - - ".github/actions/docker-build/action.yaml" - - ".github/workflows/dockers-gateway-mirror-image.yml" - - "go.mod" - - "go.sum" - - "internal/**" - - "!internal/**/*_test.go" - - "!internal/**/*_mock.go" - - "!internal/db/**" - - "!internal/k8s/**" - - "apis/grpc/**" - - "pkg/gateway/mirror/**" - - "cmd/gateway/nirror/**" - - "pkg/gateway/internal/**" - - "dockers/gateway/mirror/Dockerfile" - - "versions/GO_VERSION" + - hack/docker/gen/main.go + - dockers/gateway/mirror/Dockerfile + - hack/actions/gen/main.go + - .github/workflows/dockers-gateway-mirror-image.yaml + - .github/actions/docker-build/action.yaml + - .github/workflows/_docker-image.yaml + - cmd/gateway/mirror/** + - pkg/gateway/mirror/** + - pkg/gateway/internal/** + - apis/grpc/** + - apis/proto/** + - go.mod + - go.sum + - versions/GO_VERSION + - internal/** + - '!internal/**/*_test.go' + - '!internal/**/*_mock.go' + - '!internal/db/**' + - Makefile + - Makefile.d/** jobs: build: uses: ./.github/workflows/_docker-image.yaml diff --git a/.github/workflows/dockers-helm-operator-image.yaml b/.github/workflows/dockers-helm-operator-image.yaml new file mode 100755 index 0000000000..ec1e04537a --- /dev/null +++ b/.github/workflows/dockers-helm-operator-image.yaml @@ -0,0 +1,72 @@ +# +# Copyright (C) 2019-2024 vdaas.org vald team +# +# 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 +# +# https://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. +# +# DO_NOT_EDIT this workflow file is generated by https://github.com/vdaas/vald/blob/main/hack/actions/gen/main.go +name: 'Build docker image: helm-operator' +on: + push: + branches: + - main + - release/v*.* + - '!release/v*.*.*' + tags: + - '*.*.*' + - v*.*.* + - '*.*.*-*' + - v*.*.*-* + pull_request: + paths: + - hack/docker/gen/main.go + - dockers/operator/helm/Dockerfile + - hack/actions/gen/main.go + - .github/workflows/dockers-helm-operator-image.yaml + - .github/actions/docker-build/action.yaml + - .github/workflows/_docker-image.yaml + - cmd/operator/helm/** + - pkg/operator/helm/** + - charts/vald/Chart.yaml + - charts/vald/values.yaml + - charts/vald/templates/** + - charts/vald-helm-operator/Chart.yaml + - charts/vald-helm-operator/values.yaml + - charts/vald-helm-operator/templates/** + - versions/OPERATOR_SDK_VERSION + - Makefile + - Makefile.d/** + pull_request_target: + paths: + - hack/docker/gen/main.go + - dockers/operator/helm/Dockerfile + - hack/actions/gen/main.go + - .github/workflows/dockers-helm-operator-image.yaml + - .github/actions/docker-build/action.yaml + - .github/workflows/_docker-image.yaml + - cmd/operator/helm/** + - pkg/operator/helm/** + - charts/vald/Chart.yaml + - charts/vald/values.yaml + - charts/vald/templates/** + - charts/vald-helm-operator/Chart.yaml + - charts/vald-helm-operator/values.yaml + - charts/vald-helm-operator/templates/** + - versions/OPERATOR_SDK_VERSION + - Makefile + - Makefile.d/** +jobs: + build: + uses: ./.github/workflows/_docker-image.yaml + with: + target: helm-operator + secrets: inherit diff --git a/.github/workflows/dockers-helm-operator-image.yml b/.github/workflows/dockers-helm-operator-image.yml deleted file mode 100644 index 3b36c307f7..0000000000 --- a/.github/workflows/dockers-helm-operator-image.yml +++ /dev/null @@ -1,59 +0,0 @@ -# -# Copyright (C) 2019-2024 vdaas.org vald team -# -# 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 -# -# https://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 docker image: helm-operator" -on: - push: - branches: - - "main" - - "release/v*.*" - - "!release/v*.*.*" - tags: - - "*.*.*" - - "v*.*.*" - - "*.*.*-*" - - "v*.*.*-*" - pull_request: - paths: - - ".github/actions/docker-build/action.yaml" - - ".github/workflows/_docker-image.yaml" - - ".github/workflows/dockers-helm-operator-image.yml" - - "dockers/operator/helm/Dockerfile" - - "charts/vald/Chart.yaml" - - "charts/vald/values.yaml" - - "charts/vald/templates/**" - - "charts/vald-helm-operator/Chart.yaml" - - "charts/vald-helm-operator/values.yaml" - - "charts/vald-helm-operator/templates/**" - - "versions/OPERATOR_SDK_VERSION" - pull_request_target: - paths: - - ".github/actions/docker-build/action.yaml" - - ".github/workflows/_docker-image.yaml" - - ".github/workflows/dockers-helm-operator-image.yml" - - "dockers/operator/helm/Dockerfile" - - "charts/vald/Chart.yaml" - - "charts/vald/values.yaml" - - "charts/vald/templates/**" - - "charts/vald-helm-operator/Chart.yaml" - - "charts/vald-helm-operator/values.yaml" - - "charts/vald-helm-operator/templates/**" - - "versions/OPERATOR_SDK_VERSION" -jobs: - build: - uses: ./.github/workflows/_docker-image.yaml - with: - target: operator/helm - secrets: inherit diff --git a/.github/workflows/dockers-index-correction-image.yaml b/.github/workflows/dockers-index-correction-image.yaml new file mode 100755 index 0000000000..ed4060a8c6 --- /dev/null +++ b/.github/workflows/dockers-index-correction-image.yaml @@ -0,0 +1,78 @@ +# +# Copyright (C) 2019-2024 vdaas.org vald team +# +# 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 +# +# https://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. +# +# DO_NOT_EDIT this workflow file is generated by https://github.com/vdaas/vald/blob/main/hack/actions/gen/main.go +name: 'Build docker image: index-correction' +on: + push: + branches: + - main + - release/v*.* + - '!release/v*.*.*' + tags: + - '*.*.*' + - v*.*.* + - '*.*.*-*' + - v*.*.*-* + pull_request: + paths: + - hack/docker/gen/main.go + - dockers/index/job/correction/Dockerfile + - hack/actions/gen/main.go + - .github/workflows/dockers-index-correction-image.yaml + - .github/actions/docker-build/action.yaml + - .github/workflows/_docker-image.yaml + - cmd/index/job/correction/** + - pkg/index/job/correction/** + - apis/grpc/** + - apis/proto/** + - go.mod + - go.sum + - versions/GO_VERSION + - internal/** + - '!internal/**/*_test.go' + - '!internal/**/*_mock.go' + - '!internal/db/**' + - '!internal/k8s/**' + - Makefile + - Makefile.d/** + pull_request_target: + paths: + - hack/docker/gen/main.go + - dockers/index/job/correction/Dockerfile + - hack/actions/gen/main.go + - .github/workflows/dockers-index-correction-image.yaml + - .github/actions/docker-build/action.yaml + - .github/workflows/_docker-image.yaml + - cmd/index/job/correction/** + - pkg/index/job/correction/** + - apis/grpc/** + - apis/proto/** + - go.mod + - go.sum + - versions/GO_VERSION + - internal/** + - '!internal/**/*_test.go' + - '!internal/**/*_mock.go' + - '!internal/db/**' + - '!internal/k8s/**' + - Makefile + - Makefile.d/** +jobs: + build: + uses: ./.github/workflows/_docker-image.yaml + with: + target: index-correction + secrets: inherit diff --git a/.github/workflows/dockers-index-correction.yml b/.github/workflows/dockers-index-correction.yml deleted file mode 100644 index c1bb1b8a29..0000000000 --- a/.github/workflows/dockers-index-correction.yml +++ /dev/null @@ -1,63 +0,0 @@ -# -# Copyright (C) 2019-2024 vdaas.org vald team -# -# 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 -# -# https://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 docker image: index-correction" -on: - push: - branches: - - main - tags: - - "*.*.*" - - "v*.*.*" - - "*.*.*-*" - - "v*.*.*-*" - pull_request: - paths: - - ".github/actions/docker-build/action.yaml" - - ".github/workflows/_docker-image.yaml" - - ".github/workflows/dockers-index-correction.yml" - - "go.mod" - - "go.sum" - - "internal/**" - - "!internal/**/*_test.go" - - "!internal/db/**" - - "!internal/k8s/**" - - "apis/grpc/**" - - "pkg/index/job/correction/**" - - "cmd/index/job/correction/**" - - "dockers/index/job/correction/Dockerfile" - - "versions/GO_VERSION" - pull_request_target: - paths: - - ".github/actions/docker-build/action.yaml" - - ".github/workflows/_docker-image.yaml" - - ".github/workflows/dockers-index-correction.yml" - - "go.mod" - - "go.sum" - - "internal/**" - - "!internal/**/*_test.go" - - "!internal/db/**" - - "!internal/k8s/**" - - "apis/grpc/**" - - "pkg/index/job/correction/**" - - "cmd/index/job/correction/**" - - "dockers/index/job/correction/Dockerfile" - - "versions/GO_VERSION" -jobs: - build: - uses: ./.github/workflows/_docker-image.yaml - with: - target: index-correction - secrets: inherit diff --git a/.github/workflows/dockers-index-creation-image.yaml b/.github/workflows/dockers-index-creation-image.yaml new file mode 100755 index 0000000000..1d17b7d10f --- /dev/null +++ b/.github/workflows/dockers-index-creation-image.yaml @@ -0,0 +1,78 @@ +# +# Copyright (C) 2019-2024 vdaas.org vald team +# +# 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 +# +# https://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. +# +# DO_NOT_EDIT this workflow file is generated by https://github.com/vdaas/vald/blob/main/hack/actions/gen/main.go +name: 'Build docker image: index-creation' +on: + push: + branches: + - main + - release/v*.* + - '!release/v*.*.*' + tags: + - '*.*.*' + - v*.*.* + - '*.*.*-*' + - v*.*.*-* + pull_request: + paths: + - hack/docker/gen/main.go + - dockers/index/job/creation/Dockerfile + - hack/actions/gen/main.go + - .github/workflows/dockers-index-creation-image.yaml + - .github/actions/docker-build/action.yaml + - .github/workflows/_docker-image.yaml + - cmd/index/job/creation/** + - pkg/index/job/creation/** + - apis/grpc/** + - apis/proto/** + - go.mod + - go.sum + - versions/GO_VERSION + - internal/** + - '!internal/**/*_test.go' + - '!internal/**/*_mock.go' + - '!internal/db/**' + - '!internal/k8s/**' + - Makefile + - Makefile.d/** + pull_request_target: + paths: + - hack/docker/gen/main.go + - dockers/index/job/creation/Dockerfile + - hack/actions/gen/main.go + - .github/workflows/dockers-index-creation-image.yaml + - .github/actions/docker-build/action.yaml + - .github/workflows/_docker-image.yaml + - cmd/index/job/creation/** + - pkg/index/job/creation/** + - apis/grpc/** + - apis/proto/** + - go.mod + - go.sum + - versions/GO_VERSION + - internal/** + - '!internal/**/*_test.go' + - '!internal/**/*_mock.go' + - '!internal/db/**' + - '!internal/k8s/**' + - Makefile + - Makefile.d/** +jobs: + build: + uses: ./.github/workflows/_docker-image.yaml + with: + target: index-creation + secrets: inherit diff --git a/.github/workflows/dockers-index-creation.yml b/.github/workflows/dockers-index-creation.yml deleted file mode 100644 index 531e16aedf..0000000000 --- a/.github/workflows/dockers-index-creation.yml +++ /dev/null @@ -1,63 +0,0 @@ -# -# Copyright (C) 2019-2024 vdaas.org vald team -# -# 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 -# -# https://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 docker image: index-creation" -on: - push: - branches: - - main - tags: - - "*.*.*" - - "v*.*.*" - - "*.*.*-*" - - "v*.*.*-*" - pull_request: - paths: - - ".github/actions/docker-build/action.yaml" - - ".github/workflows/_docker-image.yaml" - - ".github/workflows/dockers-index-creation.yml" - - "go.mod" - - "go.sum" - - "internal/**" - - "!internal/**/*_test.go" - - "!internal/db/**" - - "!internal/k8s/**" - - "apis/grpc/**" - - "pkg/index/job/creation/**" - - "cmd/index/job/creation/**" - - "dockers/index/job/creation/Dockerfile" - - "versions/GO_VERSION" - pull_request_target: - paths: - - ".github/actions/docker-build/action.yaml" - - ".github/workflows/_docker-image.yaml" - - ".github/workflows/dockers-index-creation.yml" - - "go.mod" - - "go.sum" - - "internal/**" - - "!internal/**/*_test.go" - - "!internal/db/**" - - "!internal/k8s/**" - - "apis/grpc/**" - - "pkg/index/job/creation/**" - - "cmd/index/job/creation/**" - - "dockers/index/job/creation/Dockerfile" - - "versions/GO_VERSION" -jobs: - build: - uses: ./.github/workflows/_docker-image.yaml - with: - target: index-creation - secrets: inherit diff --git a/.github/workflows/dockers-index-operator-image.yaml b/.github/workflows/dockers-index-operator-image.yaml new file mode 100755 index 0000000000..f83b0f6c86 --- /dev/null +++ b/.github/workflows/dockers-index-operator-image.yaml @@ -0,0 +1,76 @@ +# +# Copyright (C) 2019-2024 vdaas.org vald team +# +# 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 +# +# https://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. +# +# DO_NOT_EDIT this workflow file is generated by https://github.com/vdaas/vald/blob/main/hack/actions/gen/main.go +name: 'Build docker image: index-operator' +on: + push: + branches: + - main + - release/v*.* + - '!release/v*.*.*' + tags: + - '*.*.*' + - v*.*.* + - '*.*.*-*' + - v*.*.*-* + pull_request: + paths: + - hack/docker/gen/main.go + - dockers/index/operator/Dockerfile + - hack/actions/gen/main.go + - .github/workflows/dockers-index-operator-image.yaml + - .github/actions/docker-build/action.yaml + - .github/workflows/_docker-image.yaml + - cmd/index/operator/** + - pkg/index/operator/** + - apis/grpc/** + - apis/proto/** + - go.mod + - go.sum + - versions/GO_VERSION + - internal/** + - '!internal/**/*_test.go' + - '!internal/**/*_mock.go' + - '!internal/db/**' + - Makefile + - Makefile.d/** + pull_request_target: + paths: + - hack/docker/gen/main.go + - dockers/index/operator/Dockerfile + - hack/actions/gen/main.go + - .github/workflows/dockers-index-operator-image.yaml + - .github/actions/docker-build/action.yaml + - .github/workflows/_docker-image.yaml + - cmd/index/operator/** + - pkg/index/operator/** + - apis/grpc/** + - apis/proto/** + - go.mod + - go.sum + - versions/GO_VERSION + - internal/** + - '!internal/**/*_test.go' + - '!internal/**/*_mock.go' + - '!internal/db/**' + - Makefile + - Makefile.d/** +jobs: + build: + uses: ./.github/workflows/_docker-image.yaml + with: + target: index-operator + secrets: inherit diff --git a/.github/workflows/dockers-index-operator.yml b/.github/workflows/dockers-index-operator.yml deleted file mode 100644 index fcc748d63e..0000000000 --- a/.github/workflows/dockers-index-operator.yml +++ /dev/null @@ -1,63 +0,0 @@ -# -# Copyright (C) 2019-2024 vdaas.org vald team -# -# 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 -# -# https://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 docker image: index-operator" -on: - push: - branches: - - main - tags: - - "*.*.*" - - "v*.*.*" - - "*.*.*-*" - - "v*.*.*-*" - pull_request: - paths: - - ".github/actions/docker-build/action.yaml" - - ".github/workflows/_docker-image.yaml" - - ".github/workflows/dockers-index-operator.yml" - - "go.mod" - - "go.sum" - - "internal/**" - - "!internal/**/*_test.go" - - "!internal/db/**" - - "internal/k8s/**" - - "apis/grpc/**" - - "pkg/index/operator/**" - - "cmd/index/operator/**" - - "dockers/index/operator/Dockerfile" - - "versions/GO_VERSION" - pull_request_target: - paths: - - ".github/actions/docker-build/action.yaml" - - ".github/workflows/_docker-image.yaml" - - ".github/workflows/dockers-index-operator.yml" - - "go.mod" - - "go.sum" - - "internal/**" - - "!internal/**/*_test.go" - - "!internal/db/**" - - "internal/k8s/**" - - "apis/grpc/**" - - "pkg/index/operator/**" - - "cmd/index/operator/**" - - "dockers/index/operator/Dockerfile" - - "versions/GO_VERSION" -jobs: - build: - uses: ./.github/workflows/_docker-image.yaml - with: - target: index-operator - secrets: inherit diff --git a/.github/workflows/dockers-index-save-image.yaml b/.github/workflows/dockers-index-save-image.yaml new file mode 100755 index 0000000000..568fbcb0b6 --- /dev/null +++ b/.github/workflows/dockers-index-save-image.yaml @@ -0,0 +1,78 @@ +# +# Copyright (C) 2019-2024 vdaas.org vald team +# +# 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 +# +# https://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. +# +# DO_NOT_EDIT this workflow file is generated by https://github.com/vdaas/vald/blob/main/hack/actions/gen/main.go +name: 'Build docker image: index-save' +on: + push: + branches: + - main + - release/v*.* + - '!release/v*.*.*' + tags: + - '*.*.*' + - v*.*.* + - '*.*.*-*' + - v*.*.*-* + pull_request: + paths: + - hack/docker/gen/main.go + - dockers/index/job/save/Dockerfile + - hack/actions/gen/main.go + - .github/workflows/dockers-index-save-image.yaml + - .github/actions/docker-build/action.yaml + - .github/workflows/_docker-image.yaml + - cmd/index/job/save/** + - pkg/index/job/save/** + - apis/grpc/** + - apis/proto/** + - go.mod + - go.sum + - versions/GO_VERSION + - internal/** + - '!internal/**/*_test.go' + - '!internal/**/*_mock.go' + - '!internal/db/**' + - '!internal/k8s/**' + - Makefile + - Makefile.d/** + pull_request_target: + paths: + - hack/docker/gen/main.go + - dockers/index/job/save/Dockerfile + - hack/actions/gen/main.go + - .github/workflows/dockers-index-save-image.yaml + - .github/actions/docker-build/action.yaml + - .github/workflows/_docker-image.yaml + - cmd/index/job/save/** + - pkg/index/job/save/** + - apis/grpc/** + - apis/proto/** + - go.mod + - go.sum + - versions/GO_VERSION + - internal/** + - '!internal/**/*_test.go' + - '!internal/**/*_mock.go' + - '!internal/db/**' + - '!internal/k8s/**' + - Makefile + - Makefile.d/** +jobs: + build: + uses: ./.github/workflows/_docker-image.yaml + with: + target: index-save + secrets: inherit diff --git a/.github/workflows/dockers-index-save.yml b/.github/workflows/dockers-index-save.yml deleted file mode 100644 index 4669b534bf..0000000000 --- a/.github/workflows/dockers-index-save.yml +++ /dev/null @@ -1,63 +0,0 @@ -# -# Copyright (C) 2019-2024 vdaas.org vald team -# -# 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 -# -# https://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 docker image: index-save" -on: - push: - branches: - - main - tags: - - "*.*.*" - - "v*.*.*" - - "*.*.*-*" - - "v*.*.*-*" - pull_request: - paths: - - ".github/actions/docker-build/action.yaml" - - ".github/workflows/_docker-image.yaml" - - ".github/workflows/dockers-index-save.yml" - - "go.mod" - - "go.sum" - - "internal/**" - - "!internal/**/*_test.go" - - "!internal/db/**" - - "!internal/k8s/**" - - "apis/grpc/**" - - "pkg/index/job/save/**" - - "cmd/index/job/save/**" - - "dockers/index/job/save/Dockerfile" - - "versions/GO_VERSION" - pull_request_target: - paths: - - ".github/actions/docker-build/action.yaml" - - ".github/workflows/_docker-image.yaml" - - ".github/workflows/dockers-index-save.yml" - - "go.mod" - - "go.sum" - - "internal/**" - - "!internal/**/*_test.go" - - "!internal/db/**" - - "!internal/k8s/**" - - "apis/grpc/**" - - "pkg/index/job/save/**" - - "cmd/index/job/save/**" - - "dockers/index/job/save/Dockerfile" - - "versions/GO_VERSION" -jobs: - build: - uses: ./.github/workflows/_docker-image.yaml - with: - target: index-save - secrets: inherit diff --git a/.github/workflows/dockers-loadtest-image.yaml b/.github/workflows/dockers-loadtest-image.yaml new file mode 100755 index 0000000000..6e561548bd --- /dev/null +++ b/.github/workflows/dockers-loadtest-image.yaml @@ -0,0 +1,79 @@ +# +# Copyright (C) 2019-2024 vdaas.org vald team +# +# 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 +# +# https://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. +# +# DO_NOT_EDIT this workflow file is generated by https://github.com/vdaas/vald/blob/main/hack/actions/gen/main.go +name: 'Build docker image: loadtest' +on: + push: + branches: + - main + - release/v*.* + - '!release/v*.*.*' + tags: + - '*.*.*' + - v*.*.* + - '*.*.*-*' + - v*.*.*-* + pull_request: + paths: + - hack/docker/gen/main.go + - dockers/tools/cli/loadtest/Dockerfile + - hack/actions/gen/main.go + - .github/workflows/dockers-loadtest-image.yaml + - .github/actions/docker-build/action.yaml + - .github/workflows/_docker-image.yaml + - cmd/tools/cli/loadtest/** + - pkg/tools/cli/loadtest/** + - apis/grpc/** + - apis/proto/** + - go.mod + - go.sum + - versions/GO_VERSION + - internal/** + - '!internal/**/*_test.go' + - '!internal/**/*_mock.go' + - '!internal/db/**' + - '!internal/k8s/**' + - Makefile + - Makefile.d/** + pull_request_target: + paths: + - hack/docker/gen/main.go + - dockers/tools/cli/loadtest/Dockerfile + - hack/actions/gen/main.go + - .github/workflows/dockers-loadtest-image.yaml + - .github/actions/docker-build/action.yaml + - .github/workflows/_docker-image.yaml + - cmd/tools/cli/loadtest/** + - pkg/tools/cli/loadtest/** + - apis/grpc/** + - apis/proto/** + - go.mod + - go.sum + - versions/GO_VERSION + - internal/** + - '!internal/**/*_test.go' + - '!internal/**/*_mock.go' + - '!internal/db/**' + - '!internal/k8s/**' + - Makefile + - Makefile.d/** +jobs: + build: + uses: ./.github/workflows/_docker-image.yaml + with: + target: loadtest + platforms: linux/amd64 + secrets: inherit diff --git a/.github/workflows/dockers-loadtest-image.yml b/.github/workflows/dockers-loadtest-image.yml deleted file mode 100644 index 75e84f4cd2..0000000000 --- a/.github/workflows/dockers-loadtest-image.yml +++ /dev/null @@ -1,66 +0,0 @@ -# -# Copyright (C) 2019-2024 vdaas.org vald team -# -# 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 -# -# https://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 docker image: loadtest" -on: - push: - branches: - - "main" - - "release/v*.*" - - "!release/v*.*.*" - tags: - - "*.*.*" - - "v*.*.*" - - "*.*.*-*" - - "v*.*.*-*" - pull_request: - paths: - - ".github/actions/docker-build/action.yaml" - - ".github/workflows/_docker-image.yaml" - - ".github/workflows/dockers-loadtest-image.yml" - - "go.mod" - - "go.sum" - - "internal/**" - - "!internal/**/*_test.go" - - "!internal/db/**" - - "!internal/k8s/**" - - "apis/grpc/**" - - "pkg/tools/cli/loadtest/**" - - "cmd/tools/cli/loadtest/**" - - "dockers/tools/cli/loadtest/Dockerfile" - - "versions/GO_VERSION" - pull_request_target: - paths: - - ".github/actions/docker-build/action.yaml" - - ".github/workflows/_docker-image.yaml" - - ".github/workflows/dockers-loadtest-image.yml" - - "go.mod" - - "go.sum" - - "internal/**" - - "!internal/**/*_test.go" - - "!internal/db/**" - - "!internal/k8s/**" - - "apis/grpc/**" - - "pkg/tools/cli/loadtest/**" - - "cmd/tools/cli/loadtest/**" - - "dockers/tools/cli/loadtest/Dockerfile" - - "versions/GO_VERSION" -jobs: - build: - uses: ./.github/workflows/_docker-image.yaml - with: - target: loadtest - platforms: linux/amd64 - secrets: inherit diff --git a/.github/workflows/dockers-manager-index-image.yaml b/.github/workflows/dockers-manager-index-image.yaml new file mode 100755 index 0000000000..d7a22972b7 --- /dev/null +++ b/.github/workflows/dockers-manager-index-image.yaml @@ -0,0 +1,78 @@ +# +# Copyright (C) 2019-2024 vdaas.org vald team +# +# 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 +# +# https://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. +# +# DO_NOT_EDIT this workflow file is generated by https://github.com/vdaas/vald/blob/main/hack/actions/gen/main.go +name: 'Build docker image: manager-index' +on: + push: + branches: + - main + - release/v*.* + - '!release/v*.*.*' + tags: + - '*.*.*' + - v*.*.* + - '*.*.*-*' + - v*.*.*-* + pull_request: + paths: + - hack/docker/gen/main.go + - dockers/manager/index/Dockerfile + - hack/actions/gen/main.go + - .github/workflows/dockers-manager-index-image.yaml + - .github/actions/docker-build/action.yaml + - .github/workflows/_docker-image.yaml + - cmd/manager/index/** + - pkg/manager/index/** + - apis/grpc/** + - apis/proto/** + - go.mod + - go.sum + - versions/GO_VERSION + - internal/** + - '!internal/**/*_test.go' + - '!internal/**/*_mock.go' + - '!internal/db/**' + - '!internal/k8s/**' + - Makefile + - Makefile.d/** + pull_request_target: + paths: + - hack/docker/gen/main.go + - dockers/manager/index/Dockerfile + - hack/actions/gen/main.go + - .github/workflows/dockers-manager-index-image.yaml + - .github/actions/docker-build/action.yaml + - .github/workflows/_docker-image.yaml + - cmd/manager/index/** + - pkg/manager/index/** + - apis/grpc/** + - apis/proto/** + - go.mod + - go.sum + - versions/GO_VERSION + - internal/** + - '!internal/**/*_test.go' + - '!internal/**/*_mock.go' + - '!internal/db/**' + - '!internal/k8s/**' + - Makefile + - Makefile.d/** +jobs: + build: + uses: ./.github/workflows/_docker-image.yaml + with: + target: manager-index + secrets: inherit diff --git a/.github/workflows/dockers-manager-index-image.yml b/.github/workflows/dockers-manager-index-image.yml deleted file mode 100644 index 774979664c..0000000000 --- a/.github/workflows/dockers-manager-index-image.yml +++ /dev/null @@ -1,65 +0,0 @@ -# -# Copyright (C) 2019-2024 vdaas.org vald team -# -# 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 -# -# https://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 docker image: manager-index" -on: - push: - branches: - - "main" - - "release/v*.*" - - "!release/v*.*.*" - tags: - - "*.*.*" - - "v*.*.*" - - "*.*.*-*" - - "v*.*.*-*" - pull_request: - paths: - - ".github/actions/docker-build/action.yaml" - - ".github/workflows/_docker-image.yaml" - - ".github/workflows/dockers-manager-index-image.yml" - - "go.mod" - - "go.sum" - - "internal/**" - - "!internal/**/*_test.go" - - "!internal/db/**" - - "!internal/k8s/**" - - "apis/grpc/**" - - "pkg/manager/index/**" - - "cmd/manager/index/**" - - "dockers/manager/index/Dockerfile" - - "versions/GO_VERSION" - pull_request_target: - paths: - - ".github/actions/docker-build/action.yaml" - - ".github/workflows/_docker-image.yaml" - - ".github/workflows/dockers-manager-index-image.yml" - - "go.mod" - - "go.sum" - - "internal/**" - - "!internal/**/*_test.go" - - "!internal/db/**" - - "!internal/k8s/**" - - "apis/grpc/**" - - "pkg/manager/index/**" - - "cmd/manager/index/**" - - "dockers/manager/index/Dockerfile" - - "versions/GO_VERSION" -jobs: - build: - uses: ./.github/workflows/_docker-image.yaml - with: - target: manager-index - secrets: inherit diff --git a/.github/workflows/dockers-readreplica-rotate-image.yaml b/.github/workflows/dockers-readreplica-rotate-image.yaml new file mode 100755 index 0000000000..fd18858755 --- /dev/null +++ b/.github/workflows/dockers-readreplica-rotate-image.yaml @@ -0,0 +1,76 @@ +# +# Copyright (C) 2019-2024 vdaas.org vald team +# +# 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 +# +# https://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. +# +# DO_NOT_EDIT this workflow file is generated by https://github.com/vdaas/vald/blob/main/hack/actions/gen/main.go +name: 'Build docker image: readreplica-rotate' +on: + push: + branches: + - main + - release/v*.* + - '!release/v*.*.*' + tags: + - '*.*.*' + - v*.*.* + - '*.*.*-*' + - v*.*.*-* + pull_request: + paths: + - hack/docker/gen/main.go + - dockers/index/job/readreplica/rotate/Dockerfile + - hack/actions/gen/main.go + - .github/workflows/dockers-readreplica-rotate-image.yaml + - .github/actions/docker-build/action.yaml + - .github/workflows/_docker-image.yaml + - cmd/index/job/readreplica/rotate/** + - pkg/index/job/readreplica/rotate/** + - apis/grpc/** + - apis/proto/** + - go.mod + - go.sum + - versions/GO_VERSION + - internal/** + - '!internal/**/*_test.go' + - '!internal/**/*_mock.go' + - '!internal/db/**' + - Makefile + - Makefile.d/** + pull_request_target: + paths: + - hack/docker/gen/main.go + - dockers/index/job/readreplica/rotate/Dockerfile + - hack/actions/gen/main.go + - .github/workflows/dockers-readreplica-rotate-image.yaml + - .github/actions/docker-build/action.yaml + - .github/workflows/_docker-image.yaml + - cmd/index/job/readreplica/rotate/** + - pkg/index/job/readreplica/rotate/** + - apis/grpc/** + - apis/proto/** + - go.mod + - go.sum + - versions/GO_VERSION + - internal/** + - '!internal/**/*_test.go' + - '!internal/**/*_mock.go' + - '!internal/db/**' + - Makefile + - Makefile.d/** +jobs: + build: + uses: ./.github/workflows/_docker-image.yaml + with: + target: readreplica-rotate + secrets: inherit diff --git a/.github/workflows/dockers-readreplica-rotate.yml b/.github/workflows/dockers-readreplica-rotate.yml deleted file mode 100644 index 724e88a3f1..0000000000 --- a/.github/workflows/dockers-readreplica-rotate.yml +++ /dev/null @@ -1,63 +0,0 @@ -# -# Copyright (C) 2019-2024 vdaas.org vald team -# -# 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 -# -# https://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 docker image: readreplica-rotate" -on: - push: - branches: - - main - tags: - - "*.*.*" - - "v*.*.*" - - "*.*.*-*" - - "v*.*.*-*" - pull_request: - paths: - - ".github/actions/docker-build/action.yaml" - - ".github/workflows/_docker-image.yaml" - - ".github/workflows/dockers-readreplica-rotate.yml" - - "go.mod" - - "go.sum" - - "internal/**" - - "!internal/**/*_test.go" - - "!internal/db/**" - - "internal/k8s/**" - - "apis/grpc/**" - - "pkg/index/job/readreplica/rotate/**" - - "cmd/index/job/readreplica/rotate/**" - - "dockers/index/job/readreplica/rotate/Dockerfile" - - "versions/GO_VERSION" - pull_request_target: - paths: - - ".github/actions/docker-build/action.yaml" - - ".github/workflows/_docker-image.yaml" - - ".github/workflows/dockers-readreplica-rotate.yml" - - "go.mod" - - "go.sum" - - "internal/**" - - "!internal/**/*_test.go" - - "!internal/db/**" - - "internal/k8s/**" - - "apis/grpc/**" - - "pkg/index/job/readreplica/rotate/**" - - "cmd/index/job/readreplica/rotate/**" - - "dockers/index/job/readreplica/rotate/Dockerfile" - - "versions/GO_VERSION" -jobs: - build: - uses: ./.github/workflows/_docker-image.yaml - with: - target: readreplica-rotate - secrets: inherit diff --git a/Makefile b/Makefile index 4a5e001f71..42b9302bfc 100644 --- a/Makefile +++ b/Makefile @@ -442,6 +442,11 @@ license: dockerfile: $(call gen-dockerfile,$(ROOTDIR),$(MAINTAINER)) +.PHONY: workflow +## generate workflows +workflow: + $(call gen-workflow,$(ROOTDIR),$(MAINTAINER)) + .PHONY: init ## initialize development environment init: \ diff --git a/Makefile.d/functions.mk b/Makefile.d/functions.mk index 8267ef416c..1e97c315d8 100644 --- a/Makefile.d/functions.mk +++ b/Makefile.d/functions.mk @@ -326,6 +326,23 @@ define gen-dockerfile rm -rf $$BIN_PATH endef +define gen-workflow + BIN_PATH="$(TEMP_DIR)/vald-actions-gen"; \ + rm -rf $$BIN_PATH; \ + MAINTAINER=$2 \ + GOPRIVATE=$(GOPRIVATE) \ + GOARCH=$(GOARCH) \ + GOOS=$(GOOS) \ + go build -modcacherw \ + -mod=readonly \ + -a \ + -tags "osusergo netgo static_build" \ + -trimpath \ + -o $$BIN_PATH $(ROOTDIR)/hack/actions/gen/main.go; \ + $$BIN_PATH $1; \ + rm -rf $$BIN_PATH +endef + define gen-vald-helm-schema BIN_PATH="$(TEMP_DIR)/vald-helm-schema-gen"; \ rm -rf $$BIN_PATH; \ diff --git a/hack/actions/gen/main.go b/hack/actions/gen/main.go new file mode 100644 index 0000000000..d5be92145f --- /dev/null +++ b/hack/actions/gen/main.go @@ -0,0 +1,733 @@ +// +// Copyright (C) 2019-2024 vdaas.org vald team +// +// 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 +// +// https://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. +// + +package main + +import ( + "bytes" + "context" + "errors" + "fmt" + "io/fs" + "os" + "os/signal" + "strings" + "syscall" + "text/template" + "time" + + "github.com/vdaas/vald/internal/file" + "github.com/vdaas/vald/internal/log" + "github.com/vdaas/vald/internal/safety" + "github.com/vdaas/vald/internal/sync/errgroup" + "gopkg.in/yaml.v2" +) + +var license string = `# +# Copyright (C) 2019-{{.Year}} {{.Maintainer}} +# +# 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 +# +# https://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. +# +# DO_NOT_EDIT this workflow file is generated by https://github.com/vdaas/vald/blob/main/hack/actions/gen/main.go +` + +var licenseTmpl *template.Template = template.Must(template.New("license").Parse(license)) + +type ( + Workflow struct { + Name string `yaml:"name"` + On On `yaml:"on"` + Jobs Jobs `yaml:"jobs"` + } + + On struct { + Schedule Schedule `yaml:"schedule,omitempty"` + Push Push `yaml:"push"` + PullRequest PullRequest `yaml:"pull_request"` + PullRequestTarget PullRequest `yaml:"pull_request_target"` + } + + Schedule []struct { + Cron string `yaml:"cron,omitempty"` + } + + Push struct { + Branches []string `yaml:"branches"` + Tags []string `yaml:"tags"` + } + + PullRequest struct { + Paths Paths `yaml:"paths"` + } + + Jobs struct { + Build Build `yaml:"build"` + } + + Build struct { + Uses string `yaml:"uses"` + With With `yaml:"with"` + Secrets string `yaml:"secrets"` + } + + With struct { + Target string `yaml:"target"` + Platforms string `yaml:"platforms,omitempty"` + } + + Paths []string +) + +type Data struct { + AliasImage bool + ConfigExists bool + Year int + ContainerType ContainerType + AppName string + BinDir string + BuildUser string + BuilderImage string + BuilderTag string + BuildStageName string + Maintainer string + PackageDir string + RootDir string + RuntimeImage string + RuntimeTag string + RuntimeUser string + Name string + BuildPlatforms string + Arguments map[string]string + Environments map[string]string + Entrypoints []string + EnvironmentsSlice []string + ExtraCopies []string + ExtraImages []string + ExtraPackages []string + Preprocess []string + RunCommands []string + RunMounts []string + StageFiles []string + PullRequestPaths []string +} + +type ContainerType int + +const ( + Go ContainerType = iota + Rust + DevContainer + HelmOperator + CIContainer + Other +) + +const ( + organization = "vdaas" + repository = "vald" + defaultMaintainer = organization + ".org " + repository + " team <" + repository + "@" + organization + ".org>" + defaultBuildUser = "root:root" + maintainerKey = "MAINTAINER" + minimumArgumentLength = 2 + ubuntuVersion = "22.04" + + ngtPreprocess = "make ngt/install" + faissPreprocess = "make faiss/install" + + helmOperatorRootdir = "/opt/helm" + helmOperatorWatchFile = helmOperatorRootdir + "/watches.yaml" + helmOperatorChartsDir = helmOperatorRootdir + "/charts" +) + +var ( + clangBuildDeps = []string{ + "cmake", + "gcc", + "g++", + "unzip", + "libssl-dev", + } + ngtBuildDeps = []string{ + "liblapack-dev", + "libomp-dev", + "libopenblas-dev", + } + faissBuildDeps = []string{ + "gfortran", + } + devContainerDeps = []string{ + "gawk", + "gnupg2", + "graphviz", + "jq", + "libhdf5-dev", + "libaec-dev", + "sed", + "zip", + } + + ciContainerPreprocess = []string{ + "make GOARCH=${TARGETARCH} GOOS=${TARGETOS} deps GO_CLEAN_DEPS=false", + "make GOARCH=${TARGETARCH} GOOS=${TARGETOS} golangci-lint/install", + "make GOARCH=${TARGETARCH} GOOS=${TARGETOS} gotestfmt/install", + "make cmake/install", + "make buf/install", + "make hdf5/install", + "make helm-docs/install", + "make helm/install", + "make k3d/install", + "make k9s/install", + "make kind/install", + "make kubectl/install", + "make kubelinter/install", + "make reviewdog/install", + "make tparse/install", + "make valdcli/install", + "make yq/install", + "make minikube/install", + "make stern/install", + "make telepresence/install", + } + + devContainerPreprocess = []string{ + "curl -fsSL https://deb.nodesource.com/setup_current.x | bash -", + "apt-get clean", + "apt-get update -y", + "apt-get upgrade -y", + "apt-get install -y --no-install-recommends --fix-missing nodejs", + "npm install -g npm@latest", + "apt-get clean", + "apt-get autoclean -y", + "apt-get autoremove -y", + "make delve/install", + "make gomodifytags/install", + "make gopls/install", + "make gotests/install", + "make impl/install", + "make staticcheck/install", + } +) + +const baseWorkflowTmpl string = `name: "Build docker image: %s" +on: + schedule: + - cron: "0 * * * *" + push: + branches: + - "main" + - "release/v*.*" + - "!release/v*.*.*" + tags: + - "*.*.*" + - "v*.*.*" + - "*.*.*-*" + - "v*.*.*-*" + pull_request: + paths: + - "hack/docker/gen/main.go" + - "dockers/%s/Dockerfile" + - "hack/actions/gen/main.go" + - ".github/workflows/dockers-%s-image.yaml" + - ".github/actions/docker-build/action.yaml" + - ".github/workflows/_docker-image.yaml" + - "cmd/%s/**" + - "pkg/%s/**" + pull_request_target: + paths: [] + +jobs: + build: + uses: "./.github/workflows/_docker-image.yaml" + with: + target: "%s" + platforms: "" + secrets: "inherit" +` + +const ( + cmdBenchOperatorsPath = "cmd/tools/benchmark/operators/**" + pkgBenchOperatorsPath = "pkg/tools/benchmark/operators/**" + cmdBenchJobsPath = "cmd/tools/benchmark/jobs/**" + pkgBenchJobsPath = "pkg/tools/benchmark/jobs/**" + + agentInternalPath = "pkg/agent/internal/**" + gatewayInternalPath = "pkg/gateway/internal/**" + + apisGrpcPath = "apis/grpc/**" + apisProtoPath = "apis/proto/**" + + hackPath = "hack/**" + + chartsValdPath = "charts/vald" + helmOperatorPath = "charts/vald-helm-operator" + chartPath = chartsValdPath + "/Chart.yaml" + valuesPath = chartsValdPath + "/values.yaml" + templatesPath = chartsValdPath + "/templates/**" + helmOperatorChartPath = helmOperatorPath + "/Chart.yaml" + helmOperatorValuesPath = helmOperatorPath + "/values.yaml" + helmOperatorTemplatesPath = helmOperatorPath + "/templates/**" + + goModPath = "go.mod" + goSumPath = "go.sum" + + cargoLockPath = "rust/Cargo.lock" + cargoTomlPath = "rust/Cargo.toml" + rustBinAgentDirPath = "rust/bin/agent" + rustNgtRsPath = "rust/libs/ngt-rs/**" + rustNgtPath = "rust/libs/ngt/**" + rustProtoPath = "rust/libs/proto/**" + + internalPath = "internal/**" + internalStoragePath = "internal/db/storage/blob/**" + excludeTestFilesPath = "!internal/**/*_test.go" + excludeMockFilesPath = "!internal/**/*_mock.go" + excludeDbPath = "!internal/db/**" + excludeK8sPath = "!internal/k8s/**" + + versionsPath = "versions" + operatorSDKVersionPath = versionsPath + "/OPERATOR_SDK_VERSION" + goVersionPath = versionsPath + "/GO_VERSION" + rustVersionPath = versionsPath + "/RUST_VERSION" + faissVersionPath = versionsPath + "/FAISS_VERSION" + ngtVersionPath = versionsPath + "/NGT_VERSION" + + makefilePath = "Makefile" + makefileDirPath = "Makefile.d/**" +) + +const ( + agentNgt = "agent-ngt" + agentFaiss = "agent-faiss" + agentSidecar = "agent-sidecar" + agent = "agent" + + discovererK8s = "discoverer-k8s" + + gateway = "gateway" + gatewayLb = "gateway-lb" + gatewayFilter = "gateway-filter" + gatewayMirror = "gateway-mirror" + + managerIndex = "manager-index" + + indexCorrection = "index-correction" + indexCreation = "index-creation" + indexSave = "index-save" + indexOperator = "index-operator" + + readreplicaRotate = "readreplica-rotate" + + benchJob = "benchmark-job" + benchOperator = "benchmark-operator" + + helmOperator = "helm-operator" + + loadtest = "loadtest" + + ciContainer = "ci-container" + devContainer = "dev-container" + + buildbase = "buildbase" + buildkit = "buildkit" + binfmt = "binfmt" + buildkitSyftScanner = "buildkit-syft-scanner" +) + +const ( + multiPlatforms = amd64Platform + "," + arm64Platform + amd64Platform = "linux/amd64" + arm64Platform = "linux/arm64" +) + +func (data *Data) initPullRequestPaths() { + switch data.Name { + // the benchmark components trigger each other, not just themselves + case benchJob: + data.PullRequestPaths = append(data.PullRequestPaths, + cmdBenchOperatorsPath, + pkgBenchOperatorsPath, + ) + case benchOperator: + data.PullRequestPaths = append(data.PullRequestPaths, + cmdBenchJobsPath, + pkgBenchJobsPath, + ) + case agentFaiss, agentNgt: + data.PullRequestPaths = append(data.PullRequestPaths, agentInternalPath) + default: + if strings.Contains(strings.ToLower(data.Name), gateway) { + data.PullRequestPaths = append(data.PullRequestPaths, gatewayInternalPath) + } + } + + switch data.ContainerType { + case HelmOperator: + data.PullRequestPaths = append(data.PullRequestPaths, + chartPath, + valuesPath, + templatesPath, + helmOperatorChartPath, + helmOperatorValuesPath, + helmOperatorTemplatesPath, + operatorSDKVersionPath, + ) + case DevContainer, CIContainer: + data.PullRequestPaths = append(data.PullRequestPaths, + apisGrpcPath, + apisProtoPath, + hackPath, + ) + case Go: + data.PullRequestPaths = append(data.PullRequestPaths, + apisGrpcPath, + apisProtoPath, + goModPath, + goSumPath, + goVersionPath, + internalPath, + excludeTestFilesPath, + excludeMockFilesPath, + excludeDbPath, + ) + switch data.Name { + case discovererK8s, indexOperator, gatewayMirror, readreplicaRotate, agentNgt, benchJob, benchOperator: + default: + data.PullRequestPaths = append(data.PullRequestPaths, excludeK8sPath) + } + case Rust: + data.PullRequestPaths = append(data.PullRequestPaths, + apisGrpcPath, + apisProtoPath, + cargoLockPath, + cargoTomlPath, + rustBinAgentDirPath, + rustNgtRsPath, + rustNgtPath, + rustProtoPath, + rustVersionPath, + faissVersionPath, + ngtVersionPath, + ) + } + if strings.EqualFold(data.Name, agentFaiss) || data.ContainerType == Rust { + data.PullRequestPaths = append(data.PullRequestPaths, faissVersionPath) + } + if strings.EqualFold(data.Name, agentNgt) || data.ContainerType == Rust { + data.PullRequestPaths = append(data.PullRequestPaths, ngtVersionPath) + } + + if data.Name == agentSidecar { + data.PullRequestPaths = append(data.PullRequestPaths, internalStoragePath) + } + if !data.AliasImage { + data.PullRequestPaths = append(data.PullRequestPaths, makefilePath, makefileDirPath) + } +} + +func (data *Data) initData() { + data.initPullRequestPaths() + + if data.AliasImage { + data.BuildPlatforms = multiPlatforms + } + if data.ContainerType == CIContainer || data.Name == loadtest { + data.BuildPlatforms = amd64Platform + } + + data.Year = time.Now().Year() + if maintainer := os.Getenv(maintainerKey); maintainer != "" { + data.Maintainer = maintainer + } else { + data.Maintainer = defaultMaintainer + } +} + +func (data *Data) generateWorkflowStruct() (*Workflow, error) { + workflow := &Workflow{} + baseWorkflow := fmt.Sprintf(baseWorkflowTmpl, + data.Name, + data.PackageDir, + data.Name, + data.PackageDir, + data.PackageDir, + data.Name, + ) + err := yaml.NewDecoder(strings.NewReader(baseWorkflow)).Decode(workflow) + if err != nil { + return nil, fmt.Errorf("Error decoding YAML: %v", err) + } + + if !data.AliasImage { + workflow.On.Schedule = nil + } + workflow.On.PullRequest.Paths = append(workflow.On.PullRequest.Paths, data.PullRequestPaths...) + workflow.On.PullRequestTarget.Paths = workflow.On.PullRequest.Paths + workflow.Jobs.Build.With.Platforms = data.BuildPlatforms + + return workflow, nil +} + +func main() { + log.Init() + if len(os.Args) < minimumArgumentLength { + // skipcq: RVV-A0003 + log.Fatal(errors.New("invalid argument")) + } + + ctx, cancel := signal.NotifyContext(context.Background(), syscall.SIGINT, + syscall.SIGQUIT, + syscall.SIGHUP, + syscall.SIGALRM, + syscall.SIGKILL, + syscall.SIGTERM) + defer cancel() + + eg, egctx := errgroup.New(ctx) + for n, d := range map[string]Data{ + "vald-agent-ngt": { + AppName: "ngt", + PackageDir: "agent/core/ngt", + ExtraPackages: append(clangBuildDeps, ngtBuildDeps...), + Preprocess: []string{ngtPreprocess}, + }, + "vald-agent-faiss": { + AppName: "faiss", + PackageDir: "agent/core/faiss", + ExtraPackages: append(clangBuildDeps, + append(ngtBuildDeps, + faissBuildDeps...)...), + Preprocess: []string{faissPreprocess}, + }, + "vald-agent": { + AppName: "agent", + PackageDir: "agent/core/agent", + ContainerType: Rust, + RuntimeImage: "gcr.io/distroless/cc-debian12", + ExtraPackages: append(clangBuildDeps, + append(ngtBuildDeps, + faissBuildDeps...)...), + Preprocess: []string{ + ngtPreprocess, + faissPreprocess, + }, + }, + "vald-agent-sidecar": { + AppName: "sidecar", + PackageDir: "agent/sidecar", + }, + "vald-discoverer-k8s": { + AppName: "discoverer", + PackageDir: "discoverer/k8s", + }, + "vald-gateway-lb": { + AppName: "lb", + PackageDir: "gateway/lb", + }, + "vald-gateway-filter": { + AppName: "filter", + PackageDir: "gateway/filter", + }, + "vald-gateway-mirror": { + AppName: "mirror", + PackageDir: "gateway/mirror", + }, + "vald-manager-index": { + AppName: "index", + PackageDir: "manager/index", + }, + "vald-index-correction": { + AppName: "index-correction", + PackageDir: "index/job/correction", + }, + "vald-index-creation": { + AppName: "index-creation", + PackageDir: "index/job/creation", + }, + "vald-index-save": { + AppName: "index-save", + PackageDir: "index/job/save", + }, + "vald-readreplica-rotate": { + AppName: "readreplica-rotate", + PackageDir: "index/job/readreplica/rotate", + }, + "vald-index-operator": { + AppName: "index-operator", + PackageDir: "index/operator", + }, + "vald-benchmark-job": { + AppName: "job", + PackageDir: "tools/benchmark/job", + ExtraPackages: append(clangBuildDeps, "libhdf5-dev", "libaec-dev"), + Preprocess: []string{ + "make hdf5/install", + }, + }, + "vald-benchmark-operator": { + AppName: "operator", + PackageDir: "tools/benchmark/operator", + }, + "vald-helm-operator": { + AppName: "helm-operator", + PackageDir: "operator/helm", + ContainerType: HelmOperator, + Arguments: map[string]string{ + "OPERATOR_SDK_VERSION": "latest", + }, + ExtraCopies: []string{ + "--from=operator /usr/local/bin/${APP_NAME} {{$.BinDir}}/${APP_NAME}", + }, + ExtraImages: []string{ + "quay.io/operator-framework/helm-operator:${OPERATOR_SDK_VERSION} AS operator", + }, + ExtraPackages: []string{"upx"}, + Preprocess: []string{ + "mkdir -p " + helmOperatorChartsDir, + `{ \ + echo "---"; \ + echo "- version: v1"; \ + echo " group: vald.vdaas.org"; \ + echo " kind: ValdRelease"; \ + echo " chart: ` + helmOperatorChartsDir + `/vald"; \ + echo "- version: v1"; \ + echo " group: vald.vdaas.org"; \ + echo " kind: ValdHelmOperatorRelease"; \ + echo " chart: ` + helmOperatorChartsDir + `/vald-helm-operator"; \ + } > ` + helmOperatorWatchFile, + "make GOARCH=${TARGETARCH} GOOS=${TARGETOS} helm/schema/vald", + "make GOARCH=${TARGETARCH} GOOS=${TARGETOS} helm/schema/vald-helm-operator", + "cp -r charts/* " + helmOperatorChartsDir + "/", + "upx \"{{$.BinDir}}/${APP_NAME}\"", + }, + StageFiles: []string{ + helmOperatorWatchFile, + helmOperatorChartsDir + "/vald", + helmOperatorChartsDir + "/vald-helm-operator", + }, + Entrypoints: []string{"{{$.BinDir}}/{{.AppName}}", "run", "--watches-file=" + helmOperatorWatchFile}, + }, + "vald-loadtest": { // note: this name is a little different from that of docker/gen/main.go + AppName: "loadtest", + PackageDir: "tools/cli/loadtest", + ExtraPackages: append(clangBuildDeps, "libhdf5-dev", "libaec-dev"), + Preprocess: []string{ + "make hdf5/install", + }, + }, + "vald-ci-container": { + AppName: "ci-container", + ContainerType: CIContainer, + PackageDir: "ci/base", + RuntimeUser: defaultBuildUser, + ExtraPackages: append([]string{"npm"}, append(clangBuildDeps, + append(ngtBuildDeps, + append(faissBuildDeps, + devContainerDeps...)...)...)...), + Preprocess: append(ciContainerPreprocess, ngtPreprocess, faissPreprocess), + Entrypoints: []string{"/bin/bash"}, + }, + "vald-dev-container": { + AppName: "dev-container", + BuilderImage: "mcr.microsoft.com/devcontainers/base", + BuilderTag: "ubuntu" + ubuntuVersion, + BuildUser: defaultBuildUser, + RuntimeUser: defaultBuildUser, + ContainerType: DevContainer, + PackageDir: "dev", + ExtraPackages: append(clangBuildDeps, + append(ngtBuildDeps, + append(faissBuildDeps, + devContainerDeps...)...)...), + Preprocess: append(devContainerPreprocess, + append(ciContainerPreprocess, + ngtPreprocess, + faissPreprocess)...), + }, + "vald-buildbase": { + AppName: "buildbase", + AliasImage: true, + PackageDir: "buildbase", + BuilderImage: "ubuntu", + BuilderTag: "devel", + }, + "vald-buildkit": { + AppName: "buildkit", + AliasImage: true, + PackageDir: "buildkit", + BuilderImage: "moby/buildkit", + BuilderTag: "master", + }, + "vald-binfmt": { + AppName: "binfmt", + AliasImage: true, + PackageDir: "binfmt", + BuilderImage: "tonistiigi/binfmt", + BuilderTag: "master", + }, + "vald-buildkit-syft-scanner": { + AppName: "scanner", + AliasImage: true, + PackageDir: "buildkit/syft/scanner", + BuilderImage: "docker/buildkit-syft-scanner", + BuilderTag: "edge", + BuildStageName: "scanner", + }, + } { + name := n + data := d + + eg.Go(safety.RecoverFunc(func() error { + data.Name = strings.TrimPrefix(name, "vald-") + data.initData() + + log.Infof("Generating %s's workflow", data.Name) + workflow, err := data.generateWorkflowStruct() + if err != nil { + return fmt.Errorf("Error generating workflowStruct: %w", err) + } + workflowYamlTmp, err := yaml.Marshal(workflow) + if err != nil { + return fmt.Errorf("error marshaling workflowStruct to YAML: %w", err) + } + + // remove the double quotation marks from the generated key "on": (note that the word "on" is a reserved word in gopkg.in/yaml.v2) + workflowYaml := strings.Replace(string(workflowYamlTmp), "\"on\":", "on:", 1) + + buf := bytes.NewBuffer(make([]byte, 0, len(license)+len(workflowYaml))) + err = licenseTmpl.Execute(buf, data) + if err != nil { + return fmt.Errorf("error executing template: %w", err) + } + buf.WriteString(workflowYaml) + _, err = file.OverWriteFile(egctx, file.Join(os.Args[1], ".github/workflows", "dockers-"+data.Name+"-image.yaml"), buf, fs.ModePerm) + if err != nil { + return fmt.Errorf("error writing file: %w", err) + } + return nil + })) + } + eg.Wait() +} From 626873f50f206eedcd0f3df9871c0e9df998dff3 Mon Sep 17 00:00:00 2001 From: Hiroto Funakoshi Date: Wed, 11 Sep 2024 13:31:27 +0900 Subject: [PATCH 2/2] Introduce an observability crate using opentelemetry-rust (#2535) (#2609) * feat: add observability crate * fix: fix crate name * feat: add module files * feat: create config * fix: implement from trait * feat: add tracer and meter macro * feat: add license * fix: use full module path * fix: add shutdown method * feat: add build method to crate tracer provider and meter provider * fix: module path * fix: add export timeout duration and comment * feat: update interface * feat: add endpint configuration to root configuration * fix: update deps * fix: small refactor * fix: deleted build method to create trace and metrics provider --------- Signed-off-by: hlts2 --- rust/libs/observability/src/config.rs | 142 ++++++++++++++++++ rust/libs/observability/src/lib.rs | 19 +++ rust/libs/observability/src/macros.rs | 150 +++++++++++++++++++ rust/libs/observability/src/observability.rs | 124 +++++++++++++++ 4 files changed, 435 insertions(+) create mode 100644 rust/libs/observability/src/config.rs create mode 100644 rust/libs/observability/src/lib.rs create mode 100644 rust/libs/observability/src/macros.rs create mode 100644 rust/libs/observability/src/observability.rs diff --git a/rust/libs/observability/src/config.rs b/rust/libs/observability/src/config.rs new file mode 100644 index 0000000000..1faa8fd90e --- /dev/null +++ b/rust/libs/observability/src/config.rs @@ -0,0 +1,142 @@ +// +// Copyright (C) 2019-2024 vdaas.org vald team +// +// 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 +// +// https://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. +// +use std::collections::HashMap; +use std::time::Duration; + +use opentelemetry::KeyValue; +use opentelemetry_sdk::{self, Resource}; + +#[derive(Clone, Debug)] +pub struct Config { + pub enabled: bool, + pub endpoint: String, + pub attributes: HashMap, + pub tracer: Tracer, + pub meter: Meter, +} + +#[derive(Clone, Debug, Default)] +pub struct Tracer { + pub enabled: bool, +} + +#[derive(Clone, Debug)] +pub struct Meter { + pub enabled: bool, + pub export_duration: Duration, + pub export_timeout_duration: Duration, +} + +impl Config { + pub fn new() -> Self { + Self::default() + } + + pub fn enabled(mut self, enabled: bool) -> Self { + self.enabled = enabled; + self + } + + pub fn endpoint(mut self, endpoint: &str) -> Self { + self.endpoint = endpoint.to_string(); + self + } + + pub fn attributes(mut self, attrs: HashMap) -> Self { + self.attributes = attrs; + self + } + + pub fn attribute(mut self, key: &str, value: &str) -> Self { + self.attributes.insert(key.to_string(), value.to_string()); + self + } + + pub fn tracer(mut self, cfg: Tracer) -> Self { + self.tracer = cfg; + self + } + + pub fn meter(mut self, cfg: Meter) -> Self { + self.meter = cfg; + self + } +} + +impl Default for Config { + fn default() -> Self { + Self { + enabled: false, + endpoint: "".to_string(), + attributes: HashMap::new(), + tracer: Tracer::default(), + meter: Meter::default(), + } + } +} + +impl From<&Config> for Resource { + fn from(value: &Config) -> Self { + let key_values: Vec = value + .attributes + .iter() + .map(|(key, val)| KeyValue::new(key.clone(), val.clone())) + .collect(); + Resource::new(key_values) + } +} + +impl Tracer { + pub fn new() -> Self { + Tracer::default() + } + + pub fn enabled(mut self, enabled: bool) -> Self { + self.enabled = enabled; + self + } +} + +impl Meter { + pub fn new() -> Self { + Meter::default() + } + + pub fn enabled(mut self, enabled: bool) -> Self { + self.enabled = enabled; + self + } + + pub fn export_duration(mut self, dur: Duration) -> Self { + self.export_duration = dur; + self + } + + pub fn export_timeout_duration(mut self, dur: Duration) -> Self { + self.export_timeout_duration = dur; + self + } +} + +impl Default for Meter { + fn default() -> Self { + Self { + enabled: false, + export_duration: Duration::from_secs(1), + export_timeout_duration: Duration::from_secs(5), + } + } +} diff --git a/rust/libs/observability/src/lib.rs b/rust/libs/observability/src/lib.rs new file mode 100644 index 0000000000..bf0aef235c --- /dev/null +++ b/rust/libs/observability/src/lib.rs @@ -0,0 +1,19 @@ +// +// Copyright (C) 2019-2024 vdaas.org vald team +// +// 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 +// +// https://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. +// + +pub mod config; +pub mod macros; +pub mod observability; diff --git a/rust/libs/observability/src/macros.rs b/rust/libs/observability/src/macros.rs new file mode 100644 index 0000000000..21b57f5331 --- /dev/null +++ b/rust/libs/observability/src/macros.rs @@ -0,0 +1,150 @@ +// +// Copyright (C) 2019-2024 vdaas.org vald team +// +// 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 +// +// https://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. +// +#[macro_export] +macro_rules! tracer { + () => {{ + tracer!("vald") + }}; + + ($name:expr) => {{ + opentelemetry::global::tracer($name) + }}; +} + +#[macro_export] +macro_rules! ctx_span { + ($ctx:expr, $name:expr) => {{ + ctx_span!($ctx, $name, opentelemetry::trace::SpanKind::Internal) + }}; + + ($ctx:expr, $name:expr, $kind:expr) => {{ + let tracer = tracer!(); + let parent_ctx: &opentelemetry::Context = $ctx; + let span = tracer + .span_builder($name) + .with_kind($kind) + .start_with_context(&tracer, parent_ctx); + opentelemetry::Context::current_with_span(span) + }}; +} + +#[macro_export] +macro_rules! meter { + () => {{ + meter!("vald") + }}; + + ($name:expr) => {{ + opentelemetry::global::meter($name) + }}; +} + +#[derive(Debug, PartialEq)] +pub enum InstrumentKind { + UpdownCounter, + Counter, + Histogram, + Gauge, +} + +#[macro_export] +macro_rules! instrument { + (InstrumentKind::Counter, $typ:ty, $name:expr, $disc:expr, $unit:expr) => {{ + let meter = meter!(); + paste::paste! { + meter + .[<$typ _counter>]($name) // typ = f64 or u64 + .with_description($disc) + .with_unit($unit) + .init() + } + }}; + + (InstrumentKind::Counter, $typ:ty, $name:expr, $disc:expr, $unit:expr, $measurement:expr, $key_value:expr) => {{ + let meter = meter!(); + paste::paste! { + meter + .[<$typ _observable_counter>]($name) // typ = f64 or u64 + .with_description($disc) + .with_unit($unit) + .with_callback(|observe| { + observe.observe($measurement, $key_value); + }) + .init() + } + }}; + + (InstrumentKind::UpdownCounter, $typ:ty, $name:expr, $disc:expr, $unit:expr) => {{ + let meter = meter!(); + paste::paste! { + meter + .[<$typ _up_down_counter>]($name) // typ = f64 or i64 + .with_description($disc) + .with_unit($unit) + .init() + } + }}; + + (InstrumentKind::UpdownCounter, $typ:ty, $name:expr, $disc:expr, $unit:expr, $measurement:expr, $key_value:expr) => {{ + let meter = meter!(); + paste::paste! { + meter + .[<$typ _observable_up_down_counter>]($name) // typ = f64 or i64 + .with_description($disc) + .with_unit($unit) + .with_callback(|observe| { + observe.observe($measurement, $key_value); + }) + .init() + } + }}; + + (InstrumentKind::Histogram, $typ:ty, $name:expr, $disc:expr, $unit:expr) => {{ + let meter = meter!(); + paste::paste! { + meter + .[<$typ _histogram>]($name) // typ = f64 or i64 + .with_description($disc) + .with_unit($unit) + .init() + } + }}; + + (InstrumentKind::Gauge, $typ:ty, $name:expr, $disc:expr, $unit:expr) => {{ + let meter = meter!(); + paste::paste! { + meter + .[<$typ _gauge>]($name) // typ = f64 or i64 or u64 + .with_description($disc) + .with_unit($unit) + .init() + } + }}; + + (InstrumentKind::Gauge, $typ:ty, $name:expr, $disc:expr, $unit:expr, $measurement:expr, $key_value:expr) => {{ + let meter = meter!(); + paste::paste! { + meter + .[<$typ _observable_gauge>]($name) // typ = f64 or u64 or u64 + .with_description($disc) + .with_unit($unit) + .with_callback(|observe| { + observe.observe($measurement, $key_value); + }) + .init() + } + }}; +} diff --git a/rust/libs/observability/src/observability.rs b/rust/libs/observability/src/observability.rs new file mode 100644 index 0000000000..a80ab6d92a --- /dev/null +++ b/rust/libs/observability/src/observability.rs @@ -0,0 +1,124 @@ +// +// Copyright (C) 2019-2024 vdaas.org vald team +// +// 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 +// +// https://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. +// +use anyhow::{Context, Ok, Result}; +use opentelemetry::global::{self, shutdown_tracer_provider}; +use opentelemetry_otlp::WithExportConfig; +use opentelemetry_sdk::metrics::SdkMeterProvider; +use opentelemetry_sdk::propagation::TraceContextPropagator; +use opentelemetry_sdk::trace::{self, TracerProvider}; +use opentelemetry_sdk::{runtime, Resource}; +use url::Url; + +use crate::config::Config; + +pub const SERVICE_NAME: &str = opentelemetry_semantic_conventions::resource::SERVICE_NAME; + +pub trait Observability { + fn shutdown(&mut self) -> Result<()>; +} + +pub struct ObservabilityImpl { + config: Config, + meter_provider: Option, + tracer_provider: Option, +} + +impl ObservabilityImpl { + pub fn new(cfg: Config) -> Result { + let mut obj = ObservabilityImpl { + config: cfg, + meter_provider: None, + tracer_provider: None, + }; + + if !obj.config.enabled { + return Ok(obj); + } + + if obj.config.meter.enabled { + // NOTE: Since the agent implementation does not use views, we will use the simplest implementation for the current phase. + // If we want flexibility and customization, use SdkMeterProvider::builder. + let provider = opentelemetry_otlp::new_pipeline() + .metrics(runtime::Tokio) + .with_period(obj.config.meter.export_duration) + .with_resource(Resource::from(obj.config())) + .with_timeout(obj.config.meter.export_timeout_duration) + .with_exporter( + opentelemetry_otlp::new_exporter().tonic().with_endpoint( + Url::parse(obj.config.endpoint.as_str())? + .join("/v1/metrics")? + .as_str(), + ), + ) + .build()?; + obj.meter_provider = Some(provider.clone()); + global::set_meter_provider(provider.clone()); + } + + if obj.config.tracer.enabled { + let tracer = opentelemetry_otlp::new_pipeline() + .tracing() + .with_exporter( + opentelemetry_otlp::new_exporter().tonic().with_endpoint( + Url::parse(obj.config.endpoint.as_str())? + .join("/v1/traces")? + .as_str(), + ), + ) + .with_trace_config( + trace::config() + .with_sampler(trace::Sampler::AlwaysOn) + .with_resource(Resource::from(obj.config())) + .with_id_generator(trace::RandomIdGenerator::default()), + ) + .install_batch(runtime::Tokio)?; + let provider = tracer.provider().context("failed to get provider")?; + obj.tracer_provider = Some(provider.clone()); + global::set_text_map_propagator(TraceContextPropagator::new()); + global::set_tracer_provider(provider.clone()); + } + Ok(obj) + } + + fn config(&self) -> &Config { + &self.config + } +} + +impl Observability for ObservabilityImpl { + fn shutdown(&mut self) -> Result<()> { + if !self.config.enabled { + return Ok(()); + } + + if self.config.meter.enabled { + if let Some(ref provider) = self.meter_provider { + provider.force_flush()?; + provider.shutdown()?; + } + } + + if self.config.meter.enabled { + if let Some(ref provider) = self.tracer_provider { + for result in provider.force_flush() { + result?; + } + shutdown_tracer_provider(); + } + } + Ok(()) + } +}