mirror of
https://github.com/danog/docker-php-extension-installer.git
synced 2024-11-26 12:04:43 +01:00
Add lint script
Co-authored-by: Michele Locati <michele@locati.it> Co-authored-by: Quan TRAN <itscaro@users.noreply.github.com>
This commit is contained in:
parent
0f552e12a4
commit
04989ff86d
@ -8,3 +8,7 @@ end_of_line = lf
|
|||||||
charset = utf-8
|
charset = utf-8
|
||||||
trim_trailing_whitespace = false
|
trim_trailing_whitespace = false
|
||||||
insert_final_newline = true
|
insert_final_newline = true
|
||||||
|
|
||||||
|
[*.{bat,cmd}]
|
||||||
|
end_of_line = crlf
|
||||||
|
charset = latin1
|
||||||
|
@ -24,7 +24,7 @@ jobs:
|
|||||||
language: go
|
language: go
|
||||||
go: '1.13'
|
go: '1.13'
|
||||||
before_script: GO111MODULE=on go install mvdan.cc/sh/v3/cmd/shfmt
|
before_script: GO111MODULE=on go install mvdan.cc/sh/v3/cmd/shfmt
|
||||||
script: shfmt -d -s -ln posix -i 0 -ci -kp install-php-extensions scripts/common scripts/travisci-test-extensions scripts/travisci-update-readme scripts/update-readme
|
script: shfmt -d -s -ln posix -i 0 -ci -kp install-php-extensions scripts/common scripts/lint scripts/travisci-test-extensions scripts/travisci-update-readme scripts/update-readme
|
||||||
|
|
||||||
- <<: *test-extensions-job-template
|
- <<: *test-extensions-job-template
|
||||||
name: Test extensions on Alpine 3.7
|
name: Test extensions on Alpine 3.7
|
||||||
|
@ -144,6 +144,10 @@ Some extension has special requirements:
|
|||||||
|
|
||||||
## How to contribute
|
## How to contribute
|
||||||
|
|
||||||
|
### Formatting code
|
||||||
|
|
||||||
|
Before submitting any pull request, be sure to execute the `lint` script in the `scripts` directory (or `lint.bat` on Windows).
|
||||||
|
|
||||||
### Adding support to a new PHP extension?
|
### Adding support to a new PHP extension?
|
||||||
|
|
||||||
1. change the `install-php-extensions` script
|
1. change the `install-php-extensions` script
|
||||||
|
3
scripts/Dockerfile-shfmt
Normal file
3
scripts/Dockerfile-shfmt
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
FROM golang
|
||||||
|
|
||||||
|
RUN go get github.com/mvdan/sh/cmd/shfmt
|
30
scripts/lint
Executable file
30
scripts/lint
Executable file
@ -0,0 +1,30 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
set -o errexit
|
||||||
|
set -o nounset
|
||||||
|
|
||||||
|
if ! docker --version >/dev/null 2>/dev/null; then
|
||||||
|
printf 'Docker is not installed, or it is not running\n' >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
#SRC_DIR="$(CDPATH= cd -- "$(dirname -- "$0")" && cd .. pwd)"
|
||||||
|
|
||||||
|
if ! docker build -t docker-php-extension-installer-shfmt:latest -f scripts/Dockerfile-shfmt -q .; then
|
||||||
|
printf 'ERROR!' >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
fix() {
|
||||||
|
printf 'Fixing %s... ' "$1"
|
||||||
|
if docker run --rm -v "$SRC_DIR:/src" -w /src docker-php-extension-installer-shfmt:latest shfmt -s -ln posix -i 0 -ci -kp -w "$1"; then
|
||||||
|
printf 'done.\n'
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
fix install-php-extensions
|
||||||
|
fix scripts/common
|
||||||
|
fix scripts/lint
|
||||||
|
fix scripts/travisci-test-extensions
|
||||||
|
fix scripts/travisci-update-readme
|
||||||
|
fix scripts/update-readme
|
34
scripts/lint.bat
Normal file
34
scripts/lint.bat
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
@echo off
|
||||||
|
setlocal
|
||||||
|
|
||||||
|
docker --version >NUL 2>NUL
|
||||||
|
if errorlevel 1 goto :no-docker
|
||||||
|
|
||||||
|
cd /d "%~dp0.."
|
||||||
|
if errorlevel 1 goto err
|
||||||
|
set SRC_DIR=%CD%
|
||||||
|
|
||||||
|
docker build -t docker-php-extension-installer-shfmt:latest -f scripts\Dockerfile-shfmt -q .
|
||||||
|
if errorlevel 1 goto :err
|
||||||
|
|
||||||
|
call :fix install-php-extensions
|
||||||
|
call :fix scripts/common
|
||||||
|
call :fix scripts/lint
|
||||||
|
call :fix scripts/travisci-test-extensions
|
||||||
|
call :fix scripts/travisci-update-readme
|
||||||
|
call :fix scripts/update-readme
|
||||||
|
goto :eof
|
||||||
|
|
||||||
|
:no-docker
|
||||||
|
echo Docker is not installed, or it's not running >&2
|
||||||
|
goto :eof
|
||||||
|
|
||||||
|
:err
|
||||||
|
echo ERROR! >&2
|
||||||
|
goto :eof
|
||||||
|
|
||||||
|
:fix
|
||||||
|
echo|set /p="Fixing %1... "
|
||||||
|
docker run --rm -v "%SRC_DIR%:/src" -w /src docker-php-extension-installer-shfmt:latest shfmt -s -ln posix -i 0 -ci -kp -w %1
|
||||||
|
if not errorlevel 1 echo done.
|
||||||
|
exit /b 0
|
Loading…
Reference in New Issue
Block a user