mirror of
https://github.com/DOI-DO/j40-cejst-2.git
synced 2025-02-23 18:14:19 -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
|
uses: actions/setup-node@v2
|
||||||
with:
|
with:
|
||||||
node-version: ${{ matrix.node-version }}
|
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: |
|
run: |
|
||||||
echo "DESTINATION_FOLDER=$(echo $PR_NUMBER-$GITHUB_SHA | cut -c 1-11)" >> $GITHUB_ENV
|
echo "New translations required! The en.json was modified, please update translations in other language files."
|
||||||
- name: Install
|
|
||||||
run: npm ci
|
# - name: Set DESTINATION_FOLDER for branch
|
||||||
- name: Build
|
# run: |
|
||||||
run: npm run build --if-present
|
# echo "DESTINATION_FOLDER=$(echo $PR_NUMBER-$GITHUB_SHA | cut -c 1-11)" >> $GITHUB_ENV
|
||||||
env:
|
# - name: Install
|
||||||
# See the client readme for more info on environment variables:
|
# run: npm ci
|
||||||
# https://github.com/usds/justice40-tool/blob/main/client/README.md
|
# - name: Build
|
||||||
DATA_SOURCE: cdn
|
# run: npm run build --if-present
|
||||||
SITE_URL: "${{ secrets.STAGE_SITE_URL }}"
|
# env:
|
||||||
PATH_PREFIX: "/justice40-tool/${{env.DESTINATION_FOLDER}}"
|
# # See the client readme for more info on environment variables:
|
||||||
MAPBOX_STYLES_READ_TOKEN: "${{ secrets.MAPBOX_STYLES_READ_TOKEN }}"
|
# # https://github.com/usds/justice40-tool/blob/main/client/README.md
|
||||||
- name: Get directory contents
|
# DATA_SOURCE: cdn
|
||||||
run: ls -la public
|
# SITE_URL: "${{ secrets.STAGE_SITE_URL }}"
|
||||||
- name: Lint
|
# PATH_PREFIX: "/justice40-tool/${{env.DESTINATION_FOLDER}}"
|
||||||
run: npm run lint
|
# MAPBOX_STYLES_READ_TOKEN: "${{ secrets.MAPBOX_STYLES_READ_TOKEN }}"
|
||||||
# Disabling for now due to jsonlint - TODO: put this back
|
# - name: Get directory contents
|
||||||
# - name: License Check
|
# run: ls -la public
|
||||||
# run: npm run licenses
|
# - name: Lint
|
||||||
- name: Test
|
# run: npm run lint
|
||||||
run: npm test
|
# # Disabling for now due to jsonlint - TODO: put this back
|
||||||
- name: Check for security vulnerabilities
|
# # - name: License Check
|
||||||
run: npm audit --production
|
# # run: npm run licenses
|
||||||
- name: Cypress / Gherkin integration tests 🌃
|
# - name: Test
|
||||||
uses: cypress-io/github-action@v2
|
# run: npm test
|
||||||
with:
|
# - name: Check for security vulnerabilities
|
||||||
working-directory: ${{env.WORKING_DIRECTORY}}
|
# run: npm audit --production
|
||||||
start: npm start
|
# - name: Cypress / Gherkin integration tests 🌃
|
||||||
wait-on: "http://localhost:8000"
|
# uses: cypress-io/github-action@v2
|
||||||
- name: Upload Artifact
|
# with:
|
||||||
uses: actions/upload-artifact@v2
|
# working-directory: ${{env.WORKING_DIRECTORY}}
|
||||||
with:
|
# start: npm start
|
||||||
name: J40Static
|
# wait-on: "http://localhost:8000"
|
||||||
# Upload-artifact does not support the default working directory
|
# - name: Upload Artifact
|
||||||
# See more: https://github.com/actions/upload-artifact/issues/87
|
# uses: actions/upload-artifact@v2
|
||||||
path: ./client/public
|
# with:
|
||||||
deploy:
|
# name: J40Static
|
||||||
runs-on: ubuntu-latest
|
# # Upload-artifact does not support the default working directory
|
||||||
needs: build
|
# # See more: https://github.com/actions/upload-artifact/issues/87
|
||||||
steps:
|
# path: ./client/public
|
||||||
- name: Checkout source
|
# deploy:
|
||||||
uses: actions/checkout@v2
|
# runs-on: ubuntu-latest
|
||||||
- name: Download Artifacts
|
# needs: build
|
||||||
uses: actions/download-artifact@v2
|
# steps:
|
||||||
with:
|
# - name: Checkout source
|
||||||
name: J40Static
|
# uses: actions/checkout@v2
|
||||||
path: ./public
|
# - name: Download Artifacts
|
||||||
- name: Set DESTINATION_FOLDER for branch
|
# uses: actions/download-artifact@v2
|
||||||
run: |
|
# with:
|
||||||
echo "DESTINATION_FOLDER=$(echo $PR_NUMBER-$GITHUB_SHA | cut -c 1-11)" >> $GITHUB_ENV
|
# name: J40Static
|
||||||
- name: Configure AWS Credentials
|
# path: ./public
|
||||||
uses: aws-actions/configure-aws-credentials@v1
|
# - name: Set DESTINATION_FOLDER for branch
|
||||||
with:
|
# run: |
|
||||||
aws-access-key-id: ${{ secrets.CLIENT_DEV_AWS_ACCESS_KEY_ID }}
|
# echo "DESTINATION_FOLDER=$(echo $PR_NUMBER-$GITHUB_SHA | cut -c 1-11)" >> $GITHUB_ENV
|
||||||
aws-secret-access-key: ${{ secrets.CLIENT_DEV_AWS_SECRET_ACCESS_KEY }}
|
# - name: Configure AWS Credentials
|
||||||
aws-region: us-east-1
|
# uses: aws-actions/configure-aws-credentials@v1
|
||||||
- name: Deploy to Geoplatform AWS
|
# with:
|
||||||
run: aws s3 sync ./public/ s3://usds-geoplatform-justice40-website/justice40-tool/${{env.DESTINATION_FOLDER}} --acl public-read --delete
|
# aws-access-key-id: ${{ secrets.CLIENT_DEV_AWS_ACCESS_KEY_ID }}
|
||||||
- name: Update PR with deployed URL
|
# aws-secret-access-key: ${{ secrets.CLIENT_DEV_AWS_SECRET_ACCESS_KEY }}
|
||||||
uses: mshick/add-pr-comment@v1
|
# aws-region: us-east-1
|
||||||
with:
|
# - name: Deploy to Geoplatform AWS
|
||||||
# Deploy to S3 for the staging URL
|
# run: aws s3 sync ./public/ s3://usds-geoplatform-justice40-website/justice40-tool/${{env.DESTINATION_FOLDER}} --acl public-read --delete
|
||||||
message: |
|
# - name: Update PR with deployed URL
|
||||||
**🚢 PR Deployed! 🚢**
|
# uses: mshick/add-pr-comment@v1
|
||||||
Find it here: http://usds-geoplatform-justice40-website.s3-website-us-east-1.amazonaws.com/justice40-tool/${{env.DESTINATION_FOLDER}}/en/cejst/ !
|
# with:
|
||||||
repo-token: ${{ secrets.GITHUB_TOKEN }}
|
# # Deploy to S3 for the staging URL
|
||||||
repo-token-user-login: "github-actions[bot]" # The user.login for temporary GitHub tokens
|
# message: |
|
||||||
allow-repeats: false # This is the default
|
# **🚢 PR Deployed! 🚢**
|
||||||
- name: Printing deployment URLs
|
# Find it here: http://usds-geoplatform-justice40-website.s3-website-us-east-1.amazonaws.com/justice40-tool/${{env.DESTINATION_FOLDER}}/en/cejst/ !
|
||||||
run: |
|
# repo-token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
echo "Github pages: https://usds.github.io/justice40-tool/$DESTINATION_FOLDER/en"
|
# 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==",
|
"integrity": "sha512-SEQu7vl8KjNL2eoGBLF3+wAjpsNfA9XMlXAYj/3EdaNfAlxKthD1xjEQfGOUhllCGGJVNY34bRr6lPINhNjyZw==",
|
||||||
"dev": true
|
"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": {
|
"hyphenate-style-name": {
|
||||||
"version": "1.0.4",
|
"version": "1.0.4",
|
||||||
"resolved": "https://registry.npmjs.org/hyphenate-style-name/-/hyphenate-style-name-1.0.4.tgz",
|
"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",
|
"lint:fix": "npm run lint -- --quiet --fix",
|
||||||
"intl:extract": "formatjs extract 'src/**/*.tsx' --out-file src/intl/en.json",
|
"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",
|
"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": {
|
"devDependencies": {
|
||||||
"@formatjs/cli": "^4.2.15",
|
"@formatjs/cli": "^4.2.15",
|
||||||
|
@ -61,6 +62,7 @@
|
||||||
"gatsby-plugin-react-helmet": "^4.6.0",
|
"gatsby-plugin-react-helmet": "^4.6.0",
|
||||||
"gatsby-plugin-sass": "^4.5.0",
|
"gatsby-plugin-sass": "^4.5.0",
|
||||||
"gh-pages": "^3.2.0",
|
"gh-pages": "^3.2.0",
|
||||||
|
"husky": "^7.0.4",
|
||||||
"identity-obj-proxy": "^3.0.0",
|
"identity-obj-proxy": "^3.0.0",
|
||||||
"jest": "^27.0.1",
|
"jest": "^27.0.1",
|
||||||
"license-checker": "^25.0.1",
|
"license-checker": "^25.0.1",
|
||||||
|
|
|
@ -58,7 +58,7 @@ export const CENSUS_TRACT_FEEDBACK = {
|
||||||
description={'census tract feedback section'}
|
description={'census tract feedback section'}
|
||||||
/>,
|
/>,
|
||||||
PARAGRAPH3: <FormattedMessage
|
PARAGRAPH3: <FormattedMessage
|
||||||
id={'contact.page.census.tract.feedback.para1'}
|
id={'contact.page.census.tract.feedback.para3'}
|
||||||
defaultMessage={`
|
defaultMessage={`
|
||||||
In addition, you can provide feedback on the tool via this {improvementSurvey}.
|
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',
|
description: 'Proposed or listed NPL (Superfund) sites within 5 kilometers',
|
||||||
},
|
},
|
||||||
PROX_RMP: {
|
PROX_RMP: {
|
||||||
id: 'areaDetail.indicator.description.prox.npl',
|
id: 'areaDetail.indicator.description.prox.rmp',
|
||||||
defaultMessage: 'Risk Management Plan facilities within 5 kilometers',
|
defaultMessage: 'Risk Management Plan facilities within 5 kilometers',
|
||||||
description: 'Risk Management Plan facilities within 5 kilometers',
|
description: 'Risk Management Plan facilities within 5 kilometers',
|
||||||
},
|
},
|
||||||
|
|
|
@ -72,9 +72,9 @@ export const FORMULA = {
|
||||||
}}
|
}}
|
||||||
/>,
|
/>,
|
||||||
THEN: <FormattedMessage
|
THEN: <FormattedMessage
|
||||||
id={'methodology.page.formula.second'}
|
id={'methodology.page.formula.third'}
|
||||||
defaultMessage={ `{then} the community is considered disadvantaged.`}
|
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= {{
|
values= {{
|
||||||
then: <span>THEN</span>,
|
then: <span>THEN</span>,
|
||||||
}}
|
}}
|
||||||
|
@ -243,7 +243,7 @@ export const CATEGORIES = {
|
||||||
},
|
},
|
||||||
CLEAN_ENERGY: {
|
CLEAN_ENERGY: {
|
||||||
METHODOLOGY: <FormattedMessage
|
METHODOLOGY: <FormattedMessage
|
||||||
id= {'indicator.categories.climate.change.methodology'}
|
id= {'indicator.categories.clean.energy.methodology'}
|
||||||
defaultMessage= {`Clean energy and energy efficiency category`}
|
defaultMessage= {`Clean energy and energy efficiency category`}
|
||||||
description= {`Clean energy and energy efficiency methodology`}
|
description= {`Clean energy and energy efficiency methodology`}
|
||||||
/>,
|
/>,
|
||||||
|
@ -573,7 +573,7 @@ export const RESPONSIBLE_PARTIES = {
|
||||||
|
|
||||||
export const SOURCE_LINKS = {
|
export const SOURCE_LINKS = {
|
||||||
CENSUS_ACS_15_19: <FormattedMessage
|
CENSUS_ACS_15_19: <FormattedMessage
|
||||||
id= {'category.source.census.link'}
|
id= {'category.source.census.link.15'}
|
||||||
defaultMessage= {'{sourceCensusLink} from {date15_19}'}
|
defaultMessage= {'{sourceCensusLink} from {date15_19}'}
|
||||||
description= {'source link for Census ACS'}
|
description= {'source link for Census ACS'}
|
||||||
values= {{
|
values= {{
|
||||||
|
@ -588,7 +588,7 @@ export const SOURCE_LINKS = {
|
||||||
}}
|
}}
|
||||||
/>,
|
/>,
|
||||||
CENSUS_ACS_10: <FormattedMessage
|
CENSUS_ACS_10: <FormattedMessage
|
||||||
id= {'category.source.census.link'}
|
id= {'category.source.census.link.10'}
|
||||||
defaultMessage= {'{sourceCensusLink} from {date10}'}
|
defaultMessage= {'{sourceCensusLink} from {date10}'}
|
||||||
description= {'source link for Census ACS'}
|
description= {'source link for Census ACS'}
|
||||||
values= {{
|
values= {{
|
||||||
|
@ -1045,7 +1045,7 @@ export const INDICATORS = [
|
||||||
domID: 'median-home',
|
domID: 'median-home',
|
||||||
indicator: 'Median home value',
|
indicator: 'Median home value',
|
||||||
description: <FormattedMessage
|
description: <FormattedMessage
|
||||||
id= {'category.lead.paint.description.text'}
|
id= {'category.median.home.value.description.text'}
|
||||||
defaultMessage= {`
|
defaultMessage= {`
|
||||||
Median home value of owner-occupied housing units in the census tract.
|
Median home value of owner-occupied housing units in the census tract.
|
||||||
`}
|
`}
|
||||||
|
@ -1187,13 +1187,13 @@ export const INDICATORS = [
|
||||||
domID: 'heart-disease',
|
domID: 'heart-disease',
|
||||||
indicator: 'Heart disease',
|
indicator: 'Heart disease',
|
||||||
description: <FormattedMessage
|
description: <FormattedMessage
|
||||||
id= {'category.diabetes.description.text'}
|
id= {'category.heart.disease.description.text'}
|
||||||
defaultMessage= {`
|
defaultMessage= {`
|
||||||
Weighted percent of people ages 18 years and older who report ever having been told
|
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
|
by a doctor, nurse, or other health professionals that they had angina or
|
||||||
coronary heart disease.
|
coronary heart disease.
|
||||||
`}
|
`}
|
||||||
description= {'description text for diabetes'}
|
description= {'description text for heart disease'}
|
||||||
/>,
|
/>,
|
||||||
usedIn: CATEGORIES.HEALTH_BURDENS.METHODOLOGY,
|
usedIn: CATEGORIES.HEALTH_BURDENS.METHODOLOGY,
|
||||||
responsibleParty: RESPONSIBLE_PARTIES.CDC,
|
responsibleParty: RESPONSIBLE_PARTIES.CDC,
|
||||||
|
|
File diff suppressed because it is too large
Load diff
Loading…
Add table
Reference in a new issue