Skip to content

Merge pull request #511 from Plant-Tracer/fix-509 #2089

Merge pull request #511 from Plant-Tracer/fix-509

Merge pull request #511 from Plant-Tracer/fix-509 #2089

# See https://docs.github.com/en/actions/guides/building-and-testing-python
# 2020-02-20 slg - For Dreamhost, we are now using Python 3.9 and Ubuntu-18.04
# There is no way to generate a random password that can be used in the services section, so that will need to be moved to a repository secret of RANDOM_PASSWORD
name: CI (pip)
on: [push, pull_request]
jobs:
build:
strategy:
matrix:
os: ['ubuntu-latest'] # with MySQL service, we now only run on ubuntu
python-version: [3.11] # installed version on Dreamhost
runs-on: ${{ matrix.os }}
services:
# https://stackoverflow.com/questions/72294279/how-to-connect-to-mysql-databas-using-github-actions
mysql:
image: mysql:8.0
env:
# The MySQL docker container requires these environment variables to be set
# so we can create and migrate the test database.
# See: https://hub.docker.com/_/mysql
MYSQL_DATABASE: testdb
MYSQL_ROOT_PASSWORD: testrootpass
ports:
# Opens port 3306 on service container and host
# https://docs.github.com/en/actions/using-containerized-services/about-service-containers
- 3306:3306
# Before continuing, verify the mysql container is reachable from the ubuntu host
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3
timeout-minutes: 10
steps:
- name: Checkout
uses: actions/checkout@v4
with:
submodules: true
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: "Configure ubuntu with ffmpeg"
if: startsWith(matrix.os, 'ubuntu')
uses: FedericoCarboni/setup-ffmpeg@v3
id: setup-ffmpeg
- name: "Configure ubuntu"
if: startsWith(matrix.os, 'ubuntu')
run: |
make install-ubuntu
- name: "Configure MacOS"
if: startsWith(matrix.os, 'macos')
run: |
make install-macos
- name: "Configure Windows"
if: startsWith(matrix.os, 'windows')
run: |
make install-windows
- name: "Install Chrome"
id: setup-chrome
uses: browser-actions/setup-chrome@v1.7.1
with:
chrome-version: stable
- name: "Show Chrome info"
run: |
echo Installed Chrome to ${{ steps.setup-chrome.outputs.chrome-path }}
${{ steps.setup-chrome.outputs.chrome-path }} --version
- name: Install chromedriver
uses: nanasess/setup-chromedriver@v2.2.2
- name: Update GITHUB_PATH and install Python dependencies
run: |
echo "$HOME/.local/bin" >> $GITHUB_PATH
make install-python-dependencies
- name: Lint with pylint
run: |
make pylint
- name: JavaScript and HTML eslint
run: |
make eslint
- name: Create local MySQL database
if: startsWith(matrix.os, 'ubuntu')
env:
MYSQL_ROOT_PASSWORD: testrootpass
PLANTTRACER_CREDENTIALS: etc/credentials.ini
run: |
echo the following assumes that the root configuration is in etc/github_actions_mysql_rootconfig.ini
make create_localdb
- name: Validate app framework
env:
PLANTTRACER_CREDENTIALS: etc/credentials.ini
run: |
make pytest-app-framework
- name: Run coverage test
if: startsWith(matrix.os, 'ubuntu')
env:
SKIP_ENDPOINT_TEST: ${{ vars.SKIP_ENDPOINT_TEST }}
PLANTTRACER_CREDENTIALS: etc/credentials.ini
run: |
CHROME_PATH=${{ steps.setup-chrome.outputs.chrome-path }} make coverage
- name: Upload to codecov.io
if: startsWith(matrix.os, 'ubuntu')
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
verbose: true
files: ./coverage.xml
- name: Show files in directory
env:
PLANTTRACER_CREDENTIALS: etc/credentials.ini
run: |
make coverage
ls -l
- name: Run JavaScript tests and coverage
env:
PLANTTRACER_CREDENTIALS: etc/credentials.ini
run: |
make jscoverage