Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GH Actions: add shellcheck job + allow scripts to pass the new check #924

Draft
wants to merge 4 commits into
base: develop
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ The linter can be run locally using `composer lint`.

[PHP Parallel Lint]: https://github.com/php-parallel-lint/PHP-Parallel-Lint

## Coding Style
## PHP Coding Style

Please follow the existing coding style and best practices.
This project uses [PHP_CodeSniffer][] to detect coding standard violations and apply automated fixes (whenever possible).
Expand All @@ -72,6 +72,19 @@ This project uses [PHP_CodeSniffer][] to detect coding standard violations and a

[PHP_CodeSniffer]: https://github.com/squizlabs/PHP_CodeSniffer

## Shell script QA & Coding Style

All shell scripts used in this project are, and should be, located in the `/scripts` directory.

Please follow the existing coding style and best practices.
This project uses [ShellCheck][] to detect violations.

* Shellcheck can be [installed on all platforms][shellcheck-install]
* All files can be checked for coding standard violations by running `shellcheck`.

[ShellCheck]: https://github.com/koalaman/shellcheck
[shellcheck-install]: https://github.com/koalaman/shellcheck#user-content-installing

## Unit Tests

PRs should include unit tests for all changes.
Expand Down
18 changes: 18 additions & 0 deletions .github/workflows/cs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,3 +67,21 @@ jobs:
- name: Show PHPCS results in PR
if: ${{ always() && steps.phpcs.outcome == 'failure' }}
run: cs2pr ./phpcs-report.xml

shellcheck: #----------------------------------------------------------------------
name: 'ShellCheck'
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up problem matcher
uses: lumaxis/shellcheck-problem-matchers@v2
with:
format: gcc

- name: Run ShellCheck
uses: ludeeus/[email protected]
with:
format: gcc
9 changes: 9 additions & 0 deletions .shellcheckrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
shell=bash
color=always

external-sources=false
source-path=/scripts
source-path=/scripts/proxy

# Turn on all checks.
enable=all
13 changes: 7 additions & 6 deletions scripts/proxy/start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,17 @@ PROXYDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
PORT=${PORT:-9000}

PROXYBIN=${PROXYBIN:-"$(which mitmdump)"}
ARGS="-s '$PROXYDIR/proxy.py' -p $PORT"
if [[ ! -z "$AUTH" ]]; then
ARGS="$ARGS --proxyauth $AUTH"

ARGS=(-s "$PROXYDIR/proxy.py" -p "$PORT")
if [[ -n "$AUTH" ]]; then
ARGS+=("--proxyauth" "$AUTH")
fi
PIDFILE="$PROXYDIR/proxy-$PORT.pid"

set -x

start-stop-daemon --verbose --start --background --pidfile $PIDFILE --make-pidfile --exec $PROXYBIN -- $ARGS
start-stop-daemon --verbose --start --background --pidfile "$PIDFILE" --make-pidfile --exec "$PROXYBIN" -- "${ARGS[@]}"

ps -p $(cat $PIDFILE) u
ps -p "$(cat "$PIDFILE")" u
sleep 2
ps -p $(cat $PIDFILE) u
ps -p "$(cat "$PIDFILE")" u
4 changes: 2 additions & 2 deletions scripts/proxy/stop.sh
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
#!/usr/bin/env bash

PROXYDIR="$PWD/$(dirname $0)"
PROXYDIR="$PWD/$(dirname "$0")"
PORT=${PORT:-9000}

PIDFILE="$PROXYDIR/proxy-$PORT.pid"

set -x

start-stop-daemon --verbose --stop --pidfile $PIDFILE --remove-pidfile
start-stop-daemon --verbose --stop --pidfile "$PIDFILE" --remove-pidfile
Loading