forked from cve-search/cve-search
-
Notifications
You must be signed in to change notification settings - Fork 40
142 lines (135 loc) · 5.22 KB
/
unit_tests.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
name: Build & Test
on:
push:
branches:
- master
pull_request:
branches:
- master
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [ '3.10' ]
steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Cache pip
id: cache-pip
uses: actions/cache@v2
with:
# This path is specific to Ubuntu
# path: ~/.cache/pip
path: ${{ env.pythonLocation}}
# Look to see if there is a cache hit for the corresponding requirements file
key: ${{ runner.os }}_${{ env.pythonLocation}}_pip_v1_${{ matrix.python-version }}_${{ hashFiles('requirements.txt') }}_${{ hashFiles('requirements-dev.txt') }}
- name: Install dependencies
if: steps.cache-pip.outputs.cache-hit != 'true'
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
pip install -r requirements-dev.txt
test:
needs: build
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [ '3.10' ]
mongodb-version: [ '4.4' ]
steps:
- uses: actions/checkout@v2
- name: Start MongoDB
uses: supercharge/mongodb-github-action@1.3.0
with:
mongodb-version: ${{ matrix.mongodb-version }}
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Cache pip
id: cache-pip
uses: actions/cache@v2
with:
# This path is specific to Ubuntu
# path: ~/.cache/pip
path: ${{ env.pythonLocation}}
# Look to see if there is a cache hit for the corresponding requirements file
key: ${{ runner.os }}_${{ env.pythonLocation}}_pip_v1_${{ matrix.python-version }}_${{ hashFiles('requirements.txt') }}_${{ hashFiles('requirements-dev.txt') }}
- name: Inserting test data
run: |
python3 ./test/test_data/setup_test_data.py
- name: Test with pytest
run: |
pytest --doctest-modules --junitxml=junit/test-results_${{ matrix.python-version }}.xml --cov-report=xml --cov-report=html --cov=./ test/unit
- name: Upload pytest test results
uses: actions/upload-artifact@v2
with:
name: pytest-results_${{ matrix.python-version }}
path: junit/test-results_${{ matrix.python-version }}.xml
# Use always() to always run this step to publish test results when there are test failures
# if: ${{ always() }}
# - name: Upload coverage to Codecov
# uses: codecov/codecov-action@v1
# with:
# file: junit/test-results_${{ matrix.python-version }}.xml
# flags: unittests
# env_vars: OS,PYTHON
# name: codecov-umbrella
# fail_ci_if_error: true
# verbose: true
# web_tests:
# needs: build
# runs-on: ubuntu-latest
# steps:
# - uses: actions/checkout@v2
# - name: Set up Python 3.10
# uses: actions/setup-python@v2
# with:
# python-version: '3.10'
# - name: Cache pip
# id: cache-pip
# uses: actions/cache@v2
# with:
# # This path is specific to Ubuntu
# # path: ~/.cache/pip
# path: ${{ env.pythonLocation}}
# # Look to see if there is a cache hit for the corresponding requirements file
# key: ${{ runner.os }}_${{ env.pythonLocation}}_pip_v1_3.10_${{ hashFiles('requirements.txt') }}_${{ hashFiles('requirements-dev.txt') }}
# - name: Install latest docker version
# run: |
# curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
# sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
# sudo apt-get update
# sudo apt-get -y -o Dpkg::Options::="--force-confnew" install docker-ce
# - name: Clone Cve Search Docker and Run docker-compose
# if: github.event_name == 'push'
# run: |
# git clone https://github.com/cve-search/CVE-Search-Docker.git
# cd CVE-Search-Docker
# docker-compose build
# docker-compose up -d
# sleep 180
# - name: Clone Cve Search Docker and Run docker-compose
# if: github.event_name == 'pull_request'
# env:
# PR_REPO_OWNER: ${{ github.actor }}
# PR_REPO_NAME: /cve-search
# PR_BRANCH: ${{ github.head_ref }}
# run: |
# git clone https://github.com/cve-search/CVE-Search-Docker.git
# cd CVE-Search-Docker
# docker-compose build --build-arg REPO=$PR_REPO_OWNER$PR_REPO_NAME --build-arg BRANCH=$PR_BRANCH
# docker-compose up -d
# sleep 180
# - name: Test with pytest
# run: |
# pytest --doctest-modules --junitxml=junit/test-results_web_${{ matrix.python-version }}.xml test/web/
# - name: Upload pytest test results
# uses: actions/upload-artifact@v2
# with:
# name: pytest-results_web_${{ matrix.python-version }}
# path: junit/test-results_web_${{ matrix.python-version }}.xml