Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions .github/workflows/linting.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
---
name: "Lint"

"on":
pull_request:

jobs:
lint:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Run ShellCheck
uses: ludeeus/action-shellcheck@2.0.0
6 changes: 4 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,15 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python: ['3.9', '3.10', '3.11']
python: ["3.9", "3.10", "3.11"]

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

- name: Run ShellCheck
uses: ludeeus/action-shellcheck@2.0.0

- name: Set up Python ${{ matrix.python }}
uses: actions/setup-python@v3
with:
Expand All @@ -38,4 +41,3 @@ jobs:
run: |
python -m pip install coveralls
coveralls --service=github

33 changes: 17 additions & 16 deletions check.sh
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
#!/bin/bash
#shellcheck disable=SC2312

# This script handles some basic QA checks on the source

NOPOST=$1
LIBRARY_NAME=`hatch project metadata name`
LIBRARY_VERSION=`hatch version | awk -F "." '{print $1"."$2"."$3}'`
POST_VERSION=`hatch version | awk -F "." '{print substr($4,0,length($4))}'`
LIBRARY_NAME=$(hatch project metadata name)
LIBRARY_VERSION=$(hatch version | awk -F "." '{print $1"."$2"."$3}')
POST_VERSION=$(hatch version | awk -F "." '{print substr($4,0,length($4))}')
TERM=${TERM:="xterm-256color"}

success() {
Expand All @@ -21,27 +22,26 @@ warning() {
}

while [[ $# -gt 0 ]]; do
K="$1"
case $K in
K="${1}"
case ${K} in
-p|--nopost)
NOPOST=true
shift
;;
*)
if [[ $1 == -* ]]; then
printf "Unrecognised option: $1\n";
printf "Unrecognised option: %s\n" "${1}"
exit 1
fi
POSITIONAL_ARGS+=("$1")
shift
esac
done

inform "Checking $LIBRARY_NAME $LIBRARY_VERSION\n"

inform "Checking ${LIBRARY_NAME} ${LIBRARY_VERSION}\n"
inform "Checking for trailing whitespace..."
grep -IUrn --color "[[:blank:]]$" --exclude-dir=dist --exclude-dir=.tox --exclude-dir=.git --exclude=PKG-INFO
if [[ $? -eq 0 ]]; then

if grep -IUrn --color "[[:blank:]]$" --exclude-dir=dist --exclude-dir=.tox --exclude-dir=.git --exclude=PKG-INFO; then
warning "Trailing whitespace found!"
exit 1
else
Expand All @@ -50,8 +50,8 @@ fi
printf "\n"

inform "Checking for DOS line-endings..."
grep -lIUrn --color $'\r' --exclude-dir=dist --exclude-dir=.tox --exclude-dir=.git --exclude=Makefile
if [[ $? -eq 0 ]]; then

if grep -lIUrn --color $'\r' --exclude-dir=dist --exclude-dir=.tox --exclude-dir=.git --exclude=Makefile; then
warning "DOS line-endings found!"
exit 1
else
Expand All @@ -60,7 +60,8 @@ fi
printf "\n"

inform "Checking CHANGELOG.md..."
cat CHANGELOG.md | grep ^${LIBRARY_VERSION} > /dev/null 2>&1
cat CHANGELOG.md | grep ^"${LIBRARY_VERSION}" > /dev/null 2>&1

if [[ $? -eq 1 ]]; then
warning "Changes missing for version ${LIBRARY_VERSION}! Please update CHANGELOG.md."
exit 1
Expand All @@ -76,10 +77,10 @@ if [[ $? -eq 1 ]]; then
fi
printf "\n"

if [[ $NOPOST ]]; then
if [[ ${NOPOST} ]]; then
inform "Checking for .postN on library version..."
if [[ "$POST_VERSION" != "" ]]; then
warning "Found .$POST_VERSION on library version."
if [[ "${POST_VERSION}" != "" ]]; then
warning "Found .${POST_VERSION} on library version."
inform "Please only use these for testpypi releases."
exit 1
else
Expand Down
Loading