Skip to content

adjusted file scan analyzers to use TLP in a smart way #3725

adjusted file scan analyzers to use TLP in a smart way

adjusted file scan analyzers to use TLP in a smart way #3725

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/[email protected]
with:
ref: ${{ github.base_ref }}
- uses: actions/[email protected]
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/[email protected]
- name: Set up Python
uses: actions/[email protected]
with:
python-version: 3.9
- name: Install Dependencies
run: |
pip3 install --upgrade pip
pip3 install -r requirements/test-requirements.txt
- name: Black formatter
run: |
black . --check --diff --exclude "migrations|venv"
- name: Lint with flake8 (PEP8 enforcer + linter)
run: |
flake8 . --config=.flake8 --show-source
- name: isort
run: |
isort . --profile black --filter-files --check-only --diff --skip configuration/ldap_config.py
backend-tests:
runs-on: ubuntu-latest
needs: linters
steps:
- name: Cancel Previous Runs
uses: styfle/[email protected]
with:
access_token: ${{ github.token }}
- name: Checkout IntelOwl
uses: actions/[email protected]
- name: Prepare Launch
run: |
unzip -P infected 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: Startup script requirements
run: |
pip3 install -r requirements/pre-requirements.txt
- name: Startup script launch (Slow)
if: contains(github.base_ref, 'master')
run: |
cp docker/env_file_integrations_template docker/env_file_integrations
python3 start.py --all_analyzers ci up --build -d
env:
DOCKER_BUILDKIT: 1
BUILDKIT_PROGRESS: "plain"
STAGE: "ci"
REPO_DOWNLOADER_ENABLED: false
- name: Startup script launch (Fast)
if: "!contains(github.base_ref, 'master')"
run: |
python3 start.py ci up --build -d
env:
DOCKER_BUILDKIT: 1
BUILDKIT_PROGRESS: "plain"
STAGE: "ci"
REPO_DOWNLOADER_ENABLED: false
- name: Docker debug
run: |
docker ps -a
- 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: "Coverage: generate xml and transfer from docker container to host"
run: |
docker exec intelowl_uwsgi coverage combine
docker exec intelowl_uwsgi coverage xml
docker cp intelowl_uwsgi:/opt/deploy/intel_owl/coverage.xml coverage.xml
- name: "Upload coverage to Codecov"
uses: codecov/[email protected]
with:
files: ./coverage.xml
fail_ci_if_error: true
verbose: true
frontend-tests:
runs-on: ubuntu-latest
needs: ["detect-changes"]
if: ${{ needs.detect-changes.outputs.frontend > 0 }}
steps:
- uses: actions/[email protected]
- name: Set up NodeJS
uses: actions/setup-node@v3
with:
node-version: 15
- name: Cache node modules
uses: actions/cache@v3
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