Skip to content

Commit

Permalink
Fix linters and tests not running properly
Browse files Browse the repository at this point in the history
  • Loading branch information
rumpelsepp committed Dec 28, 2023
1 parent fe74a7b commit 3d1195f
Show file tree
Hide file tree
Showing 8 changed files with 56 additions and 39 deletions.
10 changes: 10 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# SPDX-FileCopyrightText: Stefan Tatschner
#
# SPDX-License-Identifier: CC0-1.0

version: 2
updates:
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "monthly"
21 changes: 0 additions & 21 deletions .github/workflows/bats.yml

This file was deleted.

15 changes: 7 additions & 8 deletions .github/workflows/linters.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,13 @@ permissions: {}
jobs:
linters:
runs-on: ubuntu-latest
container: debian:stable

steps:
- uses: actions/checkout@v3
- name: shellcheck
uses: ludeeus/action-shellcheck@master
- name: shfmt
uses: collin-miller/shfmt-action@v1
with:
args: -d penrun config.sh
- name: reuse compliance
uses: fsfe/reuse-action@v2
- name: install linters
run: |
apt-get update && apt-get install -y git util-linux shellcheck shfmt reuse make
- name: run linters
run: |
make lint
22 changes: 22 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# SPDX-FileCopyrightText: Stefan Tatschner
#
# SPDX-License-Identifier: CC0-1.0

on: [push, pull_request]

name: "Tests"
permissions: {}

jobs:
tests:
runs-on: ubuntu-latest
container: debian:stable

steps:
- uses: actions/checkout@v3
- name: install bats
run: |
apt-get update && apt-get install -y bats jq zstd git util-linux make
- name: run bats
run: |
make test
6 changes: 6 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
FROM debian:latest

RUN apt-get update && apt-get install -y bats jq zstd git shellcheck shfmt reuse make

WORKDIR /code
ENTRYPOINT ["bash"]
7 changes: 4 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,13 @@

.PHONY: lint
lint:
find . -iname "*.sh" -or -iname "*.bats" -exec shellcheck '{}' \;
find . \( -iname "penrun" -or -iname "*.sh" -or -iname "*.bats" \) | xargs shellcheck
find . \( -iname "penrun" -or -iname "*.sh" -or -iname "*.bats" \) | xargs shfmt -d

.PHONY: fmt
fmt:
find . -iname "*.sh" -or -iname "*.bats" -exec shfmt -w '{}' \;
find . \( -iname "penrun" -or -iname "*.sh" -or -iname "*.bats" \) | xargs shfmt -w

.PHONY: test
test:
bats -x -r tests
2 changes: 1 addition & 1 deletion penrun
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ run_cmd() {
}

usage() {
echo "penrun [-nsuh] [-C CMD] [-S SEC] [-T TPL] [-c FILE]"
echo "penrun [-bnsuh] [-C CMD] [-S SEC] [-T TPL] [-c FILE]"
echo " [-d DIR] [-e EXT] [-j JOBS] [-p CMD] [-t TAG] COMMAND"
echo ""
echo "options:"
Expand Down
12 changes: 6 additions & 6 deletions tests/setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
# SPDX-License-Identifier: Apache-2.0

setup() {
# https://bats-core.readthedocs.io/en/stable/tutorial.html#let-s-do-some-setup
DIR="$( cd "$( dirname "$BATS_TEST_FILENAME" )" >/dev/null 2>&1 && pwd )"
PATH="$DIR/..:$PATH"
cd "$BATS_TEST_TMPDIR" || exit 1
# https://bats-core.readthedocs.io/en/stable/tutorial.html#let-s-do-some-setup
DIR="$(cd "$(dirname "$BATS_TEST_FILENAME")" >/dev/null 2>&1 && pwd)"
PATH="$DIR/..:$PATH"

cd "$BATS_TEST_TMPDIR" || exit 1
}

trim_string() {
sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//' <<< "$1"
sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//' <<<"$1"
}

0 comments on commit 3d1195f

Please sign in to comment.