-
Notifications
You must be signed in to change notification settings - Fork 8
62 lines (58 loc) · 2.38 KB
/
actionTests.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
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'
FLASK_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' # only run deploy on pull requests 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' # only run deploy on pull requests 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' # only run deploy on pull requests 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 }}/?)"