Tests #1044
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: Tests | |
on: | |
push: | |
branches: [master] | |
pull_request: | |
branches: [master] | |
workflow_dispatch: | |
inputs: | |
update_channel: | |
type: choice | |
description: 'Update channel' | |
options: | |
- latest | |
- stable | |
default: stable | |
env: | |
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }} | |
UPDATE_CHANNEL: ${{ inputs.update_channel || 'stable' }} | |
jobs: | |
notify-build-start: | |
# Secrets are not available for forks for security reasons, so pull | |
# request checks will fail when trying to send the Slack notification. | |
# Unfortunately, there's no way to explicitly check that a secret is | |
# available, so we check for event_name instead: | |
# https://github.com/actions/runner/issues/520 | |
if: ${{ github.event_name != 'pull_request' && inputs.update_channel != 'latest' }} | |
runs-on: ubuntu-latest | |
steps: | |
- uses: ivelum/[email protected] | |
id: slack | |
with: | |
channel_id: C0PT3267R | |
status: STARTED | |
color: '#ee9b00' | |
outputs: | |
status_message_id: ${{ steps.slack.outputs.message_id }} | |
lint-and-tests: | |
runs-on: ubuntu-latest | |
strategy: | |
fail-fast: false | |
matrix: | |
python: ['3.7', '3.8', '3.9', '3.10', '3.11'] | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: actions/setup-python@v4 | |
with: | |
python-version: ${{ matrix.python }} | |
cache: 'pip' | |
- run: pip install -r requirements-tests.txt | |
- run: pip install --editable . | |
- run: flake8 --isort-show-traceback && pytest -m "not selenium" | |
setup-test: | |
name: Set up an on-premise instance | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Setup python | |
uses: actions/setup-python@v4 | |
with: | |
python-version: 3.11 | |
cache: 'pip' | |
- name: Install Teamplify | |
run: pip3 install --editable . | |
- name: Configure | |
run: teamplify configure | |
- name: Create backup directory | |
run: mkdir ${{ runner.temp }}/backup | |
- name: Set backup_mount | |
run: sed -i -e '/backup_mount =/ s|= .*|= ${{ runner.temp }}/backup|' ~/.teamplify.ini | |
- name: Set product key | |
run: sed -i -e '/product_key =/ s|= .*|= ${{ secrets.ONPREMISE_PRODUCT_KEY }}|' ~/.teamplify.ini | |
- name: Set update channel | |
run: sed -i -e '/update_channel =/ s|= .*|= ${{ env.UPDATE_CHANNEL }}|' ~/.teamplify.ini | |
- name: Disable crash reports | |
run: sed -i -e '/send_crash_reports =/ s|= .*|= no|' ~/.teamplify.ini | |
- name: Install stable Chrome | |
id: install-chrome | |
uses: browser-actions/setup-chrome@v1 | |
with: | |
chrome-version: stable | |
- name: Setup ChromeDriver | |
uses: nanasess/setup-chromedriver@v2 | |
- name: Login to public ECR | |
run: docker login -u AWS -p $(aws --region us-east-1 ecr-public get-login-password) public.ecr.aws | |
- name: Wait for Teamplify to start | |
run: teamplify start | |
- run: pip install -r requirements-tests.txt | |
- name: Check that the login page is available | |
run: pytest -m "selenium" | |
- name: Test Teamplify backup command | |
run: teamplify backup ${{ runner.temp }}/backup/test-backup.sql.gz | |
notify-build-failure: | |
if: ${{ failure() && github.event_name != 'pull_request' }} | |
needs: [lint-and-tests, setup-test, notify-build-start] | |
runs-on: ubuntu-latest | |
steps: | |
- name: Notify slack fail | |
uses: ivelum/[email protected] | |
with: | |
channel_id: C0PT3267R | |
status: FAILED | |
color: '#d7263d' | |
notify-build-success: | |
if: ${{ github.event_name != 'pull_request' && inputs.update_channel != 'latest' }} | |
needs: [lint-and-tests, setup-test, notify-build-start] | |
runs-on: ubuntu-latest | |
steps: | |
- name: Notify slack success | |
uses: ivelum/[email protected] | |
with: | |
message_id: ${{ needs.notify-build-start.outputs.status_message_id }} | |
channel_id: C0PT3267R | |
status: SUCCESS | |
color: '#16db65' |