Skip to content

Enhance context with additional Ansible variables #1099

Enhance context with additional Ansible variables

Enhance context with additional Ansible variables #1099

Workflow file for this run

name: Code Coverage
on:
push:
branches:
- main
pull_request:
branches:
- main
# have the ability to trigger this workflow manually
workflow_dispatch:
jobs:
build:
name: Unit Test and SonarCloud Scan
runs-on: ubuntu-latest
env:
ANSIBLE_AI_DATABASE_HOST: localhost
ANSIBLE_AI_DATABASE_NAME: wisdom
ANSIBLE_AI_DATABASE_PASSWORD: wisdom
ANSIBLE_AI_DATABASE_USER: wisdom
ARI_KB_PATH: ../ari/kb/
DJANGO_SETTINGS_MODULE: main.settings.development
ENABLE_ARI_POSTPROCESS: True
ENABLE_ANSIBLE_LINT_POSTPROCESS: True
PYTHONUNBUFFERED: 1
SECRET_KEY: somesecret
services:
postgres:
image: docker.io/library/postgres:alpine
env:
POSTGRES_USER: wisdom
POSTGRES_PASSWORD: wisdom
POSTGRES_DB: wisdom
ports:
- 5432:5432
# needed because the postgres container does not provide a healthcheck
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
##############
# Python tests
##############
- name: Setup Python 3.9
uses: actions/setup-python@v4
with:
python-version: '3.9'
- name: Install dependencies
run: |
python3 -m pip install --upgrade pip
pip install -r requirements.txt
pip install coverage
- name: Retrieve ari knowledge base from s3
run: |
KB_ARI_PATH=s3://rhaw-knowledgebase-868937679750-us-east-1/ari/v0.0.12-all-slim
aws s3 cp --recursive ${KB_ARI_PATH}/data ari/kb/data
aws s3 cp --recursive ${KB_ARI_PATH}/rules ari/kb/rules
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_DEFAULT_REGION: us-east-1
- name: Running Unit Tests
run: |
cd ansible_wisdom
coverage run --rcfile=../setup.cfg manage.py test
coverage xml
coverage report --rcfile=../setup.cfg --format=markdown > code-coverage-results.md
- name: Add Coverage PR Comment
uses: thollander/actions-comment-pull-request@v2
with:
filePath: ansible_wisdom/code-coverage-results.md
if: ${{ github.event_name == 'pull_request' && !github.event.pull_request.head.repo.fork }}
# See https://sonarsource.atlassian.net/browse/SONARPY-1203
- name: Fix paths in coverage file
run: |
sed -i 's/\/home\/runner\/work\/ansible-wisdom-service\/ansible-wisdom-service\//\/github\/workspace\//g' ansible_wisdom/coverage.xml
##################
# TypeScript tests
##################
- name: Use Node.js
uses: actions/setup-node@v3
with:
node-version: '20.x'
cache: 'npm'
cache-dependency-path: ./ansible_wisdom_console_react/package-lock.json
- name: Install Dependencies
run: npm ci
working-directory: ./ansible_wisdom_console_react
- name: Run tests
run: npm run test
working-directory: ./ansible_wisdom_console_react
#####################
# SonarCloud coverage
#####################
- name: SonarCloud Scan
uses: SonarSource/sonarcloud-github-action@master
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
####################
# OpenAPI file check
####################
- name: Ensure the OpenAPI file is up to date
run: |
make run-server &
sleep 10
make create-cachetable
make update-openapi-schema
git diff --exit-code -- tools/openapi-schema/ansible-wisdom-service.yaml