From c484316a63873638cea2a7b3ee4cdad14944613c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=BA=90=E6=96=87=E9=9B=A8?= <41315874+fumiama@users.noreply.github.com> Date: Thu, 6 Apr 2023 14:32:07 +0800 Subject: [PATCH] add ci --- .github/workflows/ci.yml | 29 +++++++++++++++++++++++++++++ main.go | 19 ++++++++++++++++++- 2 files changed, 47 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/ci.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..915f426 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,29 @@ +name: CI +on: [ push, pull_request ] +jobs: + golangci: + name: CI + runs-on: ubuntu-latest + steps: + - name: Set up Go + uses: actions/setup-go@master + with: + go-version: '1.20' + + - name: Check out code into the Go module directory + uses: actions/checkout@master + with: + submodules: 'true' + fetch-depth: 0 + + - name: Run Check + run: | + echo "ls ./" + ls + rm -rf Wife/*.go Wife/*.md Wife/.git + echo "ls Wife/" + ls Wife/ + go mod init updater + sed -i '1,3d' main.go + go mod tidy + go run main.go -c diff --git a/main.go b/main.go index 6da76bf..aa6e243 100644 --- a/main.go +++ b/main.go @@ -6,6 +6,7 @@ package main import ( "crypto/md5" "encoding/hex" + "flag" "fmt" "io/fs" "os" @@ -19,6 +20,22 @@ import ( ) func main() { + c := flag.Bool("c", false, "check repo only") + flag.Parse() + es, err := fs.ReadDir(os.DirFS("./"), ".") + if err != nil { + panic(err) + } + for _, es := range es { + if es.IsDir() && es.Name()[0] != '.' { + if !unicode.IsUpper([]rune(es.Name())[0]) { + panic("failed: 文件夹 " + es.Name() + " 首字母必须为大写") + } + } + } + if *c { + return + } var files []string fs.WalkDir(os.DirFS("./"), ".", func(path string, d fs.DirEntry, err error) error { if err != nil { @@ -41,7 +58,7 @@ func main() { *(*uintptr)(unsafe.Add(unsafe.Pointer(&md5s[i]), unsafe.Sizeof(uintptr(0)))) = uintptr(16) } r := registry.NewRegedit("reilia.fumiama.top:32664", "", "fumiama", os.Getenv("REILIA_SPS")) - err := r.Connect() + err = r.Connect() if err != nil { panic(err) }