Skip to content

Deploy docs and add performance benchmark #150

Deploy docs and add performance benchmark

Deploy docs and add performance benchmark #150

Workflow file for this run

name: Test and Deploy
# Triggers on pushes to main, dev and tags.
on:
workflow_dispatch:
push:
branches:
- main
- develop
tags:
- 'v*'
paths:
# Only run test and docker publish if some code have changed
- 'pyproject.toml'
- 'infrastructure/aws/**'
- 'titiler/**'
- '.pre-commit-config.yaml'
- '.github/workflows/ci.yml'
# Run tests on pull requests.
pull_request:
env:
LATEST_PY_VERSION: '3.10'
permissions:
id-token: write # This is required for requesting the JWT
contents: read # This is required for actions/checkout
jobs:
tests:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ['3.10', '3.11', '3.12']
steps:
- uses: actions/checkout@v4
- name: Install uv
uses: astral-sh/setup-uv@v3
with:
version: "0.5.*"
enable-cache: true
- name: Set up Python ${{ matrix.python-version }}
run: uv python install ${{ matrix.python-version }}
- name: Install dependencies
run: |
uv sync --all-extras
- name: run pre-commit
if: ${{ matrix.python-version == env.LATEST_PY_VERSION }}
run: |
uv run pre-commit run --all-files
- name: Run tests
run: uv run pytest
deploy:
needs: [tests]
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/main' || github.ref == 'refs/heads/develop' || startsWith(github.ref, 'refs/tags/v')
defaults:
run:
working-directory: infrastructure/aws
steps:
- uses: actions/checkout@v4
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v2
with:
role-to-assume: ${{ secrets.deploy_role_arn }}
role-session-name: samplerolesession
aws-region: us-west-2
- name: Set up node
uses: actions/setup-node@v4
with:
node-version: '14.x'
- name: Install cdk
run: npm install -g
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.12'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install -r requirements-cdk.txt
# Build and deploy to the development environment whenever there is a push to main or dev
- name: Build & Deploy Development
if: github.ref == 'refs/heads/main' || github.ref == 'refs/heads/develop'
run: npm run cdk -- deploy titiler-cmr-staging --require-approval never
env:
# STACK_ALARM_EMAIL: ${{ secrets.ALARM_EMAIL }}
STACK_ROLE_ARN: ${{ secrets.lambda_role_arn }}
STACK_STAGE: staging
STACK_ADDITIONAL_ENV: '{"TITILER_CMR_S3_AUTH_STRATEGY":"iam", "TITILER_CMR_API_DEBUG":"TRUE"}'
# Build and deploy to production deployment whenever there a new tag is pushed
- name: Build & Deploy Production
if: startsWith(github.ref, 'refs/tags/v')
run: npm run cdk -- deploy titiler-cmr-production --require-approval never
env:
# STACK_ALARM_EMAIL: ${{ secrets.ALARM_EMAIL }}
STACK_ROLE_ARN: ${{ secrets.lambda_role_arn }}
STACK_STAGE: production
STACK_ADDITIONAL_ENV: '{"TITILER_CMR_S3_AUTH_STRATEGY":"iam"}'