This repository has been archived by the owner on Jan 5, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
132 lines (114 loc) · 3.48 KB
/
main.yaml
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
name: Main branch testing
on:
push:
branches: [ main ]
jobs:
django_test:
name: pytest
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [3.10.5, 3.11.2]
steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
pip install -r requirements_dev.txt
-
name: Run tests
env:
DJANGO_SETTINGS_MODULE: commendationSite.settings_CI
MICROSOFT_AUTH_CLIENT_ID: ${{ secrets.MICROSOFT_AUTH_CLIENT_ID }}
MICROSOFT_AUTH_CLIENT_SECRET: ${{ secrets.MICROSOFT_AUTH_CLIENT_SECRET }}
run: |
python manage.py test --failfast --noinput --verbosity=3
coverage:
name: Check test coverage
runs-on: ubuntu-latest
needs: django_test
steps:
- uses: actions/checkout@v3
- name: Set up Python 3.10.5
uses: actions/setup-python@v2
with:
python-version: 3.10.5
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
pip install -r requirements_dev.txt
- name: Run tests
env:
DJANGO_SETTINGS_MODULE: commendationSite.settings_CI
run: |
coverage run manage.py test --noinput
coverage combine
- name: Coverage Reports
run: |
coverage report -m
coverage xml
- name: Upload coverage as artifact
uses: actions/upload-artifact@v3
with:
name: coverage
path: coverage.xml
- name: Report results to DeepSource
continue-on-error: true
run: |
coverage xml
curl https://deepsource.io/cli | sh
./bin/deepsource report --analyzer test-coverage --key python --value-file ./coverage.xml
env:
DEEPSOURCE_DSN: ${{ secrets.DEEPSOURCE_DSN }}
lint:
# Run isort and black to check for import order and code formatting
name: Lint
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v3
- name: Set up Python 3.10.5
uses: actions/setup-python@v2
with:
python-version: 3.10.5
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
pip install -r requirements_dev.txt
- name: Run isort
run: |
isort .
- name: Run black
run: |
black .
- name: Commit and push changes
uses: stefanzweifel/git-auto-commit-action@v4
with:
commit_message: "style: Format ${{ github.sha }}"
commit_options: '--no-verify --signoff'
# deploy:
# name: Deploy to dev
# runs-on: ubuntu-latest
# needs: [django_test, coverage, lint]
# steps:
# - name: Checkout
# uses: actions/checkout@v2
# - name: Create SSH key
# run: |
# mkdir -p ~/.ssh/
# echo "${{ secrets.SSH_PRIVATE_KEY }}" > ~/.ssh/id_ed25519
# chmod 600 ~/.ssh/id_ed25519
# ssh-keyscan -t rsa ${{ secrets.SSH_HOST }} >> ~/.ssh/known_hosts
# shell: bash
# - name: Deploy to dev environment
# run: |
# ssh -i ~/.ssh/id_ed25519 ${{ secrets.SSH_USER }}@${{ secrets.SSH_HOST }} -p ${{ secrets.SSH_PORT }} "cd /var/www/ && ./update-DCS.sh"
# shell: bash