Skip to content

Commit

Permalink
Merge branch 'main' into htmx-refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
shapiromatron authored Jun 13, 2024
2 parents 52212ce + 584e95c commit ccb2a23
Show file tree
Hide file tree
Showing 42 changed files with 471 additions and 2,951 deletions.
70 changes: 26 additions & 44 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:

services:
postgres:
image: postgres:12-alpine
image: postgres:16-alpine
env:
POSTGRES_USER: hawc
POSTGRES_PASSWORD: password
Expand All @@ -30,23 +30,18 @@ jobs:
- 6379:6379

steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v3
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: '3.12'
architecture: 'x64'
- name: try to restore pip cache
uses: actions/cache@v3
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('requirements/*.txt') }}
restore-keys: |
${{ runner.os }}-pip-
cache: 'pip'
- name: install
run: |
mv tests/data/ci-webpack-stats.json hawc/webpack-stats.json
pip install -U pip wheel
pip install -r requirements/dev.txt
python -m pip install -U pip wheel
python -m pip install -e ".[dev,docs]"
python -m pip install -e client
- name: lint-py
run: |
make lint-py
Expand Down Expand Up @@ -90,40 +85,32 @@ jobs:
name: frontend
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: '18.x'
- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "::set-output name=dir::$(yarn cache dir)"
- name: try to restore yarn cache
uses: actions/cache@v3
id: yarn-cache
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('frontend/package.json') }}
restore-keys: |
${{ runner.os }}-yarn-
node-version: 20
cache: 'yarn'
cache-dependency-path: 'frontend/yarn.lock'
- name: install
run: |
yarn --cwd ./frontend install
yarn --cwd ./frontend install --frozen-lockfile
- name: lint
run: |
make lint-js
yarn --cwd ./frontend run lint
- name: test
run: |
npm --prefix ./frontend run test
yarn --cwd ./frontend run test
- name: build for integration tests
run: |
npm --prefix ./frontend run build
yarn --cwd ./frontend run build
- name: Upload webpack build
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: webpack-build
path: |
hawc/webpack-stats.json
hawc/static/bundles/
retention-days: 1

integration:
name: integration
Expand All @@ -132,7 +119,7 @@ jobs:

services:
postgres:
image: postgres:12-alpine
image: postgres:16-alpine
env:
POSTGRES_USER: hawc
POSTGRES_PASSWORD: password
Expand All @@ -152,27 +139,22 @@ jobs:
PUBMED_API_KEY: ${{ secrets.PUBMED_API_KEY }}

steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v3
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: '3.12'
architecture: 'x64'
- name: try to restore pip cache
uses: actions/cache@v3
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('requirements/*.txt') }}
restore-keys: |
${{ runner.os }}-pip-
cache: 'pip'
- name: Download webpack build
uses: actions/download-artifact@v3
uses: actions/download-artifact@v4
with:
name: webpack-build
path: hawc
- name: install hawc
run: |
pip install -U pip
pip install -r requirements/dev.txt
python -m pip install -U pip wheel
python -m pip install -e ".[dev,docs]"
python -m pip install -e client
playwright install --with-deps chromium
# https://github.uint.cloudmunity/t/how-to-retry-a-failed-step-in-github-actions-workflow/125880
- name: run integration tests
Expand Down
5 changes: 4 additions & 1 deletion .readthedocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,7 @@ mkdocs:
configuration: docs/mkdocs.yml
python:
install:
- requirements: requirements/docs.txt
- method: pip
path: .
extra_requirements:
- docs
5 changes: 3 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,9 @@ export PRINT_HELP_PYSCRIPT
BROWSER := python -c "$$BROWSER_PYSCRIPT"

sync-dev: ## Sync dev environment after code checkout
python -m pip install -U pip
python -m pip install -r requirements/dev.txt
python -m pip install -U pip uv
uv pip install -e ".[dev,docs]"
uv pip install -e client
yarn --cwd frontend
python manage.py migrate
python manage.py recreate_views
Expand Down
3 changes: 1 addition & 2 deletions compose/app/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,11 @@ RUN apt-get update && \
\
mkdir -p /app/logs

COPY ./requirements /app/build/requirements
COPY ./dist /app/build/dist

WORKDIR /app/build
RUN pip install -U pip && \
pip install -r /app/build/requirements/production.txt --no-cache-dir && \
pip install "$(ls dist/hawc-*.whl | head -1)[prod]" --no-cache-dir && \
pip uninstall -y pip setuptools && \
rm -rf /app/build && \
chown -R app:app /app
Expand Down
2 changes: 1 addition & 1 deletion compose/postgres/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM postgres:12-alpine
FROM postgres:16-alpine

RUN apk update && \
apk upgrade --available && \
Expand Down
37 changes: 12 additions & 25 deletions docs/docs/development.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ following applications installed on your local development system:
- [Python](https://www.python.org/) == 3.12
- [Node.js](https://nodejs.org)
- [Yarn](https://yarnpkg.com/) < 2
- [PostgreSQL](https://www.postgresql.org/) >= 12
- [PostgreSQL](https://www.postgresql.org/) >= 16

When writing code for HAWC, there are a few requirements for code acceptance. We have built-in CI using github actions for enforcement:

Expand All @@ -28,15 +28,17 @@ mkdir -p ~/dev
cd ~/dev
git clone https://github.com/shapiromatron/hawc.git

# create virtual environment and install requirements
# create virtual environment
cd ~/dev/hawc
python -m venv venv

# activate the environment
source ./venv/bin/activate

# install requirements
./venv/bin/pip install -r ./requirements/dev.txt
python -m pip install -U pip uv
uv pip install -e ".[dev,docs]"
uv pip install -e client

# create a PostgreSQL database and superuser
createuser --superuser --no-password hawc
Expand All @@ -60,8 +62,9 @@ git clone https://github.com/shapiromatron/hawc.git
:: install python requirements
cd %HOMEPATH%\dev\hawc
python -m pip install --upgrade pip
pip install -r requirements\dev.txt
python -m pip install -U pip uv
uv pip install -e ".[dev,docs]"
uv pip install -e client
:: setup and start PostgreSQL; in this example we'll put it in dev
cd %HOMEPATH%\dev
Expand Down Expand Up @@ -492,26 +495,6 @@ Possible values include:
- PRIME (default application; as hosted at <https://hawcproject.org>)
- EPA (EPA application; as hosted at EPA)

### Compiling USWDS

The EPA flavor of HAWC uses a framework from the [U.S. Web Design System](https://designsystem.digital.gov/) (USWDS) adapted for the agency. USWDS is a large package with thousands of resources; HAWC only includes a subset of these files. Including further components requires installing USWDS, and adding the component names to [`frontend/uswds/sass/styles.scss`](https://designsystem.digital.gov/components/packages/). The following command will rebuild this code:

```bash
cd ~/dev/hawc/frontend

# rebuild CSS
npm run uswds-compile

# copy fonts, img, js
npm run uswds-copy-assets
```

After running, manually delete unused fonts and images.

A few major revisions were made to the compiled USWDS assets, most notably:

- Update the fonts path location to pull from an external delivery network instead of the `../fonts` location in the styles.css file. This was done using a search/replace on that file.

### Updating EPA.gov style

There are multiple styles available when using HAWC; and the EPA style has to be updated periodically for the same look at feel as the EPA website. The following steps describe how to update HAWC styling with the EPA theme:
Expand All @@ -525,6 +508,10 @@ There are multiple styles available when using HAWC; and the EPA style has to be
6. Overwrite any necessary changes in `hawc/static/css/epa-hawc.css` to maintain HAWC styling.
7. Test changes locally to ensure HAWC matches EPA.gov styling. On the base.html, you may want to disable caching for the header and footer components (or cache for 1 second) so it makes it easier to see the changes.

A few revisions were made to USWDS assets:

* Update the fonts path location to pull from an external delivery network instead of the `../fonts` location in the styles.css file. This was done using a search/replace on that file.

### Materialized views

HAWC is in essence two different systems with very different data requirements:
Expand Down
1 change: 0 additions & 1 deletion frontend/.eslintignore
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
shared/parsers
uswds/node_modules
7 changes: 1 addition & 6 deletions frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
"scripts": {
"clean": "rimraf ../hawc/static/bundles/* && rimraf ../hawc/webpack-stats.json",
"build": "npm run clean && webpack --config webpack.config.js",
"uswds-compile": "gulp -f ./uswds/gulpfile.js compileSass",
"uswds-copy-assets": "gulp -f ./uswds/gulpfile.js copyAssets",
"start": "node devServer.js",
"lint": "eslint --cache .",
"format": "eslint --cache --fix .",
Expand All @@ -30,8 +28,6 @@
"@babel/preset-env": "^7.22.7",
"@babel/preset-react": "^7.22.5",
"@babel/runtime": "^7.22.6",
"@uswds/compile": "^1.0.0",
"@uswds/uswds": "^3.5.0",
"assert": "^2.0.0",
"babel-eslint": "^10.1.0",
"babel-loader": "^8.3.0",
Expand All @@ -53,7 +49,7 @@
"webpack": "^5.88.1",
"webpack-bundle-tracker": "^2.0.1",
"webpack-cli": "^5.1.4",
"webpack-dev-middleware": "^6.1.1"
"webpack-dev-middleware": "^6.1.2"
},
"dependencies": {
"clipboard": "~2.0.11",
Expand All @@ -69,7 +65,6 @@
"quill": "^1.3.7",
"react": "^16.14.0",
"react-autosuggest": "^10.1.0",
"react-datepicker": "~4.16.0",
"react-dom": "^16.14.0",
"react-plotly.js": "^2.6.0",
"react-quill": "^1.3.5",
Expand Down
60 changes: 0 additions & 60 deletions frontend/shared/components/ReactDatePicker.js

This file was deleted.

10 changes: 5 additions & 5 deletions frontend/summary/summaryTable/studyEvaluationTable/Table.js
Original file line number Diff line number Diff line change
Expand Up @@ -390,9 +390,9 @@ class Table extends Component {
onClick = store.interactiveOnClick(rowIdx, colIdx);

return onClick == null ? null : (
<p className="previewModalIcon float-right">
<span className="previewModalIcon float-right">
<i className="fa fa-external-link" onClick={onClick}></i>
</p>
</span>
);
}
renderSubheaders() {
Expand Down Expand Up @@ -474,7 +474,7 @@ class Table extends Component {
key={col.key}
className={
editable && editingColumn && editIndex == idx
? "bg-light"
? "bg-lightblue"
: null
}
style={
Expand Down Expand Up @@ -508,7 +508,7 @@ class Table extends Component {
key={rowIdx}
className={
editable && editingRow && editIndex == rowIdx
? "bg-light"
? "bg-lightblue"
: null
}>
{workingSettings.columns.map((col, colIdx) => {
Expand All @@ -518,7 +518,7 @@ class Table extends Component {
key={colIdx}
className={`previewModalParent${
editable && store.editingCell(rowIdx, colIdx)
? " bg-light"
? " bg-lightblue"
: col.attribute == COL_ATTRIBUTE.ROB.id
? " text-center align-middle cursor-pointer"
: ""
Expand Down
Loading

0 comments on commit ccb2a23

Please sign in to comment.