add task to cleanup tmp directory for log files #2479
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # GeoSight is UNICEF's geospatial web-based business intelligence platform. | |
| # | |
| # Contact : geosight-no-reply@unicef.org | |
| # | |
| # .. note:: This program is free software; you can redistribute it and/or modify | |
| # it under the terms of the GNU Affero General Public License as published by | |
| # the Free Software Foundation; either version 3 of the License, or | |
| # (at your option) any later version. | |
| # | |
| # __author__ = 'irwan@kartoza.com' | |
| # __date__ = '13/06/2023' | |
| # __copyright__ = ('Copyright 2023, Unicef') | |
| name: Tests | |
| on: | |
| push: | |
| branches: [ main ] | |
| pull_request: | |
| branches: [ main, version-2.0.0, Filter-improvement ] | |
| jobs: | |
| flake8_py3: | |
| name: Python Lint | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Setup Python | |
| uses: actions/setup-python@v4 | |
| with: | |
| python-version: 3.8.18 | |
| architecture: x64 | |
| - name: Checkout Repository | |
| uses: actions/checkout@v3 | |
| with: | |
| fetch-depth: 0 | |
| - name: Display branch | |
| run: git branch --show-current | |
| - name: Install flake8 | |
| run: pip install flake8 flake8-docstrings pydoclint[flake8] | |
| - name: Run flake8 on changed/untracked Python files | |
| run: | | |
| files=$( | |
| { git diff --name-only origin/main...HEAD; | |
| git ls-files --others --exclude-standard; | |
| } | grep '\.py$' | sort -u | |
| ) | |
| echo "Changed/untracked Python files:" | |
| echo "$files" | |
| if [ -n "$files" ]; then | |
| flake8 $files | |
| else | |
| echo "No Python files to lint." | |
| fi | |
| build_image: | |
| needs: flake8_py3 | |
| name: Build Docker Image | |
| runs-on: ubuntu-latest | |
| env: | |
| APP_IMAGE: kartoza/geosight:dev | |
| steps: | |
| - name: Checkout Repository | |
| uses: actions/checkout@v3 | |
| with: | |
| ref: ${{ github.head_ref }} | |
| - name: Display branch | |
| run: git branch --show-current | |
| - name: Set up QEMU | |
| uses: docker/setup-qemu-action@v2 | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v2 | |
| - name: Build Docker Image | |
| uses: docker/build-push-action@v4 | |
| with: | |
| context: . | |
| file: deployment/docker/Dockerfile | |
| push: false | |
| load: true | |
| target: test | |
| tags: ${{ env.APP_IMAGE }} | |
| cache-from: | | |
| type=gha,scope=test | |
| type=gha,scope=prod | |
| cache-to: type=gha,scope=test | |
| - name: Save Docker Image as Tar File | |
| run: docker save -o /tmp/my-image.tar ${{ env.APP_IMAGE }} | |
| - name: Upload Docker Image Cache | |
| uses: actions/cache@v3 | |
| with: | |
| path: /tmp/my-image.tar | |
| key: ${{ runner.os }}-docker-image-${{ github.sha }} | |
| - name: ✅ Check GDAL version inside geosight_dev | |
| run: | | |
| docker run --rm --entrypoint "" kartoza/geosight:dev sh -c '\ | |
| VERSION=$(gdalinfo --version | awk '\''{print $2}'\'') && \ | |
| echo "GDAL version: $VERSION" && \ | |
| if [ "$(printf "%s\n" "3.0.9" "$VERSION" | sort -V | head -n1)" = "3.0.9" ] && [ "$VERSION" != "3.0.9" ]; then \ | |
| echo "✅ GDAL version is greater than 3.0.9"; \ | |
| else \ | |
| echo "❌ GDAL version is NOT greater than 3.0.9"; exit 1; \ | |
| fi' | |
| django_app_tests: | |
| needs: build_image | |
| name: Django App Tests | |
| runs-on: ubuntu-latest | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| test_suite: [ | |
| { id: "backend-tests", mode: "backend" }, | |
| { id: "e2e-project-creation", mode: "e2e", path: "tests/admin/project_creation/", workers: 2, script: "make load-test-data" }, | |
| { id: "e2e-project-view", mode: "e2e", path: "tests/admin/project_view/", workers: 3, script: "make load-test-data" }, | |
| { id: "e2e-project-features", mode: "e2e", path: "tests/admin/project_features/", workers: 3, script: "make load-test-data" }, | |
| { id: "e2e-project-features-2", mode: "e2e", path: "tests/admin/project_features_2/", workers: 3, script: "make load-test-data" }, | |
| { id: "e2e-admin-create", mode: "e2e", path: "tests/admin/admin_create/", workers: 3, script: "make load-test-data" }, | |
| { id: "e2e-admin-list", mode: "e2e", path: "tests/admin/admin_list/", workers: 3, script: "make load-test-data" }, | |
| { id: "e2e-admin-edit", mode: "e2e", path: "tests/admin/admin_edit/", workers: 3, script: "make load-test-data" }, | |
| { id: "e2e-importer", mode: "e2e", path: "tests/admin/importer/", workers: 3, script: "make load-test-data" }, | |
| { id: "e2e-project-bookmark-embed", mode: "e2e", path: "tests/admin/project_bookmark_embed/", workers: 3, script: "make load-test-data" }, | |
| # Filter | |
| { id: "e2e-admin-list-filter", mode: "e2e", path: "tests/admin/admin_filter/", workers: 3, script: "make load-test-data-for-filter" }, | |
| # Contributor | |
| { id: "e2e-contributor", mode: "e2e", path: "tests/contributor/", workers: 3, script: "make load-test-data" }, | |
| # Creator | |
| { id: "e2e-creator", mode: "e2e", path: "tests/creator/", workers: 3, script: "make load-test-data" }, | |
| # Mobile | |
| { id: "e2e-project-view-mobile", mode: "e2e", path: "tests/admin/project_view_mobile/", workers: 3, script: "make load-test-data" }, | |
| # With default dataset | |
| { id: "e2e-project-creation-with-default-dataset", mode: "e2e", path: "tests/admin/project_creation_with_default_dataset/", workers: 3, script: "make load-test-data-default-dataset" }, | |
| ] | |
| env: | |
| APP_IMAGE: kartoza/geosight | |
| steps: | |
| - name: Checkout Repository | |
| uses: actions/checkout@v3 | |
| with: | |
| ref: ${{ github.head_ref }} | |
| - name: Display branch | |
| run: git branch --show-current | |
| - name: Restore Docker Image from Cache | |
| uses: actions/cache@v3 | |
| with: | |
| path: /tmp/my-image.tar | |
| key: ${{ runner.os }}-docker-image-${{ github.sha }} | |
| - name: Load Docker Image | |
| run: docker load -i /tmp/my-image.tar | |
| - name: Run docker-compose services | |
| run: | | |
| ./setup.sh | |
| cd deployment | |
| echo "Override docker-compose.test.yml for testing purposes" | |
| cp docker-compose.test.yml docker-compose.override.yml | |
| cd ../ | |
| make dev-ci-test | |
| make wait-db | |
| - name: Backend (Prepare container and test) | |
| if: ${{ matrix.test_suite.mode == 'backend' }} | |
| run: | | |
| make dev-initialize | |
| make dev-test | |
| - name: E2E (Prepare container) | |
| if: ${{ matrix.test_suite.mode == 'e2e' }} | |
| run: | | |
| make dev-initialize | |
| make dev-runserver | |
| ${{ matrix.test_suite.script }} | |
| make sleep | |
| - name: E2E (Test production ready) | |
| if: ${{ matrix.test_suite.mode == 'e2e' }} | |
| run: | | |
| make production-check | |
| curl http://localhost:2000/ | |
| if [ $? -ne 0 ]; then | |
| echo "Curl command failed" | |
| exit 1 | |
| fi | |
| - name: E2E (Test) | |
| if: ${{ matrix.test_suite.mode == 'e2e' }} | |
| working-directory: ./playwright/ci-test | |
| run: | | |
| npm install | |
| npm ci | |
| npx playwright install --with-deps chromium | |
| npx playwright test ${{ matrix.test_suite.path }} --workers ${{ matrix.test_suite.workers }} | |
| - name: Upload Playwright Screenshots | |
| if: failure() | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: playwright-screenshots-${{ matrix.test_suite.id }} | |
| path: playwright/ci-test/playwright-results/ |