-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improve actions, linting and documentation
- Loading branch information
1 parent
0db7820
commit a851887
Showing
16 changed files
with
469 additions
and
76 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -57,19 +57,6 @@ jobs: | |
echo "repo-name=${{ github.event.client_payload.github.payload.repository.full_name }}" >> $GITHUB_OUTPUT | ||
fi | ||
# Since we are using a repository-dispatch event, we have to explicitly set a run check. We initialize it to a "pending" state. | ||
# - uses: octokit/[email protected] | ||
# name: "Initialize run check to 'pending (For PR-only)" | ||
# with: | ||
# route: POST /repos/${{ github.repository }}/statuses/${{ steps.configure.outputs.commit-ref }} | ||
# state: "pending" | ||
# description: "Component build status" | ||
# context: "Components building" | ||
# target_url: "https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}" | ||
# env: | ||
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
# if: ${{ github.event_name == 'repository_dispatch' }} | ||
|
||
build: | ||
permissions: | ||
contents: write | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
name: Check Generated Helm documentation | ||
on: | ||
pull_request: | ||
types: | ||
- opened | ||
- reopened | ||
- synchronize | ||
|
||
jobs: | ||
generated-helm-documentation: | ||
name: Check Helm Documentation | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
with: | ||
ref: "${{ github.event.pull_request.head.sha }}" | ||
persist-credentials: false | ||
|
||
- name: Setup helm-docs | ||
run: | | ||
version=1.11.0 | ||
arch=x86_64 | ||
curl -LO https://github.com/norwoodj/helm-docs/releases/download/v${version}/helm-docs_${version}_linux_${arch}.tar.gz | ||
tar -zxvf helm-docs_${version}_linux_${arch}.tar.gz | ||
sudo mv helm-docs /usr/local | ||
- name: Run the automatic generation of helm-docs | ||
working-directory: ./deployments/node | ||
run: | | ||
/usr/local/helm-docs -o new_README.md -t README.gotmpl | ||
- name: Gather the helm-docs differences | ||
id: helm-docs-diff | ||
working-directory: ./deployments/node | ||
run: | | ||
output=$(diff README.md new_README.md | head -n 100 ) | ||
exit_code=$([ "${output}" ] && echo 1 || echo 0) | ||
# Required to correctly manage multi-line outputs | ||
output="${output//'%'/'%25'}" | ||
output="${output//$'\n'/'%0A'}" | ||
output="${output//$'\r'/'%0D'}" | ||
# Store the different as step output | ||
echo "diff=${output}" >> $GITHUB_OUTPUT | ||
# Trigger a failure in case the diff is not empty | ||
exit ${exit_code} | ||
- name: Log the error if the diff is not empty (in case the comment cannot be generated) | ||
run: | | ||
echo "The Helm README.md appear to be out-of-date." | ||
echo | ||
echo "Here it is an excerpt of the diff:" | ||
echo "${{ steps.helm-docs-diff.outputs.diff }}" | ||
if: failure() | ||
|
||
- name: Issue a comment in case the diff is not empty | ||
uses: peter-evans/create-or-update-comment@v3 | ||
with: | ||
token: ${{ secrets.CI_TOKEN }} | ||
issue-number: ${{ github.event.pull_request.number }} | ||
body: | | ||
The Helm README.md appears to be out-of-date. | ||
Please, run | ||
``` | ||
make docs | ||
``` | ||
<details> | ||
<summary>Here it is an excerpt of the diff:</summary> | ||
```diff | ||
${{ steps.helm-docs-diff.outputs.diff }} | ||
``` | ||
</details> | ||
reactions: confused | ||
if: | | ||
github.event_name != 'push' && failure() && | ||
github.event.pull_request.head.repo.full_name == github.repository |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,125 @@ | ||
name: Linting | ||
on: | ||
pull_request: | ||
|
||
jobs: | ||
golangci: | ||
name: Lint golang files | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
with: | ||
ref: ${{ github.event.pull_request.head.sha }} | ||
repository: ${{github.event.pull_request.head.repo.full_name}} | ||
persist-credentials: false | ||
|
||
- name: Setup Go | ||
uses: actions/setup-go@v4 | ||
with: | ||
go-version: "1.21" | ||
cache: false | ||
|
||
- name: golangci-lint | ||
uses: golangci/[email protected] | ||
with: | ||
only-new-issues: true | ||
version: v1.54.2 | ||
args: --timeout=900s | ||
|
||
gomodtidy: | ||
name: Enforce go.mod tidiness | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
with: | ||
ref: "${{ github.event.pull_request.head.sha }}" | ||
repository: ${{github.event.pull_request.head.repo.full_name}} | ||
persist-credentials: false | ||
|
||
- name: Setup Go | ||
uses: actions/setup-go@v4 | ||
with: | ||
go-version: "1.21" | ||
|
||
- name: Execute go mod tidy and check the outcome | ||
working-directory: ./ | ||
run: | | ||
go mod tidy | ||
exit_code=$(git diff --exit-code) | ||
exit ${exit_code} | ||
- name: Issue a comment in case the of failure | ||
uses: peter-evans/create-or-update-comment@v3 | ||
with: | ||
token: ${{ secrets.CI_TOKEN }} | ||
issue-number: ${{ github.event.pull_request.number }} | ||
body: | | ||
The `go.mod` and/or `go.sum` files appear not to be correctly tidied. | ||
Please, rerun `go mod tidy` to fix the issues. | ||
reactions: confused | ||
if: | | ||
failure() && github.event.pull_request.head.repo.full_name == github.repository | ||
shelllint: | ||
name: Lint bash files | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v4 | ||
with: | ||
ref: "${{ github.event.pull_request.head.sha }}" | ||
repository: ${{github.event.pull_request.head.repo.full_name}} | ||
persist-credentials: false | ||
- name: Run Shellcheck | ||
uses: ludeeus/[email protected] | ||
env: | ||
# Allow 'source' outside of FILES | ||
SHELLCHECK_OPTS: -x | ||
|
||
markdownlint: | ||
name: Lint markdown files | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Check out code | ||
uses: actions/checkout@v4 | ||
with: | ||
ref: "${{ github.event.pull_request.head.sha }}" | ||
repository: ${{github.event.pull_request.head.repo.full_name}} | ||
persist-credentials: false | ||
- name: Lint markdown files | ||
uses: avto-dev/markdown-lint@v1 | ||
with: | ||
config: ".markdownlint.yml" | ||
args: "**/*.md" | ||
ignore: .github/ISSUE_TEMPLATE/*.md | ||
|
||
doclint: | ||
name: Lint documentation files | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Check out code | ||
uses: actions/checkout@v4 | ||
with: | ||
ref: "${{ github.event.pull_request.head.sha }}" | ||
repository: ${{github.event.pull_request.head.repo.full_name}} | ||
persist-credentials: false | ||
- name: Setup python3 | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: "3.x" | ||
- name: Install python3 dependencies | ||
working-directory: ./docs | ||
run: | | ||
pip3 install -r requirements.txt | ||
- name: Build documentation | ||
working-directory: ./docs | ||
run: | | ||
make dummy | ||
- name: Check external links | ||
working-directory: ./docs | ||
run: | | ||
make linkcheck |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,154 @@ | ||
run: | ||
timeout: 10m | ||
skip-files: | ||
- "zz_generated.*.go" | ||
skip-dirs: | ||
- "pkg/client" | ||
|
||
linters-settings: | ||
exhaustive: | ||
check-generated: false | ||
default-signifies-exhaustive: true | ||
|
||
goheader: | ||
values: | ||
const: | ||
AUTHORS: FLUIDOS Project | ||
template: |- | ||
Copyright 2019-{{ YEAR }} {{ AUTHORS }} | ||
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. | ||
lll: | ||
line-length: 150 | ||
gomodguard: | ||
blocked: | ||
modules: | ||
- github.com/go-logr/logr: | ||
recommendations: | ||
- k8s.io/klog/v2 | ||
gci: | ||
sections: | ||
- 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/fluidos-project/node) # Groups all imports with the specified Prefix. | ||
goconst: | ||
min-len: 2 | ||
min-occurrences: 2 | ||
gocritic: | ||
enabled-tags: | ||
- diagnostic | ||
- experimental | ||
- opinionated | ||
- performance | ||
- style | ||
disabled-checks: | ||
# Conflicts with govet check-shadowing | ||
- sloppyReassign | ||
goimports: | ||
local-prefixes: github.com/fluidos-project/node | ||
govet: | ||
check-shadowing: true | ||
misspell: | ||
locale: US | ||
nolintlint: | ||
allow-leading-space: true # don't require machine-readable nolint directives (i.e. with no leading space) | ||
allow-unused: false # report any unused nolint directives | ||
require-explanation: true # require an explanation for nolint directives | ||
require-specific: true # require nolint directives to be specific about which linter is being skipped | ||
dupl: | ||
threshold: 300 | ||
|
||
linters: | ||
disable-all: true | ||
enable: | ||
- asciicheck | ||
- bodyclose | ||
# - depguard | ||
- dogsled | ||
- dupl | ||
- errcheck | ||
- errorlint | ||
- exhaustive | ||
- exportloopref | ||
# - funlen | ||
# - gochecknoglobals | ||
# - gochecknoinits | ||
# - gocognit | ||
- gci | ||
- goconst | ||
- gocritic | ||
- gocyclo | ||
- godot | ||
# - godox | ||
# - goerr113 | ||
- gofmt | ||
- goheader | ||
- goimports | ||
- gomodguard | ||
# - gomnd | ||
- goprintffuncname | ||
- gosec | ||
- gosimple | ||
- govet | ||
- ineffassign | ||
- lll | ||
# - maligned | ||
- misspell | ||
- nakedret | ||
# - nestif | ||
- noctx | ||
- nolintlint | ||
# - prealloc | ||
- revive | ||
- rowserrcheck | ||
- staticcheck | ||
- stylecheck | ||
# - testpackage | ||
- typecheck | ||
- unconvert | ||
- unparam | ||
- unused | ||
- whitespace | ||
# - wsl | ||
|
||
issues: | ||
#fix: true | ||
|
||
max-issues-per-linter: 0 | ||
max-same-issues: 0 | ||
|
||
# Disable the default exclude patterns (as they disable the mandatory comments) | ||
exclude-use-default: false | ||
exclude: | ||
# errcheck: Almost all programs ignore errors on these functions and in most cases it's ok | ||
- Error return value of .((os\.)?std(out|err)\..*|.*Close|.*Flush|os\.Remove(All)?|.*printf?|os\.(Un)?Setenv). is not checked | ||
|
||
exclude-rules: | ||
- linters: | ||
- govet | ||
text: 'declaration of "(err|ctx)" shadows declaration at' | ||
- linters: | ||
- gosec | ||
# Disable the check to test that HTTP clients are not using an insecure TLS connection. | ||
# We need it to contact the remote authentication services exposing a self-signed certificate | ||
text: TLS InsecureSkipVerify set true. | ||
- linters: | ||
- errorlint | ||
# Disable the check to test errors type assertion on switches. | ||
text: type switch on error will fail on wrapped errors. Use errors.As to check for specific errors | ||
|
||
# Exclude the following linters from running on tests files. | ||
- path: _test\.go | ||
linters: | ||
- whitespace |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
default: true | ||
line-length: false | ||
no-inline-html: false | ||
no-duplicate-header: | ||
siblings_only: true |
Oops, something went wrong.