Skip to content

Adding health-checks to workflow #1

Adding health-checks to workflow

Adding health-checks to workflow #1

# name: EDLM Portal Backend Code CI/CD
on:
push:
branches:
- health-checks
jobs:
pip-install:
name: pip-install
runs-on: ubuntu-latest
env:
OS: ubuntu-latest
PYTHON: '3.12'
outputs:
cache-hit: ${{ steps.cache.outputs.cache-hit }}
steps:
- name: Check out code
uses: actions/checkout@v2
- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: 3.12
- name: Cache pip dependencies
id: cache
uses: actions/cache@v3
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}
restore-keys:
${{ runner.os }}-pip
- name: Install Dependencies
run: |
sudo apt-get update
python -m pip install --upgrade pip
pip install setuptools
pip install -r ./requirements.txt
# Run pylint on code
lint:
name: lint
runs-on: ubuntu-latest
env:
OS: ubuntu-latest
PYTHON: '3.12'
steps:
- name: Check out code
uses: actions/checkout@v2
- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: 3.12
- name: Installing pylint
run: |
sudo apt-get update
python -m pip install --upgrade pip
pip install pylint
- name: Running lint
run: pylint .
code-coverage:
# Kicks off the workflow and prepares Github to run coverage test using a ubuntu-latest container.
name: code-coverage
runs-on: ubuntu-latest
needs: pip-install
env:
OS: ubuntu-latest
PYTHON: '3.12'
steps:
- name: Check out code
uses: actions/checkout@v2
- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: 3.12
- name: restore pip dependencies from cache
uses: actions/cache@v3
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}
# Start running test scripts and generate the coverage report
- name: Generate Coverage Report
env:
GITHUB_TOKEN: ${{ secrets.ACCESS_TOKEN }}
CERT_VOLUME: ${{ secrets.CERT_VOLUME }}
run: |
echo "Cloning private repository"
git clone https://openlxp-host:${{ secrets.ACCESS_TOKEN }}@github.com/OpenLXP/openlxp-private.git
echo "Private repository cloned successfully"
echo "Copying .env file from openlxp-private to current working directory"
cp ./openlxp-private/openlxp-xds-env/.env .
echo "Copied .env file successfully"
echo "Create openlxp docker network"
docker network create openlxp
echo "Docker network successfully created"
echo "Running coverage unit test"
docker compose --env-file ./.env run app sh -c "python manage.py waitdb && coverage run manage.py test --tag=unit && flake8 && coverage report && coverage report --fail-under=80"