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

feat(ci): introduce shfmt #2956

Merged
merged 1 commit into from
Jan 20, 2025
Merged
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
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
8 changes: 4 additions & 4 deletions .github/bin/bleeding
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@
SHA=$1
DATE=$2

if [ -z "$SHA" ] || [ -z "$DATE" ] ; then
echo "Usage: .github/bin/bleeding SHA DATE"
exit 1
if [ -z "$SHA" ] || [ -z "$DATE" ]; then
echo "Usage: .github/bin/bleeding SHA DATE"
exit 1
fi

# Install Weblate from main branch
sed -i \
-e "s/\\(ENV WEBLATE_VERSION=.*\\)/\\1+$( date --date "$DATE" -I )/" \
-e "s/\\(ENV WEBLATE_VERSION=.*\\)/\\1+$(date --date "$DATE" -I)/" \
-e "/ENV WEBLATE_VERSION/a \
ENV WEBLATE_DOCKER_GIT_REVISION=$SHA" \
-e "/LABEL org.opencontainers.image.version/a \
Expand Down
40 changes: 20 additions & 20 deletions .github/bin/get-buildx-args
Original file line number Diff line number Diff line change
Expand Up @@ -7,26 +7,26 @@
# Generate command-line options for docker buildx build

# Load from GitHub Actions cache
if [ -n "$MATRIX_ARCHITECTURE" ] ; then
if [ -n "$MATRIX_ARCHITECTURE" ]; then
echo --cache-from "type=gha,scope=$MATRIX_ARCHITECTURE"
else
for arch in linux/amd64 linux/arm64 ; do
for arch in linux/amd64 linux/arm64; do
echo --cache-from "type=gha,scope=$arch"
done
fi

# Expose annotations
if [ "$1" != "load" ] ; then
if [ "$1" != "load" ]; then
WEBLATE_VERSION=$(sed -n 's/^ENV WEBLATE_VERSION=\(.*\)/\1/p' Dockerfile | head -n 1)
sed -n "s/^LABEL \(org.opencontainers.image.*\)/--annotation index:\1/p" Dockerfile | sed -e "s/\\\$WEBLATE_VERSION/${WEBLATE_VERSION}/"
fi

# Write to GitHub Actions cache unless publishing (not compatible with push)
if [ "$1" != "publish" ] ; then
if [ "$1" != "publish" ]; then
echo --cache-to "type=gha,mode=max,scope=$MATRIX_ARCHITECTURE"
fi

if [ "$1" = "load" ] ; then
if [ "$1" = "load" ]; then
# Ommit list of platforms loading, see https://github.com/docker/buildx/issues/59
echo --output=type=docker
# Test tag, to avoid collistion with real ones
Expand All @@ -37,30 +37,30 @@ else
# Enable more platforms in future:
# linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64,linux/386,linux/ppc64le,linux/s390x

if [ "$1" = "publish-bleeding" ] ; then
if [ "$1" = "publish-bleeding" ]; then
# Publishing bleeding edge image
echo --output "type=image,push=true"
echo --tag "${DOCKER_IMAGE:-weblate/weblate}:bleeding"
echo --tag "${DOCKER_IMAGE:-weblate/weblate}:bleeding-$(cat .github/args-date)-$(cat .github/args-sha)"
elif [ "$1" = "publish" ] || [ "$1" = "publish-stable" ] ; then
elif [ "$1" = "publish" ] || [ "$1" = "publish-stable" ]; then
# Publishing normal image
echo --output "type=image,push=true"

# Generate tags
case "$GITHUB_REF" in
refs/tags/[0-9]*)
RELEASE="${GITHUB_REF#refs/tags/}"
MINOR="${RELEASE%.*.*}"
MAJOR="${MINOR%.*}"
echo --tag "${DOCKER_IMAGE:-weblate/weblate}:$RELEASE"
echo --tag "${DOCKER_IMAGE:-weblate/weblate}:$MINOR"
echo --tag "${DOCKER_IMAGE:-weblate/weblate}:$MAJOR"
echo --tag "${DOCKER_IMAGE:-weblate/weblate}:latest"
;;
refs/heads/main)
echo --tag "${DOCKER_IMAGE:-weblate/weblate}:edge"
echo --tag "${DOCKER_IMAGE:-weblate/weblate}:edge-$(date -I)-${GITHUB_SHA}"
;;
refs/tags/[0-9]*)
RELEASE="${GITHUB_REF#refs/tags/}"
MINOR="${RELEASE%.*.*}"
MAJOR="${MINOR%.*}"
echo --tag "${DOCKER_IMAGE:-weblate/weblate}:$RELEASE"
echo --tag "${DOCKER_IMAGE:-weblate/weblate}:$MINOR"
echo --tag "${DOCKER_IMAGE:-weblate/weblate}:$MAJOR"
echo --tag "${DOCKER_IMAGE:-weblate/weblate}:latest"
;;
refs/heads/main)
echo --tag "${DOCKER_IMAGE:-weblate/weblate}:edge"
echo --tag "${DOCKER_IMAGE:-weblate/weblate}:edge-$(date -I)-${GITHUB_SHA}"
;;
esac
else
echo --output "type=image,push=false"
Expand Down
4 changes: 4 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@ repos:
rev: v0.10.0.1
hooks:
- id: shellcheck
- repo: https://github.com/scop/pre-commit-shfmt
rev: v3.10.0-2
hooks:
- id: shfmt

ci:
autoupdate_schedule: quarterly
2 changes: 1 addition & 1 deletion health_check
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/sh
set -e

if [ -f /app/data/ssl/privkey.pem ] ; then
if [ -f /app/data/ssl/privkey.pem ]; then
curl --cacert /app/data/ssl/fullchain.pem https://localhost:4443/healthz/ || exit 1
else
curl http://localhost:8080/healthz/ || exit 1
Expand Down
Loading
Loading