Update README.md #82
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
############################################################################## | |
############################################################################## | |
# | |
# Push Workflow | |
# | |
############################################################################## | |
############################################################################## | |
name: Push Workflow | |
on: | |
push: | |
branches: | |
- "**" | |
env: | |
CODECOV_UNIQUE_NAME: CODECOV_UNIQUE_NAME-${{ github.run_id }}-${{ github.run_number }} | |
DATABASE_NAME: switchmap_unittest | |
DATABASE_USERNAME: switchmap_unittest | |
DATABASE_PASSWORD: switchmap_unittest | |
MYSQL_ROOT_USERNAME: root | |
MYSQL_ROOT_PASSWORD: root | |
jobs: | |
Test-Application: | |
name: Test Application | |
needs: [Linting-and-Formatting] | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Set up Python 3.11 | |
uses: actions/setup-python@v3 | |
with: | |
python-version: 3.11 | |
- name: Install Ubuntu packages | |
run: sudo apt-get install -y python3 python3-pip snmp libsnmp-dev gcc python-dev-is-python3 python3-venv mysql-server | |
- name: Cache pip packages | |
uses: actions/cache@v4 | |
with: | |
path: ~/.cache/pip | |
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }} | |
restore-keys: | | |
${{ runner.os }}-pip- | |
- name: Install dependencies and test | |
run: | | |
python3 -m venv venv | |
source venv/bin/activate | |
python -m pip install --upgrade pip | |
pip3 install -r requirements.txt | |
pip install pytest-cov coverage | |
tests/bin/error_code_report.py | |
tests/bin/test_db_config_setup.py | |
sudo systemctl start mysql.service | |
sudo mysql -u${{ env.MYSQL_ROOT_USERNAME }} -p${{ env.MYSQL_ROOT_PASSWORD }} -e "CREATE DATABASE ${{ env.DATABASE_NAME }};" | |
sudo mysql -u${{ env.MYSQL_ROOT_USERNAME }} -p${{ env.MYSQL_ROOT_PASSWORD }} -e "CREATE USER '${{ env.DATABASE_USERNAME }}'@'localhost' IDENTIFIED BY '${{ env.DATABASE_PASSWORD }}';" | |
sudo mysql -u${{ env.MYSQL_ROOT_USERNAME }} -p${{ env.MYSQL_ROOT_PASSWORD }} -e "GRANT ALL PRIVILEGES ON ${{ env.DATABASE_NAME }}.* TO '${{ env.DATABASE_USERNAME }}'@'localhost';" | |
sudo mysql -u${{ env.MYSQL_ROOT_USERNAME }} -p${{ env.MYSQL_ROOT_PASSWORD }} -e "FLUSH PRIVILEGES;" | |
pytest --cov=switchmap --cov-report=lcov:coverage/coverage.lcov --cov-report=term-missing tests/switchmap_ | |
- name: Upload coverage to Codecov | |
uses: codecov/codecov-action@v5 | |
with: | |
token: ${{ secrets.CODECOV_TOKEN }} | |
slug: PalisadoesFoundation/switchmap-ng | |
verbose: true | |
files: ./coverage/coverage.lcov | |
gcov_ignore: "docs/" | |
fail_ci_if_error: false | |
name: "${{env.CODECOV_UNIQUE_NAME}}" | |
Linting-and-Formatting: | |
name: Linting and Formatting Checks | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout Repository | |
uses: actions/checkout@v4 | |
- name: Set up Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: 3.9 | |
- name: Install Linting and Formatting Tools | |
run: | | |
python -m pip install --upgrade pip | |
pip install flake8 black pydocstyle flake8-docstrings | |
- name: Run Black Formatter Check | |
run: | | |
black --check . | |
- name: Run Flake8 Linter | |
run: | | |
flake8 --docstring-convention google switchmap bin setup tests .github --ignore E402,E722,E203,F401,W503 | |
- name: Run Pydocstyle for Docstring Style | |
run: | | |
pydocstyle switchmap setup bin tests --convention=google --add-ignore=D415,D205 | |