Skip to content

Commit

Permalink
[ci] enforce shfmt
Browse files Browse the repository at this point in the history
  • Loading branch information
jameslamb committed Nov 2, 2023
1 parent 9002cff commit 7c4899d
Show file tree
Hide file tree
Showing 5 changed files with 70 additions and 56 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/static-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,7 @@ jobs:
ruff \
shellcheck \
types-requests
apt-get update
apt-get install --no-install-recommends -y \
shfmt
make lint
8 changes: 8 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,11 @@ clean:

.PHONY: format
format:
shfmt \
--write \
--indent 4 \
--space-redirects \
./bin
isort .
black .

Expand All @@ -39,6 +44,9 @@ install:

.PHONY: lint
lint:
shfmt \
--diff \
./bin || echo "shfmt found errors, re-run 'make format'" && exit 1
shellcheck \
--exclude=SC2002 \
bin/*.sh
Expand Down
4 changes: 2 additions & 2 deletions bin/check-test-packages.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
set -e -u -o pipefail

if [[ $OSTYPE == 'darwin'* ]]; then
OS_NAME="macos"
OS_NAME="macos"
else
OS_NAME="linux"
OS_NAME="linux"
fi

check_distro() {
Expand Down
77 changes: 40 additions & 37 deletions bin/create-test-data-bdist.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@
set -e -u -o pipefail

if [[ $OSTYPE == 'darwin'* ]]; then
OS_NAME="macos"
OS_NAME="macos"
else
OS_NAME="linux"
export PATH="/opt/python/cp311-cp311/bin:${PATH}"
OS_NAME="linux"
export PATH="/opt/python/cp311-cp311/bin:${PATH}"
fi

pip install --upgrade --no-cache-dir pip
Expand All @@ -28,41 +28,44 @@ clean_build_artifacts() {
}

pushd tests/data/baseballmetrics
clean_build_artifacts
if [[ $OS_NAME == "linux" ]]; then
echo "building linux wheels"
pip wheel \
-w ./dist \
--config-setting='cmake.build-type=Debug' \
.
mv \
./dist/baseballmetrics-0.1.0-py3-none-manylinux_2_28_x86_64.whl \
./dist/debug-baseballmetrics-0.1.0-py3-none-manylinux_2_28_x86_64.whl
pip wheel \
-w ./dist \
--config-setting='cmake.build-type=Release' \
.
auditwheel repair \
-w ./dist \
--plat='manylinux_2_28_x86_64' \
./dist/*.whl
elif [[ $OS_NAME == "macos" ]]; then
echo "building macOS wheels"
pip wheel \
-w ./dist \
--config-setting='cmake.build-type=Debug' \
.
mv \
./dist/baseballmetrics-0.1.0-py3-none-macosx_*.whl \
./dist/debug-baseballmetrics-0.1.0-py3-none-macosx_10_15_x86_64.macosx_11_6_x86_64.macosx_12_5_x86_64.whl

pip wheel -w ./dist .
mv \
clean_build_artifacts

if [[ $OS_NAME == "linux" ]]; then
echo "building linux wheels"
pip wheel \
-w ./dist \
--config-setting='cmake.build-type=Debug' \
.
mv \
./dist/baseballmetrics-0.1.0-py3-none-manylinux_2_28_x86_64.whl \
./dist/debug-baseballmetrics-0.1.0-py3-none-manylinux_2_28_x86_64.whl
pip wheel \
-w ./dist \
--config-setting='cmake.build-type=Release' \
.
auditwheel repair \
-w ./dist \
--plat='manylinux_2_28_x86_64' \
./dist/*.whl
elif [[ $OS_NAME == "macos" ]]; then
echo "building macOS wheels"
pip wheel \
-w ./dist \
--config-setting='cmake.build-type=Debug' \
.
mv \
./dist/baseballmetrics-0.1.0-py3-none-macosx_*.whl \
./dist/baseballmetrics-0.1.0-py3-none-macosx_10_15_x86_64.macosx_11_6_x86_64.macosx_12_5_x86_64.whl
fi
./dist/debug-baseballmetrics-0.1.0-py3-none-macosx_10_15_x86_64.macosx_11_6_x86_64.macosx_12_5_x86_64.whl

pip wheel -w ./dist .
mv \
./dist/*.whl \
../
echo "done building wheels"
./dist/baseballmetrics-0.1.0-py3-none-macosx_*.whl \
./dist/baseballmetrics-0.1.0-py3-none-macosx_10_15_x86_64.macosx_11_6_x86_64.macosx_12_5_x86_64.whl
fi

mv \
./dist/*.whl \
../
echo "done building wheels"
popd
34 changes: 17 additions & 17 deletions bin/create-test-data-sdist.sh
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,13 @@ curl https://www.apache.org/licenses/LICENSE-2.0.txt \
--output /tmp/base-package/LICENSE.txt

pushd /tmp/base-package
python setup.py sdist \
--format=zip
rm -rf ./base-package.egg-info
python setup.py sdist \
--format=zip
rm -rf ./base-package.egg-info

python -m build \
--no-isolation \
--sdist
python -m build \
--no-isolation \
--sdist
popd

mv \
Expand Down Expand Up @@ -155,21 +155,21 @@ EOF

# files and directories that don't need to be in a Python distribution
pushd /tmp/problematic-package
git init --initial-branch='main'
echo '*.csv' > ./.gitignore
echo 'ignored: [DL3008]' > ./.hadolint.yaml
# nested file
echo '*.csv' > ./problematic_package/.gitignore
git init --initial-branch='main'
echo '*.csv' > ./.gitignore
echo 'ignored: [DL3008]' > ./.hadolint.yaml
# nested file
echo '*.csv' > ./problematic_package/.gitignore
popd

pushd /tmp/problematic-package
python setup.py sdist \
--format=zip
rm -rf ./problematic-package.egg-info
python setup.py sdist \
--format=zip
rm -rf ./problematic-package.egg-info

python -m build \
--no-isolation \
--sdist
python -m build \
--no-isolation \
--sdist
popd

mv \
Expand Down

0 comments on commit 7c4899d

Please sign in to comment.