Merge pull request #1383 from trheyi/main

Refactor AIGC ID Handling in Load Function
This commit is contained in:
Max 2025-12-15 12:21:19 +08:00 committed by GitHub
commit 1e665423b1
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 44 additions and 1 deletions

View file

@ -40,6 +40,7 @@ env:
OPENAI_TEST_KEY: ${{ secrets.OPENAI_TEST_KEY }} OPENAI_TEST_KEY: ${{ secrets.OPENAI_TEST_KEY }}
TEST_MOAPI_SECRET: ${{ secrets.OPENAI_TEST_KEY }} TEST_MOAPI_SECRET: ${{ secrets.OPENAI_TEST_KEY }}
OPENAI_API_KEY: ${{ secrets.OPENAI_TEST_KEY }}
TEST_MOAPI_MIRROR: https://api.openai.com TEST_MOAPI_MIRROR: https://api.openai.com
# DeepSeek API Configuration # DeepSeek API Configuration
@ -314,11 +315,21 @@ jobs:
with: with:
ref: ${{ env.HEAD }} ref: ${{ env.HEAD }}
- name: Setup Apple Private Key
run: |
mkdir -p ../app/openapi/certs/apple
echo "${{ secrets.APPLE_PRIVATE_KEY_USER }}" > ../app/openapi/certs/apple/signin_client_secret_key.p8
- name: Setup Go ${{ matrix.go }} - name: Setup Go ${{ matrix.go }}
uses: actions/setup-go@v5 uses: actions/setup-go@v5
with: with:
go-version: ${{ matrix.go }} go-version: ${{ matrix.go }}
- name: Start Redis
uses: supercharge/redis-github-action@1.4.0
with:
redis-version: 6
- name: Setup Go Tools - name: Setup Go Tools
run: make tools run: make tools
@ -468,6 +479,11 @@ jobs:
with: with:
go-version: ${{ matrix.go }} go-version: ${{ matrix.go }}
- name: Start Redis
uses: supercharge/redis-github-action@1.4.0
with:
redis-version: 6
- name: Setup Go Tools - name: Setup Go Tools
run: make tools run: make tools

View file

@ -44,6 +44,7 @@ env:
OPENAI_TEST_KEY: ${{ secrets.OPENAI_TEST_KEY }} OPENAI_TEST_KEY: ${{ secrets.OPENAI_TEST_KEY }}
TEST_MOAPI_SECRET: ${{ secrets.OPENAI_TEST_KEY }} TEST_MOAPI_SECRET: ${{ secrets.OPENAI_TEST_KEY }}
OPENAI_API_KEY: ${{ secrets.OPENAI_TEST_KEY }}
TEST_MOAPI_MIRROR: https://api.openai.com TEST_MOAPI_MIRROR: https://api.openai.com
# DeepSeek API Configuration # DeepSeek API Configuration
@ -273,11 +274,21 @@ jobs:
- name: Checkout Code - name: Checkout Code
uses: actions/checkout@v4 uses: actions/checkout@v4
- name: Setup Apple Private Key
run: |
mkdir -p ../app/openapi/certs/apple
echo "${{ secrets.APPLE_PRIVATE_KEY_USER }}" > ../app/openapi/certs/apple/signin_client_secret_key.p8
- name: Setup Go ${{ matrix.go }} - name: Setup Go ${{ matrix.go }}
uses: actions/setup-go@v5 uses: actions/setup-go@v5
with: with:
go-version: ${{ matrix.go }} go-version: ${{ matrix.go }}
- name: Start Redis
uses: supercharge/redis-github-action@1.4.0
with:
redis-version: 6
- name: Setup Go Tools - name: Setup Go Tools
run: make tools run: make tools
@ -379,6 +390,11 @@ jobs:
with: with:
go-version: ${{ matrix.go }} go-version: ${{ matrix.go }}
- name: Start Redis
uses: supercharge/redis-github-action@1.4.0
with:
redis-version: 6
- name: Setup Go Tools - name: Setup Go Tools
run: make tools run: make tools

View file

@ -28,7 +28,7 @@ func Load(cfg config.Config) error {
return nil return nil
} }
id := share.ID(root, file) id := aigcID(root, file)
_, err := LoadFile(file, id) _, err := LoadFile(file, id)
if err != nil { if err != nil {
messages = append(messages, err.Error()) messages = append(messages, err.Error())
@ -48,6 +48,17 @@ func Load(cfg config.Config) error {
return nil return nil
} }
// aigcID parses AIGC ID from file path
// Special handling for .ai.yml and .ai.yaml extensions
// e.g., "aigcs/translate.ai.yml" -> "translate"
func aigcID(root, file string) string {
id := share.ID(root, file)
// Remove "_ai" suffix caused by .ai.yml/.ai.yaml extension
// share.ID treats .yml/.yaml as single extension, so "translate.ai.yml" becomes "translate_ai"
id = strings.TrimSuffix(id, "_ai")
return id
}
// LoadFile load AIGC by file // LoadFile load AIGC by file
func LoadFile(file string, id string) (*DSL, error) { func LoadFile(file string, id string) (*DSL, error) {