-
Notifications
You must be signed in to change notification settings - Fork 0
110 lines (110 loc) · 3.25 KB
/
test.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
name: Python Tests
on:
pull_request:
paths:
- "mpscraper/**"
- "tests/**"
- "poetry.lock"
- "pyproject.toml"
- ".github/workflows/test.yml"
push:
branches:
- "main"
paths:
- "mpscraper/**"
- "tests/**"
- "poetry.lock"
- "pyproject.toml"
- ".github/workflows/test.yml"
env:
PYTHON_VERSION: "3.12"
jobs:
lint:
name: Lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install Python 3
uses: actions/setup-python@v5
with:
python-version: ${{ env.PYTHON_VERSION }}
- uses: pre-commit/action@v3.0.1
env:
RUFF_OUTPUT_FORMAT: github
test:
strategy:
fail-fast: true
matrix:
os: ["ubuntu-latest"]
python-version: ["3.12"]
runs-on: ${{ matrix.os }}
timeout-minutes: 10
steps:
- uses: actions/checkout@v4
- name: Install Python 3
uses: actions/setup-python@v5
with:
python-version: ${{ env.PYTHON_VERSION }}
- name: Install xvfb & chromium-browser
run: |
sudo apt-get update
sudo apt-get install -y xvfb chromium-browser
- name: Setup Chromedriver
uses: nanasess/setup-chromedriver@v2
env:
CHROMEAPP: chromium-browser
- name: Run Chromedriver
run: |
echo "CHROMIUM_PATH=$(which chromium)" >> "$GITHUB_ENV"
echo "CHROMEDRIVER_PATH=$(which chromedriver)" >> "$GITHUB_ENV"
export DISPLAY=:99
chromedriver --url-base=/wd/hub &
sudo Xvfb -ac :99 -screen 0 1280x1024x24 > /dev/null 2>&1 &
- name: Install Poetry
uses: snok/install-poetry@v1
with:
virtualenvs-create: true
virtualenvs-in-project: true
- name: Load cached venv
id: cached-poetry-dependencies
uses: actions/cache@v4
with:
path: .venv
key: venv-${{ runner.os }}-${{ hashFiles('**/poetry.lock') }}
- name: Install dependencies
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
run: poetry install --no-interaction --no-root
- name: Run Pytest
run: |
source .venv/bin/activate
pytest -vv --cov=./mpscraper --cov-report=xml ./tests
- name: Upload Coverage to Codecov
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
security:
runs-on: "ubuntu-latest"
steps:
- uses: actions/checkout@v4
- name: Install Python 3
uses: actions/setup-python@v5
with:
python-version: ${{ env.PYTHON_VERSION }}
- name: Install Poetry
uses: snok/install-poetry@v1
with:
virtualenvs-create: true
virtualenvs-in-project: true
- name: Load cached venv
id: cached-poetry-dependencies
uses: actions/cache@v4
with:
path: .venv
key: venv-${{ runner.os }}-${{ hashFiles('**/poetry.lock') }}
- name: Install dependencies
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
run: poetry install --no-interaction --no-root
- name: Run Bandit
run: |-
source .venv/bin/activate
bandit -r ./mpscraper