Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Setup alembic #441

Closed
wants to merge 64 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
64 commits
Select commit Hold shift + click to select a range
e613320
alembic setup
nrjadkry May 28, 2023
32d6cf8
Merge branch 'development' of github.com:hotosm/fmtm into setup-alembic
nrjadkry May 30, 2023
7a7882c
alembic.ini file moved to app directory
nrjadkry Jun 1, 2023
bd40e16
Base.metadata.create_all(bind=engine) removed since alembic is used …
nrjadkry Jun 1, 2023
c96af13
env.py for alembic is moved inside app directory
nrjadkry Jun 1, 2023
b0bfb9b
script.py.mako is moved inside app directory
nrjadkry Jun 1, 2023
ac24b56
readme for alembic moved in app directory
nrjadkry Jun 1, 2023
c9906ec
updated alembic.ini file to exclude postgis exxtension
nrjadkry Jun 4, 2023
e81bd03
updated env.py in migrations to exclude postgis extension
nrjadkry Jun 4, 2023
d125256
sqlalchemy url obtained from settings for alembic migrations
nrjadkry Jun 4, 2023
330cbad
sqlalchemy url obtained from env in config settings
nrjadkry Jun 4, 2023
9f5d771
first migration file
nrjadkry Jun 4, 2023
c543d2c
fix: create project single AOI
varun2948 Sep 11, 2023
bd1ecc1
fix: commented pagination for future
varun2948 Sep 11, 2023
cddc460
fix: edit project symbol changes on regex
varun2948 Sep 11, 2023
3cba915
fix: remove data extract on different dropdown selection
varun2948 Sep 11, 2023
75ad914
ci: move pytest and jest workflows to actions
spwoodcock Sep 11, 2023
5871741
ci: reusable test actions --> workflows
spwoodcock Sep 11, 2023
9c6229c
ci: reusable action --> workflow (pytest, jest)
spwoodcock Sep 11, 2023
fa0406a
fix: set underpass api url via env var
spwoodcock Sep 11, 2023
8f812f5
docs: add UNDERPASS_API_URL to env example
spwoodcock Sep 11, 2023
59da130
Merge pull request #826 from hotosm/feat-projectinfo-bug
robsavoye Sep 12, 2023
66e5659
Merge pull request #828 from hotosm/fix/underpass-env-var
robsavoye Sep 12, 2023
15a32d8
feat: remove microfrontend (#831)
varun2948 Sep 14, 2023
0356f78
build: fix label newline in prod.dockerfile
spwoodcock Sep 14, 2023
890c268
Overhaul CI, use reusable workflows (#830)
spwoodcock Sep 20, 2023
82ef69b
ci: fix flow, remove frontend-map refs
spwoodcock Sep 20, 2023
53a3e36
ci: set paths on parent workflows, not reusable workflows
spwoodcock Sep 20, 2023
6a554b4
ci: tweak workflows needs ordering
spwoodcock Sep 20, 2023
1010e20
ci: remove all refs to frontend-map or ui-map
spwoodcock Sep 20, 2023
53f033b
docs: remove all refs to microfrontend
spwoodcock Sep 20, 2023
962b2c8
build: fix add prod stage to frontend dockerfile
spwoodcock Sep 20, 2023
51aa885
build: remove APP_NAME from frontend (microfrontend)
spwoodcock Sep 20, 2023
cddb028
ci: some secret vars via secrets, env via vars
spwoodcock Sep 20, 2023
3338abd
ci: fix workflow secret --> secrets
spwoodcock Sep 20, 2023
9026b15
ci: set secret vars in env first (pytest)
spwoodcock Sep 20, 2023
6cfbc08
ci: add GIT_BRANCH to deploy workflow
spwoodcock Sep 20, 2023
e1525a2
ci: add GIT_BRANCH to backend docker compose cmds
spwoodcock Sep 20, 2023
60022de
ci: add extract-versions to needs to smoke & deploy
spwoodcock Sep 20, 2023
4e84e68
ci: update backend smoke test manual containers
spwoodcock Sep 20, 2023
d0ac9de
ci: backend smoke test use multiline
spwoodcock Sep 20, 2023
5edb754
ci: backend smoke test port mapping
spwoodcock Sep 20, 2023
cad4f63
ci: comment backend smoke tests until db init fixed
spwoodcock Sep 20, 2023
b140834
Feat New Create Project and Docker Build Changes (#840)
varun2948 Sep 22, 2023
67fe116
refactor: update refs to frontend/main --> frontend
spwoodcock Sep 22, 2023
1217fc6
ci: run pre-commit hooks on all files
spwoodcock Sep 22, 2023
98f0349
changed single polygon to merged polygon POI if uploaded multi polygo…
Sujanadh Sep 25, 2023
3bc4fde
ci: upgrade pre-commit versions
spwoodcock Sep 25, 2023
8139e34
style: run pre-commit hooks on all
spwoodcock Sep 25, 2023
1946e39
alembic setup
nrjadkry May 28, 2023
62a9e3d
alembic.ini file moved to app directory
nrjadkry Jun 1, 2023
24aa0a8
fix conflict in main.py file
nrjadkry Sep 26, 2023
d1d8aa2
env.py for alembic is moved inside app directory
nrjadkry Jun 1, 2023
be9127b
script.py.mako is moved inside app directory
nrjadkry Jun 1, 2023
cadce01
readme for alembic moved in app directory
nrjadkry Jun 1, 2023
b122d6d
updated alembic.ini file to exclude postgis exxtension
nrjadkry Jun 4, 2023
ddfca4e
updated env.py in migrations to exclude postgis extension
nrjadkry Jun 4, 2023
3a97024
sqlalchemy url obtained from settings for alembic migrations
nrjadkry Jun 4, 2023
5ce1d76
fix: conflict in config file
nrjadkry Sep 26, 2023
04977e2
first migration file
nrjadkry Jun 4, 2023
5fd4d5a
fix: merge conflicts
nrjadkry Sep 26, 2023
f29e347
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Sep 26, 2023
5b029a2
fix:default value for sqlalchemy url in config file
nrjadkry Sep 26, 2023
a48d003
Merge branch 'setup-alembic' of github.com:hotosm/fmtm into setup-ale…
nrjadkry Sep 26, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
71 changes: 14 additions & 57 deletions .all-contributorsrc
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@
"projectOwner": "hotosm",
"repoType": "github",
"repoHost": "https://github.com",
"files": [
"README.md"
],
"files": ["README.md"],
"imageSize": 100,
"badgeTemplate": "[![All Contributors](https://img.shields.io/badge/HOTOSM-Thanks%20for%20contributing!-red/github/all-contributors/hotosm/FMTM?color=red&style=flat-square)](#contributors)",
"commit": true,
Expand All @@ -16,132 +14,91 @@
"name": "Ivan Gayton",
"avatar_url": "https://avatars.githubusercontent.com/u/5991943?v=4",
"profile": "http://ivangayton.net",
"contributions": [
"projectManagement",
"code",
"review",
"ideas"
]
"contributions": ["projectManagement", "code", "review", "ideas"]
},
{
"login": "robsavoye",
"name": "Rob Savoye",
"avatar_url": "https://avatars.githubusercontent.com/u/71342768?v=4",
"profile": "https://www.hotosm.org",
"contributions": [
"maintenance",
"mentoring",
"code",
"review",
"ideas"
]
"contributions": ["maintenance", "mentoring", "code", "review", "ideas"]
},
{
"login": "krtonga",
"name": "krtonga",
"avatar_url": "https://avatars.githubusercontent.com/u/7307817?v=4",
"profile": "https://github.com/krtonga",
"contributions": [
"code",
"doc",
"tool",
"ideas"
]
"contributions": ["code", "doc", "tool", "ideas"]
},
{
"login": "spwoodcock",
"name": "Sam",
"avatar_url": "https://avatars.githubusercontent.com/u/78538841?v=4",
"profile": "https://github.com/spwoodcock",
"contributions": [
"code",
"review",
"infra",
"ideas"
]
"contributions": ["code", "review", "infra", "ideas"]
},
{
"login": "petya-kangalova",
"name": "Petya ",
"avatar_url": "https://avatars.githubusercontent.com/u/98902727?v=4",
"profile": "https://www.hotosm.org/people/petya-kangalova/",
"contributions": [
"doc",
"eventOrganizing",
"ideas"
]
"contributions": ["doc", "eventOrganizing", "ideas"]
},
{
"login": "Mudi-business",
"name": "Mohamed Bakari Mohamed",
"avatar_url": "https://avatars.githubusercontent.com/u/52991565?v=4",
"profile": "http://zanrevenue.org",
"contributions": [
"code"
]
"contributions": ["code"]
},
{
"login": "biomassives",
"name": "G. Willson",
"avatar_url": "https://avatars.githubusercontent.com/u/4379874?v=4",
"profile": "https://www.scdhub.org",
"contributions": [
"code"
]
"contributions": ["code"]
},
{
"login": "Ndacyayisenga-droid",
"name": "Tayebwa Noah",
"avatar_url": "https://avatars.githubusercontent.com/u/58124613?v=4",
"profile": "https://github.com/Ndacyayisenga-droid",
"contributions": [
"doc"
]
"contributions": ["doc"]
},
{
"login": "mohammadareeb95",
"name": "Mohammad Areeb",
"avatar_url": "https://avatars.githubusercontent.com/u/77102111?v=4",
"profile": "https://github.com/mohammadareeb95",
"contributions": [
"doc"
]
"contributions": ["doc"]
},
{
"login": "AugustHottie",
"name": "AugustHottie",
"avatar_url": "https://avatars.githubusercontent.com/u/96122635?v=4",
"profile": "https://github.com/AugustHottie",
"contributions": [
"doc"
]
"contributions": ["doc"]
},
{
"login": "Balofire",
"name": "Ahmeed Etti-Balogun",
"avatar_url": "https://avatars.githubusercontent.com/u/102294666?v=4",
"profile": "https://github.com/Balofire",
"contributions": [
"doc"
]
"contributions": ["doc"]
},
{
"login": "Roseford",
"name": "Uju",
"avatar_url": "https://avatars.githubusercontent.com/u/75838716?v=4",
"profile": "https://github.com/Roseford",
"contributions": [
"doc"
]
"contributions": ["doc"]
},
{
"login": "neelimagoogly",
"name": "Neelima Mohanty",
"avatar_url": "https://avatars.githubusercontent.com/u/97789856?v=4",
"profile": "https://github.com/neelimagoogly",
"contributions": [
"doc"
]
"contributions": ["doc"]
}
],
"contributorsPerLine": 7,
Expand Down
4 changes: 3 additions & 1 deletion .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ ODK_CENTRAL_PASSWD=fmtm
URL_SCHEME=http
API_URL=127.0.0.1:8000
FRONTEND_MAIN_URL=127.0.0.1:8080
FRONTEND_MAP_URL=127.0.0.1:8081
# API_PREFIX=/api

### OSM ###
Expand All @@ -34,3 +33,6 @@ FMTM_DB_HOST=fmtm-db
FMTM_DB_USER=fmtm
FMTM_DB_PASSWORD=fmtm
FMTM_DB_NAME=fmtm

### Underpass (optional) ###
# UNDERPASS_API_URL=
190 changes: 106 additions & 84 deletions .github/workflows/build_and_deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,119 +9,141 @@ on:
- development
paths:
# Workflow is triggered only if src changes
- "src/**"
- src/**
# Allow manual trigger
workflow_dispatch:

env:
REGISTRY: ghcr.io
GIT_BRANCH: ${{ github.ref_name }}

jobs:
build-and-push-images:
pytest:
uses: ./.github/workflows/r-pytest.yml
with:
image_tag: ci-${{ github.ref_name }}

frontend-tests:
uses: ./.github/workflows/r-frontend_tests.yml

extract-versions:
needs:
- pytest
- frontend-tests
uses: ./.github/workflows/r-extract_versions.yml

backend-build:
uses: ./.github/workflows/r-build_backend.yml
needs: extract-versions
with:
api_version: ${{ needs.extract-versions.outputs.api_version }}
build_target: prod
image_tags: |
"ghcr.io/hotosm/fmtm/backend:${{ needs.extract-versions.outputs.api_version }}-${{ github.ref_name }}"
"ghcr.io/hotosm/fmtm/backend:latest"

frontend-main-build:
uses: ./.github/workflows/r-build_frontend.yml
needs: extract-versions
with:
environment: ${{ github.ref_name }}
name: main
app_version: ${{ needs.extract-versions.outputs.frontend_main_version }}
build_target: prod
image_tags: |
"ghcr.io/hotosm/fmtm/frontend:${{ needs.extract-versions.outputs.frontend_main_version }}-${{ github.ref_name }}"
"ghcr.io/hotosm/fmtm/frontend:latest"

smoke-test-backend:
runs-on: ubuntu-latest
needs:
- extract-versions
- backend-build
environment:
name: ${{ github.ref_name }}
permissions:
contents: read
packages: write

steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Log in to the Container registry
uses: docker/login-action@v2
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Persist env vars
run: echo "${{ secrets.DOTENV }}" >> $GITHUB_ENV

- name: Extract api version
id: extract_api_version
- name: Environment to .env
env:
GIT_BRANCH: ${{ github.ref_name }}
API_VERSION: ${{ needs.extract-versions.outputs.api_version }}
FRONTEND_MAIN_VERSION: ${{ needs.extract-versions.outputs.frontend_main_version }}
run: |
cd src/backend
echo "API_VERSION=$(python -c 'from app.__version__ import __version__; print(__version__)')" >> $GITHUB_ENV
echo "${{ secrets.DOTENV }}" > .env
echo "GIT_BRANCH=${GIT_BRANCH}" >> .env
echo "API_VERSION=${API_VERSION}" >> .env
echo "FRONTEND_MAIN_VERSION=${FRONTEND_MAIN_VERSION}" >> .env

- name: Extract frontend versions
id: extract_frontend_versions
- name: Backend smoke test
run: |
cd src/frontend
echo "FRONTEND_MAIN_VERSION=$(jq -r '.version' main/package.json)" >> $GITHUB_ENV
echo "FRONTEND_MAP_VERSION=$(jq -r '.version' fmtm_openlayer_map/package.json)" >> $GITHUB_ENV
echo "Not implemented"
# source .env
# docker network create fmtm

# docker pull "postgis/postgis:14-3.3-alpine"
# docker run --rm -d \
# --name=fmtm-db \
# --network=fmtm \
# -e POSTGRES_USER=fmtm \
# -e POSTGRES_PASSWORD=fmtm \
# -e POSTGRES_DB=fmtm \
# "postgis/postgis:14-3.3-alpine"

# docker pull "ghcr.io/hotosm/fmtm/backend:${API_VERSION}-${GIT_BRANCH}"
# docker run --rm -d \
# --network=fmtm \
# -p 8080:8080 \
# -e FRONTEND_MAIN_URL="http://test.com" \
# -e OSM_CLIENT_ID="test" \
# -e OSM_CLIENT_SECRET="test" \
# -e OSM_SECRET_KEY="test" \
# "ghcr.io/hotosm/fmtm/backend:${API_VERSION}-${GIT_BRANCH}"

# # First wait 10 seconds for API
# sleep 10
# # Check the exit status of curl and exit the job if it fails
# if ! curl -f http://localhost:8080/docs; then
# echo "curl failed to access http://localhost:8080/docs"
# exit 1
# fi

smoke-test-frontend:
runs-on: ubuntu-latest
needs:
- extract-versions
- frontend-main-build
environment:
name: ${{ github.ref_name }}

- name: Build and push backend
uses: docker/build-push-action@v4
with:
context: src/backend
target: prod
push: true
tags: |
"ghcr.io/hotosm/fmtm/backend:${{ env.API_VERSION }}-${{ github.ref_name }}"
"ghcr.io/hotosm/fmtm/backend:latest"
build-args: |
APP_VERSION=${{ env.API_VERSION }}

- name: Build and push frontend main
uses: docker/build-push-action@v4
with:
context: src/frontend
file: src/frontend/prod.dockerfile
push: true
tags: "ghcr.io/hotosm/fmtm/frontend/main:${{ env.FRONTEND_MAIN_VERSION }}-${{ github.ref_name }}"
build-args: |
APP_NAME=main
APP_VERSION=${{ env.FRONTEND_MAIN_VERSION }}
API_URL=${{ env.URL_SCHEME }}://${{ env.API_URL }}
FRONTEND_MAIN_URL=${{ env.URL_SCHEME }}://${{ env.FRONTEND_MAIN_URL }}
FRONTEND_MAP_URL=${{ env.URL_SCHEME }}://${{ env.FRONTEND_MAP_URL }}

- name: Build and push frontend map
uses: docker/build-push-action@v4
with:
context: src/frontend
file: src/frontend/prod.dockerfile
push: true
tags: "ghcr.io/hotosm/fmtm/frontend/map:${{ env.FRONTEND_MAP_VERSION }}-${{ github.ref_name }}"
build-args: |
APP_NAME=fmtm_openlayer_map
APP_VERSION=${{ env.FRONTEND_MAP_VERSION }}
API_URL=${{ env.URL_SCHEME }}://${{ env.API_URL }}
FRONTEND_MAIN_URL=${{ env.URL_SCHEME }}://${{ env.FRONTEND_MAIN_URL }}
FRONTEND_MAP_URL=${{ env.URL_SCHEME }}://${{ env.FRONTEND_MAP_URL }}
steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Frontend smoke test
run: echo "Not implemented"

deploy-containers:
runs-on: ubuntu-latest
needs: build-and-push-images
needs:
- extract-versions
- smoke-test-backend
- smoke-test-frontend
environment:
name: ${{ github.ref_name }}

steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Extract api version
id: extract_api_version
run: |
cd src/backend
echo "API_VERSION=$(python -c 'from app.__version__ import __version__; print(__version__)')" >> $GITHUB_OUTPUT

- name: Extract frontend versions
id: extract_frontend_versions
run: |
cd src/frontend
echo "FRONTEND_MAIN_VERSION=$(jq -r '.version' main/package.json)" >> $GITHUB_OUTPUT
echo "FRONTEND_MAP_VERSION=$(jq -r '.version' fmtm_openlayer_map/package.json)" >> $GITHUB_OUTPUT

- name: Environment to .env
env:
GIT_BRANCH: ${{ github.ref_name }}
API_VERSION: ${{ needs.extract-versions.outputs.api_version }}
FRONTEND_MAIN_VERSION: ${{ needs.extract-versions.outputs.frontend_main_version }}
run: |
echo "${{ secrets.DOTENV }}" > .env
echo "API_VERSION=${{ steps.extract_api_version.outputs.API_VERSION }}" >> .env
echo "FRONTEND_MAIN_VERSION=${{ steps.extract_frontend_versions.outputs.FRONTEND_MAIN_VERSION }}" >> .env
echo "FRONTEND_MAP_VERSION=${{ steps.extract_frontend_versions.outputs.FRONTEND_MAP_VERSION }}" >> .env
echo "GIT_BRANCH=${GIT_BRANCH}" >> .env
echo "API_VERSION=${API_VERSION}" >> .env
echo "FRONTEND_MAIN_VERSION=${FRONTEND_MAIN_VERSION}" >> .env

- uses: webfactory/[email protected]
with:
Expand Down
Loading