Skip to content

Commit

Permalink
Merge branch 'master' into dependabot/npm_and_yarn/client/browserify-…
Browse files Browse the repository at this point in the history
…sign-4.2.2
  • Loading branch information
mluypaert authored Jan 18, 2024
2 parents b69f8cc + 40e50a1 commit 92a11b1
Show file tree
Hide file tree
Showing 52 changed files with 705 additions and 295 deletions.
53 changes: 53 additions & 0 deletions .github/workflows/PR-validation.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
name: PR validation
on:
pull_request:
types: [synchronize, opened, reopened, edited]
branches:
- master
jobs:
test-api:
permissions:
id-token: write # Required for authentication through OIDC to AWS
runs-on: ubuntu-22.04
steps:
- name: Report workflow details
run: |
echo "Repository ${{ github.repository }}."
echo "Trigger ref ${{ github.ref }}, base-ref ${{ github.base_ref }}, head_ref ${{ github.head_ref }}."
- name: Check out repository code
uses: actions/checkout@v3
- name: Report files updated in PR
run: |
git fetch -q origin ${{ github.base_ref }} ${{ github.head_ref }}
git diff --name-only origin/${{ github.base_ref }} origin/${{ github.head_ref }}
- name: Set up JDK 8
uses: actions/setup-java@v3
with:
java-version: '8'
distribution: 'temurin'
- name: Install clojure and clojure cli (clj)
uses: DeLaGuardo/[email protected]
with:
cli: 1.10.1.536
- name: Report runtime details
run: |
echo "Github runner OS: ${{ runner.os }}"
- name: AWS credentials configuration
uses: aws-actions/configure-aws-credentials@v2
with:
role-to-assume: ${{secrets.GH_ACTIONS_AWS_ROLE}}
role-session-name: gh-actions-${{github.run_id}}.${{github.run_number}}.${{github.run_attempt}}-test-api
aws-region: us-east-1
- name: Download and install Datomic Pro
run: |
aws s3 cp s3://wormbase/datomic-pro/distro/datomic-pro-1.0.6165.zip ./
unzip datomic-pro-1.0.6165.zip
cd datomic-pro-1.0.6165/
bin/maven-install
- name: Generate pom file
run: |
clojure -Spom
- name: Run Integration tests
run: |
make run-tests GOOGLE_APP_PROFILE=dev
#TODO: add UI and API build and container packaging test
15 changes: 9 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
ECR_REPO_NAME := wormbase/names
EB_APP_ENV_FILE := app-env.config
PROJ_NAME ?= wormbase-names
LOCAL_GOOGLE_REDIRECT_URI = "http://lvh.me:3000"
PROJ_NAME ?= wormbase-names-dev
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"
Expand All @@ -11,7 +11,7 @@ else ifeq ($(PROJ_NAME), wormbase-names-test)
GOOGLE_REDIRECT_URI ?= "https://test-names.wormbase.org"
GOOGLE_APP_PROFILE ?= "prod"
else
WB_DB_URI ?= "datomic:ddb://us-east-1/WSNames-test-14/wormbase"
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}
Expand Down Expand Up @@ -235,14 +235,17 @@ run-tests: google-oauth2-secrets \
@ export API_GOOGLE_OAUTH_CLIENT_ID=${GOOGLE_OAUTH_CLIENT_ID} && \
export API_GOOGLE_OAUTH_CLIENT_SECRET=${GOOGLE_OAUTH_CLIENT_SECRET} && \
export GOOGLE_REDIRECT_URI=${LOCAL_GOOGLE_REDIRECT_URI} && \
clj -A:datomic-pro:webassets:dev:test:run-tests
clojure -A:datomic-pro:logging:webassets:dev:test:run-tests

.PHONY: run-dev-server
run-dev-webserver: PORT := 4010
run-dev-webserver: google-oauth2-secrets \
$(call print-help,run-dev-webserver PORT=<port> WB_DB_URI=<datomic-uri> \
GOOGLE_REDIRECT_URI=<google-redirect-uri>,\
Run a local development webserver.)
@ export API_GOOGLE_OAUTH_CLIENT_ID=${GOOGLE_OAUTH_CLIENT_ID} && \
@ export WB_DB_URI=${WB_DB_URI} && export PORT=${PORT} && \
export GOOGLE_REDIRECT_URI=${GOOGLE_REDIRECT_URI} && \
export API_GOOGLE_OAUTH_CLIENT_ID=${GOOGLE_OAUTH_CLIENT_ID} && \
export API_GOOGLE_OAUTH_CLIENT_SECRET=${GOOGLE_OAUTH_CLIENT_SECRET} && \
clj -A:logging:datomic-pro:webassets:dev -m wormbase.names.service

Expand All @@ -259,7 +262,7 @@ run-dev-ui: google-oauth2-secrets\
.PHONY: google-oauth2-secrets
google-oauth2-secrets: \
$(call print-help,google-oauth2-secrets,\
Store the Google oauth2 client details in a secrets file.)
Store the Google oauth2 client details as env variables.)
$(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)
$(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))
Expand Down
31 changes: 27 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
* [REST API](#rest-api)
- [Tools](#tools)
* [Running a Clojure REPL](#running-a-clojure-repl)
* [Debug printing](#debug-printing)
* [Client app (web interface)](#client-app-web-interface)
- [Testing](#testing)
- [Release & deployment](#release--deployment)
Expand Down Expand Up @@ -152,6 +153,28 @@ This can be done via the following command:
clj -A:outdated
```

#### Debug printing
Standard logging is done using `ch.qos.logback/logback` (`-classic` and `-core`), but this is not flexible
for limited-scale (local) debug printing during coding and debugging. To enable more flexible debug printing:

1. In the file you want to enable temporary debug printing, replace the loading of the `clojure.tools.logging` library
with the `taoensso.timbre` library instead (using the same `:log` alias).

2. Add the following line below the library loading section
```clojure
(log/merge-config! {:level :debug})
```
This will enable all log printing up to debug level within that file,
but leave the application-default logging outside of it, enabling a
more focused log inspection.

3. Add any additional debug logging with the standard `(log/debug "string" object)`

`taoensso.timbre` will by default print logs to the following format:
```
<date> <timestamp> <device-name> <LOGLEVEL> [<namespace>] - <log message>
```
### Client app (web interface)
Correct functionality of the client app can be tested in two ways:
- Running a client development server (during development), to test individual functionality. See [instructions below](#local-rest).
Expand Down Expand Up @@ -276,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
make ui-build GOOGLE_APP_PROFILE=prod
# Generate the pom.xml file (not version-controlled)
# to ensure no errors occur (in API code)
Expand Down Expand Up @@ -309,12 +332,12 @@ 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>]
make release [AWS_PROFILE=<profile_name>] GOOGLE_APP_PROFILE=prod
# Deploy the application to an EB environmnent.
# Before execution:
# * Ensure to specify the correct EB environment name, in order to prevent
# accidental deployments to the production environment!
# * Ensure to specify the correct EB environment name,
# (otherwise deployment to non-existing dev environment will be attempted)
# * Check if the hard-coded WB_DB_URI default (see MakeFile) applies.
# If not, define WB_DB_URI to point to the appropriate datomic DB.
# * Ensure to define the correct GOOGLE_REDIRECT_URI for google authentication (http://lvh.me:3000 when developing locally)
Expand Down
6 changes: 3 additions & 3 deletions client/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"dependencies": {
"@material-ui/core": "3.9.2",
"@material-ui/icons": "3.0.2",
"@react-oauth/google": "^0.8.0",
"@react-oauth/google": "0.12.x",
"classnames": "2.2.6",
"copy-to-clipboard": "3.2.0",
"react-copy-to-clipboard": "5.1.0",
Expand Down
10 changes: 6 additions & 4 deletions client/src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,10 @@ import Main from './containers/Main';
import { theme, MuiThemeProvider } from './components/elements';

export default () => (
<GoogleOAuthProvider clientId={process.env.REACT_APP_GOOGLE_OAUTH_CLIENT_ID}>
<React.StrictMode>
<React.StrictMode>
<GoogleOAuthProvider
clientId={process.env.REACT_APP_GOOGLE_OAUTH_CLIENT_ID}
>
<BrowserRouter>
<Authenticate>
<EntityTypesContextProvider>
Expand All @@ -18,6 +20,6 @@ export default () => (
</EntityTypesContextProvider>
</Authenticate>
</BrowserRouter>
</React.StrictMode>
</GoogleOAuthProvider>
</GoogleOAuthProvider>
</React.StrictMode>
);
4 changes: 2 additions & 2 deletions client/src/components/elements/SpeciesSelect.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { useDataFetch } from '../../containers/Authenticate';

const SpeciesSelect = (props) => {
const memoizedFetchFunc = useCallback(
(authorizedFetch) =>
(fetchFn) =>
mockFetchOrNot(
(mockFetch) => {
return mockFetch.get('*', [
Expand All @@ -27,7 +27,7 @@ const SpeciesSelect = (props) => {
]);
},
() =>
authorizedFetch(`/api/species`, {
fetchFn(`/api/species`, {
method: 'GET',
})
),
Expand Down
2 changes: 1 addition & 1 deletion client/src/containers/Authenticate/Login.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class Login extends Component {
<div className={classes.errorMessage}>{errorMessage}</div>
</div>
) : null}
<Button onClick={onSignIn} variant="raised">
<Button onClick={onSignIn} variant="contained">
Login with Google
</Button>
</div>
Expand Down
2 changes: 1 addition & 1 deletion client/src/containers/Authenticate/Logout.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { Button } from '../../components/elements';
const Logout = (props) => {
return (
<Button
variant="raised"
variant="contained"
onClick={() => {
props.onLogout();
props.history.push('/');
Expand Down
20 changes: 3 additions & 17 deletions client/src/containers/Authenticate/Profile.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import React from 'react';
import { CopyToClipboard } from 'react-copy-to-clipboard';
import PropTypes from 'prop-types';
import { withStyles } from '../../components/elements';

Expand All @@ -10,19 +9,7 @@ const Profile = (props) => {
<span>ID: {props.id}</span>
<br />
<span>Email: {props.email}</span>
<span>
ID-token:{' '}
<div>
<textarea>{props.id_token}</textarea>
<br />
<CopyToClipboard text={props.id_token}>
<div>
<button>Copy to clipboard</button>
</div>
</CopyToClipboard>
</div>
</span>
<div className={props.classes.logout}>{props.children}</div>
<div className={props.classes.actions}>{props.children}</div>
</div>
);
};
Expand All @@ -32,7 +19,6 @@ Profile.propTypes = {
name: PropTypes.string.isRequired,
email: PropTypes.string.isRequired,
id: PropTypes.string.isRequired,
onLogout: PropTypes.func.isRequired,
children: PropTypes.element,
};

Expand All @@ -44,8 +30,8 @@ const styles = (theme) => ({
justifyContent: 'center',
alignItems: 'center',
},
logout: {
margin: theme.spacing.unit * 6,
actions: {
margin: theme.spacing.unit * 4,
},
});

Expand Down
Loading

0 comments on commit 92a11b1

Please sign in to comment.