mirror of
https://github.com/d0zingcat/gocryptotrader.git
synced 2026-05-14 07:26:47 +00:00
* tests: Replace !errors.Is(err, target) with testify equivalents * codebase: Manual !errors.Is(err, target) replacements * typo: Replace errMisMatchedEvent with errMismatchedEvent * tests: Enhance error messages for better output * tests: Refactor error assertions in various test cases to use require and improve clarity * misc linter: Fix assert should wording * tests: Simplify assertions in TestCreateSignals for clarity and conciseness * tests: Enhance assertion message in TestCreateSignals
54 lines
2.2 KiB
YAML
54 lines
2.2 KiB
YAML
name: misc
|
|
on: [push, pull_request]
|
|
jobs:
|
|
lint:
|
|
name: miscellaneous checks
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
- name: Check for currency.NewPair(BTC, USD) used instead of currency.NewBTCUSD
|
|
run: |
|
|
grep -r -n --color=always -E "currency.NewPair\(currency.BTC, currency.USDT?\)" * || exit 0
|
|
echo "::error::Replace currency.NewPair(BTC, USD*) with currency.NewBTCUSD*()"
|
|
exit 1
|
|
|
|
- name: Check for missing postfix `f` format func variant for testify assertions
|
|
run: |
|
|
grep -r -n -P --include="*.go" --color=always '(assert|require)\.[A-Za-z_]\w*?(?<!f)\((?:(?!fmt\.Sprintf).)*%.*' || exit 0
|
|
echo "::error::Replace func with the `…f` func variant (e.g. Equalf, Errorf)"
|
|
exit 1
|
|
|
|
- name: Check for quoted and backticked %s usage in format specifier strings
|
|
run: |
|
|
grep -r -n --include='*.go' --color=always -E "[\`']%s[\`']" . || exit 0
|
|
echo "::error::Replace '%s' or `%s` format specifier with %q"
|
|
exit 1
|
|
|
|
- name: Check for testify `require… "should"` and `assert… "must"` message consistency
|
|
run: |
|
|
exit_code=0
|
|
|
|
echo "Checking for 'should' in require messages..."
|
|
grep -r -n --include="*.go" --color=always -E 'require\.[A-Za-z0-9_]+.*"[^"]*should[^"]*"' . && exit_code=1 || true
|
|
|
|
echo "Checking for 'must' in assert messages..."
|
|
grep -r -n --include="*.go" --color=always -E 'assert\.[A-Za-z0-9_]+.*"[^"]*must[^"]*"' . && exit_code=1 || true
|
|
|
|
if [ $exit_code -eq 1 ]; then
|
|
echo "::error::Replace \"should\" in require messages and \"must\" in assert messages"
|
|
exit 1
|
|
fi
|
|
|
|
- name: Check for errors.Is(err, nil) usage
|
|
run: |
|
|
grep -r -n --include='*_test.go' --color=always -E "errors.Is\([^,]+, nil" . || exit 0
|
|
echo "::error::Replace errors.Is(err, nil) with testify equivalents"
|
|
exit 1
|
|
|
|
- name: Check for !errors.Is(err, target) usage
|
|
run: |
|
|
grep -r -n --include='*_test.go' --color=always -P '!errors\.Is\(\s*[^,]+\s*,\s*[^)]+\s*\)' . || exit 0
|
|
echo "::error::Replace !errors.Is(err, target) with testify equivalents"
|
|
exit 1
|
|
|