Skip to content

Commit 52fe4ee

Browse files
committed
Added script for printing out pre-commit hook versions
1 parent e8683ca commit 52fe4ee

File tree

3 files changed

+44
-1
lines changed

3 files changed

+44
-1
lines changed

install.sh

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,25 @@ if [[ $# -eq 0 ]] ; then
1616
GRAY='\033[1;30m'; RED='\033[0;31m'; LRED='\033[1;31m'; GREEN='\033[0;32m'; LGREEN='\033[1;32m'; ORANGE='\033[0;33m'; YELLOW='\033[1;33m'; BLUE='\033[0;34m'; LBLUE='\033[1;34m'; PURPLE='\033[0;35m'; LPURPLE='\033[1;35m'; CYAN='\033[0;36m'; LCYAN='\033[1;36m'; LGRAY='\033[0;37m'; WHITE='\033[1;37m';
1717
fi
1818

19-
# Install dependencies
19+
# Install package dependencies
2020
sudo apt-get update
2121
sudo apt-get install libudev-dev libusb-1.0
2222
sudo apt-get install -y gettext
23+
24+
# Install dependencies for these scripts
25+
if test -d "actions-ci"; then
26+
pip install -r actions-ci/requirements.txt
27+
else
28+
echo "Directory 'actions-ci' does not exist!"
29+
echo "CI expects the 'actions-ci-circuitpython-libs' tools being checked out to said directory."
30+
exit 1
31+
fi
32+
33+
# Install dependencies for the library
2334
pip install -r requirements.txt
2435
if test -f "optional_requirements.txt"; then
2536
pip install -r optional_requirements.txt
2637
fi
38+
39+
# Install build tool
2740
pip install circuitpython-build-tools

print_precommit_versions.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# SPDX-FileCopyrightText: 2023 Alec Delaney, for Adafruit Industries
2+
#
3+
# SPDX-License-Identifier: MIT
4+
5+
"""
6+
Script for printing the versions of the contents of .pre-commit-config.yaml
7+
8+
Author(s): Alec Delaney, for Adafruit Industries
9+
"""
10+
11+
from typing import TypedDict
12+
import yaml
13+
14+
15+
class PreCommitRepo(TypedDict):
16+
"""Typed dictionary structure of a pre-commit hook"""
17+
18+
repo: str
19+
rev: str
20+
hooks: list[dict[str, str]]
21+
22+
23+
with open(".pre-commit-config.yaml", mode="r", encoding="utf-8") as yamlfile:
24+
repos: list[PreCommitRepo] = yaml.safe_load(yamlfile)["repos"]
25+
26+
print("Using the following pre-commit hook versions:")
27+
for repo in repos:
28+
print(f' * {repo["repo"]} @ {repo["rev"]}')

requirements.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
# SPDX-FileCopyrightText: 2019 Adafruit Industries
22
#
33
# SPDX-License-Identifier: Unlicense
4+
5+
pyyaml~=6.0

0 commit comments

Comments
 (0)