|
1 | | -name: GeoNode Build & Test (Reusable) |
| 1 | +name: GeoNode Test Suites |
2 | 2 |
|
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] |
14 | 4 |
|
15 | 5 | 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 |
18 | 12 |
|
19 | 13 | steps: |
20 | | - - uses: actions/checkout@v4 |
| 14 | + - name: Checkout repository |
| 15 | + uses: actions/checkout@v4 |
21 | 16 |
|
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 |
24 | 23 | with: |
25 | | - name: buildx-cache |
26 | 24 | path: /tmp/.buildx-cache |
| 25 | + key: geonode-cache-${{ github.run_id }} |
27 | 26 |
|
28 | | - - name: Load Docker cache |
| 27 | + - name: Build the stack (Docker Compose v2) |
29 | 28 | 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 |
32 | 32 |
|
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 }} |
35 | 39 |
|
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 |
55 | 50 |
|
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 |
67 | 58 |
|
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]))") |
73 | 66 |
|
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]))") |
81 | 74 |
|
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 |
0 commit comments