Skip to content

Merge pull request #1184 from BCStudentSoftwareDevTeam/1151-Other-Com… #1626

Merge pull request #1184 from BCStudentSoftwareDevTeam/1151-Other-Com…

Merge pull request #1184 from BCStudentSoftwareDevTeam/1151-Other-Com… #1626

Workflow file for this run

name: Celts CI
on:
workflow_dispatch:
push:
branches:
- development
- production
pull_request:
branches:
- development
- production
jobs:
build:
runs-on: ubuntu-latest
permissions:
pull-requests: write
strategy:
matrix:
python-version: ["3.7", "3.8", "3.9", "3.10", "3.11"]
# each step can define `env` vars, but it's easiest to define them on the build level
env:
MYSQL_DATABASE: 'celts'
MYSQL_USER: 'celts_user'
MYSQL_PASSWORD: 'password'
MYSQL_ROOT_PASSWORD: 'root'
APP_ENV: 'testing'
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
cache: 'pip'
- run: sudo /etc/init.d/mysql start
- name: Install dependencies
run: source setup.sh
- name: Activate environment and reset database
run: . venv/bin/activate && database/reset_database.sh test
- name: Run tests
run: . venv/bin/activate && ./tests/run_tests.sh && coverage html --omit=tests/*
- name: Deploy code coverage report
if: github.event_name == 'pull_request' && matrix.python-version == '3.11' && github.event.pull_request.head.repo.full_name == github.repository # only run deploy on pull requests that are from the base repo and python 3.11
uses: peaceiris/actions-gh-pages@v3
with:
deploy_key: ${{ secrets.COVERAGE_DEPLOY_KEY }}
external_repository: BCStudentSoftwareDevTeam/coverage
publish_branch: main
publish_dir: ./htmlcov
destination_dir: ${{ github.repository }}/${{ github.head_ref }}
exclude_assets: ".gitignore" # without exclude_assets, htmlcov/ was being removed and not pushed to the coverage repo
- name: Coverage report URL
if: github.event_name == 'pull_request' && matrix.python-version == '3.11' && github.event.pull_request.head.repo.full_name == github.repository # only run deploy on pull requests that are from the base repo and python 3.11
run: echo '[View Code Coverage](https://bcstudentsoftwaredevteam.github.io/coverage/${{ github.repository }}/${{ github.head_ref }}/?)' >> $GITHUB_STEP_SUMMARY
- name: Put coverage link on PR
if: github.event_name == 'pull_request' && matrix.python-version == '3.11' && github.event.pull_request.head.repo.full_name == github.repository # only run deploy on pull requests that are from the base repo and python 3.11
uses: mshick/add-pr-comment@v2
with:
refresh-message-position: True
message: "[View Code Coverage](https://bcstudentsoftwaredevteam.github.io/coverage/${{ github.repository }}/${{ github.head_ref }}/?)"