Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master' into pr/556
Browse files Browse the repository at this point in the history
  • Loading branch information
trim21 committed Dec 10, 2024
2 parents f67e767 + 40ab299 commit 98fc478
Show file tree
Hide file tree
Showing 189 changed files with 8,285 additions and 2,550 deletions.
6 changes: 4 additions & 2 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,12 @@ on:
- "**.go.json"
- "etc/Dockerfile"

env:
GOTOOLCHAIN: "local"

jobs:
docker:
runs-on: ubuntu-22.04
runs-on: ubuntu-24.04

steps:
- uses: actions/checkout@v4
Expand All @@ -46,7 +49,6 @@ jobs:
key: go-cache-122-${{ hashFiles('**/go.sum') }}-build
restore-keys: |
go-cache-122-${{ hashFiles('**/go.sum') }}-
go-cache-122-
- name: Install Task
uses: arduino/setup-task@v2
Expand Down
5 changes: 4 additions & 1 deletion .github/workflows/lint-review.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ on:
permissions:
contents: read

env:
GOTOOLCHAIN: "local"

jobs:
lint:
runs-on: ubuntu-latest
Expand All @@ -29,4 +32,4 @@ jobs:

- run: gofmt -w -s .

- uses: autofix-ci/action@ea32e3a12414e6d3183163c3424a7d7a8631ad84
- uses: autofix-ci/action@ff86a557419858bb967097bfc916833f5647fa8c
12 changes: 6 additions & 6 deletions .github/workflows/lint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,12 @@ on:
- ".golangci.yaml"
- ".github/workflows/lint.yaml"

env:
GOTOOLCHAIN: "local"

jobs:
lint:
runs-on: ubuntu-22.04
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v4

Expand All @@ -43,13 +46,10 @@ jobs:
key: go-cache-122-${{ hashFiles('**/go.sum') }}-lint
restore-keys: |
go-cache-122-${{ hashFiles('**/go.sum') }}-
go-cache-122-
- run: go get -t ./...

- name: Run linters
uses: golangci/golangci-lint-action@v4
uses: golangci/golangci-lint-action@v6
with:
version: v1.57.2
skip-pkg-cache: true
skip-build-cache: true
version: v1.61.0
13 changes: 8 additions & 5 deletions .github/workflows/release-docker.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,20 @@ on:
push:
tags:
- "v*.*.*"
branches:
- master
branches-ignore:
- "renovate/**"

permissions:
packages: write

env:
GOTOOLCHAIN: "local"

jobs:
docker:
name: "docker"

runs-on: ubuntu-22.04
runs-on: ubuntu-24.04
env:
IMAGE: "ghcr.io/${{ github.repository_owner }}/chii"

Expand All @@ -36,7 +39,6 @@ jobs:
key: go-cache-122-${{ hashFiles('**/go.sum') }}-build
restore-keys: |
go-cache-122-${{ hashFiles('**/go.sum') }}-
go-cache-122-
- run: echo "SHA=${GITHUB_REF##*/}" >> $GITHUB_ENV
if: "${{ startsWith(github.ref, 'refs/tags/') }}"
Expand All @@ -63,6 +65,7 @@ jobs:
images: ${{ env.IMAGE }}
tags: |
type=semver,event=tag,pattern=v{{version}}
type=raw,value={{commit_date 'YYYY-MM-DD'}}-{{sha}}
type=ref,event=branch
type=ref,event=branch,suffix=-${{ env.SHA }}
Expand All @@ -74,7 +77,7 @@ jobs:
password: ${{ github.token }}

- name: Build Final Docker Image
uses: docker/build-push-action@v5
uses: docker/build-push-action@v6
with:
context: ./
provenance: false
Expand Down
28 changes: 8 additions & 20 deletions .github/workflows/release-openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,21 @@ name: Release(openapi)

on:
push:
tags:
- "v*.*.*"
branches:
- master
workflow_dispatch:

env:
GOTOOLCHAIN: "local"

jobs:
openapi:
runs-on: ubuntu-22.04
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 16
node-version: 20

- run: npm ci
- run: npm run build
Expand All @@ -26,26 +29,11 @@ jobs:
- run: cp ./dist/v0.yaml ./api/open-api/v0.yaml

- name: Create Pull Request
uses: peter-evans/create-pull-request@v6
uses: peter-evans/create-pull-request@v7
with:
path: api
token: ${{ secrets.PAT }}
title: Update Openapi Specification from bangumi/server
push-to-fork: Trim21-bot/api
branch: "update-upstream"
author: "github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>"

- uses: actions/checkout@v4
with:
repository: "bangumi/dev-docs"
path: dev-docs
# - run: cp ./dist/private.yaml ./dev-docs/api.yaml
# - name: Create Pull Request
# uses: peter-evans/create-pull-request@v4
# with:
# path: dev-docs
# token: ${{ secrets.PAT }}
# title: Update Openapi Specification from bangumi/server
# push-to-fork: Trim21-bot/dev-docs
# branch: "update-upstream"
# author: "github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>"
5 changes: 4 additions & 1 deletion .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,12 @@ on:
tags:
- "v*.*.*"

env:
GOTOOLCHAIN: "local"

jobs:
github:
runs-on: ubuntu-22.04
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v4
with:
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/test-openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ on:
- "package-lock.json"
- ".github/workflows/test-openapi.yaml"

env:
GOTOOLCHAIN: "local"

jobs:
test:
runs-on: "${{ matrix.os }}"
Expand Down
10 changes: 6 additions & 4 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,15 @@ on:
- "**.go"
- "**.go.json"

env:
GOTOOLCHAIN: "local"

jobs:
test:
runs-on: ubuntu-22.04
runs-on: ubuntu-24.04
steps:
- run: git clone https://github.com/bangumi/dev-env $HOME/dev-env
- run: cd ~/dev-env && docker-compose up -d
- run: cd ~/dev-env && docker compose up -d

- uses: actions/checkout@v4
with:
Expand All @@ -53,7 +56,6 @@ jobs:
key: go-cache-122-${{ hashFiles('**/go.sum') }}-test
restore-keys: |
go-cache-122-${{ hashFiles('**/go.sum') }}-
go-cache-122-
- run: go get -t ./...

Expand All @@ -70,7 +72,7 @@ jobs:
MYSQL_DB: bangumi
REDIS_URI: "redis://:[email protected]:6379/0"

- uses: codecov/codecov-action@v4
- uses: codecov/codecov-action@v5
with:
files: coverage.out
token: ${{ secrets.CODECOV_TOKEN }} # required
31 changes: 12 additions & 19 deletions .golangci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,7 @@ run:
# If false (default) - golangci-lint acquires file lock on start.
allow-parallel-runners: true

skip-files: []

go: "1.22"
go: "1.23"

# output configuration options
output:
Expand Down Expand Up @@ -106,8 +104,6 @@ linters-settings:
- standard # Captures all standard packages if they do not match another section.
- default # Contains all imports that could not be matched to another section type.
- prefix(github.com/bangumi/server) # Groups all imports with the specified Prefix.
sectionSeparators:
- newLine

depguard:
rules:
Expand All @@ -131,7 +127,7 @@ linters-settings:
- pkg: "github.com/golang/mock"
desc: 'use "github.com/stretchr/testify/mock" and "github.com/vektra/mockery"'

gomnd:
mnd:
# settings:
# mnd:
# the list of enabled checks, see https://github.com/tommy-muehle/go-mnd/#checks for description.
Expand All @@ -141,8 +137,8 @@ linters-settings:
- operation
- return
- assign
ignored-functions: strconv\..*,time\..*,make,math\..*,strings\..*
ignored-numbers: 1,2,3,10,100,1000,10000
ignored-functions: [strconv\..*, time\..*, make, math\..*, strings\..*]
ignored-numbers: ["1", "2", "3", "10", "100", "1000", "10000"]

gosimple:
# Select the Go version to target. The default is '1.13'.
Expand Down Expand Up @@ -181,7 +177,7 @@ linters-settings:
checks: ["all"]

stylecheck:
# Select the Go version to target. The default is '1.13'.
# Select the Go version to target. The default is '1.13'.

testpackage:
# regexp pattern to skip files
Expand All @@ -203,12 +199,9 @@ linters-settings:
nlreturn:
block-size: 3

ifshort:
# Maximum length of vars declaration measured in number of lines, after which linter won't suggest using short syntax.
# Has higher priority than max-decl-chars.
max-decl-lines: 1
# Maximum length of vars declaration measured in number of characters, after which linter won't suggest using short syntax.
max-decl-chars: 30
gosec:
excludes:
- G115

tagliatelle:
# Check the struck tag name case.
Expand Down Expand Up @@ -236,8 +229,9 @@ linters:
- errchkjson
- errname
- errorlint
# https://github.com/golangci/golangci-lint/issues/5065
- exhaustive
- exportloopref
- copyloopvar
- forbidigo
- forcetypeassert
- funlen
Expand All @@ -250,9 +244,8 @@ linters:
- gocritic
- gocyclo
- godot
- goerr113
- gofmt
- gomnd
- mnd
- gomoddirectives
- gomodguard
- goprintffuncname
Expand Down Expand Up @@ -319,7 +312,7 @@ issues:
- source: 'var .* sync\.Once'
linters: [gochecknoglobals]

- linters: [goerr113, errorlint]
- linters: [err113, errorlint]
source: "if err == redis.Nil {"

# https://github.com/kunwardeep/paralleltest/issues/8
Expand Down
29 changes: 27 additions & 2 deletions Taskfile.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,15 @@ tasks:
generates:
- ./dist/chii.exe
cmds:
- go build -ldflags '-w -s' -trimpath -o dist/chii.exe main.go
- go build -trimpath -o dist/chii.exe main.go
env:
CGO_ENABLED: "0"

lint:
silent: true
desc: Run 'golangci-lint'
cmds:
- golangci-lint run --fix
- golangci-lint --path-prefix "{{ .TASKFILE_DIR }}" run --fix

test:
desc: Run mocked tests, need nothing.
Expand All @@ -44,6 +44,31 @@ tasks:
env:
CGO_ENABLED: "0"

web:
desc: Run Web Server
aliases:
- serve
- server
cmds:
- go run main.go --config config.yaml web

consumer:
desc: Run Kafka Consumer
aliases:
- canal
cmds:
- go run main.go canal --config config.yaml

openapi-test:
desc: Test OpenAPI Schema
cmds:
- npm run test

openapi:
desc: Build OpenAPI Schema
cmds:
- npm run build

bench:
desc: Run benchmark
cmds:
Expand Down
Loading

0 comments on commit 98fc478

Please sign in to comment.