diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 79cd155..752203f 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -19,7 +19,7 @@ jobs: python --version pip install --upgrade pip pip --version - pip install -r requirements.txt + make setup - name: Run lint run: make lint diff --git a/Makefile b/Makefile index cf6e874..b3a56e3 100644 --- a/Makefile +++ b/Makefile @@ -1,12 +1,21 @@ +# These targets do not construct files named after the target itself. Rerun them every time. +.PHONY: setup build test dist/main lint + +# This first target is the one that runs by default. +dist/archive.tar.gz: dist/main + tar -czvf dist/archive.tar.gz dist/main + setup: - ./build.sh - + ./setup.sh + +build: dist/main + test: - PYTHONPATH=./src pytest - -dist/archive.tar.gz: - tar -czvf dist/archive.tar.gz dist/main + . .venv/bin/activate && PYTHONPATH=./src pytest + +dist/main: + . .venv/bin/activate && python -m PyInstaller --onefile --hidden-import="googleapiclient" --add-data="./src:src" src/main.py lint: - pylint --disable=C0114,E0401,E1101,C0116,W0613,R0913,C0116,R0914,C0103,W0201,W0719 src/ + . .venv/bin/activate && pylint --disable=C0114,E0401,E1101,C0116,W0613,R0913,C0116,R0914,C0103,W0201,W0719 src/ diff --git a/build.sh b/setup.sh similarity index 82% rename from build.sh rename to setup.sh index bc268b9..ddafb5d 100755 --- a/build.sh +++ b/setup.sh @@ -1,7 +1,11 @@ #!/usr/bin/env bash # setup.sh -- environment bootstrapper for python virtualenv -set -euo pipefail +# x: print out commands as they are run +# e: exit on any failure +# u: using a nonexistent environment variable is an error +# o pipefail: in a pipeline, any intermediate step exiting with failure counts as an overall fail +set -xeuo pipefail SUDO=sudo if ! command -v $SUDO; then @@ -32,9 +36,7 @@ echo creating virtualenv at $VIRTUAL_ENV python3 -m venv $VIRTUAL_ENV echo installing dependencies from requirements.txt $VIRTUAL_ENV/bin/pip install -r requirements.txt -U -source $VIRTUAL_ENV/bin/activate -$PYTHON -m PyInstaller --onefile --hidden-import="googleapiclient" --add-data="./src:src" src/main.py + # When running as a local module, we need meta.json to be in the same directory as the module. +mkdir -p dist ln -sf ../meta.json dist -tar -czvf dist/archive.tar.gz dist/main -