Skip to content

Commit

Permalink
fix test stage
Browse files Browse the repository at this point in the history
  • Loading branch information
RitheeshBaradwaj committed Sep 16, 2023
1 parent 8e0e0d4 commit c7df135
Show file tree
Hide file tree
Showing 2 changed files with 115 additions and 113 deletions.
226 changes: 114 additions & 112 deletions .github/workflows/python-build.yml
Original file line number Diff line number Diff line change
@@ -1,112 +1,114 @@
name: Build and Test Python Package

on:
push:
branches:
- main
pull_request:

jobs:
build:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: 3.10.x

- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install libsox-dev
sudo apt-get install sox -y
sudo apt install ffmpeg -y
python -m pip install --upgrade pip
pip install -r requirements.txt
- name: Build package
run: |
python setup.py sdist bdist_wheel
- name: Upload package to Github Releases
uses: actions/upload-artifact@v2
with:
name: mimasa-build
path: dist

test:
runs-on: ubuntu-latest
needs: build

steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: 3.10.x

- name: Download package artifacts
uses: actions/download-artifact@v2
with:
name: mimasa-build

- name: Install package & dependencies
run: |
sudo apt-get update
sudo apt-get install libsox-dev
sudo apt-get install sox -y
sudo apt install ffmpeg -y
python -m pip install --upgrade pip
python -m pip install *.whl
- name: Run unit tests
run: python src/api/mimasa/manage.py test face_detection

- name: Generate Coverage Reports
run: |
coverage run src/api/mimasa/manage.py test face_detection
coverage html
- name: Upload coverage report to Github Releases
uses: actions/upload-artifact@v2
with:
name: mimasa-coverage-report
path: _coverage_report

- name: Download artifacts
uses: actions/download-artifact@v2
with:
name: mimasa-coverage-report

- name: Post Coverage Report Comment
if: ${{ github.event_name }} == 'pull_request'
uses: actions/github-script@v4
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const result = await github.pulls.list({
owner: context.repo.owner,
repo: context.repo.repo,
head: context.sha,
});
if (result.data.length) {
const fs = require('fs');
const path = require('path');
const reportPath = path.join(process.env.GITHUB_WORKSPACE, '_coverage_report/index.html');
const report = fs.readFileSync(reportPath, 'utf8');
const comment = `## Coverage Report\n\n${report}`;
const pullRequest = result.data[0];
await github.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: pullRequest.number,
body: comment,
});
}
name: Build and Test Python Package

on:
push:
branches:
- main
pull_request:

jobs:
build:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: 3.10.x

- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install libsox-dev
sudo apt-get install sox -y
sudo apt install ffmpeg -y
python -m pip install --upgrade pip
pip install -r requirements.txt
- name: Build package
run: |
python setup.py sdist bdist_wheel
- name: Upload package to Github Releases
uses: actions/upload-artifact@v2
with:
name: mimasa-build
path: dist

test:
runs-on: ubuntu-latest
needs: build

steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: 3.10.x

- name: Download package artifacts
uses: actions/download-artifact@v2
with:
name: mimasa-build

- name: Install package & dependencies
run: |
sudo apt-get update
sudo apt-get install libsox-dev
sudo apt-get install sox -y
sudo apt install ffmpeg -y
python -m pip install --upgrade pip
python -m pip install *.whl
- name: Run unit tests
run: |
python src/common/download_data.py
python src/api/mimasa/manage.py test face_detection
- name: Generate Coverage Reports
run: |
coverage run src/api/mimasa/manage.py test face_detection
coverage html
- name: Upload coverage report to Github Releases
uses: actions/upload-artifact@v2
with:
name: mimasa-coverage-report
path: _coverage_report

- name: Download artifacts
uses: actions/download-artifact@v2
with:
name: mimasa-coverage-report

- name: Post Coverage Report Comment
if: ${{ github.event_name }} == 'pull_request'
uses: actions/github-script@v4
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const result = await github.pulls.list({
owner: context.repo.owner,
repo: context.repo.repo,
head: context.sha,
});
if (result.data.length) {
const fs = require('fs');
const path = require('path');
const reportPath = path.join(process.env.GITHUB_WORKSPACE, '_coverage_report/index.html');
const report = fs.readFileSync(reportPath, 'utf8');
const comment = `## Coverage Report\n\n${report}`;
const pullRequest = result.data[0];
await github.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: pullRequest.number,
body: comment,
});
}
2 changes: 1 addition & 1 deletion src/common/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@


def is_venv():
"""Returns if the current env is a venv"""
"""Returns true if the current env is a venv"""
return hasattr(sys, "real_prefix") or (hasattr(sys, "base_prefix") and sys.base_prefix != sys.prefix)


Expand Down

0 comments on commit c7df135

Please sign in to comment.