-
-
Notifications
You must be signed in to change notification settings - Fork 442
155 lines (135 loc) · 4.26 KB
/
pull_request_automation.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
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.11
- 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|.ipython|docs_env|.cache"
- 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 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: Startup script launch (Slow)
if: contains(github.base_ref, 'master')
run: |
cp docker/env_file_integrations_template docker/env_file_integrations
./start ci up --all_analyzers -- --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: |
./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
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@v4
with:
node-version: 18
- name: Cache node modules
uses: actions/cache@v4
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