-
Notifications
You must be signed in to change notification settings - Fork 0
137 lines (114 loc) · 4.32 KB
/
CI.yml
File metadata and controls
137 lines (114 loc) · 4.32 KB
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
# This workflow will install Python dependencies, run tests and lint with a single version of Python
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions
name: CI pipeline
on:
push:
paths-ignore:
- '**.md'
- '**.png'
- '**.jpg'
- '**.webp'
branches: [ master ]
pull_request:
branches: [ master ]
workflow_dispatch:
inputs:
python_version:
type: choice
description: Choose python version
required: true
options:
- "3.11"
- "3.10"
- "3.9"
default: "3.10"
maria_tag:
default: "10.8.3-jammy"
wp_tag:
default: "6.0.1"
schedule:
- cron: "0 0 * * FRI"
jobs:
build:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3
- name: Set the variables
env:
DEFAULT_MARIA_TAG: "10.8.3-jammy"
DEFAULT_WP_TAG: "6.0.1"
DEFAULT_PY_VERSION: '3.10'
run: |
echo "PY_VERS=${{ github.event.inputs.python_version || env.DEFAULT_PY_VERSION }}" >> $GITHUB_ENV
echo "MARIA_TAG=${{ github.event.inputs.maria_tag || env.DEFAULT_MARIA_TAG }}" >> $GITHUB_ENV
echo "WP_TAG=${{ github.event.inputs.wp_tag || env.DEFAULT_WP_TAG }}" >> $GITHUB_ENV
- name: Set up ${{env.PY_VERS}}
uses: actions/setup-python@v3
with:
python-version: ${{env.PY_VERS}}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install flake8 pytest coverage
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
- name: Lint with flake8
run: |
# stop the build if there are Python syntax errors or undefined names
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
- name: Check dir
run: |
ls -la
- name: Check ports
run: |
sudo ss -tulpn
- name: Spin up DB container
run: |
docker run --name mariadb -e MYSQL_ROOT_PASSWORD=mypass -p 3306:3306 -d --restart unless-stopped mariadb:${{env.MARIA_TAG}}
- name: Spin up WordPress container
run: |
# Query, can we expose on 0? Or localhost only?
docker run -p 80:80 -p 443:443 -p 127.0.0.1:8066:22 --name mywp -d --restart unless-stopped wordpress:${{env.WP_TAG}}
mariadb_addy=$(docker inspect --format '{{ .NetworkSettings.IPAddress }}' mariadb)
sed -i "s/172.17.0.3/$mariadb_addy/" wp-config.php
docker cp wp-config.php mywp:/var/www/html/wp-config.php
docker cp ssl-params.conf mywp:/etc/apache2/conf-available/ssl-params.conf
docker cp wordpress.conf mywp:/etc/apache2/sites-available/wordpress.conf
docker exec -i mywp bash < wp_provisioning.sh
docker restart mywp
docker exec -i mywp /etc/init.d/ssh start
- name: Await return of mariadb container
run: |
while ! docker exec mariadb mysql -uroot -pmypass -e "SELECT 1" >/dev/null 2>&1; do
echo sleeping.
docker ps
sleep 1
done
- name: Use WP's IP for DB user
run: |
wp_addy=$(docker inspect --format '{{ .NetworkSettings.IPAddress }}' mywp)
echo "wp_addy = $wp_addy"
sed -i "s/wpdockerip/$wp_addy/" wpdbsetup.sql
cp tests/config_template.json tests/config.json
docker ps
- name: Grab WP's self-signed cert
run: |
echo quit | openssl s_client -showcerts -servername "localhost" -connect localhost:443 > self-signed-cacert.crt
- name: Inject SQL scripts to MySQL
run: |
docker exec -i mariadb mysql -uroot -pmypass < wpdbsetup.sql
docker exec -i mariadb mysql -uroot -pmypass wordpress < full_db_220727_0953.sql
- name: Test with pytest for coverage
run: |
cd tests
PYTHONPATH=.. coverage run --source="../wp_api" -m pytest
- name: Test coverage
run: |
cd tests
PYTHONPATH=.. coverage report -m --fail-under=95
coverage json
- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v3
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}