Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: make fix #33

Merged
merged 13 commits into from
Jun 28, 2023
133 changes: 55 additions & 78 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
@@ -1,85 +1,62 @@
# Copyright © 2023 OpenIMSDK open source community. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# For most projects, this workflow file will not need changing; you simply need
# to commit it to your repository.
#
# You may wish to alter this file to override the set of languages analyzed,
# or to provide custom queries or build logic.
#
# ******** NOTE ********
# We have attempted to detect the languages in your repository. Please check
# the `language` matrix defined below to confirm you have the correct set of
# supported CodeQL languages.
#
name: "CodeQL"
name: "Code Scanning - Action"

on:
push:
branches: [ main ]
branches: [main]
pull_request:
# The branches below must be a subset of the branches above
branches: "*"
# schedule:
# - cron: '23 2 * * 2'
branches: [main]
schedule:
# ┌───────────── minute (0 - 59)
# │ ┌───────────── hour (0 - 23)
# │ │ ┌───────────── day of the month (1 - 31)
# │ │ │ ┌───────────── month (1 - 12 or JAN-DEC)
# │ │ │ │ ┌───────────── day of the week (0 - 6 or SUN-SAT)
# │ │ │ │ │
# │ │ │ │ │
# │ │ │ │ │
# * * * * *
- cron: '30 1 * * 0'

jobs:
# analyze:
# name: Analyze
# runs-on: ubuntu-latest
# permissions:
# actions: read
# contents: read
# security-events: write

# strategy:
# fail-fast: false
# matrix:
# language: [ 'go' ]
# # CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python' ]
# # Learn more:
# # https://docs.github.com/en/free-pro-team@latest/github/finding-security-vulnerabilities-and-errors-in-your-code/configuring-code-scanning#changing-the-languages-that-are-analyzed

# steps:
# - name: Checkout repository
# uses: actions/checkout@v2

# # Initializes the CodeQL tools for scanning.
# - name: Initialize CodeQL
# uses: github/codeql-action/init@v1
# with:
# languages: ${{ matrix.language }}
# # If you wish to specify custom queries, you can do so here or in a config file.
# # By default, queries listed here will override any specified in a config file.
# # Prefix the list here with "+" to use these queries and those in the config file.
# # queries: ./path/to/local/query, your-org/your-repo/queries@main

# # Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
# # If this step fails, then you should remove it and run the build manually (see below)
# - name: Autobuild
# uses: github/codeql-action/autobuild@v1

# # ℹ️ Command-line programs to run using the OS shell.
# # 📚 https://git.io/JvXDl

# # ✏️ If the Autobuild fails above, remove it and uncomment the following three lines
# # and modify them (or add more) to build your code if your project
# # uses a compiled language

# #- run: |
# # make bootstrap
# # make release

# - name: Perform CodeQL Analysis
# uses: github/codeql-action/analyze@v1
CodeQL-Build:
# CodeQL runs on ubuntu-latest, windows-latest, and macos-latest
runs-on: ubuntu-latest

permissions:
# required for all workflows
security-events: write

# only required for workflows in private repositories
actions: read
contents: read

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

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v2
# Override language selection by uncommenting this and choosing your languages
# with:
# languages: go, javascript, csharp, python, cpp, java, ruby

# Autobuild attempts to build any compiled languages (C/C++, C#, Go, or Java).
# If this step fails, then you should remove it and run the build manually (see below).
- name: Autobuild
uses: github/codeql-action/autobuild@v2

# ℹ️ Command-line programs to run using the OS shell.
# 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun

# ✏️ If the Autobuild fails above, remove it and uncomment the following
# three lines and modify them (or add more) to build your code if your
# project uses a compiled language

#- run: |
# make bootstrap
# make release

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v2
39 changes: 39 additions & 0 deletions .github/workflows/golangci-lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# Copyright 2020 Lingfei Kong <[email protected]>. All rights reserved.
# Use of this source code is governed by a MIT style
# license that can be found in the LICENSE file.

name: OpenKF golangci-lint
on:
push:
pull_request:
types: [opened, reopened]
jobs:
golangci:
name: lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-go@v4
with:
go-version: '1.20'
cache: false
- name: golangci-lint
uses: golangci/golangci-lint-action@v3
with:
# Require: version of golangci-lint to use in form of v1.2 or v1.2.3 or `latest` to use the latest version
version: v1.53

# Optional: working directory, useful for monorepos
working-directory: server

# Optional: golangci-lint command line arguments.
#
# Note: by default the `.golangci.yml` file should be at the root of the repository.
# The location of the configuration file can be changed by using `--config=`
# args: --timeout=30m --config=/my/path/.golangci.yml --issues-exit-code=0

# Optional: show only new issues if it's a pull request. The default value is `false`.
only-new-issues: true

# Optional:The mode to install golangci-lint. It can be 'binary' or 'goinstall'.
install-mode: "goinstall"
69 changes: 69 additions & 0 deletions .github/workflows/kubekf.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
name: OpenKF CI

on:
push:
pull_request:
types: [opened, reopened]

jobs:
openkf:
name: Test with go ${{ matrix.go_version }} on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
environment:
name: openkf

strategy:
matrix:
go_version: [1.18]
os: [ubuntu-latest]

steps:
- name: Set up Go ${{ matrix.go_version }}
uses: actions/setup-go@v2
with:
go-version: ${{ matrix.go_version }}
id: go

- name: Check out code into the Go module directory
uses: actions/checkout@v2

- name: Run go modules tidy
run: |
make tidy

- name: Generate all necessary files, such as error code files
run: |
make generate

- name: Check syntax and styling of go sources
run: |
set -e
make lint

- name: Run unit test and get test coverage
run: |
make cover

- name: Build source code for host platform
run: |
make build

- name: Collect Test Coverage File
uses: actions/[email protected]
with:
name: main-output
path: _output/tmp/coverage.out

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1

- name: Login to DockerHub
uses: docker/login-action@v1
with:
username: ${{ env.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Build docker images for host arch and push images to registry
run: |
set -e
make docker-push
21 changes: 6 additions & 15 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ run:
- util
- .*~
- api/swagger/docs
- server/docs

# default is true. Enables skipping of directories:
# vendor$, third_party$, testdata$, examples$, Godeps$, builtin$
Expand Down Expand Up @@ -175,7 +176,7 @@ linters-settings:
# put imports beginning with prefix after 3rd-party packages;
# only support one prefix
# if not set, use goimports.local-prefixes
prefix: github.com/marmotedu/iam
prefix: github.com/OpenIMSDK/OpenKF
gocognit:
# minimal code complexity to report, 30 by default (but we recommend 10-20)
min-complexity: 30
Expand Down Expand Up @@ -294,8 +295,8 @@ linters-settings:
simplify: true

gofumpt:
# Select the Go version to target. The default is `1.15`.
lang-version: "1.15"
# Select the Go version to target. The default is `1.18`.
lang-version: "1.18"

# Choose whether or not to use the extra rules that are disabled
# by default
Expand Down Expand Up @@ -332,7 +333,7 @@ linters-settings:
goimports:
# put imports beginning with prefix after 3rd-party packages;
# it's a comma-separated list of prefixes
local-prefixes: github.com/marmotedu/iam
local-prefixes: github.com/OpenIMSDK/OpenKF
golint:
# minimal confidence for issues, default is 0.8
min-confidence: 0.9
Expand All @@ -350,9 +351,6 @@ linters-settings:
# List of allowed `replace` directives. Default is empty.
replace-allow-list:
- google.golang.org/grpc
- github.com/marmotedu/api
- github.com/marmotedu/component-base
- github.com/marmotedu/marmotedu-sdk-go

# Allow to not explain why the version has been retracted in the `retract` directives. Default is false.
retract-allow-no-explanation: false
Expand All @@ -373,11 +371,6 @@ linters-settings:
- go.uber.org
- go.etcd.io
blocked:
modules:
- github.com/pkg/errors:
recommendations:
- github.com/marmotedu/errors
reason: "`github.com/marmotedu/errors` is the log package used by marmotedu projects."
versions:
- github.com/MakeNowJust/heredoc:
version: "> 2.0.9"
Expand Down Expand Up @@ -416,7 +409,7 @@ linters-settings:

gosimple:
# Select the Go version to target. The default is '1.13'.
go: "1.15"
go: "1.18"
# https://staticcheck.io/docs/options#checks
checks: [ "all" ]

Expand Down Expand Up @@ -473,8 +466,6 @@ linters-settings:
alias: $1$2
# using `jwt` alias for `github.com/appleboy/gin-jwt/v2` package
jwt: github.com/appleboy/gin-jwt/v2
# using `metav1` alias for `github.com/marmotedu/component-base/pkg/meta/v1` package
metav1: github.com/marmotedu/component-base/pkg/meta/v1

ireturn:
# ireturn allows using `allow` and `reject` settings at the same time.
Expand Down
Loading