Skip to content

Commit

Permalink
feat: migrating eino's devops ability (#1)
Browse files Browse the repository at this point in the history
* feat: migrating eino's devops ability
  • Loading branch information
BytePender authored Dec 23, 2024
1 parent 8638810 commit 97ad3cb
Show file tree
Hide file tree
Showing 52 changed files with 8,906 additions and 54 deletions.
45 changes: 27 additions & 18 deletions .github/workflows/pr-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,21 +16,30 @@ jobs:
- name: Check Spell
uses: crate-ci/typos@master

golangci-lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: stable
# for self-hosted, the cache path is shared across projects
# and it works well without the cache of github actions
# Enable it if we're going to use Github only
cache: true

- name: Golangci Lint
# https://golangci-lint.run/
uses: golangci/golangci-lint-action@v6
with:
version: latest
# golangci-lint:
# runs-on: ubuntu-latest
# steps:
# - uses: actions/checkout@v4
# - name: Set up Go
# uses: actions/setup-go@v5
# with:
# go-version: stable
# # for self-hosted, the cache path is shared across projects
# # and it works well without the cache of github actions
# # Enable it if we're going to use Github only
# cache: true
#
# - name: Detect Modules
# id: detect-modules
# shell: bash
# run: |
# # Find all modules
# modules=$(find . -name "go.mod" -exec dirname {} \; | jq -R -s 'split("\n") | map(select(. != "")) | @json')
# echo "modules=$modules" >> $GITHUB_OUTPUT
# - name: Golangci Lint
# # https://golangci-lint.run/
# uses: golangci/golangci-lint-action@v6
# with:
# version: latest
# args: |
# $(for module in $(echo ${{ steps.detect-modules.outputs.modules }} | jq -r '.[]'); do echo "$module/..."; done)
105 changes: 87 additions & 18 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -1,34 +1,103 @@
name: Tests
name: EinoExtTest

on: [ push, pull_request ]
on: [ pull_request ]

jobs:
unit-benchmark-test:
unit_test:
name: "eino ext unit test"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Go
- name: "Set up Go"
uses: actions/setup-go@v5
with:
go-version: stable

- name: Unit Test
run: go test -race -covermode=atomic -coverprofile=coverage.out ./...
go-version: "1.18"
- name: "GoTest"
run: |
modules=`find . -name "go.mod" -exec dirname {} \;`
echo $modules
list=""
coverpkg=""
if [[ ! -f "go.work" ]];then go work init;fi
for module in $modules; do go work use $module; list=$module"/... "$list; coverpkg=$module"/...,"$coverpkg; done
go work sync
go test -race -coverprofile=coverage.out -gcflags="all=-l -N" -coverpkg=$coverpkg $list
# Download main (aka base) branch breakdown
- name: Download Artifact (main.breakdown)
id: download-main-breakdown
uses: dawidd6/action-download-artifact@v6
with:
branch: main
workflow_conclusion: success
name: main.breakdown
if_no_artifact_found: warn
- name: Ensure default.breakdown exists if download fails
run: |
if [ ! -f main.breakdown ]; then
echo "main.breakdown not found. Creating an empty main.breakdown file."
touch main.breakdown
else
echo "main.breakdown found."
fi
- name: "Test Coverage"
uses: vladopajic/go-test-coverage@v2
with:
config: ./.testcoverage.yml
# Save current coverage breakdown if current branch is main. It will be
# uploaded as artifact in step below.
breakdown-file-name: ${{ github.ref_name == 'main' && 'main.breakdown' || '' }}

- name: Benchmark
run: go test -bench=. -benchmem -run=none ./...
# If this is not main branch we want to show report including
# file coverage difference from main branch.
diff-base-breakdown-file-name: ${{ steps.download-main-breakdown.outputs.found_artifact && 'main.breakdown' || 'main.breakdown' }}
- name: Upload Artifact (main.breakdown)
uses: actions/upload-artifact@v4
if: github.ref_name == 'main'
with:
name: main.breakdown
path: main.breakdown # as specified via `breakdown-file-name`
if-no-files-found: error
- name: find if coverage report is already present
if: ${{ github.event.pull_request.number != null }}
uses: peter-evans/find-comment@v3
id: fc
with:
issue-number: ${{ github.event.pull_request.number }}
comment-author: 'github-actions[bot]'
body-includes: 'go-test-coverage report:'
- name: post coverage report
if: ${{ github.event.pull_request.number != null }}
uses: peter-evans/create-or-update-comment@v4
with:
token: ${{ secrets.GITHUB_TOKEN }}
issue-number: ${{ github.event.pull_request.number }}
comment-id: ${{ steps.fc.outputs.comment-id || '' }}
edit-mode: replace
body: |
go-test-coverage report:
```
${{ steps.coverage.outputs.report && fromJSON(steps.coverage.outputs.report) || 'No coverage report available' }} ```
compatibility-test:
strategy:
matrix:
go: [ "1.19", "1.20", "1.21", "1.22" ]
- name: "finally check coverage"
if: steps.coverage.outcome == 'failure'
shell: bash
run: echo "coverage check failed" && exit 1
unit-benchmark-test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: ${{ matrix.go }}
cache: true # don't use cache for self-hosted runners
- name: Unit Test
run: go test -race -covermode=atomic ./...
go-version: stable

- name: Go BenchMark
run: |
modules=`find . -name "go.mod" -exec dirname {} \;`
echo $modules
list=""
coverpkg=""
if [[ ! -f "go.work" ]];then go work init;fi
for module in $modules; do go work use $module; list=$module"/... "$list; coverpkg=$module"/...,"$coverpkg; done
go work sync
go test -bench=. -run=none $list
9 changes: 5 additions & 4 deletions .golangci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,18 @@ linters-settings:
- stdmethods
linters:
enable:
- gofumpt
- goimports
- gofmt
disable:
- errcheck
- typecheck
- deadcode
- varcheck
- staticcheck
- unused
- gosimple
- ineffassign
- gofumpt
issues:
exclude-use-default: true
exclude-files:
- ".*\\.mock\\.go$"
exclude-dirs:
exclude-dirs:
27 changes: 27 additions & 0 deletions .testcoverage.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# (mandatory)
# Path to coverage profile file (output of `go test -coverprofile` command).
#
# For cases where there are many coverage profiles, such as when running
# unit tests and integration tests separately, you can combine all those
# profiles into one. In this case, the profile should have a comma-separated list
# of profile files, e.g., 'cover_unit.out,cover_integration.out'.
profile: coverage.out

# (optional; but recommended to set)
# When specified reported file paths will not contain local prefix in the output.
local-prefix: "github.com/cloudwego/eino"

# Holds coverage thresholds percentages, values should be in range [0-100].
threshold:
# (optional; default 0)
# Minimum overall project coverage percentage required.
total: 68

# Holds regexp rules which will exclude matched files or packages
# from coverage statistics.
exclude:
# Exclude files or packages matching their paths
paths:
- "tests"
- "examples/"
- "mock/"
18 changes: 17 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,17 @@
# .github
# Eino Extend

English | [中文](README.zh_CN.md)

## Overview

## Security

If you discover a potential security issue in this project, or think you may
have discovered a security issue, we ask that you notify Bytedance Security via
our [security center](https://security.bytedance.com/src) or [vulnerability reporting email]([email protected]).

Please do **not** create a public GitHub issue.

## License

This project is licensed under the [Apache-2.0 License](LICENSE.txt).
17 changes: 17 additions & 0 deletions README.zh_CN.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Eino Extend

[English](README.md) | 中文

## 详细文档

// TODO:链接用户手册等文档

## 安全

如果你在该项目中发现潜在的安全问题,或你认为可能发现了安全问题,请通过我们的[安全中心](https://security.bytedance.com/src)[漏洞报告邮箱]([email protected])通知字节跳动安全团队。

**不要**创建公开的 GitHub Issue。

## 开源许可证

本项目依据 [Apache-2.0 许可证](LICENSE.txt) 授权。
9 changes: 9 additions & 0 deletions _typos.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,13 @@
# Typo check: https://github.com/crate-ci/typos

[default]

[default.extend-words]
Invokable = "Invokable"
invokable = "invokable"
InvokableLambda = "InvokableLambda"
InvokableRun = "InvokableRun"


[files]
extend-exclude = ["go.mod", "go.sum", "check_branch_name.sh"]
Loading

0 comments on commit 97ad3cb

Please sign in to comment.