Skip to content

Commit

Permalink
feat(ci): introduce shfmt
Browse files Browse the repository at this point in the history
  • Loading branch information
nijel committed Jan 20, 2025
1 parent d7a11b8 commit f15bbbf
Show file tree
Hide file tree
Showing 7 changed files with 59 additions and 22 deletions.
34 changes: 34 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
root = true

[*]
indent_style = space
indent_size = 2
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
spaces_around_operators = true

[*.bat]
end_of_line = crlf

[*.html]
indent_size = 2

[*.py]
indent_size = 4

[*.rst]
indent_size = 3

[*.js]
quote_type = double

[*.{markdown,md}]
trim_trailing_whitespace = false

[[shell]]
indent_style = space
indent_size = 4
space_redirects = true
simplify = true
4 changes: 4 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@ repos:
hooks:
- id: shellcheck
require_serial: true
- repo: https://github.com/scop/pre-commit-shfmt
rev: v3.10.0-2
hooks:
- id: shfmt

ci:
autoupdate_schedule: quarterly
4 changes: 2 additions & 2 deletions test-content
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/sh

STORAGE=$(mktemp)
cleanup(){
cleanup() {
rm "$STORAGE"
}
trap cleanup EXIT
Expand All @@ -15,7 +15,7 @@ docker rm tmp_$$
echo "Checking content..."

# /app/data is not checked because it contains stub for customization
if grep -E '^(app/cache|tmp|run)/.+' "$STORAGE" ; then
if grep -E '^(app/cache|tmp|run)/.+' "$STORAGE"; then
echo "Volumes contain files!"
exit 1
fi
Expand Down
25 changes: 12 additions & 13 deletions test-generate
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
#!/bin/sh
if [ "$3" = "saml" ] ; then
if [ "$3" = "saml" ]; then
TEST_EXTRA_ENV='WEBLATE_SAML_IDP_URL: https://example.com/idp'
elif [ "$3" = "celery-single" ] ; then
elif [ "$3" = "celery-single" ]; then
TEST_EXTRA_ENV='CELERY_SINGLE_PROCESS: 1'
else
TEST_EXTRA_ENV=''
fi

cat > docker-compose.override.yml <<EOT
cat > docker-compose.override.yml << EOT
services:
weblate:
image: ${TEST_CONTAINER:-weblate/weblate:edge}
Expand All @@ -22,22 +22,22 @@ services:
- 4443:4443
EOT

if [ "$3" = "split" ] ; then
mv docker-compose-split.yml docker-compose.yml
for service in celery-backup celery-beat celery-celery celery-memory celery-notify celery-translate ; do
cat >> docker-compose.override.yml <<EOT
if [ "$3" = "split" ]; then
mv docker-compose-split.yml docker-compose.yml
for service in celery-backup celery-beat celery-celery celery-memory celery-notify celery-translate; do
cat >> docker-compose.override.yml << EOT
weblate-${service}:
image: ${TEST_CONTAINER:-weblate/weblate:edge}
restart: no
environment:
WEBLATE_TIME_ZONE: Europe/Prague
WEBLATE_SITE_DOMAIN: test.example.com
EOT
done
done
fi
if [ "$3" = "read-write" ] || [ "$3" = "localtime" ] ; then
sed -i -e '/tmpfs:/D' -e '/- \/run/D' -e '/- \/tmp/D' -e '/read_only: true/D' docker-compose.yml
if [ "$3" = "localtime" ] ; then
if [ "$3" = "read-write" ] || [ "$3" = "localtime" ]; then
sed -i -e '/tmpfs:/D' -e '/- \/run/D' -e '/- \/tmp/D' -e '/read_only: true/D' docker-compose.yml
if [ "$3" = "localtime" ]; then
sed -i -e '/weblate-cache:\/app\/cache/a\
- /etc/localtime:/etc/localtime:ro' docker-compose.yml
fi
Expand All @@ -46,12 +46,11 @@ else
sed -i 's/- \/tmp/- \/tmp:exec/' docker-compose.yml
fi


IP=127.0.0.1
PORT=${1:-8080}
PROTO=${2:-http}

cat > .test.env <<EOT
cat > .test.env << EOT
URL=$PROTO://$IP:$PORT/
EOT

Expand Down
6 changes: 3 additions & 3 deletions test-online
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
. ./.test.env
echo "Checking $URL..."
TIMEOUT=0
while ! curl --insecure --fail --max-time 5 --silent --output /dev/null "$URL" ; do
while ! curl --insecure --fail --max-time 5 --silent --output /dev/null "$URL"; do
sleep 5
TIMEOUT=$((TIMEOUT + 1))
if [ $TIMEOUT -gt 300 ] ; then
if [ $TIMEOUT -gt 300 ]; then
break
fi
done
Expand All @@ -17,6 +17,6 @@ RET2=$?
# Display logs so far
docker compose logs

if [ $RET2 -ne 0 ] || [ $RET -ne 0 ] ; then
if [ $RET2 -ne 0 ] || [ $RET -ne 0 ]; then
exit 1
fi
6 changes: 3 additions & 3 deletions test-saml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/sh
if [ "$1" = "saml" ] ; then
docker compose exec -T weblate openssl x509 -in /app/data/ssl/saml.crt -text -noout
if [ "$1" = "saml" ]; then
docker compose exec -T weblate openssl x509 -in /app/data/ssl/saml.crt -text -noout
else
docker compose exec -T weblate test ! -f /app/data/ssl/saml.crt
docker compose exec -T weblate test ! -f /app/data/ssl/saml.crt
fi
2 changes: 1 addition & 1 deletion test-supervisor
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
docker compose exec -T weblate supervisorctl status all
RET=$?
# The 3 happens with EXITED check and supervisor 4
if [ $RET -ne 0 ] && [ $RET -ne 3 ] ; then
if [ $RET -ne 0 ] && [ $RET -ne 3 ]; then
docker compose logs
exit 1
fi

0 comments on commit f15bbbf

Please sign in to comment.