Refactoring/23 introduce code format check and linter check (#29) #4
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
name: "Static analysis & tests" | |
on: | |
push: | |
branches: [ "master" ] | |
pull_request: | |
jobs: | |
analysis: | |
runs-on: ubuntu-latest | |
name: Pylint Analysis | |
steps: | |
- name: Checkout repository | |
uses: actions/[email protected] | |
- name: Set up Python | |
uses: actions/[email protected] | |
with: | |
python-version: '3.11' | |
cache: 'pip' | |
- name: Install dependencies | |
run: | | |
pip install -r requirements.txt | |
- name: Analyze code with Pylint | |
id: analyze-code | |
run: | | |
pylint_score=$(pylint $(git ls-files '*.py')| grep 'rated at' | awk '{print $7}' | cut -d'/' -f1) | |
echo "PYLINT_SCORE=$pylint_score" >> $GITHUB_ENV | |
- name: Check Pylint score | |
run: | | |
if (( $(echo "$PYLINT_SCORE < 9.5" | bc -l) )); then | |
echo "Failure: Pylint score is below 9.5 (project score: $PYLINT_SCORE)." | |
exit 1 | |
else | |
echo "Success: Pylint score is above 9.5 (project score: $PYLINT_SCORE)." | |
fi | |
python-tests: | |
runs-on: ubuntu-latest | |
name: Python tests | |
steps: | |
- name: Checkout repository | |
uses: actions/[email protected] | |
- name: Set up Python | |
uses: actions/[email protected] | |
with: | |
python-version: '3.11' | |
cache: 'pip' | |
- name: Install dependencies | |
run: | | |
pip install -r requirements.txt | |
pip install coverage pytest | |
- name: Run tests | |
run: coverage run --source='similarity,column2Vec' -m pytest ./tests | |
# - name: Show coverage | |
# run: coverage report -m | |
# - name: Create coverage file | |
# run: coverage xml | |
# - name: Get Cover | |
# uses: orgoro/[email protected] | |
# with: | |
# coverageFile: coverage.xml | |
# token: ${{ secrets.GITHUB_TOKEN }} | |
# thresholdAll: 0.7 | |
# thresholdNew: 0.9 |