Skip to content

Commit

Permalink
Merge pull request #7 from doziestar/feat/auth-test
Browse files Browse the repository at this point in the history
Feat: Adding test to auth
  • Loading branch information
doziestar authored Jul 6, 2024
2 parents c469de0 + 946d24a commit 07b339e
Show file tree
Hide file tree
Showing 139 changed files with 12,693 additions and 1,741 deletions.
21 changes: 21 additions & 0 deletions .fleet/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"editor.formatOnSave": true,
"plugins": [
{
"type": "add",
"pluginName": "fleet.ai"
},
{
"type": "add",
"pluginName": "fleet.go.ai"
},
{
"type": "add",
"pluginName": "fleet.python.ai"
},
{
"type": "add",
"pluginName": "fleet.rust.ai"
}
]
}
134 changes: 134 additions & 0 deletions .github/workflows/build_and_test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
name: Go CI/CD

on:
push:
branches: [main]
pull_request:
branches: [main]

jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: "1.22"
- name: Verify workspace
run: go work sync
- name: Check formatting
run: |
all_formatted=true
for dir in $(go work edit -json | jq -r '.Use[].DiskPath'); do
echo "Checking formatting in $dir"
if [ -n "$(gofmt -s -l $dir)" ]; then
echo "Formatting issues in $dir:"
gofmt -s -l $dir
all_formatted=false
else
echo "No formatting issues in $dir"
fi
done
if [ "$all_formatted" = false ]; then
echo "Formatting errors found. Please run 'go fmt ./...' in each module to fix."
exit 1
fi
- name: Run go vet
run: |
for dir in $(go work edit -json | jq -r '.Use[].DiskPath'); do
echo "Running go vet in $dir"
go vet ./$dir/...
done
# - name: Run goimports
# run: |
# for dir in $(go work edit -json | jq -r '.Use[].DiskPath'); do
# echo "Running goimports in $dir"
# goimports -l $dir
# done

# - name: Run gocyclo
# run: |
# for dir in $(go work edit -json | jq -r '.Use[].DiskPath'); do
# echo "Running gocyclo in $dir"
# gocyclo -over 15 $dir
# done

# - name: Static check
# run: |
# for dir in $(go work edit -json | jq -r '.Use[].DiskPath'); do
# echo "Running staticcheck in $dir"
# staticcheck $dir
# done

test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: "1.22"
- name: Run tests
run: |
go work use .
for dir in $(go work edit -json | jq -r '.Use[].DiskPath'); do
echo "Running tests in $dir"
go test -v -race -coverprofile=$dir/coverage.txt -covermode=atomic ./$dir/...
done
- name: Combine coverage
run: |
echo "mode: atomic" > coverage.txt
for dir in $(go work edit -json | jq -r '.Use[].DiskPath'); do
if [ -f $dir/coverage.txt ]; then
tail -n +2 $dir/coverage.txt >> coverage.txt
fi
done
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3
with:
file: ./coverage.txt
- name: Upload coverage artifact
uses: actions/upload-artifact@v2
with:
name: coverage
path: coverage.txt

build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: "1.22"
- name: Build
run: |
for dir in $(go work edit -json | jq -r '.Use[].DiskPath'); do
echo "Building in $dir"
go build -v ./$dir/...
done
deploy-coverage:
needs: test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Download coverage artifact
uses: actions/download-artifact@v2
with:
name: coverage
- name: Generate coverage HTML
run: |
go tool cover -html=coverage.txt -o coverage.html
- name: Deploy to GitHub Pages
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.TOKEN }}
publish_dir: .
publish_branch: gh-pages
keep_files: true
user_name: "github-actions[bot]"
user_email: "github-actions[bot]@users.noreply.github.com"
commit_message: "Deploy coverage report to GitHub Pages"
43 changes: 0 additions & 43 deletions .github/workflows/deploy.yml

This file was deleted.

30 changes: 27 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,31 @@
# vendor/

# Go workspace file
go.work
go.work.sum
# go.work
# go.work.sum

.env
.env
.fleet
.idea
.vscode
*.log
*.log.*
*.log-*
.DS_Store


node_modules

web/node_modules
datavinci
ai
report
realtime

/internal/auth/coverage.txt
/internal/datasource/coverage.txt
/internal/visualization/coverage.txt
/internal/realtime/coverage.txt
/internal/report/coverage.txt
/internal/ai/coverage.txt
/pkg/coverage.txt
2 changes: 1 addition & 1 deletion .idea/datavinci.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

52 changes: 52 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-yaml
args: [--allow-multiple-documents]
# - id: check-added-large-files
# args: [--maxkb=1000]

# - repo: https://github.com/golangci/golangci-lint
# rev: v1.54.2
# hooks:
# - id: golangci-lint

- repo: https://github.com/dnephin/pre-commit-golang
rev: v0.5.1
hooks:
- id: go-fmt
# - id: go-vet
# files: \.go$
# exclude: ^datavinci/
- id: go-imports
- id: go-cyclo
# args: [-over=15]
- id: validate-toml
- id: no-go-testing
# - id: go-critic
# args: [--disable=sloppyTypeAssert]
- id: go-unit-tests
- id: go-build
- id: go-mod-tidy

# - repo: https://github.com/pre-commit/mirrors-prettier
# rev: v3.0.3
# hooks:
# - id: prettier
# types_or: [javascript, jsx, ts, tsx, json]
# files: ^web/

# - repo: https://github.com/pre-commit/mirrors-eslint
# rev: v8.49.0
# hooks:
# - id: eslint
# files: ^web/.*\.[jt]sx?$ # *.js, *.jsx, *.ts and *.tsx in web folder
# types: [file]
# additional_dependencies:
# - eslint@9.6.0
# - typescript@5.2.2
# - "@typescript-eslint/parser@6.7.0"
# - "@typescript-eslint/eslint-plugin@6.7.0"
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ FROM alpine:latest
WORKDIR /root/
COPY --from=builder /app/datavinci .
EXPOSE 8080
CMD ["./datavinci"]
CMD ["./datavinci"]
Loading

0 comments on commit 07b339e

Please sign in to comment.