Skip to content

Commit

Permalink
chore: first commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Pencil-Yao committed Nov 15, 2024
1 parent b1c0675 commit 11e470b
Show file tree
Hide file tree
Showing 15 changed files with 957 additions and 43 deletions.
48 changes: 48 additions & 0 deletions .github/workflows/build-docker-images.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: Build Docker Images

on:
push:
branches:
- master
- main
- 'v*'
workflow_dispatch:

jobs:
build:
runs-on: [self-hosted, Linux, alibaba-cloud]
defaults:
run:
shell: bash
steps:
- name: "Checking out code"
uses: actions/checkout@v2
with:
submodules: recursive
- name: "Login to DockerHub"
uses: docker/login-action@v2
with:
registry: ${{ secrets.DOCKER_REGISTRY_ADDRESS }}
username: ${{ secrets.DOCKER_REGISTRY_USERNAME }}
password: ${{ secrets.DOCKER_REGISTRY_PASSWORD }}
- name: "Set up QEMU"
uses: docker/setup-qemu-action@v1
with:
image: tonistiigi/binfmt:master
- name: "Set up Docker Buildx"
uses: docker/setup-buildx-action@v1
- name: "Building docker images"
run: |
image="${{ secrets.DOCKER_REGISTRY_ADDRESS }}/cita-cloud/$(basename ${GITHUB_REPOSITORY})"
tag=${GITHUB_REF#refs/heads/}
if [ "$tag" = 'master' ] || [ "$tag" = 'main' ]; then
tag=latest
fi
docker buildx build \
--output "type=image,push=true" \
--file "Dockerfile" \
--tag "${image}:${tag}" \
--platform "linux/amd64" \
"."
67 changes: 67 additions & 0 deletions .github/workflows/gpt-review.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
name: GPT Review

on:
pull_request:

jobs:
add_pr_comment:
name: Azure OpenAI PR Review
runs-on: [ self-hosted, Linux, alibaba-cloud ]

env:
GIT_COMMIT_HASH: ${{ github.event.pull_request.head.sha }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PR_NUMBER: ${{ github.event.pull_request.number }}
PR_TITLE: ${{ github.event.pull_request.title }}
REPOSITORY_NAME: ${{ github.repository }}
AZURE_OPENAI_API: ${{ secrets.AZURE_OPENAI_API }}
AZURE_OPENAI_API_KEY: ${{ secrets.AZURE_OPENAI_API_KEY }}
AZURE_GPT_NAME: ${{ secrets.AZURE_GPT_NAME }}
AZURE_EMBEDDING_NAME: ${{ secrets.AZURE_EMBEDDING_NAME }}
LINK: "https://github.com/${{ github.repository }}/pull/${{ github.event.pull_request.number }}"
FULL_SUMMARY: true
FILE_SUMMARY: false
TEST_SUMMARY: false
BUG_SUMMARY: true
RISK_SUMMARY: true
RISK_BREAKING: true

steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Set up Python 3.11
uses: actions/setup-python@v4
with:
python-version: 3.11

- name: Check deps
run: |
pwd
echo "generating azure.yaml..."
echo "azure_model_map:
turbo_llm_model_deployment_id: $AZURE_GPT_NAME
smart_llm_model_deployment_id: $AZURE_GPT_NAME
large_llm_model_deployment_id: $AZURE_GPT_NAME
embedding_model_deployment_id: $AZURE_EMBEDDING_NAME
" > azure.yaml
cat azure.yaml
echo "installing gpt-review..."
sudo apt-get update
python3 -m venv .env
source .env/bin/activate
python -m pip install --upgrade pip
python -m pip install gpt-review
echo "install done!"
gpt ask "hello"
- name: Gpt review
run: |
source .env/bin/activate
gpt github review \
--access-token $GITHUB_TOKEN \
--pull-request $PR_NUMBER \
--repository $REPOSITORY_NAME
82 changes: 82 additions & 0 deletions .github/workflows/rust-check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
name: Rust Check

on:
pull_request:
push:
branches:
- master
- main
- 'v*'

env:
CARGO_TERM_COLOR: always
#GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
RUSTFLAGS: -Dwarnings
RUST_BACKTRACE: 1
PROTOC_NO_VENDOR: 1

jobs:
fmt:
name: Fmt
runs-on: [ self-hosted, Linux, alibaba-cloud ]
steps:
- uses: actions/checkout@v2
- uses: arduino/[email protected]
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
- uses: actions-rs/toolchain@v1
with:
toolchain: stable
components: rustfmt
- uses: actions-rs/cargo@v1
with:
command: fmt
args: --all -- --check

clippy:
name: Clippy
runs-on: [ self-hosted, Linux, alibaba-cloud ]
steps:
- uses: actions/checkout@v2
- uses: arduino/[email protected]
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
- uses: actions-rs/toolchain@v1
with:
toolchain: stable
components: clippy
- uses: actions-rs/cargo@v1
with:
command: clippy
args: --all --all-targets

test:
name: Test
runs-on: [ self-hosted, Linux, alibaba-cloud ]
steps:
- uses: actions/checkout@v2
- uses: arduino/[email protected]
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
- uses: actions-rs/toolchain@v1
with:
toolchain: stable
- uses: actions-rs/cargo@v1
with:
command: test

build:
name: Build
runs-on: [ self-hosted, Linux, alibaba-cloud ]
steps:
- uses: actions/checkout@v2
- uses: arduino/[email protected]
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
- uses: actions-rs/toolchain@v1
with:
toolchain: stable
- uses: actions-rs/cargo@v1
with:
command: build
args: --release
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
.idea
**/logs
executor
15 changes: 15 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
FROM golang:1.21 AS builder

WORKDIR /build

COPY . /build

RUN go mod tidy && go build -o executor .

# TODO: Change to scratch
FROM ubuntu:22.04
RUN useradd -m chain
USER chain
COPY --from=builder /build/executor /usr/bin/
COPY --from=ghcr.io/grpc-ecosystem/grpc-health-probe:v0.4.19 /ko-app/grpc-health-probe /usr/bin/
CMD ["executor"]
18 changes: 11 additions & 7 deletions cmd/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
)

const ourPath = "github.com/cita-cloud/executor_noop_go"
const VERSION = "v6.7.3"

type GitInfo struct {
Commit string // head commit hash
Expand Down Expand Up @@ -55,19 +56,22 @@ func NewApp(usage string) *cli.App {
git, _ := NewGI()
app := cli.NewApp()
app.EnableBashCompletion = true
app.Version = VersionWithCommit(git.Commit, git.Date)
app.Version = VersionWithCommit(git)
app.Usage = usage
app.Copyright = "Copyright 2024 The Cita-Cloud Authors"
return app
}

func VersionWithCommit(gitCommit, gitDate string) string {
var vsn string
if len(gitCommit) >= 8 {
vsn += "-" + gitCommit[:8]
func VersionWithCommit(git GitInfo) string {
vsn := VERSION
if len(git.Commit) >= 8 {
vsn += "-" + git.Commit[:8]
}
if gitDate != "" {
vsn += "-" + gitDate
if git.Date != "" {
vsn += "-" + git.Date
}
if git.Dirty == true {
vsn += "-dirty"
}
return vsn
}
25 changes: 16 additions & 9 deletions config.go
Original file line number Diff line number Diff line change
@@ -1,13 +1,20 @@
package main

type ExecutorConfig struct {
ExecutorPort uint16 `toml:"executor_port" json:"executor_port,omitempty"`
EthCompatibility bool `toml:"eth_compatibility" json:"eth_compatibility,omitempty"`
DbPath string `json:"db_path" json:"db_path,omitempty"`
SyncMode string `json:"sync_mode" json:"sync_mode,omitempty"`
EnableMetrics bool `json:"enable_metrics" json:"enable_metrics,omitempty"`
MetricsPort uint16 `json:"metrics_port,omitempty"`
MetricsBuckets []float64 `json:"metrics_buckets,omitempty"`
Domain string `json:"domain,omitempty"`
LogConfig interface{} `json:"log_config,omitempty"`
ExecutorPort uint16 `toml:"executor_port" json:"executor_port,omitempty"`
EthCompatibility bool `toml:"eth_compatibility" json:"eth_compatibility,omitempty"`
DbPath string `toml:"db_path" json:"db_path" json:"db_path,omitempty"`
SyncMode string `toml:"sync_mode" json:"sync_mode,omitempty"`
EnableMetrics bool `toml:"enable_metrics" json:"enable_metrics,omitempty"`
MetricsPort uint16 `toml:"metrics_port" json:"metrics_port,omitempty"`
MetricsBuckets []float64 `toml:"metrics_buckets" json:"metrics_buckets,omitempty"`
Domain string `toml:"domain" json:"domain,omitempty"`
LogConfig LogConfig `toml:"log_config" json:"log_config,omitempty"`
}

type LogConfig struct {
Filter string `json:"filter,omitempty"`
MaxLevel string `toml:"max_level" json:"max_level,omitempty"`
RollingFilePath string `toml:"rolling_file_path" json:"rolling_file_path,omitempty"`
ServiceName string `toml:"service_name" json:"service_name,omitempty"`
}
Loading

0 comments on commit 11e470b

Please sign in to comment.