Skip to content

Commit 6c521f1

Browse files
authored
Merge all formatting and testing CI into one (#1312)
* Merge all formatting and testing CI into one * Remove useless statements * Don't run CodeQL or container on pushes, only PRs
1 parent 6bfcfbe commit 6c521f1

File tree

2 files changed

+12
-135
lines changed

2 files changed

+12
-135
lines changed

.github/workflows/ci.yml

+12-133
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,12 @@ on:
88
types: [opened, labeled]
99

1010
jobs:
11-
pyTest:
11+
codeValidation:
1212
if: |
1313
github.event_name == 'push' ||
1414
(
1515
github.event_name == 'pull_request' &&
1616
(
17-
contains(github.event.pull_request.title, '[run ci]') ||
18-
contains(github.event.pull_request.body, '[run ci]') ||
1917
contains(join(github.event.pull_request.labels.*.name), 'run-ci')
2018
)
2119
)
@@ -36,79 +34,12 @@ jobs:
3634
- name: Install from pipfile
3735
run: |
3836
pipenv install --system
39-
- name: Running pytest
40-
run: |
41-
cd techsupport_bot
42-
python3.11 -m pytest tests/ -p no:warnings
43-
44-
black:
45-
if: |
46-
github.event_name == 'push' ||
47-
(
48-
github.event_name == 'pull_request' &&
49-
(
50-
contains(github.event.pull_request.title, '[run ci]') ||
51-
contains(github.event.pull_request.body, '[run ci]') ||
52-
contains(join(github.event.pull_request.labels.*.name), 'run-ci')
53-
)
54-
)
55-
runs-on: ubuntu-latest
56-
steps:
57-
- uses: actions/checkout@v3
58-
- name: Set up Python 3.11
59-
uses: actions/setup-python@v3
60-
with:
61-
python-version: 3.11
62-
- name: Install dependencies
63-
run: |
64-
python -m pip install pip==$(sed -nE 's/pip = "==(.*)"/\1/p' Pipfile)
65-
BLACK_VERSION=$(sed -nE 's/black = "==(.*)"/\1/p' Pipfile)
66-
pip install black==$BLACK_VERSION
6737
- name: Analysing the code with black
6838
run: |
6939
black $(git rev-parse --show-toplevel) --check
70-
71-
pyLint:
72-
if: |
73-
github.event_name == 'push' ||
74-
(
75-
github.event_name == 'pull_request' &&
76-
(
77-
contains(github.event.pull_request.title, '[run ci]') ||
78-
contains(github.event.pull_request.body, '[run ci]') ||
79-
contains(join(github.event.pull_request.labels.*.name), 'run-ci')
80-
)
81-
)
82-
runs-on: ubuntu-latest
83-
steps:
84-
- uses: actions/checkout@v3
85-
- name: Set up Python 3.11
86-
uses: actions/setup-python@v3
87-
with:
88-
python-version: 3.11
89-
- name: Install dependencies
90-
run: |
91-
python -m pip install pip==$(sed -nE 's/pip = "==(.*)"/\1/p' Pipfile)
92-
PYLINT_VERSION=$(sed -nE 's/pylint = "==(.*)"/\1/p' Pipfile)
93-
pip install pylint==$PYLINT_VERSION
9440
- name: Analysing the code with pylint
9541
run: |
9642
pylint $(git ls-files '*.py')
97-
98-
lineEndingCheck:
99-
if: |
100-
github.event_name == 'push' ||
101-
(
102-
github.event_name == 'pull_request' &&
103-
(
104-
contains(github.event.pull_request.title, '[run ci]') ||
105-
contains(github.event.pull_request.body, '[run ci]') ||
106-
contains(join(github.event.pull_request.labels.*.name), 'run-ci')
107-
)
108-
)
109-
runs-on: ubuntu-latest
110-
steps:
111-
- uses: actions/checkout@v3
11243
- name: Check for CRLF line endings
11344
run: |
11445
for file in $(git ls-files); do
@@ -120,78 +51,26 @@ jobs:
12051
echo "CRLF line endings detected"
12152
exit 1
12253
fi
123-
124-
flake8:
125-
if: |
126-
github.event_name == 'push' ||
127-
(
128-
github.event_name == 'pull_request' &&
129-
(
130-
contains(github.event.pull_request.title, '[run ci]') ||
131-
contains(github.event.pull_request.body, '[run ci]') ||
132-
contains(join(github.event.pull_request.labels.*.name), 'run-ci')
133-
)
134-
)
135-
runs-on: ubuntu-latest
136-
steps:
137-
- uses: actions/checkout@v3
138-
- name: Set up Python 3.11
139-
uses: actions/setup-python@v3
140-
with:
141-
python-version: 3.11
142-
- name: Install dependencies
143-
run: |
144-
python -m pip install pip==$(sed -nE 's/pip = "==(.*)"/\1/p' Pipfile)
145-
pip install pipenv==$(sed -nE 's/pipenv = "==(.*)"/\1/p' Pipfile)
146-
pipenv install --system
14754
- name: Analysing the code with flake8
14855
run: |
14956
flake8 $(git rev-parse --show-toplevel)
150-
151-
isort:
152-
if: |
153-
github.event_name == 'push' ||
154-
(
155-
github.event_name == 'pull_request' &&
156-
(
157-
contains(github.event.pull_request.title, '[run ci]') ||
158-
contains(github.event.pull_request.body, '[run ci]') ||
159-
contains(join(github.event.pull_request.labels.*.name), 'run-ci')
160-
)
161-
)
162-
runs-on: ubuntu-latest
163-
steps:
164-
- uses: actions/checkout@v3
165-
- name: Set up Python 3.11
166-
uses: actions/setup-python@v3
167-
with:
168-
python-version: 3.11
169-
- name: Install dependencies
170-
run: |
171-
python -m pip install pip==$(sed -nE 's/pip = "==(.*)"/\1/p' Pipfile)
172-
ISORT_VERSION=$(sed -nE 's/isort = "==(.*)"/\1/p' Pipfile)
173-
pip install isort==$ISORT_VERSION
17457
- name: Analysing the code with isort
17558
run: |
17659
isort --check-only $(git rev-parse --show-toplevel)/ --profile black
60+
- name: Running pytest
61+
run: |
62+
cd techsupport_bot
63+
python3.11 -m pytest tests/ -p no:warnings
17764
17865
containerBuild:
17966
if: |
180-
github.event_name == 'push' ||
67+
github.event_name == 'pull_request' &&
18168
(
182-
github.event_name == 'pull_request' &&
183-
(
184-
contains(github.event.pull_request.title, '[run ci]') ||
185-
contains(github.event.pull_request.body, '[run ci]') ||
186-
contains(join(github.event.pull_request.labels.*.name), 'run-ci')
187-
)
69+
contains(join(github.event.pull_request.labels.*.name), 'run-ci')
18870
)
18971
runs-on: ubuntu-latest
19072
needs:
191-
- pyTest
192-
- pyLint
193-
- flake8
194-
- isort
73+
- codeValidation
19574
steps:
19675
- uses: actions/checkout@v3
19776
- name: Build the Docker image
@@ -201,7 +80,7 @@ jobs:
20180
if: github.event_name == 'pull_request' && github.actor == 'dependabot[bot]'
20281
runs-on: ubuntu-latest
20382
needs:
204-
- pyTest
83+
- codeValidation
20584
permissions:
20685
contents: write
20786
pull-requests: write
@@ -222,7 +101,7 @@ jobs:
222101
if: github.event_name == 'pull_request' && github.actor == 'dependabot[bot]'
223102
runs-on: ubuntu-latest
224103
needs:
225-
- pyLint
104+
- codeValidation
226105
permissions:
227106
contents: write
228107
pull-requests: write
@@ -243,7 +122,7 @@ jobs:
243122
if: github.event_name == 'pull_request' && github.actor == 'dependabot[bot]'
244123
runs-on: ubuntu-latest
245124
needs:
246-
- flake8
125+
- codeValidation
247126
permissions:
248127
contents: write
249128
pull-requests: write
@@ -264,7 +143,7 @@ jobs:
264143
if: github.event_name == 'pull_request' && github.actor == 'dependabot[bot]'
265144
runs-on: ubuntu-latest
266145
needs:
267-
- isort
146+
- codeValidation
268147
permissions:
269148
contents: write
270149
pull-requests: write

.github/workflows/codeql.yml

-2
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@
1212
name: "CodeQL"
1313

1414
on:
15-
push:
16-
branches: [ "main" ]
1715
pull_request:
1816
branches: [ "main" ]
1917
types: [opened, labeled]

0 commit comments

Comments
 (0)