Replace build.sh with make to manage airtime_mvc

This commit is contained in:
jo 2021-09-11 04:45:07 +02:00
parent f161fb0e0a
commit 9a7c3e0d21
6 changed files with 45 additions and 43 deletions

View File

@ -84,18 +84,12 @@ jobs:
restore-keys: | restore-keys: |
${{ runner.os }}-composer- ${{ runner.os }}-composer-
- name: Install dependencies - name: Run tests
run: |
composer install --no-progress --dev
working-directory: airtime_mvc
- name: Run PHP tests
run: | run: |
sudo mkdir -p "$LIBRETIME_LOG_DIR" sudo mkdir -p "$LIBRETIME_LOG_DIR"
sudo chown runner:runner "$LIBRETIME_LOG_DIR" sudo chown runner:runner "$LIBRETIME_LOG_DIR"
make test
php ../vendor/bin/phpunit working-directory: airtime_mvc
working-directory: airtime_mvc/tests
test: test:
runs-on: ubuntu-latest runs-on: ubuntu-latest

View File

@ -14,3 +14,6 @@ shell-format:
shell-check: shell-check:
shfmt -f . | xargs shfmt -i 2 -ci -sr -kp -d shfmt -f . | xargs shfmt -i 2 -ci -sr -kp -d
shfmt -f . | xargs shellcheck --color=always --severity=$${SEVERITY:-style} shfmt -f . | xargs shellcheck --color=always --severity=$${SEVERITY:-style}
VERSION:
tools/version.sh

12
airtime_mvc/Makefile Normal file
View File

@ -0,0 +1,12 @@
.PHONY: build
SHELL = bash
vendor:
composer install --no-progress --no-interaction
test: vendor
cd tests && ../vendor/bin/phpunit
build:
composer install --no-progress --no-interaction --no-dev

View File

@ -1,32 +0,0 @@
#!/usr/bin/env bash
set -e # Exit if any of the steps fails.
pushd airtime_mvc || (echo "could not cd in airtime_mvc!" && exit 1)
composer install --no-dev --no-interaction
popd || exit
git_build=""
if [ -d .git ]; then
echo " * Building from Git"
git_build="y"
fi
if [ "${git_build}" = "y" ]; then
git_version=$(git tag --points-at HEAD)
echo " * Version from tag: ${git_version}"
if [ "${git_version}" = "" ]; then
git_version=$(git rev-parse --short HEAD)
echo " * Overriding empty version with sha1 commit-ish: ${git_version}"
fi
echo "${git_version}" > VERSION
else
# if no file was in tarball we create one letting the user know
# if you run in to this you should grab an enriched tarball built
# by travis. It already contains the VERSION file and also bundles
# all the PHP you vendors files making the install much faster on
# your part.
if [ ! -f VERSION ]; then
echo "could not detect version for VERSION file" > VERSION
fi
fi

View File

@ -797,8 +797,9 @@ if [[ ! ${commandFound} -eq 0 ]]; then
PATH="${PATH}:/usr/local/bin" PATH="${PATH}:/usr/local/bin"
fi fi
# Run composer (install PHP dependencies) and create a VERSION file make VERSION # Create a VERSION file
loudCmd "bash ./build.sh" make -C airtime_mvc build # Install php dependencies with composer
if [ -f /etc/airtime/airtime.conf ]; then if [ -f /etc/airtime/airtime.conf ]; then
# TODO use VERSION or some other way to check for updates and handle # TODO use VERSION or some other way to check for updates and handle
# media-monitor case on it's own # media-monitor case on it's own

24
tools/version.sh Executable file
View File

@ -0,0 +1,24 @@
#!/usr/bin/env bash
set -u
error() {
echo >&2 "error: $*"
exit 1
}
command -v git > /dev/null || error "git command not found!"
command -v tee > /dev/null || error "tee command not found!"
typeset -r version_file="VERSION"
if [[ "$(git rev-parse --is-inside-work-tree 2> /dev/null)" == "true" ]]; then
tag=$(git tag --points-at HEAD | tee "$version_file" || error "could not extract tag")
if [[ -z "$tag" ]]; then
git rev-parse --short HEAD > "$version_file" || error "could not extract commit sha"
fi
else
if [[ ! -f "$version_file" ]]; then
echo "could not detect version" > VERSION
fi
fi