v6.8.0 #8126
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
| permissions: read-all | |
| name: Build & Tests | |
| on: | |
| pull_request: | |
| branches: [master, develop] | |
| paths-ignore: | |
| - "**.md" | |
| - "docs/**" | |
| - "integrations/**" | |
| jobs: | |
| detect-changes: | |
| name: Detect changes | |
| runs-on: ubuntu-latest | |
| outputs: | |
| frontend: ${{steps.diff_check.outputs.frontend}} | |
| steps: | |
| - uses: actions/checkout@v6.0.2 | |
| with: | |
| ref: ${{ github.base_ref }} | |
| - uses: actions/checkout@v6.0.2 | |
| with: | |
| clean: false | |
| - name: Generate diffs | |
| run: | | |
| git branch -a --list | cat | |
| FRONTEND_CHANGES=$(git diff --compact-summary origin/${{ github.base_ref }} -- frontend/* | wc -l) | |
| echo "::set-output name=frontend::$FRONTEND_CHANGES" | |
| id: diff_check | |
| linters: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout IntelOwl | |
| uses: actions/checkout@v6.0.2 | |
| - name: Set up Python | |
| uses: actions/setup-python@v6.3.0 | |
| with: | |
| python-version: 3.11 | |
| - name: Install Dependencies | |
| run: | | |
| pip3 install --upgrade pip | |
| pip3 install -r requirements/test-requirements.txt | |
| - name: Lint with Ruff | |
| run: | | |
| ruff check . --output-format=github | |
| - name: Check formatting with Ruff | |
| run: | | |
| ruff format . --check --diff | |
| - name: Perform ShellCheck Analysis | |
| run: bash <(curl -s https://raw.githubusercontent.com/lupaxa-cicd-toolbox/shellcheck/master/src/pipeline.sh) | |
| backend-tests: | |
| runs-on: ubuntu-latest | |
| needs: linters | |
| steps: | |
| - name: Cancel Previous Runs | |
| uses: styfle/cancel-workflow-action@0.13.0 | |
| with: | |
| access_token: ${{ github.token }} | |
| - name: Checkout IntelOwl | |
| uses: actions/checkout@v6.0.2 | |
| - name: Prepare Launch | |
| run: | | |
| unzip -P intelowl tests/test_files.zip -d test_files | |
| cp docker/env_file_app_template docker/env_file_app | |
| cp docker/env_file_postgres_template docker/env_file_postgres | |
| - name: Set image repo | |
| run: echo "IMAGE_REPO=ghcr.io/${GITHUB_REPOSITORY,,}" >> "$GITHUB_ENV" | |
| - name: Login to GHCR | |
| uses: docker/login-action@v4 | |
| with: | |
| registry: ghcr.io | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Startup script launch (Slow) | |
| # Only the develop -> master release PR runs the full build: extra analyzers plus the | |
| # chatbot stack (--ollama), which smoke-tests the ollama + celery_worker_chatbot topology | |
| # on the :ci image. Kept off every other PR because the model pull is heavy. | |
| if: github.base_ref == 'master' && github.head_ref == 'develop' | |
| run: | | |
| cp docker/env_file_integrations_template docker/env_file_integrations | |
| ./start ci up --malware_tools_analyzers --phishing_analyzers --ollama -- --build -d | |
| env: | |
| DOCKER_BUILDKIT: 1 | |
| BUILDKIT_PROGRESS: "plain" | |
| STAGE: "ci" | |
| REPO_DOWNLOADER_ENABLED: false | |
| - name: Startup script launch (Fast) | |
| # Exact complement of the Slow step so every other PR (incl. a non-develop head into | |
| # master) still gets a container up for the test steps below. | |
| if: ${{ !(github.base_ref == 'master' && github.head_ref == 'develop') }} | |
| run: | | |
| ./start ci up -- --build -d | |
| env: | |
| DOCKER_BUILDKIT: 1 | |
| BUILDKIT_PROGRESS: "plain" | |
| STAGE: "ci" | |
| REPO_DOWNLOADER_ENABLED: false | |
| - name: Docker debug | |
| if: always() | |
| run: | | |
| docker ps -a | |
| docker logs intelowl_uwsgi | |
| docker logs intelowl_daphne | |
| - name: Setup coverage | |
| run: | | |
| docker exec intelowl_uwsgi pip3 install coverage | |
| - name: Run test | |
| run: | | |
| docker exec intelowl_uwsgi coverage run manage.py test --keepdb tests | |
| - name: Run async tests | |
| run: | | |
| docker exec intelowl_uwsgi coverage run manage.py test --keepdb async_tests | |
| frontend-tests: | |
| runs-on: ubuntu-latest | |
| needs: ["detect-changes"] | |
| if: ${{ needs.detect-changes.outputs.frontend > 0 }} | |
| steps: | |
| - uses: actions/checkout@v6.0.2 | |
| - name: Set up NodeJS | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: 18 | |
| - name: Cache node modules | |
| uses: actions/cache@v6 | |
| with: | |
| path: ~/.npm | |
| key: npm-build-${{ hashFiles('frontend/package-lock.json') }} | |
| restore-keys: | | |
| npm-build-${{ hashFiles('frontend/package-lock.json') }} | |
| npm-build- | |
| npm | |
| - name: Install dependencies | |
| run: | | |
| npm i --no-optional --no-audit --no-fund | |
| working-directory: ./frontend | |
| - name: Lint with eslint | |
| run: | | |
| npm run lint | |
| working-directory: ./frontend | |
| - name: Lint with prettier | |
| run: | | |
| npm run prettier:check | |
| working-directory: ./frontend | |
| - name: Lint with stylelint | |
| run: | | |
| npm run prettier:stylelint-check | |
| working-directory: ./frontend | |
| - name: Test with Jest | |
| run: | | |
| npm run test -- --silent --coverage | |
| working-directory: ./frontend |