Reduce pytest time #869
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
name: Continuous Integration | |
on: | |
pull_request: | |
types: [assigned, opened, synchronize, reopened] | |
jobs: | |
pytest: | |
runs-on: ubuntu-latest | |
environment: CI Environment | |
steps: | |
- uses: actions/checkout@v2 | |
- uses: satackey/[email protected] | |
continue-on-error: true | |
with: | |
key: qbo-api-${{ hashFiles('requirements.txt') }} | |
restore-keys: | | |
qbo-api-${{ hashFiles('requirements.txt') }} | |
- name: Build docker image | |
run: | | |
docker-compose -f docker-compose-pipeline.yml build | |
- name: Bring up Services and test for token health | |
run: | | |
docker-compose -f docker-compose-pipeline.yml up -d | |
docker-compose -f docker-compose-pipeline.yml exec -T api pytest tests/ --cov --cov-report=xml --cov-fail-under=96 --junit-xml=test-reports/report.xml | |
echo "STATUS=$(cat pytest-coverage.txt | grep 'Required test' | awk '{ print $1 }')" >> $GITHUB_ENV | |
echo "FAILED=$(cat test-reports/report.xml | awk -F'=' '{print $5}' | awk -F' ' '{gsub(/"/, "", $1); print $1}')" >> $GITHUB_ENV | |
env: | |
FYLE_BASE_URL: ${{ secrets.FYLE_BASE_URL }} | |
FYLE_CLIENT_ID: ${{ secrets.FYLE_CLIENT_ID }} | |
FYLE_CLIENT_SECRET: ${{ secrets.FYLE_CLIENT_SECRET }} | |
FYLE_REFRESH_TOKEN: ${{ secrets.FYLE_REFRESH_TOKEN }} | |
FYLE_TOKEN_URI: ${{ secrets.FYLE_TOKEN_URI }} | |
FYLE_SERVER_URL: ${{ secrets.FYLE_SERVER_URL }} | |
QBO_CLIENT_ID: ${{ secrets.QBO_CLIENT_ID }} | |
QBO_CLIENT_SECRET: ${{ secrets.QBO_CLIENT_SECRET }} | |
QBO_REDIRECT_URI: ${{ secrets.QBO_REDIRECT_URI }} | |
QBO_TOKEN_URI: ${{ secrets.QBO_TOKEN_URI }} | |
ENCRYPTION_KEY: ${{ secrets.ENCRYPTION_KEY }} | |
E2E_TESTS_CLIENT_SECRET: ${{ secrets.E2E_TESTS_CLIENT_SECRET }} | |
E2E_TESTS_REALM_ID: ${{ secrets.E2E_TESTS_REALM_ID }} | |
- name: Upload coverage reports to Codecov with GitHub Action | |
uses: codecov/codecov-action@v3 | |
- name: Pytest coverage comment | |
uses: MishaKav/pytest-coverage-comment@main | |
if: ${{ always() && github.ref != 'refs/heads/master' }} | |
with: | |
create-new-comment: true | |
junitxml-path: ./test-reports/report.xml | |
- name: Evaluate Coverage | |
if: ${{ (env.STATUS == 'FAIL') || (env.FAILED > 0) }} | |
run: exit 1 |