Test new configuration #430
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
on: | |
push: | |
branches: [main, development, hotfix/cd-pipeline] | |
pull_request: | |
branches: [main] | |
jobs: | |
ci: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v2 | |
- uses: actions/setup-python@v2 | |
with: | |
python-version: 3.8 | |
- name: Install Poetry | |
run: curl -sSL https://install.python-poetry.org | python - | |
- run: poetry install | |
- name: Lint | |
run: poetry run python -m black --check . | |
- name: SonarCloud Analysis | |
uses: sonarsource/sonarcloud-github-action@master | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} | |
- name: Tests | |
env: | |
DATABASE_HOST: ${{ secrets.DATABASE_HOST}} | |
DATABASE_USER: ${{ secrets.DATABASE_USER}} | |
DATABASE_PASSWORD: ${{ secrets.DATABASE_PASSWORD}} | |
DATABASE_NAME: ${{ secrets.DATABASE_NAME}} | |
POLITRACK_API_URL: ${{ secrets.POLITRACK_API_URL}} | |
POLITRACK_USERNAME: ${{ secrets.POLITRACK_USERNAME}} | |
POLITRACK_SECRET_PASSWORD: ${{ secrets.POLITRACK_SECRET_PASSWORD}} | |
REDIS_HOST: ${{ secrets.REDIS_HOST}} | |
# Exempt tests/e2e because tests/api uses production database to test whereas tests/e2e uses localhost == avoid conflicts | |
run: poetry run pytest -m "not e2e" | |
cd: | |
runs-on: ubuntu-latest | |
needs: [ci] | |
if: ${{ github.event_name == 'push' && (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/development'|| github.ref == 'refs/heads/hotfix/cd-pipeline') }} | |
steps: | |
- name: Checkout source code | |
uses: actions/checkout@v2 | |
- name: Generate deployment package | |
run: zip -r deploy.zip . -x '*.git*' | |
- name: Deploy to EB | |
uses: einaregilsson/beanstalk-deploy@v18 | |
with: | |
aws_access_key: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
aws_secret_key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
application_name: ${{ github.ref == 'refs/heads/main' && 'backend-production' || 'backend-development' }} | |
environment_name: ${{ github.ref == 'refs/heads/main' && 'Backend-production-env' || 'Backend-development-env' }} | |
version_label: ${{ github.sha }} | |
use_existing_version_if_available: true | |
region: eu-central-1 | |
deployment_package: deploy.zip |