-
Notifications
You must be signed in to change notification settings - Fork 13
148 lines (134 loc) · 5.5 KB
/
ci-test.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
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
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
###########################################################################
# Integration test suite definition for IRIDA Uploader using GitHub Actions
###########################################################################
name: Integration Tests
on:
pull_request: # Run on all pull requests
push:
branches: # Run on any push to development or main
- development
- main
schedule: # Run weekly on development and main
- cron: 0 2 * * 1
branches: development
- cron: 0 2 * * 1
branches: main
jobs:
build-unittests:
runs-on: ubuntu-20.04 #See pre-installed software at https://github.com/actions/virtual-environments/blob/main/images/linux/Ubuntu2004-README.md
strategy:
fail-fast: False #Setting so that if one of the test suites fail, the other will continue
matrix:
python-version: [3.7, 3.8, 3.9, "3.10", 3.11]
steps:
- uses: actions/checkout@v3 #Checkout the project from git
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Run Unit Tests
run: make unittests
env:
COVERAGE_FILE: ".coverage.unit${{ matrix.python-version }}"
- name: Store coverage file
uses: actions/upload-artifact@v3
with:
name: coverage
path: .coverage.unit${{ matrix.python-version }}
build-pep8:
runs-on: ubuntu-20.04 #See pre-installed software at https://github.com/actions/virtual-environments/blob/main/images/linux/Ubuntu2004-README.md
steps:
- uses: actions/checkout@v3 #Checkout the project from git
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: 3.8
- name: Run pep8
run: make pep8
build-docs:
runs-on: ubuntu-20.04 #See pre-installed software at https://github.com/actions/virtual-environments/blob/main/images/linux/Ubuntu2004-README.md
steps:
- uses: actions/checkout@v3 #Checkout the project from git
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: 3.7
- name: Run mkdocs
run: make docs
build-irida-integration:
runs-on: ubuntu-20.04 #See pre-installed software at https://github.com/actions/virtual-environments/blob/main/images/linux/Ubuntu2004-README.md
env:
MYSQL_PORT: 3306
MYSQL_USER: test
MYSQL_PASSWORD: test
MYSQL_DATABASE: irida_uploader_test
MYSQL_HOST: 127.0.0.1
MYSQL_ROOT_PASSWORD: password
NODE_OPTIONS: "--max-old-space-size=4096"
strategy:
fail-fast: False #Setting so that if one of the test suites fail, the other will continue
matrix:
branch: ['main','development'] # IRIDA Branches to test against
steps:
- uses: actions/checkout@v3 #Checkout the project from git
- name: Setup MySQL
uses: mirromutth/mysql-action@v1.1
with:
host port: ${{ env.MYSQL_PORT }}
character set server: 'utf8'
collation server: 'utf8_general_ci'
mysql version: '5.7'
mysql database: ${{ env.MYSQL_DATABASE }}
mysql user: ${{ env.MYSQL_USER }}
mysql password: ${{ env.MYSQL_PASSWORD }}
mysql root password: ${{ env.MYSQL_ROOT_PASSWORD }} #The root superuser password
- name: Verify MySQL connection
timeout-minutes: 10
run: |
while ! mysqladmin ping -h"${{ env.MYSQL_HOST }}" -P"${{ env.MYSQL_PORT }}" --silent; do
sleep 1
done
- name: Set up JDK 17 # Installs java 17
uses: actions/setup-java@v1
with:
java-version: 17
- name: MySQL Setup (SUDO) # Sets ONLY_FULL_GROUP_BY flag and gives runner privileges over database
run: |
sudo mysql -e "SET GLOBAL sql_mode=(SELECT REPLACE(@@sql_mode,'ONLY_FULL_GROUP_BY',''));" -h ${{ env.MYSQL_HOST }} -P ${{ env.MYSQL_PORT }} -p${{ env.MYSQL_ROOT_PASSWORD }};
sudo mysql -e "CREATE USER '${{ env.MYSQL_USER }}'@'%' IDENTIFIED BY '${{ env.MYSQL_PASSWORD }}'; GRANT ALL ON ${{ env.MYSQL_DATABASE }}.* to '${{ env.MYSQL_USER }}'@'%';" -h ${{ env.MYSQL_HOST }} -P ${{ env.MYSQL_PORT }} -p${{ env.MYSQL_ROOT_PASSWORD }};
- name: Run Integration Tests ${{ matrix.branch }}
timeout-minutes: 60
run: make integrationtests branch=${{ matrix.branch }} db_host=${{ env.MYSQL_HOST }} db_port=${{ env.MYSQL_PORT }}
env:
COVERAGE_FILE: ".coverage.integration${{ matrix.branch }}"
- name: Store coverage file
uses: actions/upload-artifact@v3
with:
name: coverage
path: .coverage.integration${{ matrix.branch }}
coverage:
if: github.event_name != 'schedule'
name: Coverage
runs-on: ubuntu-latest
needs: [build-unittests, build-irida-integration]
permissions:
pull-requests: write
contents: write
steps:
- uses: actions/checkout@v3
- uses: actions/download-artifact@v3
id: download
with:
name: 'coverage'
- name: Coverage comment
id: coverage_comment
uses: py-cov-action/python-coverage-comment-action@v3
with:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
MERGE_COVERAGE_FILES: true
- name: Store Pull Request comment to be posted
uses: actions/upload-artifact@v3
if: steps.coverage_comment.outputs.COMMENT_FILE_WRITTEN == 'true'
with:
name: python-coverage-comment-action
path: python-coverage-comment-action.txt