Skip to content

Commit

Permalink
v1.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
小滋润 committed Oct 29, 2024
1 parent 9c635a7 commit 8b37aeb
Show file tree
Hide file tree
Showing 231 changed files with 26,694 additions and 3,821 deletions.
4 changes: 4 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
local_test
docker/runtime
docker/log
docker/data
3 changes: 3 additions & 0 deletions .editcofiging
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[*.go]
indent_style = tab
indent_size = 4
3 changes: 3 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[*.go]
indent_style = tab
indent_size = 4
28 changes: 28 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
*.go whitespace=fix

# Auto detect text files and perform LF normalization
* text=auto

# Always perform LF normalization on Go source files and related text files
*.go text
*.md text
*.yaml text
*.yml text
*.json text
*.sh text
*.txt text
*.xml text

# Make sure that these Windows files always have CRLF line endings in checkout
*.bat text eol=crlf
*.ps1 text eol=crlf

# Never perform LF normalization on these binary files
*.zip binary
*.tar binary
*.gz binary
*.bz2 binary
*.7z binary
*.rar binary
*.xls binary
*.xlsx binary
21 changes: 21 additions & 0 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: CI

on:
workflow_dispatch:
push:
branches: [ "main" ]

jobs:
test-and-update-docs:
uses: ./.github/workflows/common-test-and-update-docs.yml
with:
ref: ${{ github.ref }}

push-image:
needs: test-and-update-docs
uses: ./.github/workflows/common-push-image.yml
with:
tag: latest
secrets:
DOCKER_HUB_USERNAME: ${{ secrets.DOCKER_HUB_USERNAME }}
DOCKER_HUB_ACCESS_TOKEN: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}
28 changes: 28 additions & 0 deletions .github/workflows/common-create-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: Create Release

on:
workflow_call:
inputs:
draft:
required: true
type: boolean

jobs:
create-release:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Create GitHub Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref_name }}
release_name: "Release ${{ github.ref_name }}"
body: |
Release notes for version ${{ github.ref_name }}.
draft: ${{ inputs.draft }}
prerelease: false
35 changes: 35 additions & 0 deletions .github/workflows/common-push-image.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: Push Image

on:
workflow_call:
inputs:
tag:
required: true
type: string

secrets:
DOCKER_HUB_USERNAME:
required: true
DOCKER_HUB_ACCESS_TOKEN:
required: true

jobs:
push-image:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_HUB_USERNAME }}
password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}

- name: Build and push Docker image
uses: docker/build-push-action@v6
with:
context: .
file: docker/Dockerfile.build
push: true
tags: xiaozirun/leap-ledger:${{ inputs.tag }}
68 changes: 68 additions & 0 deletions .github/workflows/common-test-and-update-docs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
name: Test And Update Docs

on:
workflow_call:
inputs:
ref:
required: true
type: string

jobs:
test-and-update-docs:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Build image
run: |
docker build -t xiaozirun/leap-ledger:latest -f docker/Dockerfile .
- name: Set up Docker Compose
run: |
sudo curl -L "https://github.com/docker/compose/releases/latest/download/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose
- name: Start server
run: |
docker-compose -f docker-compose.yaml up -d leap-ledger-mysql && docker-compose -f docker-compose.yaml up -d
- name: Run tests and make report
run: |
docker exec leap-ledger-server sh -c "go install github.com/jstemmer/go-junit-report@latest"
docker exec leap-ledger-server sh -c "go test -v 2>&1 ./... -coverprofile=docs/coverage.out | go-junit-report > docs/test-report.xml"
docker exec leap-ledger-server sh -c "go tool cover -html=docs/coverage.out -o docs/coverage.html"
continue-on-error: false

- name: Upload test-report.xml
uses: actions/upload-artifact@v4
with:
name: test-report.xml
path: docs/test-report.xml

- name: Upload coverage.html
uses: actions/upload-artifact@v4
with:
name: coverage-report
path: docs/coverage.html

- name: Execute updateDocs.sh in container
run: docker exec leap-ledger-server sh "./docs/updateDocs.sh"

- name: Commit and push changes
# https://github.com/actions/checkout/discussions/479
run: |
git config --global user.name "github-actions[bot]"
git config --global user.email "github-actions[bot]@users.noreply.github.com"
git add -u docs/docs.go docs/swagger.json docs/swagger.yaml
if git diff-index --quiet HEAD --; then
echo "No changes to commit."
else
git commit -m "update docs" || echo "No changes to commit."
git push origin ${{ inputs.ref }}
fi
- name: Docker Compose Down
run: |
docker-compose -f docker-compose.yaml down
21 changes: 21 additions & 0 deletions .github/workflows/develop-CI.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: Develop CI

on:
workflow_dispatch:
push:
branches: [ "develop" ]

jobs:
test-and-update-docs:
uses: ./.github/workflows/common-test-and-update-docs.yml
with:
ref: ${{ github.ref }}

push-image:
needs: test-and-update-docs
uses: ./.github/workflows/common-push-image.yml
with:
tag: ${{ github.ref_name }}
secrets:
DOCKER_HUB_USERNAME: ${{ secrets.DOCKER_HUB_USERNAME }}
DOCKER_HUB_ACCESS_TOKEN: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}
21 changes: 21 additions & 0 deletions .github/workflows/push-tag.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: Push Tag

on:
push:
tags:
- '*'

jobs:
create-release:
uses: ./.github/workflows/common-create-release.yml
with:
draft: true

push-image:
needs: create-release
uses: ./.github/workflows/common-push-image.yml
with:
tag: ${{ github.ref_name }}
secrets:
DOCKER_HUB_USERNAME: ${{ secrets.DOCKER_HUB_USERNAME }}
DOCKER_HUB_ACCESS_TOKEN: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}
16 changes: 14 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,21 @@
*.idea

# Test binary, built with `go test -c`
*.test
local_test

/log
*.log

runtime

docker/*
!docker/redis.conf
!docker/mysql.cnf

!docker/Dockerfile
!docker/Dockerfile.build
!docker/Dockerfile.debug
!docker/Dockerfile.test

docker-compose.override.yaml

production_config.yaml
24 changes: 0 additions & 24 deletions Dockerfile

This file was deleted.

13 changes: 9 additions & 4 deletions api/request/account.go
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
package request

import accountModel "KeepAccount/model/account"
import accountModel "github.com/ZiRunHua/LeapLedger/model/account"

// AccountCreateOne 账本新建
type AccountCreateOne struct {
Name string `binding:"required"`
Icon string `binding:"required"`
Type accountModel.Type `binding:"required"`
Name string `binding:"required"`
Icon string `binding:"required"`
Location string `binding:"required"`
Type accountModel.Type `binding:"required"`
}

// AccountUpdateOne 账本修改
Expand Down Expand Up @@ -63,3 +64,7 @@ func (a *AccountUpdateUser) GetUpdateData() accountModel.UserUpdateData {
Permission: a.Role.ToUserPermission(),
}
}

type AccountUserConfigFlagUpdate struct {
Status bool
}
10 changes: 3 additions & 7 deletions api/request/category.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package request

import (
"KeepAccount/global/constant"
"github.com/ZiRunHua/LeapLedger/global/constant"
)

type CategoryOne struct {
Expand All @@ -24,12 +24,11 @@ type CategoryUpdateOne struct {
}

type CategoryCreateOneFather struct {
AccountId uint
Name string
IncomeExpense constant.IncomeExpense
}

type CategoryMoveCategory struct {
type CategoryMove struct {
Previous *uint
FatherId *uint
}
Expand All @@ -39,12 +38,10 @@ type CategoryMoveFather struct {
}

type CategoryGetTree struct {
AccountId uint `binding:"required"`
IncomeExpense *constant.IncomeExpense
}

type CategoryGetList struct {
AccountId uint `binding:"required"`
IncomeExpense *constant.IncomeExpense `binding:"omitempty"`
}

Expand All @@ -53,6 +50,5 @@ type CategoryMapping struct {
}

type CategoryGetMappingTree struct {
ParentAccountId uint `binding:"required"`
ChildAccountId uint `binding:"required"`
MappingAccountId uint `binding:"required"`
}
Loading

0 comments on commit 8b37aeb

Please sign in to comment.