Merge pull request #291 from COS301-SE-2024/snyk-upgrade-9922b650f400… #1334
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This workflow will install Python dependencies, run tests and | |
# lint with a single version of Python | |
# For more information see: | |
# https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python | |
name: Python application | |
on: | |
push: | |
permissions: | |
contents: read | |
jobs: | |
check-tests: | |
runs-on: ubuntu-latest | |
outputs: | |
tests_exist: ${{ steps.check.outputs.tests_exist }} | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v2 | |
- name: Check for test files | |
id: check | |
run: | | |
if find . -type f -name "*_test.py" | grep -q .; then | |
echo "::set-output name=tests_exist::true" | |
else | |
echo "::set-output name=tests_exist::false" | |
fi | |
run-tests: | |
runs-on: ubuntu-latest | |
needs: check-tests | |
if: needs.check-tests.outputs.tests_exist == 'true' | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set up Python 3.10 | |
uses: actions/setup-python@v3 | |
with: | |
python-version: "3.10" | |
- name: Install NLTK and Download Resources | |
run: | | |
python -m pip install nltk | |
python -c "import nltk; nltk.download('stopwords')" | |
python -c "import nltk; nltk.download('punkt')" | |
- name: Install dependencies | |
run: | | |
sudo apt update | |
sudo apt-get install poppler-utils | |
sudo apt-get install tesseract-ocr | |
python -m pip install --upgrade pip | |
pip install flake8 pytest pytest-cov | |
ls -a | |
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi | |
- name: Test with pytest | |
env: | |
SUPABASE_URL: ${{ secrets.SUPABASE_URL }} | |
SUPABASE_KEY: ${{ secrets.SUPABASE_KEY }} | |
run: | | |
ls -a | |
cd backend/backend_tests | |
pytest --cov=. --cov-report=xml --cov-append | |
continue-on-error: true | |
- name: test gnd email monitor | |
env: | |
SUPABASE_URL: ${{ secrets.SUPABASE_URL }} | |
SUPABASE_KEY: ${{ secrets.SUPABASE_KEY }} | |
run: | | |
ls -a | |
cd backend/GND_Email_Monitor | |
pytest --cov=. --cov-report=xml --cov-append | |
continue-on-error: true | |
- name: test document parser | |
env: | |
SUPABASE_URL: ${{ secrets.SUPABASE_URL }} | |
SUPABASE_KEY: ${{ secrets.SUPABASE_KEY }} | |
run: | | |
ls -a | |
cd backend/Document_parser | |
pytest --cov=. --cov-report=xml --cov-append | |
continue-on-error: true | |
- name: Move Coverage Files to Root | |
run: | | |
mv backend/backend_tests/.coverage backend/.coverage.backend_tests | |
mv backend/GND_Email_Monitor/.coverage backend/.coverage.GND_Email_Monitor_tests | |
mv backend/Document_parser/.coverage backend/.coverage.Document_parser_tests | |
- name: Combine Coverage Reports | |
run: | | |
cd backend | |
coverage combine .coverage.* | |
coverage xml -o coverage.xml | |
- name: Integration test | |
env: | |
SUPABASE_URL: ${{ secrets.SUPABASE_URL }} | |
SUPABASE_KEY: ${{ secrets.SUPABASE_KEY }} | |
run: | | |
ls -a | |
cd backend | |
python backend_entry_int_test.py | |
- name: Upload coverage reports to Codecov | |
uses: codecov/codecov-action@v4.0.1 | |
with: | |
files: ./backend/coverage.xml | |
token: ${{ secrets.CODECOV_TOKEN }} |