Skip to content

Commit

Permalink
Merge pull request #110 from COS301-SE-2023/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
ryanbasiltrickett authored Jun 27, 2023
2 parents d9f7e9f + 8ac86f5 commit 3e8a7f1
Show file tree
Hide file tree
Showing 298 changed files with 7,771 additions and 1,165 deletions.
54 changes: 54 additions & 0 deletions .github/workflows/cd-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,3 +44,57 @@ jobs:

- name: Deploy App
run: aws s3 sync ./dist/apps/app s3://dev-fridgetoplate

deploy_api:

name: API Deployment
needs: ci-workflow
runs-on: windows-latest
environment: Development

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

- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: af-south-1

- name: Setup NodeJS and Cache
uses: actions/setup-node@v3
with:
node-version: 16
cache: 'npm'

- name: Setup JDK 17 and Cache
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'temurin'

- name: Setup NX
run: npm install nx@latest

- name: Setup Enviroment Files
run: |
printf "${{ secrets.API_APPLICATION_PROPERTIES }}" > apps/api/src/main/resources/application.properties
cat apps/api/src/main/resources/application.properties
shell: bash

- name: Build API
run: npm run build:api

- name: Create ZIP Package
run: Compress-Archive -Path ./apps/api/build/libs/* -DestinationPath ./deploy_package.zip

- name: Upload API Package
run: aws s3 cp deploy_package.zip s3://fridgetoplate-api-deploy-bucket

- name: Create New API Version
run: aws elasticbeanstalk create-application-version --application-name fridgetoplate --source-bundle S3Bucket="fridgetoplate-api-deploy-bucket",S3Key="deploy_package.zip" --version-label "dev-${{ github.sha }}" --description "commit-sha-${{ github.sha }}"

- name: Deploy API
run: aws elasticbeanstalk update-environment --environment-name dev-fridgetoplate-env --version-label "dev-${{ github.sha }}"
54 changes: 54 additions & 0 deletions .github/workflows/cd-prod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,57 @@ jobs:
- name: Deploy App
if: success()
run: aws s3 sync ./dist/apps/app s3://fridgetoplate

deploy_api:

name: API Deployment
needs: ci-workflow
runs-on: windows-latest
environment: Production

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

- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: af-south-1

- name: Setup NodeJS and Cache
uses: actions/setup-node@v3
with:
node-version: 16
cache: 'npm'

- name: Setup JDK 17 and Cache
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'temurin'

- name: Setup NX
run: npm install nx@latest

- name: Setup Enviroment Files
run: |
printf "${{ secrets.API_APPLICATION_PROPERTIES }}" > apps/api/src/main/resources/application.properties
cat apps/api/src/main/resources/application.properties
shell: bash

- name: Build API
run: npm run build:api

- name: Create ZIP Package
run: Compress-Archive -Path ./apps/api/build/libs/* -DestinationPath ./deploy_package.zip

- name: Upload API Package
run: aws s3 cp deploy_package.zip s3://fridgetoplate-api-deploy-bucket

- name: Create New API Version
run: aws elasticbeanstalk create-application-version --application-name fridgetoplate --source-bundle S3Bucket="fridgetoplate-api-deploy-bucket",S3Key="deploy_package.zip" --version-label "prod-${{ github.sha }}" --description "commit-sha-${{ github.sha }}"

- name: Deploy API
run: aws elasticbeanstalk update-environment --environment-name prod-fridgetoplate-env --version-label "prod-${{ github.sha }}"
67 changes: 20 additions & 47 deletions .github/workflows/ci-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,14 @@ on:
pull_request:
branches: [ dev, feat/* ]
workflow_call:
secrets:
SONAR_TOKEN_API:
required: true

permissions:
contents: read

jobs:
test_build_api:
test_build_workspace:

name: Lint, Test & Build API
name: Lint, Test & Build Wokspace
runs-on: windows-latest
environment: Development

Expand All @@ -36,54 +33,30 @@ jobs:
java-version: '17'
distribution: 'temurin'

- name: Setup NX
run: npm install nx@latest

- name: Test API
run: npm run test:api

- name: Build API
run: npm run build:api

- name: SonarCloud Build and Analyze
working-directory: apps/api/
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN_API }}
run: ./gradlew build sonarqube --info

test_build_app:

name: Lint, Test & Build App
runs-on: ubuntu-latest
environment: Development

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

- name: Setup NodeJS and Cache
uses: actions/setup-node@v3
with:
node-version: 16
cache: 'npm'

- name: Install Dependencies
run: npm install

- name: Setup Enviroment Files
run: |
printf "${{ secrets.API_APPLICATION_PROPERTIES }}" > apps/api/src/main/resources/application.properties
cat apps/api/src/main/resources/application.properties
shell: bash

- name: Lint App
run: npx nx run app:lint

- name: Test App
run: npm run test:app
- name: Test Workspace
run: npm run test:app:ci

- name: Upload Coverage Report
uses: codecov/codecov-action@v3
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
with:
files: coverage/lcov.info

- name: Build App
run: npm run build:app:dev

- name: SonarCloud Scan
uses: SonarSource/sonarcloud-github-action@master
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN_APP }}
with:
projectBaseDir: apps/app/

- name: Build API
run: npm run build:api
71 changes: 22 additions & 49 deletions .github/workflows/ci-prod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,84 +4,57 @@ on:
pull_request:
branches: [ main ]
workflow_call:
secrets:
SONAR_TOKEN_API:
required: true

permissions:
contents: read

jobs:
test_build_api:
test_build_workspace:

name: Lint, Test & Build API
name: Lint, Test & Build Wokspace
runs-on: windows-latest
environment: Production

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

- name: Setup NodeJS and Cache
uses: actions/setup-node@v3
with:
node-version: 16
cache: 'npm'
- name: Setup JDK 17

- name: Setup JDK 17 and Cache
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'temurin'

- name: Setup NX
run: npm install nx@latest

- name: Test API
run: npm run test:api

- name: Build API
run: npm run build:api

- name: SonarCloud Build and Analyze
working-directory: apps/api/
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN_API }}
run: ./gradlew build sonarqube --info

test_build_app:

name: Lint, Test & Build App
runs-on: ubuntu-latest
environment: Production

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

- name: Setup NodeJS and Cache
uses: actions/setup-node@v3
with:
node-version: 16
cache: 'npm'

- name: Install Dependencies
run: npm install

- name: Setup Enviroment Files
run: |
printf "${{ secrets.API_APPLICATION_PROPERTIES }}" > apps/api/src/main/resources/application.properties
cat apps/api/src/main/resources/application.properties
shell: bash

- name: Lint App
run: npx nx run app:lint

- name: Test App
- name: Test Workspace
run: npm run test:app:ci

- name: Upload Coverage Report
uses: codecov/codecov-action@v3
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
with:
files: coverage/lcov.info

- name: Build App
run: npm run build:app:prod

- name: SonarCloud Scan
uses: SonarSource/sonarcloud-github-action@master
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN_APP }}
with:
projectBaseDir: apps/app/

- name: Build API
run: npm run build:api
8 changes: 7 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# See http://help.github.com/ignore-files/ for more about ignoring files.

# npm run start:app:dev

# compiled output
dist
tmp
Expand Down Expand Up @@ -40,4 +42,8 @@ testem.log
Thumbs.db

#Application Folders
.angular
.angular

#Enviroment Files
.env
.prod.env
17 changes: 8 additions & 9 deletions apps/api/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,6 @@ plugins {
id 'java'
id 'org.springframework.boot' version '3.0.6'
id 'io.spring.dependency-management' version '1.1.0'
id "org.sonarqube" version "3.5.0.2730"
}

sonarqube {
properties {
property "sonar.projectKey", "COS301-SE-2023_FridgeToPlate-API"
property "sonar.organization", "cos301-se-2023"
property "sonar.host.url", "https://sonarcloud.io"
}
}

group = 'com.fridgetoplate'
Expand All @@ -24,8 +15,16 @@ repositories {
dependencies {
implementation 'org.springframework.boot:spring-boot-starter-web'
testImplementation 'org.springframework.boot:spring-boot-starter-test'
implementation 'com.amazonaws:aws-java-sdk-dynamodb:1.11.857'
implementation 'org.projectlombok:lombok:1.18.20'
annotationProcessor 'org.projectlombok:lombok:1.18.20'
implementation 'org.springframework.boot:spring-boot-starter-graphql'
}

tasks.named('test') {
useJUnitPlatform()
}

jar {
enabled = false
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.ComponentScan;

@SpringBootApplication
@ComponentScan("com.fridgetoplate")
public class ApiApplication {

public static void main(String[] args) {
Expand Down
13 changes: 0 additions & 13 deletions apps/api/src/main/java/com/fridgetoplate/api/HelloController.java

This file was deleted.

Loading

0 comments on commit 3e8a7f1

Please sign in to comment.