Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
75 commits
Select commit Hold shift + click to select a range
1f8918a
GitHub Classroom Feedback
github-classroom[bot] Sep 15, 2024
d5a3042
Setting up GitHub Classroom Feedback
github-classroom[bot] Sep 15, 2024
9da1c67
add deadline
github-classroom[bot] Sep 15, 2024
e6d918d
Docs(README): Add group number
Yongbeom-Kim Sep 19, 2024
b2538b6
feat(Devops): Set up Terraform backend on Google Cloud Storage Bucket
Yongbeom-Kim Sep 19, 2024
ab8239e
docs: Update README
Yongbeom-Kim Sep 19, 2024
afbc4db
feat: Clean up Makefile
Yongbeom-Kim Sep 19, 2024
a315e11
feat(frontend): Template with yarn create vite
Yongbeom-Kim Sep 19, 2024
8e1675b
feat(frontent): Deploy to cloud script
Yongbeom-Kim Sep 20, 2024
fc2c383
docs: Update .env file with comments
Yongbeom-Kim Sep 20, 2024
d05910c
feat(backend): Skeleton TypeScript server with Docker image
Yongbeom-Kim Sep 20, 2024
ff33f48
feat: Terraform configs + Deployment for backend
Yongbeom-Kim Sep 20, 2024
4fd1259
feat: Integrate frontend with backend
Yongbeom-Kim Sep 20, 2024
4a19fe3
feat: Basic GitHub Actions
Yongbeom-Kim Sep 20, 2024
0e80b60
fix: Fix GCloud script
Yongbeom-Kim Sep 20, 2024
7dddf9c
feat: Fix GH Actions on push
Yongbeom-Kim Sep 20, 2024
dd1e4ad
feat: Fix GH Actions
Yongbeom-Kim Sep 20, 2024
117db9a
feat: Use container actions to cache dependencies
Yongbeom-Kim Sep 20, 2024
90a2da3
feat: Namespace frontend bucket by workspace
Yongbeom-Kim Sep 20, 2024
2565bad
feat: Add github actions for on change, pr, cleanup
Yongbeom-Kim Sep 21, 2024
25ae4b0
feat: Add API Urls on PRs
Yongbeom-Kim Sep 21, 2024
0858d6f
test
Yongbeom-Kim Sep 21, 2024
a147891
test
Yongbeom-Kim Sep 21, 2024
dbb3917
feat: make urls from base directlry to get all service URLs
Yongbeom-Kim Sep 21, 2024
e109b16
Merge pull request #2 from CS3219-AY2425S1/feat/setup
Yongbeom-Kim Sep 21, 2024
cc75956
feat: Add API Urls on PRs
Yongbeom-Kim Sep 21, 2024
3d0e20b
feat: make urls from base directlry to get all service URLs
Yongbeom-Kim Sep 21, 2024
62ab071
fix: Makefile destroy scripts
Yongbeom-Kim Sep 21, 2024
f70ac4c
Merge branch 'dev' into feat/setup
Yongbeom-Kim Sep 21, 2024
c03ca6c
Merge pull request #3 from CS3219-AY2425S1/feat/setup
Yongbeom-Kim Sep 21, 2024
62c6a6f
fix: Fix cleanup branch bug
Yongbeom-Kim Sep 21, 2024
8ded4d9
Merge pull request #4 from CS3219-AY2425S1/feat/setup
Yongbeom-Kim Sep 21, 2024
349f69a
fix: Fix ref reference in cleanup_branch.yml
Yongbeom-Kim Sep 21, 2024
fb6a421
feat(GH Actions): Add concurrency control
Yongbeom-Kim Sep 21, 2024
a3d8886
Merge pull request #5 from CS3219-AY2425S1/feat/setup
Yongbeom-Kim Sep 21, 2024
a57755b
fix(GH Actions): Fix concurrency group key
Yongbeom-Kim Sep 21, 2024
b399dae
fix(scripts): Fix frontend infra_destroy scripts
Yongbeom-Kim Sep 21, 2024
b4a158d
Merge pull request #6 from CS3219-AY2425S1/feat/setup
Yongbeom-Kim Sep 21, 2024
a48aa07
fix: Fix bugs in cleanup script
Yongbeom-Kim Sep 21, 2024
0bb57e8
Merge pull request #7 from CS3219-AY2425S1/feat/setup
Yongbeom-Kim Sep 21, 2024
ae11a99
test
Yongbeom-Kim Sep 21, 2024
9185244
Merge pull request #8 from CS3219-AY2425S1/feat/setup
Yongbeom-Kim Sep 21, 2024
16f2aa4
test
Yongbeom-Kim Sep 21, 2024
4acae1d
Merge pull request #9 from CS3219-AY2425S1/feat/setup
Yongbeom-Kim Sep 21, 2024
d2d8c48
fix: Fix ref
Yongbeom-Kim Sep 21, 2024
eb52928
fix: Fix cleanup branch script
Yongbeom-Kim Sep 21, 2024
73853b1
fix: Fix Branch cleanup action
Yongbeom-Kim Sep 21, 2024
3042a3b
fix:
Yongbeom-Kim Sep 21, 2024
94d6a34
feat: Delete attempt at clean up merged branch
Yongbeom-Kim Sep 21, 2024
d6ab1ee
Merge pull request #10 from CS3219-AY2425S1/feat/setup
Yongbeom-Kim Sep 21, 2024
2a05f23
feat: Make local for local deployment
Yongbeom-Kim Sep 23, 2024
fe240fc
feat: Remove tag immutability
Yongbeom-Kim Sep 23, 2024
7772ef2
docs: Deployment documentation
Yongbeom-Kim Sep 23, 2024
505f8fe
feat: Change . source to . ./source
Yongbeom-Kim Sep 23, 2024
9bb20f2
feat: Add bhanuka to sops secrets
Yongbeom-Kim Sep 23, 2024
e9c470c
refactor(scripts): Move make gcloud_auth into source.sh
Yongbeom-Kim Sep 25, 2024
483c72c
refactor: Refactor all scripts for consistency
Yongbeom-Kim Sep 25, 2024
f862e9e
feat: Update GH Actions
Yongbeom-Kim Sep 25, 2024
985dfe9
add question management and question api
bhnuka Sep 27, 2024
c29d332
update tab header
bhnuka Sep 27, 2024
028e6a8
refactored to follow mvc
bhnuka Sep 27, 2024
cfa1f06
more unit test for views code
bhnuka Sep 27, 2024
97441e6
more unit tests and api error handling
bhnuka Sep 27, 2024
eca9c26
more unit/integration tests for controllers and models
bhnuka Sep 27, 2024
c95a0de
more unit/integration tests for controllers and models and removed un…
bhnuka Sep 27, 2024
40fde51
removed redundant file
bhnuka Sep 27, 2024
7bd7a08
add error handling
bhnuka Sep 27, 2024
b6ac2d5
update tests for error handing and add api test
bhnuka Sep 27, 2024
1e1bbd3
change qa name back to original name
bhnuka Sep 27, 2024
7b3d2ad
delete package.json and package-lock.json and updated tests (39/44 pass)
bhnuka Sep 28, 2024
b078b4c
fixed tests all pass
bhnuka Sep 28, 2024
68ae5de
Update UI components and add CSS styling
sp4ce-cowboy Sep 29, 2024
a2ee998
Add some CSS and table changes
sp4ce-cowboy Sep 29, 2024
920043d
Remove redundant styles css file
sp4ce-cowboy Sep 29, 2024
c0244b4
Change API_URL to port 8080
sp4ce-cowboy Sep 29, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions .env
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
## Shared Environment Variables for the project
GOOGLE_APPLICATION_CREDENTIALS=./secrets/gcp_credentials.json
GCLOUD_PROJECT=cs3219-ay2425s1-project-g10
GCLOUD_REGION=us-central1
GCLOUD_ZONE=us-central1-c
GCLOUD_REPOSITORY_ID=cs3219-ay2425s1-project-g10

# Terraform backend variables
TF_BACKEND_BUCKET_NAME=${GCLOUD_PROJECT}-tfstate

Empty file added .github/.keep
Empty file.
17 changes: 17 additions & 0 deletions .github/actions/container_setup/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name: Setup Action
description: Set up environment, authenticate, and configure git for workflows under the kimyongbeom/peerprep-actions-runner container.

runs:
using: composite
steps:
- name: Configure Git
shell: bash
run: |
git config --global --add safe.directory "$PWD"

- name: Decrypt Secret Files
shell: bash
run: |
mkdir -p ${XDG_CONFIG_HOME:-$HOME/.config}/sops/age
echo $AGE_SECRET_KEY > ${XDG_CONFIG_HOME:-$HOME/.config}/sops/age/keys.txt
/bin/bash ./scripts/secret.sh decrypt
53 changes: 53 additions & 0 deletions .github/workflows/cleanup_branch.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# This is a basic workflow to help you get started with Actions

name: Branch Cleanup

# Controls when the workflow will run
on:
# On push @ branch
pull_request:
types: [closed]

# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
cleanup_infra:
# Run only if PR is merged
if: github.event.pull_request.merged == true
# The type of runner that the job will run on
runs-on: ubuntu-latest

container:
image: kimyongbeom/peerprep-actions-runner:latest
env:
AGE_SECRET_KEY: ${{ secrets.AGE_SECRET_KEY }}
volumes:
- /var/run/docker.sock:/var/run/docker.sock
options: --privileged

concurrency:
# current branch
group: ${{ github.event.pull_request.head.ref }}

permissions: write-all

# Steps represent a sequence of tasks that will be executed as part of the job
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.ref }}
- uses: ./.github/actions/container_setup

- name: Destroy Global Infrastructure
shell: bash
run: cd docker_registry && make destroy

- name: Destroy Backend
shell: bash
run: cd backend && make destroy

- name: Destroy Frontend
shell: bash
run: . $NVM_DIR/nvm.sh && cd frontend && make destroy
37 changes: 37 additions & 0 deletions .github/workflows/on_pr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# This is a basic workflow to help you get started with Actions

name: Checks on PRs

# Controls when the workflow will run
on:
# Triggers the workflow on push or pull request events but only for the "main" branch
pull_request:

# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
# This workflow contains a single job called "build"
test:
# The type of runner that the job will run on
runs-on: ubuntu-latest
container:
image: kimyongbeom/peerprep-actions-runner:latest
env:
AGE_SECRET_KEY: ${{ secrets.AGE_SECRET_KEY }}
volumes:
- /var/run/docker.sock:/var/run/docker.sock
options: --privileged
concurrency:
# current branch
group: ${{ github.head_ref }}

# Steps represent a sequence of tasks that will be executed as part of the job
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/container_setup

# Runs a single command using the runners shell
- name: Run a one-line script
run: echo Hello, world!
64 changes: 64 additions & 0 deletions .github/workflows/on_push.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
# This is a basic workflow to help you get started with Actions

name: Actions on Push

# Controls when the workflow will run
on:
# On push @ branch
push:
# When branch is created
create:

# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
# This workflow contains a single job called "build"
deploy:
# The type of runner that the job will run on
runs-on: ubuntu-latest
container:
image: kimyongbeom/peerprep-actions-runner:latest
env:
AGE_SECRET_KEY: ${{ secrets.AGE_SECRET_KEY }}
volumes:
- /var/run/docker.sock:/var/run/docker.sock
options: --privileged
concurrency:
# current branch
group: ${{ github.ref_name }}


# Steps represent a sequence of tasks that will be executed as part of the job
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/container_setup

- name: Find Changed Files
uses: dorny/paths-filter@v3
id: changes
with:
filters: |
global_infra:
- 'tf/**'
frontend:
- 'frontend/**'
backend:
- 'backend/**'

- name: Deploy Global Infrastructure
shell: bash
if: ${{ github.event_name }} == 'create' || ${{ steps.changes.outputs.global_infra }} == 'true'
run: cd docker_registry && make deploy

- name: Deploy Backend
if: ${{ github.event_name }} == 'create' || ${{ steps.changes.outputs.backend }} == 'true'
shell: bash
run: cd backend && make deploy

- name: Deploy Frontend
if: ${{ github.event_name }} == 'create' || ${{ steps.changes.outputs.frontend }} == 'true'
shell: bash
run: . $NVM_DIR/nvm.sh && cd frontend && make deploy

53 changes: 53 additions & 0 deletions .github/workflows/pr_setup.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# This is a basic workflow to help you get started with Actions

name: Setup Actions on new Pull Request

# Controls when the workflow will run
on:
# Triggers the workflow on push or pull request events but only for the "main" branch
pull_request:
types: [opened, synchronize]

# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
# This workflow contains a single job called "build"
test:
# The type of runner that the job will run on
runs-on: ubuntu-latest
container:
image: kimyongbeom/peerprep-actions-runner:latest
env:
AGE_SECRET_KEY: ${{ secrets.AGE_SECRET_KEY }}
volumes:
- /var/run/docker.sock:/var/run/docker.sock
options: --privileged
concurrency:
# current branch
group: ${{ github.head_ref }}

permissions:
contents: read
pull-requests: write

# Steps represent a sequence of tasks that will be executed as part of the job
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/container_setup
- name: Get all deployment URLs
id: urls
run: |
echo frontend=$(cd frontend && make url) >> $GITHUB_OUTPUT
echo backend=$(cd backend && make url) >> $GITHUB_OUTPUT


- name: Add a comment to the pull request
uses: peter-evans/create-or-update-comment@v3
with:
token: ${{ secrets.GITHUB_TOKEN }}
issue-number: ${{ github.event.pull_request.number }}
body: |
Frontend URL: ${{ steps.urls.outputs.frontend }}
Backend URL: ${{ steps.urls.outputs.backend }}
44 changes: 44 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
/google-cloud-sdk/
/secrets/*
# Encrypted secrets
!*.enc

# https://github.com/github/gitignore/blob/main/Terraform.gitignore
# Local .terraform directories
**/.terraform/*

# .tfstate files
*.tfstate
*.tfstate.*

# Crash log files
crash.log
crash.*.log

# Exclude all .tfvars files, which are likely to contain sensitive data, such as
# password, private keys, and other secrets. These should not be part of version
# control as they are data points which are potentially sensitive and subject
# to change depending on the environment.
*.tfvars
*.tfvars.json

# Ignore override files as they are usually used to override resources locally and so
# are not checked in
override.tf
override.tf.json
*_override.tf
*_override.tf.json

# Ignore transient lock info files created by terraform apply
.terraform.tfstate.lock.info

# Include override files you do wish to add to version control using negated pattern
# !example_override.tf

# Include tfplan files to ignore the plan output of command: terraform plan -out=tfplan
# example: *tfplan*

# Ignore CLI configuration files
.terraformrc
terraform.rc
node_modules
11 changes: 11 additions & 0 deletions .sops.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
## KEYS:
# Yongbeom: age1c0fqjnprp4pzk8kx5y23mlkreu5z34v3tkrrwrcmf56cmu3zaf0q30sqfv
# Bhanuka: age1kdym6a2z8trwn3efwj4kw2eypsh2pucl4vk3faqmqglhgx4ek47s3mt3kk
# GH Actions Runner: age1g2yz8vzyyzmdsht3398da6nu3pgl54rkw5wuveqh5wfn23r2hy0qu6d4dw

creation_rules:
# Note: must be comma separated
- age: >-
age1c0fqjnprp4pzk8kx5y23mlkreu5z34v3tkrrwrcmf56cmu3zaf0q30sqfv,
age1g2yz8vzyyzmdsht3398da6nu3pgl54rkw5wuveqh5wfn23r2hy0qu6d4dw,
age1kdym6a2z8trwn3efwj4kw2eypsh2pucl4vk3faqmqglhgx4ek47s3mt3kk
50 changes: 50 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
SHELL := /bin/bash
MAKEFLAGS += --no-print-directory

.PHONY: help deploy_tf_backend destroy_tf_backend



help: ## Display this help text
@awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\n make \033[36m\033[0m\n"} /^[$$()% 0-9a-zA-Z_-]+:.*?##/ { printf " \033[36m%-15s\033[0m %s\n", $$1, $$2 } /^##@/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 5) } ' $(MAKEFILE_LIST)


urls: ## Get the URL endpoints of all deployed resources.
@echo "FRONTEND_URL: $$(cd frontend && $(MAKE) url)"
@echo "BACKEND_URL: $$(cd backend && $(MAKE) url)"

encrypt: ## Encrypt the secrets file
./scripts/secret.sh encrypt

decrypt: ## Decrypt the secrets file
./scripts/secret.sh decrypt


## Repo-wide
deploy: ## Deploy all infrastructure and code
$(MAKE) -C docker_registry deploy
$(MAKE) -C backend deploy
$(MAKE) -C frontend deploy

# Recommended to destroy services in the reverse order of deployment.
destroy: ## Destroy all infrastructure and code
$(MAKE) -C frontend destroy
$(MAKE) -C backend destroy
$(MAKE) -C docker_registry destroy

##
## Terraform backend
##

deploy_tf_backend: ## Deploy the OpenTofu/Terraform backend to GCP
. ./source.sh && \
unset TF_WORKSPACE && \
cd tf_backend && \
tofu init && \
tofu apply -auto-approve

destroy_tf_backend: ## Destroy the OpenTofu/Terraform backend on GCP
. ./source.sh && \
unset TF_WORKSPACE && \
cd tf_backend && \
tofu destroy -auto-approve
Loading