Skip to content

Commit

Permalink
Merge pull request #51 from MeasureAuthoringTool/slack/addingNpmPubli…
Browse files Browse the repository at this point in the history
…shWorkflow

slack/addingNpmPublishWorkflow: Adding .github directory with actions…
  • Loading branch information
mcmcphillips authored Jul 28, 2022
2 parents 7c0f0bf + ffd1872 commit 34c21c0
Show file tree
Hide file tree
Showing 65 changed files with 52,453 additions and 54,725 deletions.
2 changes: 2 additions & 0 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Code owners:
* @MeasureAuthoringTool/madie-developers
27 changes: 27 additions & 0 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
## MADiE PR

Jira Ticket: [MAT-0000](https://jira.cms.gov/browse/MAT-0000)
(Optional) Related Tickets:

### Summary

### All Submissions
* [ ] This PR has the JIRA linked.
* [ ] Required tests are included.
* [ ] No extemporaneous files are included (i.e Complied files or testing results).
* [ ] This PR is merging into the **correct branch**.
* [ ] All Documentation needed for this PR is Complete (or noted in a TODO or other Ticket).
* [ ] Any breaking changes or failing automations are noted by placing a comment on this PR.

### DevSecOps
If there is a question if this PR has a security or infrastructure impact, please contact the Security or DevOps engineer assigned to this project to discuss it further.

* [ ] This PR has NO significant security impact (i.e Changing auth methods, Adding a new user type, Adding a required but vulnerable package).
* [ ] All CDN/Web dependencies are hosted internally (i.e MADiE-Root Repo).

### Reviewers
By Approving this PR you are attesting to the following:

* Code is maintainable and reusable, reuses existing code and infrastructure where appropriate, and accomplishes the task’s purpose.
* The tests appropriately test the new code, including edge cases.
* If you have any concerns they are brought up either to the developer assigned, security engineer, or leads.
27 changes: 27 additions & 0 deletions .github/workflows/gitleaks.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: Github Secrets Scanner

on: [push]

jobs:
gitleaks_scan:
runs-on: ubuntu-latest
env:
REPO: https://github.com/MeasureAuthoringTool/madie-design-system
REMOTE_EXCLUDES_URL: https://raw.githubusercontent.com/semanticbits/bmat-gitleaks-automation/master/madie-design-systems/gitleaks.toml
GITLEAKS_VERSION: v7.5.0
steps:
- name: Execute Gitleaks
run: |
wget ${REMOTE_EXCLUDES_URL} -O gitleaks.toml
wget https://github.com/zricethezav/gitleaks/releases/download/${GITLEAKS_VERSION}/gitleaks-linux-amd64 -O gitleaks
chmod +x gitleaks
echo ${GITHUB_SHA}
echo "gitleaks --repo-url=${REPO} -v --redact --commit=${GITHUB_SHA} --config-path=gitleaks.toml"
./gitleaks --repo-url=${REPO} -v --redact --commit=${GITHUB_SHA} --config-path=gitleaks.toml
- name: Slack notification
if: failure()
env:
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}
uses: Ilshidur/action-slack@master
with:
args: "Potential Secrets found in: https://github.com/{{ GITHUB_REPOSITORY }}/commit/{{ GITHUB_SHA }} Link to build with full gitleaks output: https://github.com/{{ GITHUB_REPOSITORY }}/commit/{{ GITHUB_SHA }}/checks"
59 changes: 59 additions & 0 deletions .github/workflows/npm-publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
name: npm-publish
on:
push:
branches:
- main
jobs:
npm-publish:
name: npm-publish
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v2

- name: Use Node.js 14.x
uses: actions/setup-node@v2-beta
with:
node-version: 14.x

- name: Cache node modules
uses: actions/cache@v2
env:
cache-name: cache-node-modules
with:
path: ~/.npm
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-build-${{ env.cache-name }}-
${{ runner.os }}-build-
${{ runner.os }}-
- name: Install node dependencies
run: npm ci

- name: Audit dependencies for security vulnerabilities
run: npm audit

- name: Lint the source code
run: npm run-script lint

- name: Check prettier formatting
run: npm run-script check-format

- name: Build the source code
run: npm run build

- name: Execute test coverage
run: npm run-script coverage

- name: Publish if version has been updated
uses: pascalgn/npm-publish-action@master
with: # All of theses inputs are optional
tag_name: "v%s"
tag_message: "v%s"
commit_pattern: "[\\s\\S]*Release (\\S+)"
publish_args: " --access public"
env: # More info about the environment variables in the README
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Leave this as is, it's automatically generated
NPM_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
23 changes: 23 additions & 0 deletions .github/workflows/storybook.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: Storybook
on:
push:
branches:
- develop # if any push happens on branch `develop`, run this workflow. You could also add `paths` to detect changes in specific folder

jobs:
build-and-deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/[email protected]

- name: Install and Build
run: |
npm ci
npm run build-storybook
- name: Deploy
uses: "@madie/madie-design-system/[email protected]"
with:
branch: develop
folder: storybook-static # output folder from `npm run build-storybook`
110 changes: 110 additions & 0 deletions .github/workflows/unit_test_coverage.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
# This workflow will do the following:
# - perform a clean install of node dependencies
# - lint the source code for errors
# - build the source code
# - run tests and capture code coverage
# - run end-to-end tests
# - upload the code coverage report to Codacy
# - upload the code coverage report to Codecov

name: Continuous Integration

on:
push:
branches: [main, develop]
pull_request:
branches: [main, develop]

jobs:
node_matrix:
strategy:
fail-fast: false
matrix:
version: [14, 16]
name: Checkout, install, lint, build and test with coverage
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Use Node.js (matrix)
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.version }}

- name: Cache node modules
uses: actions/cache@v3
env:
cache-name: cache-node-modules
with:
path: ~/.npm
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-build-${{ env.cache-name }}-
${{ runner.os }}-build-
${{ runner.os }}-
- name: Install node dependencies
working-directory: ./react
run: npm ci

- name: Audit dependencies for security vulnerabilities
working-directory: ./react
run: npm audit --production

- name: Lint the source code
working-directory: ./react
run: npm run-script lint

- name: Check prettier formatting
working-directory: ./react
run: npm run-script check-format

- name: Build the source code
working-directory: ./react
run: npm run build

- name: Execute test coverage
working-directory: ./react
run: npm run-script coverage

- name: Store the coverage report as an artifact
uses: actions/upload-artifact@v3
with:
name: coverage
path: react/coverage/lcov.info

upload-codacy-coverage:
name: Upload code coverage to Codacy
needs: node_matrix
runs-on: ubuntu-latest
steps:
- name: Download coverage artifact
uses: actions/download-artifact@v3
with:
name: coverage

- name: Upload code coverage to Codacy
uses: codacy/codacy-coverage-reporter-action@master
with:
project-token: ${{ secrets.CODACY_PROJECT_TOKEN }}
coverage-reports: lcov.info

upload-codecov-coverage:
name: Upload code coverage to Codecov
needs: node_matrix
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Download coverage artifact
uses: actions/download-artifact@v3
with:
name: coverage

- name: Upload code coverage to Codecov
uses: codecov/codecov-action@v2
with:
file: lcov.info
fail_ci_if_error: true
46 changes: 0 additions & 46 deletions react/.storybook/main.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
const path = require('path');
const CopyWebpackPlugin = require('copy-webpack-plugin');

module.exports = {
core: {
Expand All @@ -23,20 +21,6 @@ module.exports = {
webpackFinal: async (config) => {
// do mutation to the config

config.plugins.push(
new CopyWebpackPlugin([
{
from: path.join(__dirname, '..', '..', 'shared', 'fonts/'),
to: 'fonts/',
},
{
from: path.join(__dirname, '..', '..', 'shared', 'images/'),
to: 'images/',
force: true,
},
])
);

config.module.rules.push({
test: /\.scss$/,
resolve: {
Expand All @@ -57,36 +41,6 @@ module.exports = {
],
});

config.module.rules.push({
test: /\.svg$/,
use: [
'raw-loader',
{
loader: 'svgo-loader',
options: {
plugins: [
{ removeTitle: true },
{ convertColors: { shorthex: false } },
{ convertPathData: false },
],
},
},
],
});

// Modify default storybook SVG loader so we can use the one expected by qpp-style
// NOTE: When updating storybook dependency, double check this override.
const staticAssetLoader = config.module.rules.find((rule) => {
const regExp = rule.test;
const isRegExp = regExp && typeof regExp.test === 'function';
return isRegExp && regExp.test('.svg');
});

if (staticAssetLoader) {
// remove svg matching from storybook's default static asset loader
staticAssetLoader.test = /\.(ico|jpg|jpeg|png|gif|eot|otf|webp|ttf|woff|woff2|cur|ani|pdf)(\?.*)?$/;
}

return config;
},
};
14 changes: 10 additions & 4 deletions react/components/Footer/FooterUI.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,11 @@ const FooterUI = (props) => {
<div className="other-links">
<hr className="divider-top" />
<ul className="small">
<li>
<li>
<a
href={setLink("https://harp.cms.gov/login/terms-of-use")}
href={setLink(
"https://harp.cms.gov/login/terms-of-use"
)}
aria-label="Terms of Use"
data-track-category="FooterNav"
data-track-action="OpenTermsOfService"
Expand All @@ -64,7 +66,9 @@ const FooterUI = (props) => {
<li className="divider"></li>{" "}
<li>
<a
href={setLink("https://www.cms.gov/privacy")}
href={setLink(
"https://www.cms.gov/privacy"
)}
aria-label="Privacy Policy"
data-track-category="FooterNav"
data-track-action="OpenPrivacyPolicy"
Expand All @@ -76,7 +80,9 @@ const FooterUI = (props) => {
<li className="divider"></li>{" "}
<li>
<a
href={setLink("https://www.hhs.gov/web/governance/digital-strategy/it-policy-archive/hhs-rules-of-behavior-for-the-use-of-hhs-information-and-it-resources-policy.html")}
href={setLink(
"https://www.hhs.gov/web/governance/digital-strategy/it-policy-archive/hhs-rules-of-behavior-for-the-use-of-hhs-information-and-it-resources-policy.html"
)}
aria-label="Rules of Behavior"
data-track-category="FooterNav"
data-track-action="OpenRulesofBehavior"
Expand Down
Loading

0 comments on commit 34c21c0

Please sign in to comment.