Initial commit #2
This file contains hidden or 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: main | |
| on: [push] | |
| jobs: | |
| build: | |
| name: Build vinta_schedule_api | |
| strategy: | |
| matrix: | |
| python: [3.13] | |
| env: | |
| DATABASE_URL: "postgresql://postgres:postgres@localhost:5432/vinta_schedule_test" | |
| REDIS_URL: "redis://localhost:6379" | |
| runs-on: ubuntu-latest | |
| services: | |
| postgres: | |
| image: postgres:15 | |
| env: | |
| POSTGRES_PASSWORD: postgres | |
| POSTGRES_USER: postgres | |
| POSTGRES_DB: vinta_schedule_test | |
| ports: | |
| - 5432:5432 | |
| options: >- | |
| --health-cmd pg_isready | |
| --health-interval 10s | |
| --health-timeout 5s | |
| --health-retries 5 | |
| redis: | |
| image: redis:7 | |
| ports: | |
| - 6379:6379 | |
| options: >- | |
| --health-cmd "redis-cli ping" | |
| --health-interval 10s | |
| --health-timeout 5s | |
| --health-retries 5 | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Store branch and latest SHA | |
| run: | | |
| echo "##[set-output name=branch;]$(echo ${GITHUB_REF#refs/heads/})" | |
| echo "::set-output name=sha_short::$(git rev-parse --short HEAD)" | |
| id: git | |
| - name: Setup Python ${{ matrix.python }} | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: ${{ matrix.python }} | |
| - name: Cache pip | |
| uses: actions/cache@v4 | |
| env: | |
| cache_name: pip-cache | |
| with: | |
| path: ~/.cache/pip | |
| key: build-${{ env.cache_name }}-${{ steps.git.outputs.branch }}-${{ steps.git.outputs.sha_short }} | |
| restore-keys: | | |
| build-${{ env.cache_name }}-${{ steps.git.outputs.branch }}-${{ steps.git.outputs.sha_short }} | |
| build-${{ env.cache_name }}-${{ steps.git.outputs.branch }} | |
| build-${{ env.cache_name }} | |
| - run: python -m pip install --upgrade pip | |
| - run: python -m pip install poetry==2.1.3 | |
| - run: curl -s https://packagecloud.io/install/repositories/github/git-lfs/script.deb.sh | sudo bash | |
| - run: sudo apt-get install git-lfs --upgrade | |
| - name: Install PostgreSQL client | |
| run: sudo apt-get update && sudo apt-get install -y postgresql-client | |
| - run: poetry install --with dev --no-root --no-interaction --no-ansi | |
| - name: Generate secret key | |
| run: echo '::set-output name=SECRET_KEY::`python -c "import uuid; print(uuid.uuid4().hex + uuid.uuid4().hex)"`' | |
| id: secret_id_generator | |
| - name: Linting | |
| run: poetry run ruff check ./ | |
| env: | |
| DJANGO_SETTINGS_MODULE: "vinta_schedule_api.settings.test" | |
| SECRET_KEY: ${{ steps.secret_id_generator.outputs.SECRET_KEY }} | |
| DATABASE_URL: "postgresql://postgres:postgres@localhost:5432/vinta_schedule_test" | |
| ALLOWED_HOSTS: ".example.com" | |
| SMTP_HOST: 'example.com' | |
| SMTP_USERNAME: "test" | |
| SMTP_PASSWORD: "test" | |
| REDIS_URL: "redis://localhost:6379" | |
| SITE_DOMAIN: 'example.com' | |
| API_DOMAIN: 'api.example.com' | |
| DEFAULT_BCC_EMAILS: 'hugo@example.com' | |
| AWS_STATIC_BUCKET_NAME: 'example-static' | |
| AWS_ACCESS_KEY_ID: 'test' | |
| AWS_SECRET_ACCESS_KEY: 'test' | |
| AWS_S3_ACCESS_KEY_ID: 'test' | |
| AWS_S3_SECRET_ACCESS_KEY: 'test' | |
| AWS_MEDIA_BUCKET_NAME: 'example-media' | |
| AWS_MEDIA_LOCATION: 'media' | |
| AWS_MEDIA_S3_CUSTOM_DOMAIN: 'example.com' | |
| AWS_MEDIA_S3_ENDPOINT_URL: 'https://example.com' | |
| AWS_S3_REGION_NAME: 'us-east-1' | |
| AWS_CLOUDFRONT_KEY_ID: 'test' | |
| AWS_CLOUDFRONT_KEY: 'test' | |
| SALT_KEY: 'test_salt_key_123' | |
| TWILLIO_ACCOUNT_SID: 'FAKE_ACCOUNT_SID' | |
| TWILIO_AUTH_TOKEN: 'FAKE_ACCOUNT_SID' | |
| TWILIO_NUMBER: '+12345678901' | |
| TWILLIO_DEFAULT_BROADCAST_NUMBERS: '+12345678901,+10987654321' | |
| - run: poetry run pre-commit run --all-files | |
| env: | |
| SKIP: ruff,eslint,missing-migrations,backend-schema | |
| - run: poetry run python manage.py makemigrations --check --dry-run | |
| env: | |
| DJANGO_SETTINGS_MODULE: "vinta_schedule_api.settings.production" | |
| SECRET_KEY: ${{ steps.secret_id_generator.outputs.SECRET_KEY }} | |
| DATABASE_URL: "postgresql://postgres:postgres@localhost:5432/vinta_schedule_test" | |
| ALLOWED_HOSTS: ".example.org" | |
| SMTP_HOST: 'example.org' | |
| SMTP_USERNAME: "test" | |
| SMTP_PASSWORD: "test" | |
| REDIS_URL: "redis://localhost:6379" | |
| SITE_DOMAIN: 'example.com' | |
| API_DOMAIN: 'api.example.com' | |
| DEFAULT_BCC_EMAILS: 'hugo@example.com' | |
| AWS_STATIC_BUCKET_NAME: 'example-static' | |
| AWS_ACCESS_KEY_ID: 'test' | |
| AWS_SECRET_ACCESS_KEY: 'test' | |
| AWS_S3_ACCESS_KEY_ID: 'test' | |
| AWS_S3_SECRET_ACCESS_KEY: 'test' | |
| AWS_MEDIA_BUCKET_NAME: 'example-media' | |
| AWS_MEDIA_LOCATION: 'media' | |
| AWS_MEDIA_S3_CUSTOM_DOMAIN: 'example.com' | |
| AWS_MEDIA_S3_ENDPOINT_URL: 'https://example.com' | |
| AWS_S3_REGION_NAME: 'us-east-1' | |
| AWS_CLOUDFRONT_KEY_ID: 'test' | |
| AWS_CLOUDFRONT_KEY: 'test' | |
| SALT_KEY: 'test_salt_key_123' | |
| TWILLIO_ACCOUNT_SID: 'FAKE_ACCOUNT_SID' | |
| TWILIO_AUTH_TOKEN: 'FAKE_ACCOUNT_SID' | |
| TWILIO_NUMBER: '+12345678901' | |
| TWILLIO_DEFAULT_BROADCAST_NUMBERS: '+12345678901,+10987654321' | |
| - run: poetry run python manage.py check --deploy | |
| env: | |
| DJANGO_SETTINGS_MODULE: "vinta_schedule_api.settings.production" | |
| SECRET_KEY: ${{ steps.secret_id_generator.outputs.SECRET_KEY }} | |
| DATABASE_URL: "postgresql://postgres:postgres@localhost:5432/vinta_schedule_test" | |
| ALLOWED_HOSTS: ".example.org" | |
| SMTP_HOST: 'example.org' | |
| SMTP_USERNAME: "test" | |
| SMTP_PASSWORD: "test" | |
| REDIS_URL: "redis://localhost:6379" | |
| SITE_DOMAIN: 'example.com' | |
| API_DOMAIN: 'api.example.com' | |
| DEFAULT_BCC_EMAILS: 'hugo@example.com' | |
| AWS_STATIC_BUCKET_NAME: 'example-static' | |
| AWS_ACCESS_KEY_ID: 'test' | |
| AWS_SECRET_ACCESS_KEY: 'test' | |
| AWS_S3_ACCESS_KEY_ID: 'test' | |
| AWS_S3_SECRET_ACCESS_KEY: 'test' | |
| AWS_MEDIA_BUCKET_NAME: 'example-media' | |
| AWS_MEDIA_LOCATION: 'media' | |
| AWS_MEDIA_S3_CUSTOM_DOMAIN: 'example.com' | |
| AWS_MEDIA_S3_ENDPOINT_URL: 'https://example.com' | |
| AWS_S3_REGION_NAME: 'us-east-1' | |
| AWS_CLOUDFRONT_KEY_ID: 'test' | |
| AWS_CLOUDFRONT_KEY: 'test' | |
| SALT_KEY: 'test_salt_key_123' | |
| TWILLIO_ACCOUNT_SID: 'FAKE_ACCOUNT_SID' | |
| TWILIO_AUTH_TOKEN: 'FAKE_ACCOUNT_SID' | |
| TWILIO_NUMBER: '+12345678901' | |
| TWILLIO_DEFAULT_BROADCAST_NUMBERS: '+12345678901,+10987654321' | |
| - run: | | |
| poetry run pytest $(ARG) -vs -n auto --no-header --cov=. --cov-report=xml:junit/test-results.xml --junitxml=junit.xml -o junit_family=legacy | |
| env: | |
| DJANGO_SETTINGS_MODULE: "vinta_schedule_api.settings.test" | |
| SECRET_KEY: ${{ steps.secret_id_generator.outputs.SECRET_KEY }} | |
| DATABASE_URL: "postgresql://postgres:postgres@localhost:5432/vinta_schedule_test" | |
| ALLOWED_HOSTS: ".example.com" | |
| SMTP_HOST: 'example.com' | |
| SMTP_USERNAME: "test" | |
| SMTP_PASSWORD: "test" | |
| REDIS_URL: "redis://localhost:6379" | |
| SITE_DOMAIN: 'example.com' | |
| API_DOMAIN: 'api.example.com' | |
| DEFAULT_BCC_EMAILS: 'hugo@example.com' | |
| AWS_STATIC_BUCKET_NAME: 'example-static' | |
| AWS_ACCESS_KEY_ID: 'test' | |
| AWS_SECRET_ACCESS_KEY: 'test' | |
| AWS_S3_ACCESS_KEY_ID: 'test' | |
| AWS_S3_SECRET_ACCESS_KEY: 'test' | |
| AWS_MEDIA_BUCKET_NAME: 'example-media' | |
| AWS_MEDIA_LOCATION: 'media' | |
| AWS_MEDIA_S3_CUSTOM_DOMAIN: 'example.com' | |
| AWS_MEDIA_S3_ENDPOINT_URL: 'https://example.com' | |
| AWS_S3_REGION_NAME: 'us-east-1' | |
| AWS_CLOUDFRONT_KEY_ID: 'test' | |
| AWS_CLOUDFRONT_KEY: 'test' | |
| SALT_KEY: 'test_salt_key_123' | |
| TWILLIO_ACCOUNT_SID: 'FAKE_ACCOUNT_SID' | |
| TWILIO_AUTH_TOKEN: 'FAKE_ACCOUNT_SID' | |
| TWILIO_NUMBER: '+12345678901' | |
| TWILLIO_DEFAULT_BROADCAST_NUMBERS: '+12345678901,+10987654321' | |
| - name: Archive code coverage results | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: code-coverage-report | |
| path: junit/test-results.xml | |
| - name: Upload coverage to Codecov | |
| uses: codecov/codecov-action@v4 | |
| with: | |
| env_vars: OS,PYTHON | |
| fail_ci_if_error: true | |
| files: ./junit/test-results.xml | |
| flags: unittests | |
| name: codecov-umbrella | |
| token: ${{ secrets.CODECOV_TOKEN }} | |
| verbose: true | |
| env: | |
| CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} | |
| - name: Upload test results to Codecov | |
| if: ${{ !cancelled() }} | |
| uses: codecov/test-results-action@v1 | |
| with: | |
| token: ${{ secrets.CODECOV_TOKEN }} | |
| env: | |
| CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} |