Skip to content
This repository has been archived by the owner on Dec 18, 2023. It is now read-only.

Add test-reports workflow for develop and main with badges #284

Merged
merged 5 commits into from Dec 9, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
@@ -0,0 +1 @@
.github/ @credo-ai/repo-admins @credo-nate
81 changes: 81 additions & 0 deletions .github/workflows/test-reports.yml
@@ -0,0 +1,81 @@
name: Test Reports

on:
workflow_dispatch:
push:
nate-credoai marked this conversation as resolved.
Show resolved Hide resolved
branches:
- main
- develop
paths-ignore:
- '**.md'
- '**.rst'
- '**.ipynb'

env:
TEST_REPORTS_BUCKET_NAME: "credoai-cicd-public-artifacts"
AWS_REGION: "us-west-2"

permissions:
id-token: write
contents: read

jobs:
run-test:
runs-on: ubuntu-latest
steps:
- name: Check out repository
uses: actions/checkout@v3
- name: GitHub Slug Action
uses: rlespinasse/github-slug-action@v4.4.0
with:
prefix: CI_
- name: Install AWS CLI
id: install-aws-cli
uses: unfor19/install-aws-cli-action@v1.0.4
- name: Set up python
uses: actions/setup-python@v4
with:
python-version: 3.8
cache: 'pip'
cache-dependency-path: |
**/requirements*.txt
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install pytest pytest-cov genbadge
pip install tensorflow
pip install -r requirements.txt
pip install -r requirements-dev.txt
- name: Run tests
run: |
rm -rf test-reports/
scripts/test-reports.sh
- name: Configure AWS Credentials
id: aws-creds
if: always()
# continue-on-error: true # Set this if you don't want the workflow to error on AWS creds issue
uses: aws-actions/configure-aws-credentials@v1
with:
role-to-assume: arn:aws:iam::858725184704:role/allow-gh-actions-public
role-session-name: credoai-lens-test-reports
aws-region: ${{ env.AWS_REGION }}
- name: Push reports to S3
if: steps.aws-creds.outcome == 'success'
run: |
if [ -e "test-reports/cov.xml" ]; then
genbadge coverage -i test-reports/cov.xml -o test-reports/coverage-badge.svg
fi
if [ -e "junit.xml" ]; then
genbadge tests -i junit.xml -o test-reports/tests-badge.svg
cp junit.xml test-reports/
fi
if [ -d "test-reports" ]; then
tar czf test-reports.tgz test-reports
aws s3 sync test-reports s3://${{ env.TEST_REPORTS_BUCKET_NAME }}/$CI_GITHUB_REPOSITORY_NAME_PART_SLUG/$CI_GITHUB_REF_SLUG/
fi
- name: test-reports artifact
if: always()
uses: actions/upload-artifact@v3
with:
name: test-reports
path: ./test-reports.tgz
4 changes: 2 additions & 2 deletions .github/workflows/test.yml
Expand Up @@ -32,13 +32,13 @@ jobs:
CREDOAI_LENS_CONFIG_JSON_B64: ${{ secrets.CREDOAI_LENS_CONFIG_JSON_B64 }}
CREDOAI_LENS_PLAN_URL: ${{ secrets.CREDOAI_LENS_PLAN_URL }}
run: |
scripts/test.sh
scripts/test.sh | tee ./pytest-coverage.txt
- name: my-artifact
if: always()
uses: actions/upload-artifact@v3
with:
name: pytest-coverage
path: pytest-coverage.txt
path: ./pytest-coverage.txt
- name: Pytest coverage comment
uses: MishaKav/pytest-coverage-comment@main
with:
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Expand Up @@ -135,3 +135,6 @@ dmypy.json
*.csv
*.txt
.DS_Store

test-reports/
junit.xml
4 changes: 4 additions & 0 deletions README.md
@@ -1,5 +1,9 @@
<img src="https://raw.githubusercontent.com/credo-ai/credoai_lens/develop/docs/_static/images/credo_ai-lens.png" width="250" alt="Credo AI Lens"><br>

![Workflow](https://github.com/credo-ai/credoai_lens/actions/workflows/test-reports.yml/badge.svg)
![Tests](https://credoai-cicd-public-artifacts.s3.us-west-2.amazonaws.com/credoai_lens/main/tests-badge.svg)
[![Coverage](https://credoai-cicd-public-artifacts.s3.us-west-2.amazonaws.com/credoai_lens/main/coverage-badge.svg)](https://credoai-cicd-public-artifacts.s3.us-west-2.amazonaws.com/credoai_lens/main/html/index.html)

--------------------------------------

# Lens by Credo AI - Responsible AI Assessment Framework
Expand Down
9 changes: 9 additions & 0 deletions scripts/test-reports.sh
@@ -0,0 +1,9 @@
#!/usr/bin/env bash

set -e
set -x

bash scripts/test.sh \
--cov-report=xml:test-reports/cov.xml \
--cov-report=html:test-reports/html \
"${@}"
6 changes: 5 additions & 1 deletion scripts/test.sh
Expand Up @@ -3,4 +3,8 @@
set -e
set -x

PYTHONPATH=credoai pytest --cov-config=.coveragerc --cov=credoai --cov-report=term-missing tests "${@}"
PYTHONPATH=credoai pytest \
--junitxml=junit.xml \
--cov-config=.coveragerc \
--cov-report=term-missing \
--cov=credoai tests/ "${@}"