Skip to content

Commit

Permalink
Merge pull request #23 from xeptagondev/develop
Browse files Browse the repository at this point in the history
Latest changes
  • Loading branch information
mbelinsky authored Dec 7, 2023
2 parents 8abd713 + 72d396b commit f803b4d
Show file tree
Hide file tree
Showing 68 changed files with 1,055 additions and 1,268 deletions.
48 changes: 29 additions & 19 deletions .github/workflows/frontend-deployment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@ on:
paths:
- web/**
- .github/workflows/frontend*
- docker-compose*

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
deploy_front_end:
Expand All @@ -19,6 +24,12 @@ jobs:
REACT_APP_MAP_TYPE : "Mapbox"
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 5
- name: Check Docker variable changes
run: |
echo "docker-compose file Change...."
git diff HEAD~ -- HEAD -z ./docker-compose*
# - name: Cache modules
# uses: actions/cache@v1
# id: yarn-cache
Expand Down Expand Up @@ -47,15 +58,27 @@ jobs:
- name: Login to Amazon ECR
id: login-ecr
uses: aws-actions/amazon-ecr-login@v1
# - name: Build, tag, and push the image to Amazon ECR
# id: build-image
# env:
# ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }}
# ECR_REPOSITORY: transparency-web
# IMAGE_TAG: v1
# run: |
# # Build a docker container and push it to ECR
# docker build -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG -f web/Dockerfile . --build-arg PORT=9030 --build-arg REACT_APP_BACKEND=https://transparency-demo.carbreg.org:9000 --build-arg REACT_APP_STAT_URL=https://transparency-demo.carbreg.org:9100 --build-arg COUNTRY_NAME="CountryX" --build-arg COUNTRY_FLAG_URL="https://carbon-common-dev.s3.amazonaws.com/flag.png" --build-arg COUNTRY_CODE="NG" --build-arg REACT_APP_MAP_TYPE="Mapbox" --build-arg REACT_APP_MAPBOXGL_ACCESS_TOKEN=${{ secrets.MAPBOXGL_ACCESS_TOKEN }} --build-arg NGINX_CONFIG="nginx_prod.conf"
# echo "Pushing image to ECR..."
# docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG
# echo "::set-output name=image::$ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG"
- name: Build, tag, and push the image to Amazon ECR
id: build-image
env:
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }}
ECR_REPOSITORY: transparency-web
IMAGE_TAG: v1
IMAGE_TAG: develop
run: |
# Build a docker container and push it to ECR
docker build -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG -f web/Dockerfile . --build-arg PORT=9030 --build-arg REACT_APP_BACKEND=https://transparency-demo.carbreg.org:9000 --build-arg REACT_APP_STAT_URL=https://transparency-demo.carbreg.org:9100 --build-arg COUNTRY_NAME="CountryX" --build-arg COUNTRY_FLAG_URL="https://carbon-common-dev.s3.amazonaws.com/flag.png" --build-arg COUNTRY_CODE="NG" --build-arg REACT_APP_MAP_TYPE="Mapbox" --build-arg REACT_APP_MAPBOXGL_ACCESS_TOKEN=${{ secrets.MAPBOXGL_ACCESS_TOKEN }} --build-arg NGINX_CONFIG="nginx_prod.conf"
docker build -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG -f web/Dockerfile . --build-arg PORT=3030 --build-arg REACT_APP_BACKEND=http://localhost:9000 --build-arg REACT_APP_STAT_URL=http://localhost:9100 --build-arg COUNTRY_NAME="CountryX" --build-arg COUNTRY_FLAG_URL="https://carbon-common-dev.s3.amazonaws.com/flag.png" --build-arg COUNTRY_CODE="NG" --build-arg REACT_APP_MAP_TYPE="Mapbox" --build-arg REACT_APP_MAPBOXGL_ACCESS_TOKEN=${{ secrets.MAPBOXGL_ACCESS_TOKEN }}
echo "Pushing image to ECR..."
docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG
echo "::set-output name=image::$ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG"
Expand All @@ -64,7 +87,7 @@ jobs:
env:
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }}
ECR_REPOSITORY: transparency-web
IMAGE_TAG: v1
IMAGE_TAG: develop
PRIVATE_KEY: ${{ secrets.AWS_SSH_KEY_PRIVATE }}
HOSTNAME: ${{secrets.HOST_IP}}
USER_NAME: ec2-user
Expand All @@ -73,19 +96,6 @@ jobs:
ssh -o StrictHostKeyChecking=no -i private_key ${USER_NAME}@${HOSTNAME} '
cd repos/carbon-transparency &&
sudo $(aws ecr get-login --no-include-email --region us-east-1) &&
sudo docker stop carbon-transparency-web-1 || true &&
sudo docker rm carbon-transparency-web-1 &&
sudo docker pull 302213478610.dkr.ecr.us-east-1.amazonaws.com/transparency-web:v1 &&
docker-compose -f docker-compose-image.yml up -d web '
- name: Build, tag, and push the QA-develop image to Amazon ECR
id: build-image-develop
env:
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }}
ECR_REPOSITORY: transparency-web
IMAGE_TAG: develop
run: |
# Build a docker container and push it to ECR
docker build -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG -f web/Dockerfile . --build-arg PORT=3030 --build-arg REACT_APP_BACKEND=http://localhost:9000 --build-arg REACT_APP_STAT_URL=http://localhost:9100 --build-arg COUNTRY_NAME="CountryX" --build-arg COUNTRY_FLAG_URL="https://carbon-common-dev.s3.amazonaws.com/flag.png" --build-arg COUNTRY_CODE="NG" --build-arg REACT_APP_MAP_TYPE="Mapbox" --build-arg REACT_APP_MAPBOXGL_ACCESS_TOKEN=${{ secrets.MAPBOXGL_ACCESS_TOKEN }}
echo "Pushing image to ECR..."
docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG
echo "::set-output name=image::$ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG"
(docker stop carbon-transparency-web-1 > /dev/null && docker rm carbon-transparency-web-1 ) 2>/dev/null || true &&
sudo docker pull 302213478610.dkr.ecr.us-east-1.amazonaws.com/transparency-web:develop &&
docker-compose -f docker-compose-image.yml up -d web '
20 changes: 15 additions & 5 deletions .github/workflows/server-deployments.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ on:
paths:
- backend/**
- .github/workflows/server*
- docker-compose*

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
Expand Down Expand Up @@ -85,6 +90,12 @@ jobs:
needs: [layer, check_dependency_change]
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 5
- name: Check Docker variable changes
run: |
echo "docker-compose file Change...."
git diff HEAD~ -- HEAD -z ./docker-compose*
# - name: Use Node.js ${{ matrix.node-version }}
# uses: actions/setup-node@v3
# with:
Expand Down Expand Up @@ -126,7 +137,7 @@ jobs:
env:
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }}
ECR_REPOSITORY: transparency-services
IMAGE_TAG: v1
IMAGE_TAG: develop
run: |
# Build a docker container and push it to ECR
docker build -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG -f backend/services/Dockerfile .
Expand All @@ -138,7 +149,7 @@ jobs:
env:
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }}
ECR_REPOSITORY: transparency-services
IMAGE_TAG: v1
IMAGE_TAG: develop
PRIVATE_KEY: ${{ secrets.AWS_SSH_KEY_PRIVATE }}
HOSTNAME: ${{secrets.HOST_IP}}
USER_NAME: ec2-user
Expand All @@ -147,9 +158,8 @@ jobs:
ssh -o StrictHostKeyChecking=no -i private_key ${USER_NAME}@${HOSTNAME} '
cd repos/carbon-transparency &&
sudo $(aws ecr get-login --no-include-email --region us-east-1) &&
sudo docker stop carbon-transparency-national-1 carbon-transparency-async-operations-handler-1 carbon-transparency-stats-1 || true &&
sudo docker rm carbon-transparency-national-1 carbon-transparency-async-operations-handler-1 carbon-transparency-stats-1 &&
sudo docker pull 302213478610.dkr.ecr.us-east-1.amazonaws.com/transparency-services:v1 &&
(docker stop carbon-transparency-national-1 carbon-transparency-async-operations-handler-1 carbon-transparency-stats-1 > /dev/null && docker rm carbon-transparency-national-1 carbon-transparency-async-operations-handler-1 carbon-transparency-stats-1 ) 2>/dev/null || true &&
sudo docker pull 302213478610.dkr.ecr.us-east-1.amazonaws.com/transparency-services:develop &&
docker-compose -f docker-compose-image.yml up -d national stats async-operations-handler '
# automated-api-tests:
Expand Down
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,7 @@ backend/services/.env.local
**/coverage
.env.local
./data/*
!./data/README.md
!./data/README.md
.yalc
yalc.lock
web/public/locales/*
6 changes: 3 additions & 3 deletions backend/services/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,13 @@
"@nestjs/platform-express": "^9.0.0",
"@nestjs/swagger": "^6.1.3",
"@nestjs/typeorm": "^9.0.1",
"@undp/carbon-credit-calculator": "^1.0.0",
"@undp/carbon-services-lib": "0.0.236",
"@undp/carbon-credit-calculator": "^1.1.1",
"@undp/carbon-services-lib": "0.0.289",
"@undp/serial-number-gen": "^1.0.0",
"aws-lambda": "^1.0.7",
"aws-serverless-express": "^3.4.0",
"axios": "^1.2.4",
"carbon-services-lib": "0.0.231-CARBON-276.0",
"carbon-services-lib": "0.0.231-CARBON-323.2",
"cheerio": "^1.0.0-rc.12",
"class-transformer": "^0.5.1",
"class-validator": "^0.14.0",
Expand Down
20 changes: 11 additions & 9 deletions backend/services/src/i18n/en/programme.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,25 +24,25 @@
"overallCreditNotFoundforCountryCode": "Overall credit does not found for the country code {}",
"unExpectedProgOwnerPerc": "Unexpected project owner percentages",
"notImplementedForMitigationType": "Not implemented for mitigation type {}",
"investmentReqDoesNotExist": "Investment request does not exist",
"acceptOrRejCancelledReq": "This investment request has been cancelled",
"invalidApproverForInvestmentReq": "Invalid approver for the investment request",
"investmentReqDoesNotExist": "Financing request does not exist",
"acceptOrRejCancelledReq": "This financing request has been cancelled",
"invalidApproverForInvestmentReq": "Invalid approver for the financing request",
"invalidApproverForRetirementReq": "Invalid approver for the retirement request",
"noPendReqFound": "This transfer request has been cancelled",
"investmentAlreadyApproved": "This investment request has already been accepted",
"investmentAlreadyApproved": "This financing request has already been accepted",
"receiveCompanySuspended": "Receive company suspended",
"cerditSendingCompSuspended": "Credit sending company suspended",
"noPendingTransferReq": "This transfer request has been cancelled",
"internalErrorStatusUpdating": "Internal error on status updating",
"transferReqAlreadyProcessed": "This transfer request has already been cancelled",
"investmentReqNotExistinGiv": "Investment request does not exist in the given values",
"investmentReqNotExistinGiv": "Financing request does not exist in the given values",
"totalAmount>0": "Total Amount should be greater than 0",
"percentagesNeedsToDefineForMultipleComp": "Percentages needs to define for multiple companies",
"invalidCompPercentageForGivenComp": "Invalid company percentages for given companies",
"invalidCompCreditFromGivenComp": "Invalid company credit for given from companies",
"cantTransferCreditWithinSameComp": "Cannot transfer ownership within the same company",
"programmeNotInCreditIssuedState": "Project is not in credit issued state",
"cantInitiateTransferForOtherComp": "Cannot initiate investments for other companies",
"cantInitiateTransferForOtherComp": "Cannot initiate financing for other companies",
"fromCompInReqIsNotOwnerOfProgramme": "From company mentioned in the request does not own the project",
"companyHaveNoEnoughBalanceForTransfer": "Company {} does not have enough balance for the transfer. Available: {}",
"proponentPercMustDefinedForEvryProponentTaxId": "Proponent percentage must defined for each proponent tax id",
Expand Down Expand Up @@ -71,9 +71,9 @@
"notFOundAPendingProgrammeForTheId": "Does not found a pending project for the given project id {}",
"notInPendingState": "This project has already been authorised",
"issuedCreditCantExceedEstCredit": "Project issued credit amount can not exceed estimated credit amount",
"investmentReqRejectSuccess": "The investment request has been rejected successfully",
"investmentReqRejectSuccess": "The financing request has been rejected successfully",
"transferReqCancelSuccess": "The international transfer retire request has been cancelled successfully",
"investmentCancelSuccess": "The investment request has been cancelled successfully",
"investmentCancelSuccess": "The financing request has been cancelled successfully",
"certifierCanOnlyCertifiy": "Project certification can perform only by certifier",
"govOrProgrammeOwnerOnlyCreditRetirement": "Credit retirement can initiate only the government or project owner",
"issuedCreditCannotExceedEstCredit": "Project issue credit amount can not exceed estimated credit amount",
Expand All @@ -83,5 +83,7 @@
"internalErrorCreditFreezing": "Internal error on credit freezing",
"totalUserEstimateCreditsInvalidMsg": "Total user estimated credits cannot be greater than the project estimated credits",
"wrongSectorAndScopeMapping": "The sectoral scope doesn't match the sector",
"wrongMItigationSectorMapping": "The Mitigation type doesn't match the sector. The correct mapping is Energy - Biomass energy, Coal bed/mine methane, EE households, EE industry, EE own generation, EE service, EE supply side, Energy distribution, Fossil fuel switch, Geothermal, Hydro, Solar, Wind Health - none Education - none Transport - Transport Manufacturing -Cement, CCS, HFCs, PFCs, SF6 Hospitality - none Forestry - Forestry Waste - Landfills, Fugitive, Methane avoidance Agriculture - Agriculture Other - Marine, N2O"
"wrongMItigationSectorMapping": "The Mitigation type doesn't match the sector. The correct mapping is Energy - Biomass energy, Coal bed/mine methane, EE households, EE industry, EE own generation, EE service, EE supply side, Energy distribution, Fossil fuel switch, Geothermal, Hydro, Solar, Wind Health - none Education - none Transport - Transport Manufacturing -Cement, CCS, HFCs, PFCs, SF6 Hospitality - none Forestry - Forestry Waste - Landfills, Fugitive, Methane avoidance Agriculture - Agriculture Other - Marine, N2O",
"wrongSubMitigationMapping": "The Sub Mitigation type doesn't match the Mitigation type."

}
2 changes: 1 addition & 1 deletion backend/services/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ async function bootstrap() {
console.log("Inserting users", users);
await setupHandler.handler({ type: "IMPORT_USERS", body: users });
}

// await setupHandler.handler({type:"UPDATE_COORDINATES"})
const staticPath = join(__dirname, "..", "public");
console.log("Static file path:", staticPath);
app.useStaticAssets(staticPath);
Expand Down
6 changes: 3 additions & 3 deletions backend/services/src/national-api/programme.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Body, Controller, Post, UseGuards, Request, Put } from '@nestjs/common'
import { ApiBearerAuth, ApiTags } from '@nestjs/swagger';
import {Programme,Action,AppAbility,CheckPolicies,PoliciesGuard, PoliciesGuardEx,ProgrammeDto,ProgrammeService,
QueryDto,ConstantUpdateDto,ApiKeyJwtAuthGuard,NDCActionDto,JwtAuthGuard,ProgrammeDocumentDto,DocumentAction,ProgrammeAuth,ProgrammeIssue,ProgrammeReject,
InvestmentRequestDto,Investment,InvestmentApprove,InvestmentCancel,InvestmentReject,NDCActionViewEntity,ProgrammeDocumentViewEntity} from "@undp/carbon-services-lib";
InvestmentRequestDto,Investment,InvestmentApprove,InvestmentCancel,InvestmentReject,NDCActionViewEntity,ProgrammeDocumentViewEntity, ProgrammeMitigationIssue} from "@undp/carbon-services-lib";



Expand Down Expand Up @@ -110,8 +110,8 @@ export class ProgrammeController {
@ApiBearerAuth()
@UseGuards(ApiKeyJwtAuthGuard, PoliciesGuardEx(true, Action.Update, Programme))
@Put('issueCredit')
async issueCredit(@Body() issue: ProgrammeIssue) {
return this.programmeService.issueCredit(issue);
async issueCredit(@Body() issue: ProgrammeMitigationIssue,@Request() req) {
return this.programmeService.issueCredit(issue,req.abilityCondition);
}

@ApiBearerAuth('api_key')
Expand Down
2 changes: 2 additions & 0 deletions backend/services/src/setup/handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ export const handler: Handler = async (event) => {
logger: getLogger(ProgrammeModule),
});
const programmeService = prApp.get(ProgrammeService);
await programmeService.regenerateRegionCoordinates();
return;
}

Expand Down Expand Up @@ -193,6 +194,7 @@ export const handler: Handler = async (event) => {
company.name = event["name"];
company.logo = event["logoBase64"];
company.companyRole = CompanyRole.GOVERNMENT;
company.taxId = `00000${event["systemCountryCode"]}`

const user = new UserDto();
user.email = event["rootEmail"];
Expand Down
32 changes: 20 additions & 12 deletions backend/services/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -5385,17 +5385,25 @@
"@ucast/core" "^1.4.1"

"@undp/carbon-credit-calculator@^1.0.0":
version "1.0.0"
resolved "https://registry.yarnpkg.com/@undp/carbon-credit-calculator/-/carbon-credit-calculator-1.0.0.tgz#fbdfbb606cb7bd402ed74887dfc1f0861cfca892"
integrity sha512-7wbGm7uEYdRBWlKzATKIhFLd9Zip8yxLCi3cfAcufb5kACw8ZKqtbn+08EyZQiJbDoPB3ouM6Dx8Dl+FnqqPVg==
version "1.1.2"
resolved "https://registry.yarnpkg.com/@undp/carbon-credit-calculator/-/carbon-credit-calculator-1.1.2.tgz#a72f7d632e88e2fe5b15148548b1c4145d68dbc8"
integrity sha512-8tFp3DkHDZb6HIKVsJd7QRtx2rH1gCvE5aDAq/IinJ4HLOAnufkfPBRCmXG2mfCL5LY2icXjU0X+4Nz/zteiMA==
dependencies:
"@types/node" "^18.11.9"
convert-units "^2.3.4"

"@undp/carbon-credit-calculator@^1.1.1":
version "1.1.1"
resolved "https://registry.yarnpkg.com/@undp/carbon-credit-calculator/-/carbon-credit-calculator-1.1.1.tgz#af3d295abf0ebb4af9d5be04f09067b9247197e5"
integrity sha512-H6AoaICkxQO+tbin1faZb4RbGVfQ9kbH228b5Vaz4Zomlo+AWIhYAPl/3CXE3tbdd465KH2RPczMzC+DeRnlFg==
dependencies:
"@types/node" "^18.11.9"
convert-units "^2.3.4"

"@undp/[email protected].236":
version "0.0.236"
resolved "https://registry.yarnpkg.com/@undp/carbon-services-lib/-/carbon-services-lib-0.0.236.tgz#c5b018901b358e27e2376781fc2917b8f0d28183"
integrity sha512-e8ije5RcSMikHuZinffvNJz7/ED26nZo9zS2F4KE9k2wOz44Zs5QqnETnze7tsZZblS7GF9XVj7UbDXzKxjXrA==
"@undp/[email protected].289":
version "0.0.289"
resolved "https://registry.yarnpkg.com/@undp/carbon-services-lib/-/carbon-services-lib-0.0.289.tgz#afd52f99b575b7a4967f471eabcf2b4c12983379"
integrity sha512-6B4uVGvvEKU1IDjOXOT1Ghb1E8vUiDrLxGq4tHc7BxX1ITHxF7/ufQLiCaVuYMvLy898aFPvea5tObEBhsYSiA==
dependencies:
"@aws-sdk/client-qldb" "^3.408.0"
"@aws-sdk/client-qldb-session" "^3.408.0"
Expand All @@ -5411,7 +5419,7 @@
"@nestjs/platform-express" "^9.0.0"
"@nestjs/swagger" "^6.1.3"
"@nestjs/typeorm" "^9.0.1"
"@undp/carbon-credit-calculator" "^1.0.0"
"@undp/carbon-credit-calculator" "^1.1.1"
"@undp/serial-number-gen" "^1.0.0"
amazon-qldb-driver-nodejs "^3.0.1"
aws-kinesis-agg "^4.2.6"
Expand Down Expand Up @@ -6730,10 +6738,10 @@ caniuse-lite@^1.0.30001449:
resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30001474.tgz#13b6fe301a831fe666cce8ca4ef89352334133d5"
integrity sha512-iaIZ8gVrWfemh5DG3T9/YqarVZoYf0r188IjaGwx68j4Pf0SGY6CQkmJUIE+NZHkkecQGohzXmBGEwWDr9aM3Q==

[email protected]276.0:
version "0.0.231-CARBON-276.0"
resolved "https://registry.yarnpkg.com/carbon-services-lib/-/carbon-services-lib-0.0.231-CARBON-276.0.tgz#f859277bf85df17d9d76085d9bb10a8cc83d2d6c"
integrity sha512-YNIwmENx4RAoLDTSg4a4wqaxNi5QuxHqYjIb0kNOIQCehLZ1m+jGptZo1SJyMy0nDHX4G3YXaXZBK1mjswzr6g==
[email protected]323.2:
version "0.0.231-CARBON-323.2"
resolved "https://registry.yarnpkg.com/carbon-services-lib/-/carbon-services-lib-0.0.231-CARBON-323.2.tgz#b4a33fc0955ef8839e5e4bf857c5215872df2f43"
integrity sha512-IR0d1s7T4jUneQ6eH1muqdXJNwHaIGVhDL66X7I1dJSIvQqQ1ajG1ZZMWyMvwk/SsQB+EWeQEFCwPVYTYBEjXQ==
dependencies:
"@aws-sdk/client-qldb" "^3.408.0"
"@aws-sdk/client-qldb-session" "^3.408.0"
Expand Down
Loading

0 comments on commit f803b4d

Please sign in to comment.