-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'release-0.2.0' into feat/hamed-remove-kwh-duplicate-1279
- Loading branch information
Showing
14 changed files
with
325 additions
and
177 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -42,16 +42,31 @@ jobs: | |
echo "IMAGE_TAG retrieved from Test is $imagetag" | ||
echo "IMAGE_TAG=$imagetag" >> $GITHUB_OUTPUT | ||
get-current-time: | ||
name: Get Current Time | ||
runs-on: ubuntu-latest | ||
needs: get-image-tag | ||
|
||
outputs: | ||
CURRENT_TIME: ${{ steps.get-current-time.outputs.CURRENT_TIME }} | ||
|
||
steps: | ||
- id: get-current-time | ||
run: | | ||
TZ="America/Vancouver" | ||
echo "CURRENT_TIME=$(date '+%Y-%m-%d %H:%M:%S %Z')" >> $GITHUB_OUTPUT | ||
# Deplog the image which is running on test to prod | ||
deploy-on-prod: | ||
|
||
name: Deploy LCFS on Prod | ||
runs-on: ubuntu-latest | ||
needs: get-image-tag | ||
needs: [get-image-tag, get-current-time] | ||
timeout-minutes: 60 | ||
|
||
env: | ||
IMAGE_TAG: ${{ needs.get-image-tag.outputs.IMAGE_TAG }} | ||
CURRENT_TIME: ${{ needs.get-current-time.outputs.CURRENT_TIME }} | ||
|
||
steps: | ||
|
||
|
@@ -66,9 +81,17 @@ jobs: | |
uses: trstringer/[email protected] | ||
with: | ||
secret: ${{ github.TOKEN }} | ||
approvers: AlexZorkin,kuanfandevops,hamed-valiollahi,airinggov,areyeslo,dhaselhan,Grulin,justin-lepitzki,kevin-hashimoto | ||
approvers: AlexZorkin,kuanfandevops,hamed-valiollahi,airinggov,areyeslo,dhaselhan,Grulin | ||
minimum-approvals: 2 | ||
issue-title: "LCFS ${{env.IMAGE_TAG }} Prod Deployment" | ||
issue-title: "LCFS ${{env.IMAGE_TAG }} Prod Deployment at ${{ env.CURRENT_TIME }}." | ||
|
||
- name: Log in to Openshift | ||
uses: redhat-actions/[email protected] | ||
with: | ||
openshift_server_url: ${{ secrets.OPENSHIFT_SERVER }} | ||
openshift_token: ${{ secrets.OPENSHIFT_TOKEN }} | ||
insecure_skip_tls_verify: true | ||
namespace: ${{ env.PROD_NAMESPACE }} | ||
|
||
- name: Tag LCFS images from Test to Prod | ||
run: | | ||
|
@@ -88,6 +111,6 @@ jobs: | |
git config --global user.name "GitHub Actions" | ||
git add lcfs/charts/lcfs-frontend/values-prod.yaml | ||
git add lcfs/charts/lcfs-backend/values-prod.yaml | ||
git commit -m "update the version with pre-release number for prod" | ||
git commit -m "Update image tag ${{env.IMAGE_TAG }} for prod" | ||
git push | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -225,7 +225,7 @@ jobs: | |
uses: trstringer/[email protected] | ||
with: | ||
secret: ${{ github.TOKEN }} | ||
approvers: AlexZorkin,kuanfandevops,hamed-valiollahi,airinggov,areyeslo,dhaselhan,Grulin,justin-lepitzki,kevin-hashimoto | ||
approvers: AlexZorkin,kuanfandevops,hamed-valiollahi,airinggov,areyeslo,dhaselhan,Grulin,kevin-hashimoto | ||
minimum-approvals: 1 | ||
issue-title: "LCFS ${{ env.VERSION }}-${{ env.PRE_RELEASE }} Test Deployment" | ||
|
||
|
This file was deleted.
Oops, something went wrong.
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,23 @@ | ||
from typing import AsyncGenerator | ||
|
||
from redis.asyncio import Redis | ||
from redis.asyncio import ConnectionPool | ||
from starlette.requests import Request | ||
|
||
|
||
# Redis Pool Dependency | ||
async def get_redis_pool( | ||
request: Request, | ||
) -> AsyncGenerator[Redis, None]: # pragma: no cover | ||
) -> ConnectionPool: | ||
""" | ||
Returns connection pool. | ||
You can use it like this: | ||
>>> from redis.asyncio import ConnectionPool, Redis | ||
>>> | ||
>>> async def handler(redis_pool: ConnectionPool = Depends(get_redis_pool)): | ||
>>> async with Redis(connection_pool=redis_pool) as redis: | ||
>>> await redis.get('key') | ||
Returns the Redis connection pool. | ||
I use pools, so you don't acquire connection till the end of the handler. | ||
Usage: | ||
>>> from redis.asyncio import ConnectionPool, Redis | ||
>>> | ||
>>> async def handler(redis_pool: ConnectionPool = Depends(get_redis_pool)): | ||
>>> redis = Redis(connection_pool=redis_pool) | ||
>>> await redis.get('key') | ||
>>> await redis.close() | ||
:param request: current request. | ||
:returns: redis connection pool. | ||
:param request: Current request object. | ||
:returns: Redis connection pool. | ||
""" | ||
return request.app.state.redis_pool |
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
from starlette.requests import Request | ||
import boto3 | ||
|
||
|
||
# S3 Client Dependency | ||
async def get_s3_client( | ||
request: Request, | ||
) -> boto3.client: | ||
""" | ||
Returns the S3 client from the application state. | ||
Usage: | ||
>>> async def handler(s3_client = Depends(get_s3_client)): | ||
>>> s3_client.upload_file('file.txt', 'my-bucket', 'file.txt') | ||
:param request: Current request object. | ||
:returns: S3 client. | ||
""" | ||
return request.app.state.s3_client |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import boto3 | ||
from fastapi import FastAPI | ||
from lcfs.settings import settings | ||
|
||
|
||
async def init_s3(app: FastAPI) -> None: | ||
""" | ||
Initialize the S3 client and store it in the app state. | ||
:param app: FastAPI application. | ||
""" | ||
app.state.s3_client = boto3.client( | ||
"s3", | ||
aws_access_key_id=settings.s3_access_key, | ||
aws_secret_access_key=settings.s3_secret_key, | ||
endpoint_url=settings.s3_endpoint, | ||
region_name="us-east-1", | ||
) | ||
print("S3 client initialized.") | ||
|
||
|
||
async def shutdown_s3(app: FastAPI) -> None: | ||
""" | ||
Cleanup the S3 client from the app state. | ||
:param app: FastAPI application. | ||
""" | ||
if hasattr(app.state, "s3_client"): | ||
del app.state.s3_client | ||
print("S3 client shutdown.") |
Oops, something went wrong.