[TP-1552]: Cleanup resources after failed tests #825
Workflow file for this run
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
# This workflow will install Python dependencies, run tests and lint with a variety of Python versions | |
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions | |
name: Run tests | |
on: | |
push: | |
branches: [ master ] | |
pull_request: | |
branches: [ master ] | |
jobs: | |
build: | |
runs-on: ${{ matrix.os }} | |
timeout-minutes: 45 | |
strategy: | |
fail-fast: false | |
matrix: | |
os: [ubuntu-latest, windows-latest] | |
python-version: ["3.8", "3.9"] | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Set up Python ${{ matrix.python-version }} | |
uses: actions/setup-python@v4 | |
with: | |
python-version: ${{ matrix.python-version }} | |
- name: Install dependencies | |
run: | | |
python -m pip install --upgrade pip | |
pip install -r requirements.txt | |
pip install -r tests/requirements.txt | |
- name: Run static analysis lint | |
run: ./lint.sh check | |
- name: Prepare the API keys | |
env: | |
CLARIFAI_USER_EMAIL_SECURE_HOSTING: ${{ secrets.CLARIFAI_USER_EMAIL_SECURE_HOSTING }} | |
CLARIFAI_USER_EMAIL: ${{ secrets.INTERNAL_USER_EMAIL }} | |
CLARIFAI_USER_PASSWORD: ${{ secrets.INTERNAL_USER_PASSWORD }} | |
shell: bash | |
run: | | |
export PYTHONPATH=. | |
CLARIFAI_APP_ID="$(python scripts/app_and_key_for_tests.py --create-app python-github)" | |
CLARIFAI_API_KEY="$(python scripts/app_and_key_for_tests.py --create-key ${CLARIFAI_APP_ID})" | |
CLARIFAI_PAT_KEY="$(python scripts/app_and_key_for_tests.py --create-pat)" | |
python scripts/app_and_key_for_tests.py --create-workflow ${CLARIFAI_API_KEY} | |
CLARIFAI_APP_ID_SECURE_HOSTING="$(python scripts/app_and_key_for_tests.py --user-email ${CLARIFAI_USER_EMAIL_SECURE_HOSTING} --create-app python-github-secure-hosting)" | |
CLARIFAI_API_KEY_SECURE_HOSTING="$(python scripts/app_and_key_for_tests.py --user-email ${CLARIFAI_USER_EMAIL_SECURE_HOSTING} --create-key ${CLARIFAI_APP_ID_SECURE_HOSTING})" | |
CLARIFAI_PAT_KEY_SECURE_HOSTING="$(python scripts/app_and_key_for_tests.py --user-email ${CLARIFAI_USER_EMAIL_SECURE_HOSTING} --create-pat)" | |
CLARIFAI_SESSION_TOKEN_SECURE_HOSTING="$(python scripts/app_and_key_for_tests.py --user-email ${CLARIFAI_USER_EMAIL_SECURE_HOSTING} --create-session-token)" | |
echo "CLARIFAI_APP_ID=${CLARIFAI_APP_ID}" >> $GITHUB_ENV | |
echo "CLARIFAI_APP_ID_SECURE_HOSTING=${CLARIFAI_APP_ID_SECURE_HOSTING}" >> $GITHUB_ENV | |
echo "CLARIFAI_API_KEY=${CLARIFAI_API_KEY}" >> $GITHUB_ENV | |
echo "CLARIFAI_PAT_KEY=${CLARIFAI_PAT_KEY}" >> $GITHUB_ENV | |
echo "CLARIFAI_API_KEY_SECURE_HOSTING=${CLARIFAI_API_KEY_SECURE_HOSTING}" >> $GITHUB_ENV | |
echo "CLARIFAI_PAT_KEY_SECURE_HOSTING=${CLARIFAI_PAT_KEY_SECURE_HOSTING}" >> $GITHUB_ENV | |
echo "CLARIFAI_SESSION_TOKEN_SECURE_HOSTING=${CLARIFAI_SESSION_TOKEN_SECURE_HOSTING}" >> $GITHUB_ENV | |
pip install pytest | |
- name: Run tests | |
run: pytest tests/ -n auto | |
continue-on-error: true | |
- name: Cleanup | |
env: | |
CLARIFAI_USER_EMAIL: ${{ secrets.INTERNAL_USER_EMAIL }} | |
CLARIFAI_USER_PASSWORD: ${{ secrets.INTERNAL_USER_PASSWORD }} | |
if: ${{ always() }} | |
run: | | |
python scripts/app_and_key_for_tests.py --delete-app ${CLARIFAI_APP_ID} | |
python scripts/app_and_key_for_tests.py --user-email ${CLARIFAI_USER_EMAIL_SECURE_HOSTING} --delete-app ${CLARIFAI_APP_ID_SECURE_HOSTING} | |
- name: Slack Notify | |
if: ${{ failure() }} | |
uses: rtCamp/action-slack-notify@v2 | |
env: | |
SLACK_ICON: "https://raw.githubusercontent.com/github/explore/2c7e603b797535e5ad8b4beb575ab3b7354666e1/topics/actions/actions.png" | |
SLACK_USERNAME: "GitHub Alerts" | |
SLACK_CHANNEL: "#grpc-client-repo-alerts" | |
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }} | |
SLACK_COLOR: ${{ job.status }} | |
SLACK_MESSAGE: "Test failure" | |
SLACK_FOOTER: "Clarifai Python GRPC Repo" |