mirror of
https://github.com/DOI-DO/j40-cejst-2.git
synced 2025-02-23 10:04:18 -08:00
Add intl pre-commit hook
- add Husky lib - add pre-commit script - detect warning on extraction and abort commit - update deploy staging yml
This commit is contained in:
parent
9d920d4db4
commit
c2f2d1b047
8 changed files with 854 additions and 257 deletions
152
.github/workflows/deploy_fe_staging.yml
vendored
152
.github/workflows/deploy_fe_staging.yml
vendored
|
@ -22,76 +22,84 @@ jobs:
|
|||
uses: actions/setup-node@v2
|
||||
with:
|
||||
node-version: ${{ matrix.node-version }}
|
||||
- name: Set DESTINATION_FOLDER for branch
|
||||
- name: Get changed files using defaults
|
||||
id: changed-files
|
||||
uses: tj-actions/changed-files@v18.1
|
||||
- name: Detect if new translation are required (en.json was modified)
|
||||
if: contains(steps.changed-files.outputs.modified_files, 'client/src/intl/en.json')
|
||||
run: |
|
||||
echo "DESTINATION_FOLDER=$(echo $PR_NUMBER-$GITHUB_SHA | cut -c 1-11)" >> $GITHUB_ENV
|
||||
- name: Install
|
||||
run: npm ci
|
||||
- name: Build
|
||||
run: npm run build --if-present
|
||||
env:
|
||||
# See the client readme for more info on environment variables:
|
||||
# https://github.com/usds/justice40-tool/blob/main/client/README.md
|
||||
DATA_SOURCE: cdn
|
||||
SITE_URL: "${{ secrets.STAGE_SITE_URL }}"
|
||||
PATH_PREFIX: "/justice40-tool/${{env.DESTINATION_FOLDER}}"
|
||||
MAPBOX_STYLES_READ_TOKEN: "${{ secrets.MAPBOX_STYLES_READ_TOKEN }}"
|
||||
- name: Get directory contents
|
||||
run: ls -la public
|
||||
- name: Lint
|
||||
run: npm run lint
|
||||
# Disabling for now due to jsonlint - TODO: put this back
|
||||
# - name: License Check
|
||||
# run: npm run licenses
|
||||
- name: Test
|
||||
run: npm test
|
||||
- name: Check for security vulnerabilities
|
||||
run: npm audit --production
|
||||
- name: Cypress / Gherkin integration tests 🌃
|
||||
uses: cypress-io/github-action@v2
|
||||
with:
|
||||
working-directory: ${{env.WORKING_DIRECTORY}}
|
||||
start: npm start
|
||||
wait-on: "http://localhost:8000"
|
||||
- name: Upload Artifact
|
||||
uses: actions/upload-artifact@v2
|
||||
with:
|
||||
name: J40Static
|
||||
# Upload-artifact does not support the default working directory
|
||||
# See more: https://github.com/actions/upload-artifact/issues/87
|
||||
path: ./client/public
|
||||
deploy:
|
||||
runs-on: ubuntu-latest
|
||||
needs: build
|
||||
steps:
|
||||
- name: Checkout source
|
||||
uses: actions/checkout@v2
|
||||
- name: Download Artifacts
|
||||
uses: actions/download-artifact@v2
|
||||
with:
|
||||
name: J40Static
|
||||
path: ./public
|
||||
- name: Set DESTINATION_FOLDER for branch
|
||||
run: |
|
||||
echo "DESTINATION_FOLDER=$(echo $PR_NUMBER-$GITHUB_SHA | cut -c 1-11)" >> $GITHUB_ENV
|
||||
- name: Configure AWS Credentials
|
||||
uses: aws-actions/configure-aws-credentials@v1
|
||||
with:
|
||||
aws-access-key-id: ${{ secrets.CLIENT_DEV_AWS_ACCESS_KEY_ID }}
|
||||
aws-secret-access-key: ${{ secrets.CLIENT_DEV_AWS_SECRET_ACCESS_KEY }}
|
||||
aws-region: us-east-1
|
||||
- name: Deploy to Geoplatform AWS
|
||||
run: aws s3 sync ./public/ s3://usds-geoplatform-justice40-website/justice40-tool/${{env.DESTINATION_FOLDER}} --acl public-read --delete
|
||||
- name: Update PR with deployed URL
|
||||
uses: mshick/add-pr-comment@v1
|
||||
with:
|
||||
# Deploy to S3 for the staging URL
|
||||
message: |
|
||||
**🚢 PR Deployed! 🚢**
|
||||
Find it here: http://usds-geoplatform-justice40-website.s3-website-us-east-1.amazonaws.com/justice40-tool/${{env.DESTINATION_FOLDER}}/en/cejst/ !
|
||||
repo-token: ${{ secrets.GITHUB_TOKEN }}
|
||||
repo-token-user-login: "github-actions[bot]" # The user.login for temporary GitHub tokens
|
||||
allow-repeats: false # This is the default
|
||||
- name: Printing deployment URLs
|
||||
run: |
|
||||
echo "Github pages: https://usds.github.io/justice40-tool/$DESTINATION_FOLDER/en"
|
||||
echo "New translations required! The en.json was modified, please update translations in other language files."
|
||||
|
||||
# - name: Set DESTINATION_FOLDER for branch
|
||||
# run: |
|
||||
# echo "DESTINATION_FOLDER=$(echo $PR_NUMBER-$GITHUB_SHA | cut -c 1-11)" >> $GITHUB_ENV
|
||||
# - name: Install
|
||||
# run: npm ci
|
||||
# - name: Build
|
||||
# run: npm run build --if-present
|
||||
# env:
|
||||
# # See the client readme for more info on environment variables:
|
||||
# # https://github.com/usds/justice40-tool/blob/main/client/README.md
|
||||
# DATA_SOURCE: cdn
|
||||
# SITE_URL: "${{ secrets.STAGE_SITE_URL }}"
|
||||
# PATH_PREFIX: "/justice40-tool/${{env.DESTINATION_FOLDER}}"
|
||||
# MAPBOX_STYLES_READ_TOKEN: "${{ secrets.MAPBOX_STYLES_READ_TOKEN }}"
|
||||
# - name: Get directory contents
|
||||
# run: ls -la public
|
||||
# - name: Lint
|
||||
# run: npm run lint
|
||||
# # Disabling for now due to jsonlint - TODO: put this back
|
||||
# # - name: License Check
|
||||
# # run: npm run licenses
|
||||
# - name: Test
|
||||
# run: npm test
|
||||
# - name: Check for security vulnerabilities
|
||||
# run: npm audit --production
|
||||
# - name: Cypress / Gherkin integration tests 🌃
|
||||
# uses: cypress-io/github-action@v2
|
||||
# with:
|
||||
# working-directory: ${{env.WORKING_DIRECTORY}}
|
||||
# start: npm start
|
||||
# wait-on: "http://localhost:8000"
|
||||
# - name: Upload Artifact
|
||||
# uses: actions/upload-artifact@v2
|
||||
# with:
|
||||
# name: J40Static
|
||||
# # Upload-artifact does not support the default working directory
|
||||
# # See more: https://github.com/actions/upload-artifact/issues/87
|
||||
# path: ./client/public
|
||||
# deploy:
|
||||
# runs-on: ubuntu-latest
|
||||
# needs: build
|
||||
# steps:
|
||||
# - name: Checkout source
|
||||
# uses: actions/checkout@v2
|
||||
# - name: Download Artifacts
|
||||
# uses: actions/download-artifact@v2
|
||||
# with:
|
||||
# name: J40Static
|
||||
# path: ./public
|
||||
# - name: Set DESTINATION_FOLDER for branch
|
||||
# run: |
|
||||
# echo "DESTINATION_FOLDER=$(echo $PR_NUMBER-$GITHUB_SHA | cut -c 1-11)" >> $GITHUB_ENV
|
||||
# - name: Configure AWS Credentials
|
||||
# uses: aws-actions/configure-aws-credentials@v1
|
||||
# with:
|
||||
# aws-access-key-id: ${{ secrets.CLIENT_DEV_AWS_ACCESS_KEY_ID }}
|
||||
# aws-secret-access-key: ${{ secrets.CLIENT_DEV_AWS_SECRET_ACCESS_KEY }}
|
||||
# aws-region: us-east-1
|
||||
# - name: Deploy to Geoplatform AWS
|
||||
# run: aws s3 sync ./public/ s3://usds-geoplatform-justice40-website/justice40-tool/${{env.DESTINATION_FOLDER}} --acl public-read --delete
|
||||
# - name: Update PR with deployed URL
|
||||
# uses: mshick/add-pr-comment@v1
|
||||
# with:
|
||||
# # Deploy to S3 for the staging URL
|
||||
# message: |
|
||||
# **🚢 PR Deployed! 🚢**
|
||||
# Find it here: http://usds-geoplatform-justice40-website.s3-website-us-east-1.amazonaws.com/justice40-tool/${{env.DESTINATION_FOLDER}}/en/cejst/ !
|
||||
# repo-token: ${{ secrets.GITHUB_TOKEN }}
|
||||
# repo-token-user-login: "github-actions[bot]" # The user.login for temporary GitHub tokens
|
||||
# allow-repeats: false # This is the default
|
||||
# - name: Printing deployment URLs
|
||||
# run: |
|
||||
# echo "Github pages: https://usds.github.io/justice40-tool/$DESTINATION_FOLDER/en"
|
||||
|
|
41
client/.husky/pre-commit
Executable file
41
client/.husky/pre-commit
Executable file
|
@ -0,0 +1,41 @@
|
|||
#!/bin/bash
|
||||
|
||||
echo
|
||||
echo "[pre-commit hook msg]: running pre-commit hook ..."
|
||||
|
||||
# Husky by default expects pre-commit hooks in the root directory. We set up a custom directory for the client folder
|
||||
# https://typicode.github.io/husky/#/?id=custom-directory
|
||||
cd client
|
||||
|
||||
# This file will automatically run intl:extract and compile on every commit
|
||||
# write the extracted errors into a file
|
||||
npm run intl:extract 2> extract-err.txt
|
||||
|
||||
# check the extracted error files for warnings and abort commit if found
|
||||
if grep -F "warning" extract-err.txt
|
||||
then
|
||||
echo
|
||||
echo '[pre-commit hook msg]: ALERT: warnings found in extraction process. Please remove warnings and re-run "npm run intl:extract"'
|
||||
echo
|
||||
echo '[pre-commit hook msg]: aborting commit...'
|
||||
echo
|
||||
echo '[pre-commit hook msg]: removing extract-err file...'
|
||||
echo
|
||||
rm extract-err.txt
|
||||
echo '[pre-commit hook msg]: pre-commit hook incomplete.'
|
||||
echo
|
||||
exit 1
|
||||
else
|
||||
echo
|
||||
echo '[pre-commit hook msg]: no warnings found, continuing with commit ...'
|
||||
echo
|
||||
echo '[pre-commit hook msg]: removing extract-err file ...'
|
||||
echo
|
||||
rm extract-err.txt
|
||||
echo '[pre-commit hook msg]: adding en.json to staging area ...'
|
||||
echo
|
||||
# add the en.json to staging so that the pre-commit hook can include it in the commit
|
||||
git add src/intl/en.json
|
||||
echo '[pre-commit hook msg]: pre-commit hook complete.'
|
||||
echo
|
||||
fi
|
6
client/package-lock.json
generated
6
client/package-lock.json
generated
|
@ -12515,6 +12515,12 @@
|
|||
"integrity": "sha512-SEQu7vl8KjNL2eoGBLF3+wAjpsNfA9XMlXAYj/3EdaNfAlxKthD1xjEQfGOUhllCGGJVNY34bRr6lPINhNjyZw==",
|
||||
"dev": true
|
||||
},
|
||||
"husky": {
|
||||
"version": "7.0.4",
|
||||
"resolved": "https://registry.npmjs.org/husky/-/husky-7.0.4.tgz",
|
||||
"integrity": "sha512-vbaCKN2QLtP/vD4yvs6iz6hBEo6wkSzs8HpRah1Z6aGmF2KW5PdYuAd7uX5a+OyBZHBhd+TFLqgjUgytQr4RvQ==",
|
||||
"dev": true
|
||||
},
|
||||
"hyphenate-style-name": {
|
||||
"version": "1.0.4",
|
||||
"resolved": "https://registry.npmjs.org/hyphenate-style-name/-/hyphenate-style-name-1.0.4.tgz",
|
||||
|
|
|
@ -26,7 +26,8 @@
|
|||
"lint:fix": "npm run lint -- --quiet --fix",
|
||||
"intl:extract": "formatjs extract 'src/**/*.tsx' --out-file src/intl/en.json",
|
||||
"intl:compile-en": "formatjs compile src/intl/en.json --ast --out-file compiled-lang/en.json",
|
||||
"test:intl-extraction": "node src/intl/testIntlExtraction"
|
||||
"test:intl-extraction": "node src/intl/testIntlExtraction",
|
||||
"prepare": "cd .. && husky install client/.husky"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@formatjs/cli": "^4.2.15",
|
||||
|
@ -61,6 +62,7 @@
|
|||
"gatsby-plugin-react-helmet": "^4.6.0",
|
||||
"gatsby-plugin-sass": "^4.5.0",
|
||||
"gh-pages": "^3.2.0",
|
||||
"husky": "^7.0.4",
|
||||
"identity-obj-proxy": "^3.0.0",
|
||||
"jest": "^27.0.1",
|
||||
"license-checker": "^25.0.1",
|
||||
|
|
|
@ -58,7 +58,7 @@ export const CENSUS_TRACT_FEEDBACK = {
|
|||
description={'census tract feedback section'}
|
||||
/>,
|
||||
PARAGRAPH3: <FormattedMessage
|
||||
id={'contact.page.census.tract.feedback.para1'}
|
||||
id={'contact.page.census.tract.feedback.para3'}
|
||||
defaultMessage={`
|
||||
In addition, you can provide feedback on the tool via this {improvementSurvey}.
|
||||
`}
|
||||
|
|
|
@ -523,7 +523,7 @@ export const SIDE_PANEL_INDICATOR_DESCRIPTION = defineMessages({
|
|||
description: 'Proposed or listed NPL (Superfund) sites within 5 kilometers',
|
||||
},
|
||||
PROX_RMP: {
|
||||
id: 'areaDetail.indicator.description.prox.npl',
|
||||
id: 'areaDetail.indicator.description.prox.rmp',
|
||||
defaultMessage: 'Risk Management Plan facilities within 5 kilometers',
|
||||
description: 'Risk Management Plan facilities within 5 kilometers',
|
||||
},
|
||||
|
|
|
@ -72,9 +72,9 @@ export const FORMULA = {
|
|||
}}
|
||||
/>,
|
||||
THEN: <FormattedMessage
|
||||
id={'methodology.page.formula.second'}
|
||||
id={'methodology.page.formula.third'}
|
||||
defaultMessage={ `{then} the community is considered disadvantaged.`}
|
||||
description={'the second part of the formula used in the methodology'}
|
||||
description={'the third part of the formula used in the methodology'}
|
||||
values= {{
|
||||
then: <span>THEN</span>,
|
||||
}}
|
||||
|
@ -243,7 +243,7 @@ export const CATEGORIES = {
|
|||
},
|
||||
CLEAN_ENERGY: {
|
||||
METHODOLOGY: <FormattedMessage
|
||||
id= {'indicator.categories.climate.change.methodology'}
|
||||
id= {'indicator.categories.clean.energy.methodology'}
|
||||
defaultMessage= {`Clean energy and energy efficiency category`}
|
||||
description= {`Clean energy and energy efficiency methodology`}
|
||||
/>,
|
||||
|
@ -573,7 +573,7 @@ export const RESPONSIBLE_PARTIES = {
|
|||
|
||||
export const SOURCE_LINKS = {
|
||||
CENSUS_ACS_15_19: <FormattedMessage
|
||||
id= {'category.source.census.link'}
|
||||
id= {'category.source.census.link.15'}
|
||||
defaultMessage= {'{sourceCensusLink} from {date15_19}'}
|
||||
description= {'source link for Census ACS'}
|
||||
values= {{
|
||||
|
@ -588,7 +588,7 @@ export const SOURCE_LINKS = {
|
|||
}}
|
||||
/>,
|
||||
CENSUS_ACS_10: <FormattedMessage
|
||||
id= {'category.source.census.link'}
|
||||
id= {'category.source.census.link.10'}
|
||||
defaultMessage= {'{sourceCensusLink} from {date10}'}
|
||||
description= {'source link for Census ACS'}
|
||||
values= {{
|
||||
|
@ -1045,7 +1045,7 @@ export const INDICATORS = [
|
|||
domID: 'median-home',
|
||||
indicator: 'Median home value',
|
||||
description: <FormattedMessage
|
||||
id= {'category.lead.paint.description.text'}
|
||||
id= {'category.median.home.value.description.text'}
|
||||
defaultMessage= {`
|
||||
Median home value of owner-occupied housing units in the census tract.
|
||||
`}
|
||||
|
@ -1187,13 +1187,13 @@ export const INDICATORS = [
|
|||
domID: 'heart-disease',
|
||||
indicator: 'Heart disease',
|
||||
description: <FormattedMessage
|
||||
id= {'category.diabetes.description.text'}
|
||||
id= {'category.heart.disease.description.text'}
|
||||
defaultMessage= {`
|
||||
Weighted percent of people ages 18 years and older who report ever having been told
|
||||
by a doctor, nurse, or other health professionals that they had angina or
|
||||
coronary heart disease.
|
||||
`}
|
||||
description= {'description text for diabetes'}
|
||||
description= {'description text for heart disease'}
|
||||
/>,
|
||||
usedIn: CATEGORIES.HEALTH_BURDENS.METHODOLOGY,
|
||||
responsibleParty: RESPONSIBLE_PARTIES.CDC,
|
||||
|
|
File diff suppressed because it is too large
Load diff
Loading…
Add table
Reference in a new issue