From 23ac0310d39f55263bf36659b9e6770f62a5aa24 Mon Sep 17 00:00:00 2001 From: Sam Nie <147653722+SamNie2027@users.noreply.github.com> Date: Sun, 1 Feb 2026 13:12:34 -0500 Subject: [PATCH 1/4] Adding basic CICD, commenting out old CICD, disabling nx cloud --- .github/workflows/backend_build.yml | 33 ++++ .github/workflows/ci-cd.yml | 226 +++++++++++++-------------- .github/workflows/frontend_build.yml | 33 ++++ .github/workflows/jest.yml | 35 +++++ .github/workflows/lint.yml | 27 ++++ nx.json | 3 +- 6 files changed, 242 insertions(+), 115 deletions(-) create mode 100644 .github/workflows/backend_build.yml create mode 100644 .github/workflows/frontend_build.yml create mode 100644 .github/workflows/jest.yml create mode 100644 .github/workflows/lint.yml diff --git a/.github/workflows/backend_build.yml b/.github/workflows/backend_build.yml new file mode 100644 index 000000000..49afce767 --- /dev/null +++ b/.github/workflows/backend_build.yml @@ -0,0 +1,33 @@ +name: Backend build + +on: + push: + branches: ['main'] + pull_request: + branches: ['main'] + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + + - name: Use NodeJS 24.x + uses: actions/setup-node@v4 + with: + node-version: 24.x + cache: 'yarn' + + - name: Create .env file + run: | + + echo "AWS_SECRET_ACCESS_KEY=dummy" >> .env + echo "AWS_ACCESS_KEY_ID=dummy" >> .env + echo "AWS_REGION=us-east-2" >> .env + + - name: Install Dependencies + run: yarn install + + - name: Build backend + run: npx nx build backend \ No newline at end of file diff --git a/.github/workflows/ci-cd.yml b/.github/workflows/ci-cd.yml index bf0fcbef9..cfde90458 100644 --- a/.github/workflows/ci-cd.yml +++ b/.github/workflows/ci-cd.yml @@ -1,113 +1,113 @@ -name: CI/CD - -# First runs linter and tests all affected projects -# Then, for each project that requires deployment, deploy-- is added -# Environment variables are labelled _SHORT_DESCRIPTION - -on: - push: - branches: ['main'] - pull_request: - branches: ['main'] - workflow_dispatch: - inputs: - manual-deploy: - description: 'App to Deploy' - required: false - default: '' - -concurrency: - # Never have two deployments happening at the same time (potential race condition) - group: '{{ github.head_ref || github.ref }}' - -jobs: - pre-deploy: - runs-on: ubuntu-latest - outputs: - affected: ${{ steps.should-deploy.outputs.affected }} - steps: - - uses: actions/checkout@v3 - with: - # We need to fetch all branches and commits so that Nx affected has a base to compare against. - fetch-depth: 0 - - name: Use Node.js 20 - uses: actions/setup-node@v3 - with: - node-version: 20.x - cache: 'yarn' - - - name: Install Dependencies - run: yarn install - - # In any subsequent steps within this job (myjob) we can reference the resolved SHAs - # using either the step outputs or environment variables: - - name: Derive appropriate SHAs for base and head for `nx affected` commands - uses: nrwl/nx-set-shas@v3 - - - run: | - echo "BASE: ${{ env.NX_BASE }}" - echo "HEAD: ${{ env.NX_HEAD }}" - - - name: Nx Affected Lint - run: npx nx affected -t lint - - # - name: Nx Affected Test - # run: npx nx affected -t test - - - name: Nx Affected Build - run: npx nx affected -t build - - - name: Determine who needs to be deployed - id: should-deploy - run: | - echo "The following projects have been affected: [$(npx nx print-affected -t build --select=tasks.target.project)]"; - echo "affected=$(npx nx print-affected -t build --select=tasks.target.project)" >> "$GITHUB_OUTPUT" - - deploy-debug: - needs: pre-deploy - runs-on: ubuntu-latest - steps: - - name: Debug logs - run: | - echo "Manual Deploy: ${{github.event.inputs.manual-deploy}}"; - echo "Affected Names: ${{needs.pre-deploy.outputs.affected}}"; - echo "Event: ${{github.event_name}}"; - echo "Ref: ${{github.ref}}"; - echo "Will deploy?: ${{(github.event_name == 'push' || github.event_name == 'workflow_dispatch') && github.ref == 'refs/heads/main'}}"; - - deploy-frontend: - needs: pre-deploy - if: (contains(github.event.inputs.manual-deploy, 'c4c-ops-frontend') || contains(needs.pre-deploy.outputs.affected, 'scaffolding-frontend')) && (github.event_name == 'push' || github.event_name == 'workflow_dispatch') && github.ref == 'refs/heads/main' - runs-on: ubuntu-latest - # For "simplicity", deployment settings are configured in the AWS Amplify Console - # This just posts to a webhook telling Amplify to redeploy the main branch - steps: - - name: Tell Amplify to rebuild - run: curl -X POST -d {} ${C4C_OPS_WEBHOOK_DEPLOY} -H "Content-Type:application/json" - env: - C4C_OPS_WEBHOOK_DEPLOY: ${{ secrets.C4C_OPS_WEBHOOK_DEPLOY }} - - deploy-backend: - needs: pre-deploy - if: (contains(github.event.inputs.manual-deploy, 'c4c-ops-backend') || contains(needs.pre-deploy.outputs.affected, 'scaffolding-backend')) && (github.event_name == 'push' || github.event_name == 'workflow_dispatch') && github.ref == 'refs/heads/main' - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - name: Use Node.js 16 - uses: actions/setup-node@v3 - with: - node-version: 16.x - cache: 'yarn' - - - name: Install Dependencies - run: yarn install - - - run: npx nx build c4c-ops-backend --configuration production - - name: default deploy - uses: appleboy/lambda-action@master - with: - aws_access_key_id: ${{ secrets.AWS_ACCESS_KEY_ID }} - aws_secret_access_key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} - aws_region: ${{ secrets.AWS_REGION }} - function_name: c4c-ops-monolith-lambda - source: dist/apps/c4c-ops/c4c-ops-backend/main.js +# name: Legacy CI/CD + +# # First runs linter and tests all affected projects +# # Then, for each project that requires deployment, deploy-- is added +# # Environment variables are labelled _SHORT_DESCRIPTION + +# on: +# push: +# branches: ['main'] +# pull_request: +# branches: ['main'] +# workflow_dispatch: +# inputs: +# manual-deploy: +# description: 'App to Deploy' +# required: false +# default: '' + +# concurrency: +# # Never have two deployments happening at the same time (potential race condition) +# group: '{{ github.head_ref || github.ref }}' + +# jobs: +# pre-deploy: +# runs-on: ubuntu-latest +# outputs: +# affected: ${{ steps.should-deploy.outputs.affected }} +# steps: +# - uses: actions/checkout@v3 +# with: +# # We need to fetch all branches and commits so that Nx affected has a base to compare against. +# fetch-depth: 0 +# - name: Use Node.js 20 +# uses: actions/setup-node@v3 +# with: +# node-version: 20.x +# cache: 'yarn' + +# - name: Install Dependencies +# run: yarn install + +# # In any subsequent steps within this job (myjob) we can reference the resolved SHAs +# # using either the step outputs or environment variables: +# - name: Derive appropriate SHAs for base and head for `nx affected` commands +# uses: nrwl/nx-set-shas@v3 + +# - run: | +# echo "BASE: ${{ env.NX_BASE }}" +# echo "HEAD: ${{ env.NX_HEAD }}" + +# - name: Nx Affected Lint +# run: npx nx affected -t lint + +# # - name: Nx Affected Test +# # run: npx nx affected -t test + +# - name: Nx Affected Build +# run: npx nx affected -t build + +# - name: Determine who needs to be deployed +# id: should-deploy +# run: | +# echo "The following projects have been affected: [$(npx nx print-affected -t build --select=tasks.target.project)]"; +# echo "affected=$(npx nx print-affected -t build --select=tasks.target.project)" >> "$GITHUB_OUTPUT" + +# deploy-debug: +# needs: pre-deploy +# runs-on: ubuntu-latest +# steps: +# - name: Debug logs +# run: | +# echo "Manual Deploy: ${{github.event.inputs.manual-deploy}}"; +# echo "Affected Names: ${{needs.pre-deploy.outputs.affected}}"; +# echo "Event: ${{github.event_name}}"; +# echo "Ref: ${{github.ref}}"; +# echo "Will deploy?: ${{(github.event_name == 'push' || github.event_name == 'workflow_dispatch') && github.ref == 'refs/heads/main'}}"; + +# deploy-frontend: +# needs: pre-deploy +# if: (contains(github.event.inputs.manual-deploy, 'c4c-ops-frontend') || contains(needs.pre-deploy.outputs.affected, 'scaffolding-frontend')) && (github.event_name == 'push' || github.event_name == 'workflow_dispatch') && github.ref == 'refs/heads/main' +# runs-on: ubuntu-latest +# # For "simplicity", deployment settings are configured in the AWS Amplify Console +# # This just posts to a webhook telling Amplify to redeploy the main branch +# steps: +# - name: Tell Amplify to rebuild +# run: curl -X POST -d {} ${C4C_OPS_WEBHOOK_DEPLOY} -H "Content-Type:application/json" +# env: +# C4C_OPS_WEBHOOK_DEPLOY: ${{ secrets.C4C_OPS_WEBHOOK_DEPLOY }} + +# deploy-backend: +# needs: pre-deploy +# if: (contains(github.event.inputs.manual-deploy, 'c4c-ops-backend') || contains(needs.pre-deploy.outputs.affected, 'scaffolding-backend')) && (github.event_name == 'push' || github.event_name == 'workflow_dispatch') && github.ref == 'refs/heads/main' +# runs-on: ubuntu-latest +# steps: +# - uses: actions/checkout@v3 +# - name: Use Node.js 16 +# uses: actions/setup-node@v3 +# with: +# node-version: 16.x +# cache: 'yarn' + +# - name: Install Dependencies +# run: yarn install + +# - run: npx nx build c4c-ops-backend --configuration production +# - name: default deploy +# uses: appleboy/lambda-action@master +# with: +# aws_access_key_id: ${{ secrets.AWS_ACCESS_KEY_ID }} +# aws_secret_access_key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} +# aws_region: ${{ secrets.AWS_REGION }} +# function_name: c4c-ops-monolith-lambda +# source: dist/apps/c4c-ops/c4c-ops-backend/main.js diff --git a/.github/workflows/frontend_build.yml b/.github/workflows/frontend_build.yml new file mode 100644 index 000000000..fe3d20c43 --- /dev/null +++ b/.github/workflows/frontend_build.yml @@ -0,0 +1,33 @@ +name: Frontend build + +on: + push: + branches: ['main'] + pull_request: + branches: ['main'] + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + + - name: Use NodeJS 24.x + uses: actions/setup-node@v4 + with: + node-version: 24.x + cache: 'yarn' + + - name: Create .env file + run: | + + echo "AWS_SECRET_ACCESS_KEY=dummy" >> .env + echo "AWS_ACCESS_KEY_ID=dummy" >> .env + echo "AWS_REGION=us-east-2" >> .env + + - name: Install Dependencies + run: yarn install + + - name: Build frontend + run: npx nx build frontend \ No newline at end of file diff --git a/.github/workflows/jest.yml b/.github/workflows/jest.yml new file mode 100644 index 000000000..b892c48f0 --- /dev/null +++ b/.github/workflows/jest.yml @@ -0,0 +1,35 @@ +name: Jest run + +on: + push: + branches: ['main'] + pull_request: + branches: ['main'] + +jobs: + build: + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + + - name: Use NodeJS 24.x + uses: actions/setup-node@v4 + with: + node-version: 24.x + cache: 'yarn' + + - name: Create .env file + run: | + + echo "AWS_BUCKET_NAME=dummy" >> .env + echo "AWS_SECRET_ACCESS_KEY=dummy" >> .env + echo "AWS_ACCESS_KEY_ID=dummy" >> .env + echo "AWS_REGION=us-east-2" >> .env + + - name: Install Dependencies + run: yarn install + + - name: Run Jest tests + run: yarn test diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml new file mode 100644 index 000000000..0a01be89c --- /dev/null +++ b/.github/workflows/lint.yml @@ -0,0 +1,27 @@ +name: Linter run + +on: + push: + branches: ['main'] + pull_request: + branches: ['main'] + +jobs: + build: + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + + - name: Use Node.js 24.x + uses: actions/setup-node@v4 + with: + node-version: 24.x + cache: 'yarn' + + - name: Install Dependencies + run: yarn install + + - name: Run linter + run: yarn lint \ No newline at end of file diff --git a/nx.json b/nx.json index 4dc261d4b..bb30110fe 100644 --- a/nx.json +++ b/nx.json @@ -4,8 +4,7 @@ "default": { "runner": "nx-cloud", "options": { - "cacheableOperations": ["build", "lint", "test", "e2e"], - "accessToken": "OTc0MjgyZDgtMTYzYy00OTYwLTg5NWEtNDQ5YTg2ZjJkMDU2fHJlYWQtd3JpdGU=" + "cacheableOperations": ["build", "lint", "test", "e2e"] } } }, From 144e9ed62da3e3f8ffbb95ff336b03ea33af9c8b Mon Sep 17 00:00:00 2001 From: Sam Nie <147653722+SamNie2027@users.noreply.github.com> Date: Sun, 1 Feb 2026 13:17:25 -0500 Subject: [PATCH 2/4] Changed runner --- nx.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nx.json b/nx.json index bb30110fe..9a774f42a 100644 --- a/nx.json +++ b/nx.json @@ -2,7 +2,7 @@ "$schema": "./node_modules/nx/schemas/nx-schema.json", "tasksRunnerOptions": { "default": { - "runner": "nx-cloud", + "runner": "nx/tasks-runners/default", "options": { "cacheableOperations": ["build", "lint", "test", "e2e"] } From 70101c43824320069e7f5ed694a0c82c607c0101 Mon Sep 17 00:00:00 2001 From: Sam Nie <147653722+SamNie2027@users.noreply.github.com> Date: Thu, 5 Feb 2026 11:40:30 -0500 Subject: [PATCH 3/4] Implementing feedback --- .github/workflows/ci-cd.yml | 5 +++++ .github/workflows/frontend_build.yml | 2 +- .github/workflows/jest.yml | 1 + .github/workflows/lint.yml | 2 +- 4 files changed, 8 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci-cd.yml b/.github/workflows/ci-cd.yml index cfde90458..6562108f1 100644 --- a/.github/workflows/ci-cd.yml +++ b/.github/workflows/ci-cd.yml @@ -1,3 +1,8 @@ +# Note: +# This CICD requires AWS Amplify to be setup which tends to not be the case until the app is close to being deployed +# Therefore this is not useful for a the beginning chunk of development where everything is tested locally +# Therefore other pipelines have been made to test things locally, but once AWS Amplify is setup this can be used. + # name: Legacy CI/CD # # First runs linter and tests all affected projects diff --git a/.github/workflows/frontend_build.yml b/.github/workflows/frontend_build.yml index fe3d20c43..fc7026362 100644 --- a/.github/workflows/frontend_build.yml +++ b/.github/workflows/frontend_build.yml @@ -30,4 +30,4 @@ jobs: run: yarn install - name: Build frontend - run: npx nx build frontend \ No newline at end of file + run: npx nx build frontend diff --git a/.github/workflows/jest.yml b/.github/workflows/jest.yml index b892c48f0..286e165f2 100644 --- a/.github/workflows/jest.yml +++ b/.github/workflows/jest.yml @@ -33,3 +33,4 @@ jobs: - name: Run Jest tests run: yarn test + diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 0a01be89c..442e09280 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -24,4 +24,4 @@ jobs: run: yarn install - name: Run linter - run: yarn lint \ No newline at end of file + run: npx nx affected -t lint From cb785a206090c60e539d09098a6de80723dc303a Mon Sep 17 00:00:00 2001 From: Sam Nie <147653722+SamNie2027@users.noreply.github.com> Date: Thu, 5 Feb 2026 11:41:01 -0500 Subject: [PATCH 4/4] Update lint.yml --- .github/workflows/lint.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 442e09280..ab6f2fc14 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -7,8 +7,7 @@ on: branches: ['main'] jobs: - build: - + lint: runs-on: ubuntu-latest steps: