From b5c42c186f737211e31cf3f68c0af4678da2a4d1 Mon Sep 17 00:00:00 2001 From: sadarunnisa Date: Tue, 2 Apr 2024 12:09:36 +0530 Subject: [PATCH 1/3] ARC-106 - add infra tf commands and precommit hooks (#130) ## Description Find a way to merge husky and pre-commit. The node ecosystem takes priority, so all IaC related tools should be integrated with the node ecosystem, i.e. pre-commit is called before husky, IaC commands are added to the package.json, etc. Added hook in husky for pre-commit. Also added scripts in package.json for infra related commands. Fixes # (issue) https://github.com/sourcefuse/backstage/issues/106 ## Type of change Please delete options that are not relevant. - [ ] Bug fix (non-breaking change which fixes an issue) - [X] New feature (non-breaking change which adds functionality) - [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected) - [ ] Intermediate change (work in progress) ## How Has This Been Tested? Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration - [ ] Test A - [ ] Test B ## Checklist: - [X] Performed a self-review of my own code - [X] npm test passes on your machine - [ ] New tests added or existing tests modified to cover all changes - [ ] Code conforms with the style guide - [ ] API Documentation in code was updated - [ ] Any dependent changes have been merged and published in downstream modules --- .husky/pre-commit | 2 +- lerna.json | 1 - package.json | 14 +++++++++++++- packages/backend/src/plugins/scaffolder.ts | 1 + 4 files changed, 15 insertions(+), 3 deletions(-) diff --git a/.husky/pre-commit b/.husky/pre-commit index 7eb52a8..6434beb 100755 --- a/.husky/pre-commit +++ b/.husky/pre-commit @@ -1,4 +1,4 @@ #!/bin/sh . "$(dirname "$0")/_/husky.sh" -lerna run test:ci +lerna run lint && lerna run test:ci diff --git a/lerna.json b/lerna.json index 322929d..1f93dcd 100644 --- a/lerna.json +++ b/lerna.json @@ -1,6 +1,5 @@ { "packages": ["packages/*", "plugins/*"], "npmClient": "yarn", - "useWorkspaces": true, "version": "0.1.0" } diff --git a/package.json b/package.json index f8f26e9..b34853c 100644 --- a/package.json +++ b/package.json @@ -23,7 +23,12 @@ "create-plugin": "backstage-cli create-plugin --scope internal", "remove-plugin": "backstage-cli remove-plugin", "setup-hooks": "husky install", - "new": "backstage-cli new --scope internal" + "new": "backstage-cli new --scope internal", + "infra:init": "cd terraform && terraform init", + "infra:plan": "cd terraform && terraform plan", + "infra:apply": "cd terraform && terraform apply", + "infra:destroy": "cd terraform && terraform destroy", + "prepare": "husky install" }, "workspaces": { "packages": [ @@ -61,5 +66,12 @@ "path": "cz-format-extension" } }, + "husky": { + "hooks": { + "pre-commit": "npm run lint:all && npm run test:all", + "prepare-commit-msg": "exec < /dev/tty && git cz --hook || true", + "commit-msg": "commitlint -E HUSKY_GIT_PARAMS" + } + }, "dependencies": {} } diff --git a/packages/backend/src/plugins/scaffolder.ts b/packages/backend/src/plugins/scaffolder.ts index 55de615..5a9c626 100644 --- a/packages/backend/src/plugins/scaffolder.ts +++ b/packages/backend/src/plugins/scaffolder.ts @@ -6,6 +6,7 @@ import { createExtensionAction } from './sourceloop-extension'; import { createMicroserviceAction } from './sourceloop-ms'; import { createScaffoldAction } from './sourceloop-scaffold'; // import { DockerContainerRunner } from '@backstage/backend-common'; +// eslint-disable-next-line @backstage/no-undeclared-imports import { ScmIntegrations } from '@backstage/integration'; import { createNewFileAction } from './create-new-file.action'; From 2b17450dcf2056fb82c5d44236f8c53b246c872a Mon Sep 17 00:00:00 2001 From: sadarunnisa Date: Tue, 16 Apr 2024 11:41:43 +0530 Subject: [PATCH 2/3] feat(chore): push images to dockerhub (#133) Move docker Image to Docker Hub and Update Docker Image Everywhere ARC-108 ## Description - Move docker Image to Docker Hub - Update Docker Image Everywhere (Move from sourcefuse/sourcefuse-backstage to sourcefuse/backstage.) - Created dockerhub public repository as 'backstage' - Added Repository secrets for github username and password (SF_ARCH_DOCKERHUB_USERNAME, SF_ARCH_DOCKERHUB_PASSWORD) - Made required changes in github workflow files and docker-compose.yml Fixes # (issue) https://github.com/sourcefuse/backstage/issues/108 (Move docker Image to Docker Hub) https://github.com/sourcefuse/backstage/issues/109 (Update Docker Image Everywhere) ## Type of change Please delete options that are not relevant. - [ ] Bug fix (non-breaking change which fixes an issue) - [X] New feature (non-breaking change which adds functionality) - [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected) - [ ] Intermediate change (work in progress) ## How Has This Been Tested? Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration - [ ] Test A - [ ] Test B ## Checklist: - [X] Performed a self-review of my own code - [X] npm test passes on your machine - [ ] New tests added or existing tests modified to cover all changes - [ ] Code conforms with the style guide - [ ] API Documentation in code was updated - [ ] Any dependent changes have been merged and published in downstream modules --- .github/workflows/docker-push.yaml | 7 ++++++- docker-compose.yml | 2 +- scripts/docker-build-tag-and-push.sh | 28 +++++++++++++--------------- 3 files changed, 20 insertions(+), 17 deletions(-) diff --git a/.github/workflows/docker-push.yaml b/.github/workflows/docker-push.yaml index 8c88ad4..76b6228 100644 --- a/.github/workflows/docker-push.yaml +++ b/.github/workflows/docker-push.yaml @@ -44,6 +44,8 @@ jobs: run: | export IMAGE_TAG=${{ steps.vars.outputs.git_tag }} export ENVIRONMENT=poc + export DOCKERHUB_USERNAME=${{ secrets.SF_ARCH_DOCKERHUB_USERNAME }} + export DOCKERHUB_PASSWORD=${{ secrets.SF_ARCH_DOCKERHUB_PASSWORD }} ./scripts/docker-build-tag-and-push.sh @@ -75,5 +77,8 @@ jobs: - name: Build, Tag, and Push run: | export IMAGE_TAG=${{ steps.vars.outputs.git_tag }} - export ENVIRONMENT=prod + export ENVIRONMENT=poc + export DOCKERHUB_USERNAME=${{ secrets.SF_ARCH_DOCKERHUB_USERNAME }} + export DOCKERHUB_PASSWORD=${{ secrets.SF_ARCH_DOCKERHUB_PASSWORD }} ./scripts/docker-build-tag-and-push.sh + diff --git a/docker-compose.yml b/docker-compose.yml index 39aefd6..b9fb410 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -3,7 +3,7 @@ version: '3.4' services: backstage: container_name: backstage_container - image: sourcefuse/sourcefuse-backstage + image: sourcefuse/backstage build: . environment: ENVIRONMENT: production diff --git a/scripts/docker-build-tag-and-push.sh b/scripts/docker-build-tag-and-push.sh index 0b9ae9b..567e47c 100755 --- a/scripts/docker-build-tag-and-push.sh +++ b/scripts/docker-build-tag-and-push.sh @@ -2,34 +2,32 @@ set -e -# optional -: "${AWS_REGION:=us-east-1}" +# Optional : "${DOCKER_COMPOSE_FILE:=./docker-compose.yml}" : "${ENVIRONMENT:=poc}" -## required -AWS_ACCOUNT_ID=$(aws sts get-caller-identity --query "Account" --output text) +# Required +: "${DOCKER_USERNAME:=$DOCKERHUB_USERNAME}" +: "${DOCKER_PASSWORD:=$DOCKERHUB_PASSWORD}" : "${IMAGE_TAG:-$IMAGE_TAG}" -ECR_REGISTRY_ENDPOINT="$AWS_ACCOUNT_ID.dkr.ecr.$AWS_REGION.amazonaws.com" -IMAGE_NAME="$ECR_REGISTRY_ENDPOINT/sourcefuse-backstage" +DOCKERHUB_REGISTRY="docker.io" +IMAGE_NAME="$DOCKERHUB_REGISTRY/$DOCKER_USERNAME/backstage" -echo "Account: $AWS_ACCOUNT_ID" +echo "Docker Registry: $DOCKERHUB_REGISTRY ...\n" + +printf "\nLogging in to Docker Hub... -u $DOCKER_USERNAME -p $DOCKER_PASSWORD ImangeName $IMAGE_NAME Imagetag $IMAGE_TAG ...\n" +docker login -u "$DOCKER_USERNAME" -p "$DOCKER_PASSWORD" -printf "\nECR Login...\n" -aws ecr get-login-password \ - --region $AWS_REGION \ - | docker login \ - --username AWS \ - --password-stdin $ECR_REGISTRY_ENDPOINT printf "\nBuilding docker images...\n" docker-compose -f $DOCKER_COMPOSE_FILE build printf "\nTagging image $IMAGE_NAME:$IMAGE_TAG...\n" -docker tag sourcefuse/sourcefuse-backstage:latest $IMAGE_NAME:$IMAGE_TAG +docker images +docker tag sourcefuse/backstage:latest $IMAGE_NAME:$IMAGE_TAG -printf "\nPushing $IMAGE_NAME:$IMAGE_TAG to ECR...\n" +printf "\nPushing $IMAGE_NAME:$IMAGE_TAG to Docker Hub...\n" docker push $IMAGE_NAME:$IMAGE_TAG printf "\nAdding $IMAGE_NAME:$IMAGE_TAG to SSM Parameter...\n" From b3545534bbf9673ce2e744029a43ee47fd83a31e Mon Sep 17 00:00:00 2001 From: sadarunnisa Date: Thu, 18 Apr 2024 03:41:34 +0530 Subject: [PATCH 3/3] refactor(templates): remove old templates from app config (#135) Remove old templates from app config (Seed Templates and Repos Are Incorrect) ARC-107 ## Description Seed repos and templates are out of date with upstream changes to the Git repos. Update app-config.yml remove out dated templates. Removed react boilerplate and terraform-aws-arc-bootstrap templates from app-config.yml. Fixes # (issue) ARC-107 ## Type of change Please delete options that are not relevant. - [X] Bug fix (non-breaking change which fixes an issue) - [ ] New feature (non-breaking change which adds functionality) - [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected) - [ ] Intermediate change (work in progress) ## How Has This Been Tested? Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration - [ ] Test A - [ ] Test B ## Checklist: - [X] Performed a self-review of my own code - [ ] npm test passes on your machine - [ ] New tests added or existing tests modified to cover all changes - [ ] Code conforms with the style guide - [ ] API Documentation in code was updated - [ ] Any dependent changes have been merged and published in downstream modules --- app-config.yaml | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/app-config.yaml b/app-config.yaml index fa65cff..cc50057 100644 --- a/app-config.yaml +++ b/app-config.yaml @@ -124,16 +124,6 @@ catalog: rules: - allow: [ Template ] - - type: url - target: https://github.com/sourcefuse/sf-software-templates/blob/main/scaffolder-templates/react-boilerplate/template.yaml - rules: - - allow: [ Template ] - - - type: url - target: https://github.com/sourcefuse/sf-software-templates/blob/main/scaffolder-templates/terraform-aws-ref-arch-bootstrap/template.yaml - rules: - - allow: [ Template ] - - type: url target: https://github.com/sourcefuse/sf-software-templates/blob/main/scaffolder-templates/microservice-repo-bootstrap/template.yaml rules: @@ -161,11 +151,6 @@ catalog: - allow: [ Component ] tags: [ Backend ] - - type: url - target: https://github.com/sourcefuse/terraform-aws-ref-arch-bootstrap/blob/main/catalog-info.yaml - rules: - - allow: [ Component ] - - type: url target: https://github.com/sourcefuse/terraform-aws-arc-db/blob/main/catalog-info.yaml rules: