Skip to content

Commit 5953ffe

Browse files
committed
Add basic CI test
1 parent b26c2a0 commit 5953ffe

File tree

3 files changed

+56
-2
lines changed

3 files changed

+56
-2
lines changed

.github/workflows/lint-test-build-push.yaml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,9 @@ jobs:
1313

1414
- uses: hadolint/hadolint-action@2332a7b74a6de0dda2e2221d575162eba76ba5e5 # v3.3.0
1515

16-
- run: shellcheck **/*.sh
16+
- run: make lint
17+
18+
- run: make test
1719

1820
build-push:
1921
needs: [lint-test]
@@ -22,4 +24,3 @@ jobs:
2224
contents: read
2325
packages: write
2426
secrets: inherit
25-

Makefile

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
.PHONY: build deps lint run test
2+
3+
DOCKER_IMAGE=ghcr.io/libops/ojs:main
4+
5+
deps:
6+
docker compose pull
7+
8+
build: deps
9+
docker compose build
10+
11+
lint:
12+
@docker compose config --format json| jq -e .services.ojs.image | grep libops
13+
@if command -v hadolint > /dev/null 2>&1; then \
14+
echo "Running hadolint on Dockerfiles..."; \
15+
find . -name "Dockerfile" | xargs hadolint; \
16+
else \
17+
echo "hadolint not found, skipping Dockerfile validation"; \
18+
fi
19+
@if command -v json5 > /dev/null 2>&1; then \
20+
echo "Running json5 validation on renovate.json5"; \
21+
json5 --validate renovate.json5 > /dev/null; \
22+
else \
23+
echo "json5 not found, skipping renovate validation"; \
24+
fi
25+
26+
27+
run: build
28+
docker compose up init
29+
docker compose up -d
30+
31+
test: run
32+
./scripts/test.sh

scripts/test.sh

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#!/usr/bin/env bash
2+
3+
set -eou pipefail
4+
5+
max_attempts=10
6+
attempt=0
7+
8+
while [ $attempt -lt $max_attempts ]; do
9+
attempt=$(( attempt + 1 ))
10+
echo "Attempt $attempt of $max_attempts..."
11+
12+
sleep 60
13+
14+
if curl -sf http://localhost | grep "<img" | grep -q "Open Journal Systems"; then
15+
echo "OJS is up!"
16+
exit 0
17+
fi
18+
done
19+
20+
echo "Failed to detect OJS after $max_attempts attempts"
21+
exit 1

0 commit comments

Comments
 (0)