You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@opendal.apache.org by xu...@apache.org on 2024/07/18 14:52:40 UTC
(opendal-go-services) branch main updated: feat(internal): move generate to internal (#4)
This is an automated email from the ASF dual-hosted git repository.
xuanwo pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/opendal-go-services.git
The following commit(s) were added to refs/heads/main by this push:
new 3c69448 feat(internal): move generate to internal (#4)
3c69448 is described below
commit 3c694483e9a643292c86c30fa8b476fd113a88a0
Author: Hanchin Hsieh <me...@yuchanns.xyz>
AuthorDate: Thu Jul 18 22:52:36 2024 +0800
feat(internal): move generate to internal (#4)
Signed-off-by: Hanchin Hsieh <me...@yuchanns.xyz>
---
.github/workflows/build_artifacts.yaml | 2 +-
{generate => internal/generate}/generate.go | 11 ++++++-----
{generate => internal/generate}/go.mod | 0
{generate => internal/generate}/go.sum | 0
.../generate}/templates/embed_{{.os}}_{{.arch}}.go.tpl | 0
{generate => internal/generate}/templates/go.mod.tpl | 0
{generate => internal/generate}/templates/service.go.tpl | 0
{generate => internal/generate}/templates/service_test.go.tpl | 0
8 files changed, 7 insertions(+), 6 deletions(-)
diff --git a/.github/workflows/build_artifacts.yaml b/.github/workflows/build_artifacts.yaml
index 226bc1e..b6e9dc3 100644
--- a/.github/workflows/build_artifacts.yaml
+++ b/.github/workflows/build_artifacts.yaml
@@ -91,7 +91,7 @@ jobs:
env:
MATRIX: ${{ needs.matrix.outputs.matrix }}
VERSION: ${{ inputs.opendal_core_version }}
- working-directory: generate
+ working-directory: internal/generate
run: |
go run generate.go
- name: Auto Commit
diff --git a/generate/generate.go b/internal/generate/generate.go
similarity index 80%
rename from generate/generate.go
rename to internal/generate/generate.go
index 00e3f35..ed3ad8a 100644
--- a/generate/generate.go
+++ b/internal/generate/generate.go
@@ -26,7 +26,8 @@ var (
matrix Matrix
version string
- tpls = template.Must(template.ParseGlob("templates/*.tpl"))
+ tpls = template.Must(template.ParseGlob("templates/*.tpl"))
+ workspace = os.Getenv("GITHUB_WORKSPACE")
)
func init() {
@@ -36,7 +37,7 @@ func init() {
func genGoFile(build Build, service string) error {
pkg := strings.ReplaceAll(service, "-", "_")
- pkgPath := fmt.Sprintf("../%s", pkg)
+ pkgPath := fmt.Sprintf("%s/%s", workspace, pkg)
_, err := os.Stat(pkgPath)
if os.IsNotExist(err) {
@@ -47,8 +48,8 @@ func genGoFile(build Build, service string) error {
}
err = os.Rename(
- fmt.Sprintf("../libopendal_c_%s_%s_%s/libopendal_c.%s.so.zst", version, service, build.Target, build.Target),
- fmt.Sprintf("../%s/libopendal_c.%s.%s.so.zst", pkg, build.GOOS, build.GOARCH))
+ fmt.Sprintf("%s/libopendal_c_%s_%s_%s/libopendal_c.%s.so.zst", workspace, version, service, build.Target, build.Target),
+ fmt.Sprintf("%s/%s/libopendal_c.%s.%s.so.zst", workspace, pkg, build.GOOS, build.GOARCH))
if err != nil {
return err
}
@@ -63,7 +64,7 @@ func genGoFile(build Build, service string) error {
if err != nil {
return fmt.Errorf("parse filename: %s:%s", t.Name(), err)
}
- targetFile := fmt.Sprintf("../%s/%s", pkg, strings.Trim(buf.String(), ".tpl"))
+ targetFile := fmt.Sprintf("%s/%s/%s", workspace, pkg, strings.Trim(buf.String(), ".tpl"))
os.Remove(targetFile)
file, err := os.OpenFile(targetFile, os.O_CREATE|os.O_WRONLY, os.ModePerm)
diff --git a/generate/go.mod b/internal/generate/go.mod
similarity index 100%
rename from generate/go.mod
rename to internal/generate/go.mod
diff --git a/generate/go.sum b/internal/generate/go.sum
similarity index 100%
rename from generate/go.sum
rename to internal/generate/go.sum
diff --git a/generate/templates/embed_{{.os}}_{{.arch}}.go.tpl b/internal/generate/templates/embed_{{.os}}_{{.arch}}.go.tpl
similarity index 100%
rename from generate/templates/embed_{{.os}}_{{.arch}}.go.tpl
rename to internal/generate/templates/embed_{{.os}}_{{.arch}}.go.tpl
diff --git a/generate/templates/go.mod.tpl b/internal/generate/templates/go.mod.tpl
similarity index 100%
rename from generate/templates/go.mod.tpl
rename to internal/generate/templates/go.mod.tpl
diff --git a/generate/templates/service.go.tpl b/internal/generate/templates/service.go.tpl
similarity index 100%
rename from generate/templates/service.go.tpl
rename to internal/generate/templates/service.go.tpl
diff --git a/generate/templates/service_test.go.tpl b/internal/generate/templates/service_test.go.tpl
similarity index 100%
rename from generate/templates/service_test.go.tpl
rename to internal/generate/templates/service_test.go.tpl