Skip to content

Commit ff3761d

Browse files
committed
fix docker caches
1 parent eab287f commit ff3761d

File tree

2 files changed

+98
-91
lines changed

2 files changed

+98
-91
lines changed
Lines changed: 81 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -1,84 +1,97 @@
1-
name: GeoNode Build & Test (Reusable)
1+
name: GeoNode Test Suites
22

3-
on:
4-
workflow_call:
5-
inputs:
6-
test_suite:
7-
required: false
8-
type: string
9-
default: ""
10-
codecov_name:
11-
required: false
12-
type: string
13-
default: "default"
3+
on: [push, workflow_dispatch]
144

155
jobs:
16-
build:
17-
runs-on: ubuntu-24.04
6+
# -------------------------
7+
# BUILD IMMAGINI
8+
# -------------------------
9+
build_images:
10+
name: Build and cache Docker images
11+
runs-on: ubuntu-22.04
1812

1913
steps:
20-
- uses: actions/checkout@v4
14+
- name: Checkout repository
15+
uses: actions/checkout@v4
2116

22-
- name: Download build cache
23-
uses: actions/download-artifact@v4
17+
- name: Set up Docker Buildx
18+
uses: docker/setup-buildx-action@v3
19+
20+
# Cache condivisa per tutti i job di questo run
21+
- name: Restore Docker build cache
22+
uses: actions/cache@v4
2423
with:
25-
name: buildx-cache
2624
path: /tmp/.buildx-cache
25+
key: geonode-cache-${{ github.run_id }}
2726

28-
- name: Load Docker cache
27+
- name: Build the stack (Docker Compose v2)
2928
run: |
30-
echo "Cache restored for this job:"
31-
du -sh /tmp/.buildx-cache || true
29+
docker compose --env-file .env_test -f docker-compose-test.yml build --progress plain
30+
env:
31+
DOCKER_BUILDKIT: 1
3232

33-
- name: Start stack
34-
run: docker compose --env-file .env_test -f docker-compose-test.yml up -d
33+
- name: Save Docker build cache
34+
if: always()
35+
uses: actions/cache@v4
36+
with:
37+
path: /tmp/.buildx-cache
38+
key: geonode-cache-${{ github.run_id }}
3539

36-
- name: Wait for services
37-
run: |
38-
n=1
39-
m=10
40-
until [ $n -gt $m ]
41-
do
42-
sleep 60
43-
DJANGO_STATUS=$(docker inspect --format='{{.State.Health.Status}}' django4geonode)
44-
GEOSERVER_STATUS=$(docker inspect --format='{{.State.Health.Status}}' geoserver4geonode)
45-
echo ""
46-
echo "Waited $n min (out of $m min)"
47-
if [[ $DJANGO_STATUS == healthy && $GEOSERVER_STATUS == healthy ]]; then
48-
break
49-
fi
50-
echo "Not healthy yet..."
51-
docker ps
52-
n=$((n+1))
53-
done
54-
[[ $DJANGO_STATUS == healthy && $GEOSERVER_STATUS == healthy ]]
40+
# -------------------------
41+
# TEST JOBS (riutilizzano cache)
42+
# -------------------------
43+
geonode_test_suite_smoke:
44+
name: Smoke Tests
45+
needs: build_images
46+
uses: ./.github/workflows/_geonode-build.yml
47+
with:
48+
codecov_name: smoke_tests
49+
test_suite: ./tests/test.sh geonode.tests.smoke geonode.tests.test_rest_api geonode.tests.test_search geonode.tests.test_utils geonode.tests.test_headers
5550

56-
- name: Run tests
57-
if: ${{ inputs.test_suite != '' }}
58-
run: |
59-
docker compose --env-file .env_test -f docker-compose-test.yml exec db psql -U postgres -c 'SELECT pg_terminate_backend(pid) FROM pg_stat_activity WHERE pid <> pg_backend_pid();'
60-
docker compose --env-file .env_test -f docker-compose-test.yml exec db createdb -U postgres -T postgres test_postgres
61-
docker compose --env-file .env_test -f docker-compose-test.yml exec db createdb -U postgres -T postgres test_geonode
62-
docker compose --env-file .env_test -f docker-compose-test.yml exec db createdb -U postgres -T postgres test_geonode_data
63-
docker compose --env-file .env_test -f docker-compose-test.yml exec db psql -U postgres -d test_geonode -c 'CREATE EXTENSION IF NOT EXISTS postgis;'
64-
docker compose --env-file .env_test -f docker-compose-test.yml exec db psql -U postgres -d test_geonode_data -c 'CREATE EXTENSION IF NOT EXISTS postgis;'
65-
docker compose --env-file .env_test -f docker-compose-test.yml exec django bash -c "${{ inputs.test_suite }}"
66-
timeout-minutes: 10
51+
geonode_test_suite:
52+
name: Main Tests
53+
needs: build_images
54+
uses: ./.github/workflows/_geonode-build.yml
55+
with:
56+
codecov_name: main_tests
57+
test_suite: ./tests/test.sh $(python -c "import sys;from geonode import settings;sys.stdout.write(' '.join([a+'.tests' for a in settings.GEONODE_APPS if 'security' not in a and 'geoserver' not in a and 'upload' not in a]))") geonode.thumbs.tests geonode.people.tests geonode.people.socialaccount.providers.geonode_openid_connect.tests
6758

68-
- name: Upload to Codecov
69-
if: ${{ inputs.test_suite != '' }}
70-
run: |
71-
docker compose --env-file .env_test -f docker-compose-test.yml exec django bash -c \
72-
"bash <(curl -s https://codecov.io/bash) -t 2c0e7780-1640-45f0-93a3-e103b057d8c8 -F ${{ inputs.codecov_name }}"
59+
geonode_test_security:
60+
name: Security Tests
61+
needs: build_images
62+
uses: ./.github/workflows/_geonode-build.yml
63+
with:
64+
codecov_name: security_tests
65+
test_suite: ./tests/test.sh $(python -c "import sys;from geonode import settings;sys.stdout.write(' '.join([a+'.tests' for a in settings.GEONODE_APPS if 'security' in a]))")
7366

74-
- name: Debug logs
75-
if: failure()
76-
run: |
77-
docker ps
78-
docker logs django4geonode --tail 1000 || true
79-
docker logs geoserver4geonode --tail 1000 || true
80-
docker logs celery4geonode --tail 1000 || true
67+
geonode_test_gis_backend:
68+
name: GIS Backend Tests
69+
needs: build_images
70+
uses: ./.github/workflows/_geonode-build.yml
71+
with:
72+
codecov_name: gis
73+
test_suite: ./tests/test.sh $(python -c "import sys;from geonode import settings;sys.stdout.write(' '.join([a+'.tests' for a in settings.GEONODE_APPS if 'geoserver' in a]))")
8174

82-
- name: Stop the stack
83-
if: always()
84-
run: docker compose --env-file .env_test -f docker-compose-test.yml down -v
75+
geonode_test_rest_apis:
76+
name: REST API Tests
77+
needs: build_images
78+
uses: ./.github/workflows/_geonode-build.yml
79+
with:
80+
codecov_name: api
81+
test_suite: ./tests/test.sh geonode.api.tests geonode.base.api.tests geonode.layers.api.tests geonode.maps.api.tests geonode.documents.api.tests geonode.geoapps.api.tests
82+
83+
geonode_test_csw:
84+
name: CSW Tests
85+
needs: build_images
86+
uses: ./.github/workflows/_geonode-build.yml
87+
with:
88+
codecov_name: csw
89+
test_suite: ./tests/test.sh geonode.tests.csw geonode.catalogue.backends.tests
90+
91+
geonode_upload:
92+
name: Upload Tests
93+
needs: build_images
94+
uses: ./.github/workflows/_geonode-build.yml
95+
with:
96+
codecov_name: importer
97+
test_suite: ./tests/test.sh geonode.upload

.github/workflows/geonode-tests.yml

Lines changed: 17 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -3,49 +3,43 @@ name: GeoNode Test Suites
33
on: [push, workflow_dispatch]
44

55
jobs:
6+
# -------------------------
7+
# BUILD IMMAGINI
8+
# -------------------------
69
build_images:
710
name: Build and cache Docker images
8-
runs-on: ubuntu-24.04
11+
runs-on: ubuntu-22.04
912

1013
steps:
11-
- uses: actions/checkout@v4
14+
- name: Checkout repository
15+
uses: actions/checkout@v4
1216

1317
- name: Set up Docker Buildx
1418
uses: docker/setup-buildx-action@v3
1519

16-
# Crea una chiave cache univoca per ogni run manuale
17-
- name: Define cache key
18-
id: cache-key
19-
run: echo "key=geonode-cache-${{ github.run_id }}" >> $GITHUB_OUTPUT
20-
21-
- name: Restore Docker layer cache
20+
# Cache condivisa per tutti i job di questo run
21+
- name: Restore Docker build cache
2222
uses: actions/cache@v4
2323
with:
2424
path: /tmp/.buildx-cache
25-
key: ${{ steps.cache-key.outputs.key }}
25+
key: geonode-cache-${{ github.run_id }}
2626

27-
- name: Build stack (using cache)
27+
- name: Build the stack (Docker Compose v2)
2828
run: |
29-
docker compose --env-file .env_test -f docker-compose-test.yml build \
30-
--build-arg BUILDKIT_INLINE_CACHE=1 \
31-
--progress plain
29+
docker compose --env-file .env_test -f docker-compose-test.yml build --progress plain
3230
env:
3331
DOCKER_BUILDKIT: 1
34-
BUILDKIT_CACHE: /tmp/.buildx-cache
3532

36-
- name: Export cache for next jobs
33+
- name: Save Docker build cache
3734
if: always()
38-
run: |
39-
echo "Cache directory after build:"
40-
du -sh /tmp/.buildx-cache || true
41-
42-
- name: Upload build cache
43-
uses: actions/upload-artifact@v4
35+
uses: actions/cache@v4
4436
with:
45-
name: buildx-cache
4637
path: /tmp/.buildx-cache
38+
key: geonode-cache-${{ github.run_id }}
4739

48-
# Ogni job usa la cache e non rebuilda
40+
# -------------------------
41+
# TEST JOBS (riutilizzano cache)
42+
# -------------------------
4943
geonode_test_suite_smoke:
5044
name: Smoke Tests
5145
needs: build_images

0 commit comments

Comments
 (0)