From d6356664bdf6a2a7a4a6d2f37df92853f1363ff3 Mon Sep 17 00:00:00 2001
From: "Xinwei Xiong (cubxxw)" <3293172751nss@gmail.com>
Date: Wed, 27 Mar 2024 15:15:35 +0800
Subject: [PATCH] feat: add standardizer type check
---
.github/code-language-detector.yml | 7 +
.github/workflows/auto-assign-issue.yml | 30 ++++
.github/workflows/go-typecheck.yml | 13 ++
.github/workflows/language-check.yml | 13 ++
.github/workflows/release.yml | 63 +++++++
.github/workflows/test.yml | 22 +++
.gitignore | 3 +
.goreleaser.yaml | 213 ++++++++++++++++++++++++
README.md | 4 +-
action.yml | 29 ++++
checker/checker.go | 2 +-
formitychecker.go => composite.go | 8 +-
config/config.go | 2 -
go.mod | 5 +
go.sum | 4 +
15 files changed, 409 insertions(+), 9 deletions(-)
create mode 100644 .github/code-language-detector.yml
create mode 100644 .github/workflows/auto-assign-issue.yml
create mode 100644 .github/workflows/go-typecheck.yml
create mode 100644 .github/workflows/language-check.yml
create mode 100644 .github/workflows/release.yml
create mode 100644 .github/workflows/test.yml
create mode 100644 .goreleaser.yaml
create mode 100644 action.yml
rename formitychecker.go => composite.go (78%)
create mode 100644 go.mod
create mode 100644 go.sum
diff --git a/.github/code-language-detector.yml b/.github/code-language-detector.yml
new file mode 100644
index 0000000..9a81236
--- /dev/null
+++ b/.github/code-language-detector.yml
@@ -0,0 +1,7 @@
+directory: ./
+file_types:
+ - .go
+ - .yaml
+ - .yml
+languages:
+ - Chinese
\ No newline at end of file
diff --git a/.github/workflows/auto-assign-issue.yml b/.github/workflows/auto-assign-issue.yml
new file mode 100644
index 0000000..3bb16c5
--- /dev/null
+++ b/.github/workflows/auto-assign-issue.yml
@@ -0,0 +1,30 @@
+# Copyright © 2024 KubeCub open source community. All rights reserved.
+# Licensed under the MIT License (the "License");
+# you may not use this file except in compliance with the License.
+
+name: Assign issue to comment author
+on:
+ issue_comment:
+ types: [created]
+jobs:
+ assign-issue:
+ if: contains(github.event.comment.body, '/assign') || contains(github.event.comment.body, '/accept')
+ runs-on: ubuntu-latest
+ permissions:
+ issues: write
+ steps:
+ - name: Checkout code
+ uses: actions/checkout@v3
+
+ - name: Assign the issue
+ run: |
+ export LETASE_MILESTONES=$(curl "https://api.github.com/repos/$OWNER/$REPO/milestones" | jq -r 'last(.[]).title')
+ gh issue edit ${{ github.event.issue.number }} --add-assignee "${{ github.event.comment.user.login }}"
+ gh issue edit ${{ github.event.issue.number }} --add-label "triage/accepted"
+ gh issue edit ${{ github.event.issue.number }} --milestone "$LETASE_MILESTONES"
+ gh issue comment $ISSUE --body "@${{ github.event.comment.user.login }} Glad to see you accepted this issue🤲, this issue has been assigned to you.
I set the milestones for this issue to $LETASE_MILESTONES, we are looking forward to your PR!"
+ env:
+ GH_TOKEN: ${{ secrets.REDBOT_GITHUB_TOKEN }}
+ ISSUE: ${{ github.event.issue.html_url }}
+ OWNER: ${{ github.repository_owner }}
+ REPO: ${{ github.event.repository.name }}
\ No newline at end of file
diff --git a/.github/workflows/go-typecheck.yml b/.github/workflows/go-typecheck.yml
new file mode 100644
index 0000000..00262b5
--- /dev/null
+++ b/.github/workflows/go-typecheck.yml
@@ -0,0 +1,13 @@
+name: Go Typecheck Workflow Test
+
+on: [push, pull_request]
+
+jobs:
+ comment-language-detector:
+ runs-on: ubuntu-latest
+ steps:
+ - name: Checkout Repository
+ uses: actions/checkout@v4
+
+ - name: Code Typecheck Detector
+ uses: kubecub/typecheck@main
diff --git a/.github/workflows/language-check.yml b/.github/workflows/language-check.yml
new file mode 100644
index 0000000..4f6e3d0
--- /dev/null
+++ b/.github/workflows/language-check.yml
@@ -0,0 +1,13 @@
+name: Language Check Workflow Test
+
+on: [pull_request, push]
+
+jobs:
+ comment-language-detector:
+ runs-on: ubuntu-latest
+ steps:
+ - name: Checkout Repository
+ uses: actions/checkout@v4
+
+ - name: Code Language Detector
+ uses: kubecub/comment-lang-detector@v1.0.0
diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml
new file mode 100644
index 0000000..43e9b95
--- /dev/null
+++ b/.github/workflows/release.yml
@@ -0,0 +1,63 @@
+# Copyright © 2023 KubeCub open source community. All rights reserved.
+# Licensed under the MIT License (the "License");
+# you may not use this file except in compliance with the License.
+
+name: Go Typecheck Release Version
+
+on:
+ push:
+ tags:
+ - 'v*'
+
+permissions:
+ contents: write
+ packages: write
+ issues: write
+ id-token: write
+
+jobs:
+ goreleaser:
+ runs-on: ubuntu-latest
+ env:
+ DOCKER_CLI_EXPERIMENTAL: "enabled"
+ steps:
+ - uses: actions/checkout@v3
+ with:
+ fetch-depth: 0
+
+ - name: Setup Golang with cache
+ uses: magnetikonline/action-golang-cache@v3
+ with:
+ go-version: ${{ env.GO_VERSION }}
+
+ - run: git fetch --force --tags
+ - uses: actions/setup-go@v4
+ with:
+ go-version: stable
+
+ - name: Install Dependencies
+ run: |
+ sudo apt update && sudo apt install -y gcc-aarch64-linux-gnu \
+ libbtrfs-dev libgpgme-dev libdevmapper-dev \
+ qemu-user-static binfmt-support
+
+ - name: Login to GitHub Container Registry
+ uses: docker/login-action@v2
+ with:
+ registry: ghcr.io
+ username: ${{ github.repository_owner }}
+ password: ${{ secrets.BOT_GITHUB_TOKEN }}
+
+ # More assembly might be required: Docker logins, GPG, etc. It all depends
+ # on your needs.
+ - uses: goreleaser/goreleaser-action@v4
+ with:
+ # either 'goreleaser' (default) or 'goreleaser-pro':
+ distribution: goreleaser
+ version: latest
+ args: release --clean
+
+ env:
+ GITHUB_TOKEN: ${{ secrets.BOT_GITHUB_TOKEN }}
+ USERNAME: ${{ github.repository_owner }}
+ FURY_TOKEN: ${{ secrets.FURY_TOKEN }}
diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml
new file mode 100644
index 0000000..fc5b9f1
--- /dev/null
+++ b/.github/workflows/test.yml
@@ -0,0 +1,22 @@
+name: Type Check
+
+on: [push, pull_request]
+
+jobs:
+ comment-language-detector:
+ runs-on: ubuntu-latest
+ steps:
+ - name: Checkout Repository
+ uses: actions/checkout@v4
+
+ - name: Set up Go
+ uses: actions/setup-go@v5
+ with:
+ go-version: '1.21'
+
+ - name: Install typecheck
+ run: |
+ go install github.com/kubecub/typecheck@latest
+
+ - name: Run typecheck Detector
+ run: typecheck
diff --git a/.gitignore b/.gitignore
index 3b735ec..8bab4ec 100644
--- a/.gitignore
+++ b/.gitignore
@@ -18,4 +18,7 @@
# vendor/
# Go workspace file
+
+standardizer
+
go.work
diff --git a/.goreleaser.yaml b/.goreleaser.yaml
new file mode 100644
index 0000000..db2d477
--- /dev/null
+++ b/.goreleaser.yaml
@@ -0,0 +1,213 @@
+# Copyright © 2023 KubeCub open source community. All rights reserved.
+# Licensed under the MIT License (the "License");
+# you may not use this file except in compliance with the License.
+
+# The lines beneath this are called `modelines`. See `:help modeline`
+# Feel free to remove those if you don't want/use them.
+# yaml-language-server: $schema=https://goreleaser.com/static/schema.json
+# vim: set ts=2 sw=2 tw=0 fo=cnqoj
+
+snapshot:
+ name_template: "{{ incpatch .Version }}-next"
+
+report_sizes: true
+
+# metadata:
+# mod_timestamp: "{{ .CommitTimestamp }}"
+
+# Default: './dist'
+dist: _output/dist
+
+builds:
+ - binary: composite
+ id: composite
+ main: ./composite.go
+ goos:
+ - windows
+ - darwin
+ - linux
+ - freebsd
+ goarch:
+ - amd64
+ - 386
+ - arm
+ - arm64
+ goarm:
+ - 6
+ - 7
+
+archives:
+ - format: tar.gz
+ # this name template makes the OS and Arch compatible with the results of uname.
+ name_template: >-
+ {{ .ProjectName }}_
+ {{- title .Os }}_
+ {{- if eq .Arch "amd64" }}x86_64
+ {{- else if eq .Arch "386" }}i386
+ {{- else }}{{ .Arch }}{{ end }}
+ {{- if .Arm }}v{{ .Arm }}{{ end }}
+ # use zip for windows archives
+ files:
+ - LICENSE
+ - README.md
+ - CHANGELOG/*
+ - docs/*
+ # a more complete example, check the globbing deep dive below
+ - src: "*.md"
+ dst: docs
+
+ # Strip parent folders when adding files to the archive.
+ strip_parent: true
+
+ # File info.
+ # Not all fields are supported by all formats available formats.
+ #
+ # Default: copied from the source file
+ info:
+ # Templates: allowed (since v1.14)
+ owner: root
+
+ # Templates: allowed (since v1.14)
+ group: root
+
+ # Must be in time.RFC3339Nano format.
+ #
+ # Templates: allowed (since v1.14)
+ mtime: "{{ .CommitDate }}"
+
+ # File mode.
+ mode: 0644
+
+ format_overrides:
+ - goos: windows
+ format: zip
+
+nfpms:
+ - id: packages
+ builds:
+ - composite
+ # Your app's vendor.
+ vendor: kubecub
+ homepage: https://github.com/kubecub/composite
+ maintainer: kubbot
+ description: |-
+ Comment Lang Detector is a tool to detect the language of comments in code files.
+ Kubecub && cubxxw
+ license: MIT
+ formats:
+ - apk
+ - deb
+ - rpm
+ - termux.deb # Since: v1.11
+ - archlinux # Since: v1.13
+ dependencies:
+ - git
+ recommends:
+ - golang
+
+changelog:
+ sort: asc
+ use: github
+ filters:
+ exclude:
+ - "^test:"
+ - "^chore"
+ - "merge conflict"
+ - Merge pull request
+ - Merge remote-tracking branch
+ - Merge branch
+ - go mod tidy
+ groups:
+ - title: Dependency updates
+ regexp: '^.*?(feat|fix)\(deps\)!?:.+$'
+ order: 300
+ - title: "New Features"
+ regexp: '^.*?feat(\([[:word:]]+\))??!?:.+$'
+ order: 100
+ - title: "Security updates"
+ regexp: '^.*?sec(\([[:word:]]+\))??!?:.+$'
+ order: 150
+ - title: "Bug fixes"
+ regexp: '^.*?fix(\([[:word:]]+\))??!?:.+$'
+ order: 200
+ - title: "Documentation updates"
+ regexp: ^.*?doc(\([[:word:]]+\))??!?:.+$
+ order: 400
+ - title: "Build process updates"
+ regexp: ^.*?build(\([[:word:]]+\))??!?:.+$
+ order: 400
+ - title: Other work
+ order: 9999
+
+# # semantization
+# snapcrafts:
+# - name_template: "{{ .ProjectName }}_{{ .Arch }}{{ if .Arm }}v{{ .Arm }}{{ end }}"
+# summary: sync labels
+# description: |
+# sync labels
+# grade: stable
+# confinement: classic
+# publish: true
+
+# sboms:
+ # - artifacts: archive
+
+# signs:
+# - cmd: cosign
+# stdin: '{{ .Env.COSIGN_PWD }}'
+# args:
+# - "sign-blob"
+# - "--key=cosign.key"
+# - "--output-signature=${signature}"
+# - "${artifact}"
+# - "--yes" # needed on cosign 2.0.0+
+# artifacts: all
+
+# docker_signs:
+
+
+# .goreleaser.yaml
+milestones:
+ # You can have multiple milestone configs
+ -
+ # Repository for the milestone
+ # Default is extracted from the origin remote URL
+ repo:
+ owner: user
+ name: repo
+
+ # Whether to close the milestone
+ close: true
+
+ # Fail release on errors, such as missing milestone.
+ fail_on_error: false
+
+ # Name of the milestone
+ #
+ # Default: '{{ .Tag }}'
+ name_template: "Current Release"
+
+publishers:
+ - name: "fury.io"
+ ids:
+ - packages
+ dir: "{{ dir .ArtifactPath }}"
+ cmd: |
+ bash -c '
+ if [[ "{{ .Tag }}" =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
+ curl -F package=@{{ .ArtifactName }} https://{{ .Env.FURY_TOKEN }}@push.fury.io/{{ .Env.USERNAME }}/
+ else
+ echo "Skipping deployment: Non-production release detected"
+ fi'
+
+checksum:
+ name_template: "{{ .ProjectName }}_checksums.txt"
+ algorithm: sha256
+
+release:
+ footer: |
+ **Full Changelog**: https://github.com/kubecub/composite/compare/{{ .PreviousTag }}...{{ .Tag }}
+
+ ## Helping out
+
+ This release is only possible thanks to **all** the support of some **awesome people**!
\ No newline at end of file
diff --git a/README.md b/README.md
index b931ef1..e9700b0 100644
--- a/README.md
+++ b/README.md
@@ -6,7 +6,7 @@ An Github Actions Tools, Development of a Go-Based Conformity Checker for Projec
#### Project Name
-- `GoConformityChecker`
+- `GoConcomposite`
#### Functionality Description
@@ -54,7 +54,7 @@ package main
import (
"flag"
"fmt"
- "GoConformityChecker/checker"
+ "GoConcomposite/checker"
)
func main() {
diff --git a/action.yml b/action.yml
new file mode 100644
index 0000000..0f8df8e
--- /dev/null
+++ b/action.yml
@@ -0,0 +1,29 @@
+name: 'Conformity Checker for Project'
+description: 'composite action for conformity checker for project'
+author: 'cubxxw'
+runs:
+ using: 'composite'
+ steps:
+ - name: Checkout Repository
+ uses: actions/checkout@v4
+
+ - name: Set up Go
+ uses: actions/setup-go@v5
+ with:
+ go-version: '1.21'
+
+ - name: Install standardizer
+ run: go install github.com/kubecub/standardizer@latest
+ shell: bash
+
+ - name: Run standardizer Detector
+ run: standardizer
+ shell: bash
+
+branding:
+ icon: 'check-square'
+ color: 'blue'
+
+
+# homepage: 'http://github.com/kubecub'
+# repository: 'http://github.com/kubecub/standardizer'
\ No newline at end of file
diff --git a/checker/checker.go b/checker/checker.go
index b7e0bdc..bcda956 100644
--- a/checker/checker.go
+++ b/checker/checker.go
@@ -5,7 +5,7 @@ import (
"path/filepath"
"strings"
- "github.com/openimsdk/open-im-server/tools/formitychecker/config"
+ "github.com/kubecub/standardizer/config"
)
type Issue struct {
diff --git a/formitychecker.go b/composite.go
similarity index 78%
rename from formitychecker.go
rename to composite.go
index 0c4950c..4b28237 100644
--- a/formitychecker.go
+++ b/composite.go
@@ -6,8 +6,8 @@ import (
"fmt"
"os"
- "github.com/openimsdk/open-im-server/tools/formitychecker/checker"
- "github.com/openimsdk/open-im-server/tools/formitychecker/config"
+ "github.com/kubecub/standardizer/checker"
+ "github.com/kubecub/standardizer/config"
)
func main() {
@@ -21,8 +21,8 @@ func main() {
if configPath == "" {
configPath = "config.yaml"
- if _, err := os.Stat(".github/formitychecker.yaml"); err == nil {
- configPath = ".github/formitychecker.yaml"
+ if _, err := os.Stat(".github/composite.yaml"); err == nil {
+ configPath = ".github/composite.yaml"
}
}
diff --git a/config/config.go b/config/config.go
index c137a2b..b0e3e5b 100644
--- a/config/config.go
+++ b/config/config.go
@@ -3,7 +3,6 @@ package config
import (
"os"
- "github.com/openimsdk/open-im-server/tools/codescan/config"
"gopkg.in/yaml.v2"
)
@@ -40,7 +39,6 @@ type Issue struct {
}
type Checker struct {
- Config *config.Config
Summary struct {
CheckedDirectories int
CheckedFiles int
diff --git a/go.mod b/go.mod
new file mode 100644
index 0000000..ba597a5
--- /dev/null
+++ b/go.mod
@@ -0,0 +1,5 @@
+module github.com/kubecub/standardizer
+
+go 1.21
+
+require gopkg.in/yaml.v2 v2.4.0
diff --git a/go.sum b/go.sum
new file mode 100644
index 0000000..dd0bc19
--- /dev/null
+++ b/go.sum
@@ -0,0 +1,4 @@
+gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
+gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
+gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY=
+gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=