diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 7669c73a..f6ebe67b 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -38,7 +38,7 @@ jobs: pull-requests: write runs-on: ubuntu-22.04 steps: - - uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4 + - uses: actions/checkout@v4.1.4 - uses: ./tools/github-actions/setup-deps - name: API Test env: @@ -65,7 +65,7 @@ jobs: Build: runs-on: ubuntu-22.04 steps: - - uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4 + - uses: actions/checkout@v4.1.4 - uses: ./tools/github-actions/setup-deps - name: Run GoReleaser uses: goreleaser/goreleaser-action@v6 @@ -80,7 +80,7 @@ jobs: E2E: runs-on: ubuntu-22.04 steps: - - uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4 + - uses: actions/checkout@v4.1.4 - uses: ./tools/github-actions/setup-deps - name: Set output id: vars diff --git a/.github/workflows/check.yaml b/.github/workflows/check.yaml new file mode 100644 index 00000000..3fc5a0ff --- /dev/null +++ b/.github/workflows/check.yaml @@ -0,0 +1,39 @@ +name: File Lint Check + +on: + push: + branches: + - "master" + pull_request: + branches: + - "master" + +permissions: + contents: read + +jobs: + files-lint: + runs-on: ubuntu-22.04 + steps: + - uses: actions/checkout@v4.1.6 + - uses: ./tools/github-actions/setup-deps + - name: Setup Node + uses: actions/setup-node@v4 + with: + node-version: "21" + + - name: Markdown Lint check + run: | + make lint.markdown + + - name: Yaml Lint check + run: | + make lint.yaml + + - name: Check License + run: | + make lint.checklicense + + - name: Check Code Spell + run: | + make lint.codespell diff --git a/.github/workflows/docs.yaml b/.github/workflows/docs.yaml index cda00e8e..3b4c386b 100644 --- a/.github/workflows/docs.yaml +++ b/.github/workflows/docs.yaml @@ -14,36 +14,13 @@ permissions: contents: read jobs: - docs-lint: - runs-on: ubuntu-22.04 - steps: - - name: Check out code - uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6 - with: - ref: ${{ github.event.pull_request.head.sha }} - - - uses: ./tools/github-actions/setup-deps - - - name: Run markdown linter - uses: nosborn/github-action-markdown-cli@9b5e871c11cc0649c5ac2526af22e23525fa344d # v3.3.0 - with: - files: docs/site/content/* - config_file: ".github/markdown_lint_config.json" - - - name: Install linkinator - run: npm install -g linkinator@6.0.4 - - - name: Check links - run: make docs # docs-check-links - docs-build: runs-on: ubuntu-latest - needs: docs-lint permissions: contents: write steps: - name: Git checkout - uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6 + uses: actions/checkout@v4.1.6 with: submodules: true ref: ${{ github.event.pull_request.head.sha }} @@ -51,13 +28,13 @@ jobs: - uses: ./tools/github-actions/setup-deps - name: Setup Hugo - uses: peaceiris/actions-hugo@75d2e84710de30f6ff7268e08f310b60ef14033f # v3.0.0 + uses: peaceiris/actions-hugo@v3.0.0 with: hugo-version: "latest" extended: true - name: Setup Node - uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.1.0 + uses: actions/setup-node@v4.1.0 with: node-version: "18" @@ -65,11 +42,13 @@ jobs: run: | cp docs/api-testing-schema.json docs/site/static/api-testing-schema.json cp docs/api-testing-mock-schema.json docs/site/static/api-testing-mock-schema.json - make docs # docs-check-links + make lint.checklinks + make lint.markdown + make docs # Upload docs for GitHub Pages - name: Upload GitHub Pages artifact - uses: actions/upload-pages-artifact@56afc609e74202658d3ffba0e8f6dda462b719fa # v3.0.1 + uses: actions/upload-pages-artifact@v3.0.1 with: # Path of the directory containing the static assets. path: docs/site/public @@ -96,4 +75,4 @@ jobs: steps: - name: Deploy to GitHub Pages id: deployment - uses: actions/deploy-pages@d6db90164ac5ed86f2b6aed7e0febac5b3c0c03e # v4.0.5 + uses: actions/deploy-pages@v4.0.5 diff --git a/.github/workflows/license-check.yaml b/.github/workflows/license-check.yaml deleted file mode 100644 index 751f36e6..00000000 --- a/.github/workflows/license-check.yaml +++ /dev/null @@ -1,11 +0,0 @@ -name: License check - -on: - - pull_request - -jobs: - Test: - runs-on: ubuntu-20.04 - steps: - - name: Check License Header - uses: apache/skywalking-eyes@v0.4.0 diff --git a/.licenserc.yaml b/.licenserc.yaml deleted file mode 100644 index 0e67c6eb..00000000 --- a/.licenserc.yaml +++ /dev/null @@ -1,13 +0,0 @@ -header: - license: - spdx-id: Apache License - copyright-owner: API Testing Authors - - paths-ignore: - - 'dist' - - 'licenses' - - '**/*.md' - - 'LICENSE' - - 'NOTICE' - - comment: on-failure diff --git a/checklink_config.json b/checklink_config.json index 2d836174..1c9308e0 100644 --- a/checklink_config.json +++ b/checklink_config.json @@ -7,4 +7,4 @@ "aliveStatusCodes": [ 200 ] -} \ No newline at end of file +} diff --git a/tools/linter/codespell/.codespell.ignorewords b/tools/linter/codespell/.codespell.ignorewords new file mode 100644 index 00000000..37514b40 --- /dev/null +++ b/tools/linter/codespell/.codespell.ignorewords @@ -0,0 +1,5 @@ +keypair +keypairs +als +requestor +immediatedly diff --git a/tools/linter/codespell/.codespell.skip b/tools/linter/codespell/.codespell.skip new file mode 100644 index 00000000..1b469f96 --- /dev/null +++ b/tools/linter/codespell/.codespell.skip @@ -0,0 +1,14 @@ +.git +.idea +*.png +*.woff +*.woff2 +*.eot +*.ttf +*.jpg +*.ico +*.svg +./charts +*.js +./site/public/* +./site/node_modules/* diff --git a/tools/linter/license/.licenserc.yaml b/tools/linter/license/.licenserc.yaml new file mode 100644 index 00000000..859321e1 --- /dev/null +++ b/tools/linter/license/.licenserc.yaml @@ -0,0 +1,26 @@ +header: + license: + spdx-id: Apache License + copyright-owner: API Testing Authors + + paths: + - "**" + + paths-ignore: + - "dist" + - "licenses" + - "**/*.md" + - "LICENSE" + - "NOTICE" + + comment: on-failure + + language: + Go: + extensions: + - ".go" + comment_style_id: SlashAsterisk + + dependency: + files: + - ../../../go.mod diff --git a/.github/markdown_lint_config.json b/tools/linter/markdownlint/markdown_lint_config.json similarity index 100% rename from .github/markdown_lint_config.json rename to tools/linter/markdownlint/markdown_lint_config.json diff --git a/tools/make/docs.mk b/tools/make/docs.mk index 759a8016..f5ff5dfb 100644 --- a/tools/make/docs.mk +++ b/tools/make/docs.mk @@ -4,6 +4,8 @@ DOCS_OUTPUT_DIR := site/public +LINKINATOR_IGNORE := "github.com githubusercontent.com github.com _print v0.0.1" + ##@ Docs .PHONY: docs @@ -12,19 +14,6 @@ docs: docs.clean cd $(ROOT_DIR)/docs/site && npm install cd $(ROOT_DIR)/docs/site && npm run build:production -.PHONY: check-links -check-links: ## Check for broken links in the docs. -check-links: docs-check-links - - -.PHONY: docs-check-links -docs-check-links: - @$(LOG_TARGET) - # Check for broken links - npm install -g linkinator@6.0.4 - # https://github.com/JustinBeckwith/linkinator?tab=readme-ov-file#command-usage - linkinator docs/site/public -r --concurrency 25 -s "github.com _print v0.0.1" - # Docs site, make by hexo. .PHONY: docs-serve diff --git a/tools/make/golang.mk b/tools/make/golang.mk index 5cc6d5c4..b27991fd 100644 --- a/tools/make/golang.mk +++ b/tools/make/golang.mk @@ -68,12 +68,22 @@ go.clean: ## Clean the building output files @$(LOG_TARGET) rm -rf $(OUTPUT_DIR) +>PHONY: go.mod.vet +go.mod.vet: + @$(LOG_TARGET) + @go vet ./... + +>PHONY: go.mod.fmt +go.mod.fmt: + @$(LOG_TARGET) + @go fmt ./... + .PHONY: go.mod.lint lint: go.mod.lint go.mod.lint: @$(LOG_TARGET) @go mod tidy -compat=$(GO_VERSION) - @go fmt ./... + @make go.mod.fmt @if test -n "$$(git status -s -- go.mod go.sum)"; then \ git diff --exit-code go.mod; \ git diff --exit-code go.sum; \ diff --git a/tools/make/lint.mk b/tools/make/lint.mk index 40834860..854373ca 100644 --- a/tools/make/lint.mk +++ b/tools/make/lint.mk @@ -4,8 +4,6 @@ ##@ Lint -GITHUB_ACTION ?= - .PHONY: lint lint: ## Run all linter of code sources, including golint, yamllint. @@ -14,8 +12,6 @@ lint: ## Run all linter of code sources, including golint, yamllint. .PHONY: lint-deps lint-deps: ## Everything necessary to lint -GOLANGCI_LINT_FLAGS ?= $(if $(GITHUB_ACTION),--out-format=github-actions) - .PHONY: lint.golint lint: lint.golint lint-deps: $(tools/golangci-lint) @@ -29,3 +25,39 @@ lint-deps: $(tools/yamllint) lint.yamllint: $(tools/yamllint) @$(LOG_TARGET) $(tools/yamllint) --config-file=tools/linter/yamllint/.yamllint $$(git ls-files :*.yml :*.yaml | xargs -L1 dirname | sort -u) + +.PHONY: lint.markdown +lint: lint.markdown +lint-deps: $(tools/markdownlint) +lint.markdown: $(tools/markdownlint) + @$(LOG_TARGET) + $(tools/markdownlint) -c tools/linter/markdownlint/markdown_lint_config.json docs/site/content/** + +.PHONY: lint.markdown.fix +lint: lint.markdown.fix +lint-deps: $(tools/markdownlint) +lint.markdown.fix: $(tools/markdownlint) + @$(LOG_TARGET) + $(tools/markdownlint) -c tools/linter/markdownlint/markdown_lint_config.json --fix docs/site/content/** + +.PHONY: lint.codespell +lint: lint.codespell +lint-deps: $(tools/codespell) +lint.codespell: CODESPELL_SKIP := $(shell cat tools/linter/codespell/.codespell.skip | tr \\n ',') +lint.codespell: $(tools/codespell) + @$(LOG_TARGET) + $(tools/codespell) --skip $(CODESPELL_SKIP) --ignore-words tools/linter/codespell/.codespell.ignorewords --check-filenames + +.PHONY: lint.checklinks +lint: lint.checklinks +lint-deps: $(tools/linkinator) +lint.checklinks: $(tools/linkinator) # Check for broken links in the docs + @$(LOG_TARGET) + $(tools/linkinator) docs/site/public/ -r --concurrency 25 --skip $(LINKINATOR_IGNORE) + +.PHONY: lint.checklicense +lint: lint.checklicense +lint-deps: $(tools/skywalking-eyes) +lint.checklicense: $(tools/skywalking-eyes) # Check for broken links in the docs + @$(LOG_TARGET) + $(tools/skywalking-eyes) -c tools/linter/license/.licenserc.yaml header check diff --git a/tools/make/tools.mk b/tools/make/tools.mk index d1ba730e..355282fb 100644 --- a/tools/make/tools.mk +++ b/tools/make/tools.mk @@ -9,13 +9,17 @@ tools/protoc-gen-go = $(tools.bindir)/protoc-gen-go tools/protoc-gen-go-grpc = $(tools.bindir)/protoc-gen-go-grpc tools/goreleaser = $(tools.bindir)/goreleaser tools/buf = $(tools.bindir)/buf +tools/skywalking-eyes = $(tools.bindir)/skywalking-eyes $(tools.bindir)/%: $(tools.srcdir)/%/pin.go $(tools.srcdir)/%/go.mod + mkdir -p $(@D) cd $(