Update README.md #116
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: Pull Request Checks | |
on: | |
push: | |
branches: [ "main" ] | |
pull_request: | |
branches: [ "main" ] | |
types: [opened, synchronize] | |
permissions: | |
contents: read | |
jobs: | |
greet_contributor: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Greet the contributor | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
run: | | |
curl -s -X POST -H "Authorization: token $GITHUB_TOKEN" \ | |
-d '{"body": "👋 Thanks for the pull request! Our team will review it soon."}' \ | |
"https://api.github.com/repos/${{ github.repository }}/issues/${{ github.event.pull_request.number }}/comments" | |
lint_and_test: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Check out the repository | |
uses: actions/checkout@v3 | |
- name: Set up Python | |
uses: actions/setup-python@v4 | |
with: | |
python-version: '3.x' | |
- name: Install dependencies | |
run: | | |
python -m pip install --upgrade pip | |
pip install -r requirements.txt | |
pip install pylint ruff | |
- name: Run Python linter (Pylint) | |
id: pylint | |
run: | | |
export PYTHONPATH=. | |
pylint crs_scraper > pylint_report.txt || true | |
SCORE=$(grep -o "rated at [0-9.]\+" pylint_report.txt | awk '{print $3}') | |
echo "Pylint score: $SCORE" | |
if (( $(echo "$SCORE < 4.5" | bc -l) )); then | |
echo "Pylint score is below 4.5. Failing the job." | |
exit 1 | |
else | |
echo "Pylint score is above 4.5. Passing the job." | |
fi | |
- name: Display Pylint Report | |
if: success() || failure() | |
run: cat pylint_report.txt | |
- name: Run Ruff linter | |
id: ruff | |
run: | | |
ruff check . > ruff_report.txt || true | |
echo "Ruff linting completed." | |
- name: Display Ruff Report | |
if: success() || failure() | |
run: cat ruff_report.txt | |
# Will need later if there are tests already | |
# - name: Run tests | |
# run: | | |
# pytest |