Skip to content

Commit

Permalink
Enabled building ui without nvm usage (for CI/docker context)
Browse files Browse the repository at this point in the history
  • Loading branch information
mluypaert committed Jan 25, 2024
1 parent f241ca0 commit 4ea0c50
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 20 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/PR-validation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,5 +50,5 @@ jobs:
clojure -Spom
- name: Run Integration tests
run: |
make run-tests GOOGLE_APP_PROFILE=dev
make run-tests APP_PROFILE=dev
#TODO: add UI and API build and container packaging test
22 changes: 11 additions & 11 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,17 @@ LOCAL_GOOGLE_REDIRECT_URI := "http://lvh.me:3000"
ifeq ($(PROJ_NAME), wormbase-names)
WB_DB_URI ?= "datomic:ddb://us-east-1/WSNames/wormbase"
GOOGLE_REDIRECT_URI ?= "https://names.wormbase.org"
GOOGLE_APP_PROFILE ?= "prod"
APP_PROFILE ?= "prod"
else ifeq ($(PROJ_NAME), wormbase-names-test)
WB_DB_URI ?= "datomic:ddb://us-east-1/WSNames-test-14/wormbase"
GOOGLE_REDIRECT_URI ?= "https://test-names.wormbase.org"
GOOGLE_APP_PROFILE ?= "prod"
APP_PROFILE ?= "prod"
else
WB_DB_URI ?= "datomic:ddb-local://localhost:8000/WBNames_local/wormbase"
# Ensure GOOGLE_REDIRECT_URI is defined appropriately as an env variable or CLI argument
# if intended for AWS deployment (default is set for local execution)
GOOGLE_REDIRECT_URI ?= ${LOCAL_GOOGLE_REDIRECT_URI}
GOOGLE_APP_PROFILE ?= "dev"
APP_PROFILE ?= "dev"
endif

STORE_SECRETS_FILE = secrets.makedef
Expand Down Expand Up @@ -102,8 +102,8 @@ ui-build: ENV.GOOGLE_OAUTH_CLIENT_ID \
$(call print-help,ui-build,\
Build JS and CSS file for release.)
@ export REACT_APP_GOOGLE_OAUTH_CLIENT_ID=${GOOGLE_OAUTH_CLIENT_ID} && \
echo "Building UI using GOOGLE_APP_PROFILE: '${GOOGLE_APP_PROFILE}'" && \
./scripts/build-ui.sh
echo "Building UI using APP_PROFILE: '${APP_PROFILE}'" && \
./scripts/build-ui.sh ${APP_PROFILE}

.PHONY: clean
clean: \
Expand Down Expand Up @@ -284,20 +284,20 @@ run-dev-ui: google-oauth2-secrets\
ENV.GOOGLE_OAUTH_CLIENT_ID: source-secrets \
$(call print-help,ENV.GOOGLE_OAUTH_CLIENT_ID,\
Retrieve the GOOGLE_OAUTH_CLIENT_ID env variable for make targets from aws ssm if undefined.)
$(eval ACTION_MSG := $(if ${GOOGLE_OAUTH_CLIENT_ID},"Using predefined GOOGLE_OAUTH_CLIENT_ID.","Retrieving GOOGLE_OAUTH_CLIENT_ID from AWS SSM (GOOGLE_APP_PROFILE '${GOOGLE_APP_PROFILE}')."))
$(eval ACTION_MSG := $(if ${GOOGLE_OAUTH_CLIENT_ID},"Using predefined GOOGLE_OAUTH_CLIENT_ID.","Retrieving GOOGLE_OAUTH_CLIENT_ID from AWS SSM (APP_PROFILE '${APP_PROFILE}')."))
@echo ${ACTION_MSG}
$(if ${GOOGLE_OAUTH_CLIENT_ID},,$(eval GOOGLE_OAUTH_CLIENT_ID := $(shell aws ssm get-parameter --name "/name-service/${GOOGLE_APP_PROFILE}/google-oauth2-app-config/client-id" --query "Parameter.Value" --output text --with-decryption)))
$(call check_defined, GOOGLE_OAUTH_CLIENT_ID, Check the defined GOOGLE_APP_PROFILE value\
$(if ${GOOGLE_OAUTH_CLIENT_ID},,$(eval GOOGLE_OAUTH_CLIENT_ID := $(shell aws ssm get-parameter --name "/name-service/${APP_PROFILE}/google-oauth2-app-config/client-id" --query "Parameter.Value" --output text --with-decryption)))
$(call check_defined, GOOGLE_OAUTH_CLIENT_ID, Check the defined APP_PROFILE value\
and ensure the AWS_PROFILE variable is appropriately defined)

.PHONY: ENV.GOOGLE_OAUTH_CLIENT_SECRET
ENV.GOOGLE_OAUTH_CLIENT_SECRET: source-secrets \
$(call print-help,ENV.GOOGLE_OAUTH_CLIENT_SECRET,\
Retrieve the GOOGLE_OAUTH_CLIENT_SECRET env variable for make targets from aws ssm if undefined.)
$(eval ACTION_MSG := $(if ${GOOGLE_OAUTH_CLIENT_SECRET},"Using predefined GOOGLE_OAUTH_CLIENT_SECRET.","Retrieving GOOGLE_OAUTH_CLIENT_SECRET from AWS SSM (GOOGLE_APP_PROFILE '${GOOGLE_APP_PROFILE}')."))
$(eval ACTION_MSG := $(if ${GOOGLE_OAUTH_CLIENT_SECRET},"Using predefined GOOGLE_OAUTH_CLIENT_SECRET.","Retrieving GOOGLE_OAUTH_CLIENT_SECRET from AWS SSM (APP_PROFILE '${APP_PROFILE}')."))
@echo ${ACTION_MSG}
$(if ${GOOGLE_OAUTH_CLIENT_SECRET},,$(eval GOOGLE_OAUTH_CLIENT_SECRET := $(shell aws ssm get-parameter --name "/name-service/${GOOGLE_APP_PROFILE}/google-oauth2-app-config/client-secret" --query "Parameter.Value" --output text --with-decryption)))
$(call check_defined, GOOGLE_OAUTH_CLIENT_SECRET, Check the defined GOOGLE_APP_PROFILE value\
$(if ${GOOGLE_OAUTH_CLIENT_SECRET},,$(eval GOOGLE_OAUTH_CLIENT_SECRET := $(shell aws ssm get-parameter --name "/name-service/${APP_PROFILE}/google-oauth2-app-config/client-secret" --query "Parameter.Value" --output text --with-decryption)))
$(call check_defined, GOOGLE_OAUTH_CLIENT_SECRET, Check the defined APP_PROFILE value\
and ensure the AWS_PROFILE variable is appropriately defined)

.PHONY: google-oauth2-secrets
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@ To deploy an update for the main application, change your working dir
to the repository root dir and execute the following commands (bash):
```bash
# Build the client application to ensure no errors occur.
make ui-build GOOGLE_APP_PROFILE=prod
make ui-build APP_PROFILE=prod
# Generate the pom.xml file (not version-controlled)
# to ensure no errors occur (in API code)
Expand Down Expand Up @@ -332,7 +332,7 @@ sudo service docker start
# NOTE: To deploy a tagged or branched codeversion that does not equal your (potentially dirty) working-dir content,
# use the additional argument REF_NAME=<ref-name>
# E.g. make release AWS_PROFILE=wormbase REF_NAME=wormbase-names-1.4.7
make release [AWS_PROFILE=<profile_name>] GOOGLE_APP_PROFILE=prod
make release [AWS_PROFILE=<profile_name>] APP_PROFILE=prod
# Deploy the application to an EB environmnent.
# Before execution:
Expand Down
19 changes: 13 additions & 6 deletions scripts/build-ui.sh
Original file line number Diff line number Diff line change
@@ -1,9 +1,16 @@
#!/bin/bash
APP_PROFILE=$1

export NVM_DIR="$HOME/.nvm"

[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion
cd client/
nvm exec npm ci
nvm exec npm run build

if [ "${APP_PROFILE}" == "dev" ]; then
echo "Activating nvm"
export NVM_DIR="$HOME/.nvm"

[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion
nvm use
fi

npm ci
npm run build

0 comments on commit 4ea0c50

Please sign in to comment.