Skip to content

Commit 4c205f5

Browse files
authored
Merge pull request #6 from pimoroni/repackage
Bookworm/Pi5 Compatibility: Upgrade to latest boilerplate
2 parents 1236fc7 + db73ac4 commit 4c205f5

File tree

11 files changed

+268
-120
lines changed

11 files changed

+268
-120
lines changed

.github/workflows/build.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,10 @@ jobs:
1919

2020
steps:
2121
- name: Checkout Code
22-
uses: actions/checkout@v3
22+
uses: actions/checkout@v4
2323

2424
- name: Set up Python ${{ matrix.python }}
25-
uses: actions/setup-python@v3
25+
uses: actions/setup-python@v5
2626
with:
2727
python-version: ${{ matrix.python }}
2828

@@ -35,7 +35,7 @@ jobs:
3535
make build
3636
3737
- name: Upload Packages
38-
uses: actions/upload-artifact@v3
38+
uses: actions/upload-artifact@v4
3939
with:
4040
name: ${{ env.RELEASE_FILE }}
4141
path: dist/

.github/workflows/qa.yml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,15 @@ jobs:
1010
test:
1111
name: linting & spelling
1212
runs-on: ubuntu-latest
13-
1413
env:
1514
TERM: xterm-256color
1615

1716
steps:
1817
- name: Checkout Code
19-
uses: actions/checkout@v2
18+
uses: actions/checkout@v4
2019

2120
- name: Set up Python '3,11'
22-
uses: actions/setup-python@v3
21+
uses: actions/setup-python@v5
2322
with:
2423
python-version: '3.11'
2524

@@ -34,3 +33,7 @@ jobs:
3433
- name: Run Code Checks
3534
run: |
3635
make check
36+
37+
- name: Run Bash Code Checks
38+
run: |
39+
make shellcheck

.github/workflows/test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ jobs:
1919
uses: actions/checkout@v3
2020

2121
- name: Set up Python ${{ matrix.python }}
22-
uses: actions/setup-python@v3
22+
uses: actions/setup-python@v5
2323
with:
2424
python-version: ${{ matrix.python }}
2525

Makefile

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@ endif
2222
@echo "deploy: build and upload to PyPi"
2323
@echo "tag: tag the repository with the current version\n"
2424

25+
version:
26+
@hatch version
27+
2528
install:
2629
./install.sh --unstable
2730

@@ -30,11 +33,14 @@ uninstall:
3033

3134
dev-deps:
3235
python3 -m pip install -r requirements-dev.txt
33-
sudo apt install dos2unix
36+
sudo apt install dos2unix shellcheck
3437

3538
check:
3639
@bash check.sh
3740

41+
shellcheck:
42+
shellcheck *.sh
43+
3844
qa:
3945
tox -e qa
4046

@@ -44,7 +50,7 @@ pytest:
4450
nopost:
4551
@bash check.sh --nopost
4652

47-
tag:
53+
tag: version
4854
git tag -a "v${LIBRARY_VERSION}" -m "Version ${LIBRARY_VERSION}"
4955

5056
build: check

check.sh

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,10 @@
33
# This script handles some basic QA checks on the source
44

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

1011
success() {
1112
echo -e "$(tput setaf 2)$1$(tput sgr0)"
@@ -28,7 +29,7 @@ while [[ $# -gt 0 ]]; do
2829
;;
2930
*)
3031
if [[ $1 == -* ]]; then
31-
printf "Unrecognised option: $1\n";
32+
printf "Unrecognised option: %s\n" "$1";
3233
exit 1
3334
fi
3435
POSITIONAL_ARGS+=("$1")
@@ -39,8 +40,7 @@ done
3940
inform "Checking $LIBRARY_NAME $LIBRARY_VERSION\n"
4041

4142
inform "Checking for trailing whitespace..."
42-
grep -IUrn --color "[[:blank:]]$" --exclude-dir=dist --exclude-dir=.tox --exclude-dir=.git --exclude=PKG-INFO
43-
if [[ $? -eq 0 ]]; then
43+
if grep -IUrn --color "[[:blank:]]$" --exclude-dir=dist --exclude-dir=.tox --exclude-dir=.git --exclude=PKG-INFO; then
4444
warning "Trailing whitespace found!"
4545
exit 1
4646
else
@@ -49,8 +49,7 @@ fi
4949
printf "\n"
5050

5151
inform "Checking for DOS line-endings..."
52-
grep -lIUrn --color $'\r' --exclude-dir=dist --exclude-dir=.tox --exclude-dir=.git --exclude=Makefile
53-
if [[ $? -eq 0 ]]; then
52+
if grep -lIUrn --color $'\r' --exclude-dir=dist --exclude-dir=.tox --exclude-dir=.git --exclude=Makefile; then
5453
warning "DOS line-endings found!"
5554
exit 1
5655
else
@@ -59,8 +58,7 @@ fi
5958
printf "\n"
6059

6160
inform "Checking CHANGELOG.md..."
62-
cat CHANGELOG.md | grep ^${LIBRARY_VERSION} > /dev/null 2>&1
63-
if [[ $? -eq 1 ]]; then
61+
if ! grep "^${LIBRARY_VERSION}" CHANGELOG.md > /dev/null 2>&1; then
6462
warning "Changes missing for version ${LIBRARY_VERSION}! Please update CHANGELOG.md."
6563
exit 1
6664
else
@@ -69,8 +67,7 @@ fi
6967
printf "\n"
7068

7169
inform "Checking for git tag ${LIBRARY_VERSION}..."
72-
git tag -l | grep -E "${LIBRARY_VERSION}$"
73-
if [[ $? -eq 1 ]]; then
70+
if ! git tag -l | grep -E "${LIBRARY_VERSION}$"; then
7471
warning "Missing git tag for version ${LIBRARY_VERSION}"
7572
fi
7673
printf "\n"

examples/bargraph.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,15 @@
33

44
from scd4x import SCD4X
55

6-
BAR_CHAR = u'\u2588'
6+
BAR_CHAR = u"\u2588"
77

8-
ANSI_COLOR_RED = '\x1b[31m'
9-
ANSI_COLOR_GREEN = '\x1b[32m'
10-
ANSI_COLOR_YELLOW = '\x1b[33m'
11-
ANSI_COLOR_BLUE = '\x1b[34m'
12-
ANSI_COLOR_MAGENTA = '\x1b[35m'
13-
ANSI_COLOR_BLACK = '\x1b[30m'
14-
ANSI_COLOR_RESET = '\x1b[0m'
8+
ANSI_COLOR_RED = "\x1b[31m"
9+
ANSI_COLOR_GREEN = "\x1b[32m"
10+
ANSI_COLOR_YELLOW = "\x1b[33m"
11+
ANSI_COLOR_BLUE = "\x1b[34m"
12+
ANSI_COLOR_MAGENTA = "\x1b[35m"
13+
ANSI_COLOR_BLACK = "\x1b[30m"
14+
ANSI_COLOR_RESET = "\x1b[0m"
1515

1616

1717
colours = [ANSI_COLOR_BLUE, ANSI_COLOR_GREEN, ANSI_COLOR_YELLOW, ANSI_COLOR_RED, ANSI_COLOR_MAGENTA]
@@ -55,7 +55,7 @@
5555
t_reading = "{:.4f}c".format(temperature).ljust(BAR_WIDTH + 14)
5656
c_reading = "{:.0f}PPM".format(co2).ljust(BAR_WIDTH + 14)
5757

58-
sys.stdout.write('\x1b[0;1H')
58+
sys.stdout.write("\x1b[0;1H")
5959
sys.stdout.write(u"""{title}
6060
{blank}
6161
Temperature: {t_bar}

0 commit comments

Comments
 (0)