Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Environment Sync, Dev to Test #443

Merged
merged 16 commits into from
Oct 8, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
16 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,21 @@
"prettier",
"react"
],
"settings": {
"jsdoc": {
"preferredTypes": {
"delete": "delete",
"get": "get",
"post": "post",
"put": "put",
"json": "json",
"text": "text",
"delayResponse": "DelayResponse",
"forceStatus": "ForceStatus",
"randomSuccess": "RandomSuccess"
}
}
},
"extends": [
"react-app",
"airbnb",
Expand Down Expand Up @@ -46,7 +61,7 @@
],
"import/no-named-as-default": 0,
"import/no-named-as-default-member": 0,
"jest/no-test-callback": 0,
"jest/no-done-callback": 0,
"jest/prefer-to-have-length": 0,
"jsdoc/check-tag-names": [
2,
Expand Down
7 changes: 7 additions & 0 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,13 @@

<!-- ### Notes -->
<!-- Any issues that aren't resolved by this merge request, or things of note? -->
<!--
When moving between environments notify a specific party
1. local > CI, Dev, Design should be assigned when relative
1. CI > QA, QE, CCS/docs should be notified
1. QA > Stage, QE and CCS/docs should be notified, AND applied as PR reviewers
1. Stage > Prod, QE and CCS/docs should be notified, AND applied as PR reviewers
-->

## How to test
<!-- Are there directions to test/review? -->
Expand Down
36 changes: 36 additions & 0 deletions .github/workflows/commit_lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: Commit lint
on:
pull_request
env:
BRANCH: ${{ github.base_ref }}

jobs:
Commits:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [12.x]
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Git commits
run: |
git remote add ssh-origin "https://github.com/$GITHUB_REPOSITORY"
git fetch ssh-origin
COMMITS=$(git cherry -v ssh-origin/${{ env.BRANCH }} | grep "+")
echo ::set-env name=GIT_COMMITS::$COMMITS
- name: Setup Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
- name: Lint
uses: actions/github-script@v2
with:
script: |
const actionCommit = require(`${process.env.GITHUB_WORKSPACE}/scripts/actions.commit.js`)
const { resultsArray, resultsString } = actionCommit(process.env.GIT_COMMITS)

if (resultsArray.length) {
core.setFailed(resultsString)
}
79 changes: 79 additions & 0 deletions .github/workflows/pull_request.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
name: Pull request
on:
pull_request:
branches: [ master, main, prod, stage, test**, qa**, dev**, ci** ]
env:
BRANCH: ${{ github.base_ref }}

jobs:
Integration-checks:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [12.x]
steps:
- uses: actions/checkout@v2
- name: Setup Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
- name: Set Node.js packages yarn cache directory
id: yarn-cache-dir
run: echo ::set-output name=CACHE_DIR::$(yarn cache dir)
- name: Node.js yarn cache
uses: actions/cache@v2
with:
path: ${{ steps.yarn-cache-dir.outputs.CACHE_DIR }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn
- name: Node.js modules cache
uses: actions/cache@v2
id: modules-cache
with:
path: ${{ github.workspace }}/node_modules
key: ${{ runner.os }}-${{ matrix.node-version }}-modules-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-${{ matrix.node-version }}-modules
- name: Install Node.js packages
if: ${{ steps.modules-cache.outputs.cache-hit != 'true' }}
run: yarn install
- name: Lint and test
uses: actions/github-script@v2
with:
script: |
const { execSync } = require('child_process');
try {
console.log(`${execSync('yarn test', { stdio: 'pipe' })}`);
} catch ({ stdout, stderr }) {
core.setFailed(`${stdout}\n${stderr}`);
}
- name: Code coverage
if: ${{ success() }}
uses: codecov/codecov-action@v1
- name: Confirm beta integration
if: ${{ success() }}
uses: actions/github-script@v2
with:
script: |
const { execSync } = require('child_process');
try {
console.log(`${execSync('yarn build', { stdio: 'pipe' })}`);
} catch ({ stdout, stderr }) {
core.setFailed(`${stdout}\n${stderr}`);
}
env:
BUILD_STAGE: Beta
- name: Confirm stable integration
if: ${{ success() }}
uses: actions/github-script@v2
with:
script: |
const { execSync } = require('child_process');
try {
console.log(`${execSync('yarn build', { stdio: 'pipe' })}`);
} catch ({ stdout, stderr }) {
core.setFailed(`${stdout}\n${stderr}`);
}
env:
BUILD_STAGE: Stable
2 changes: 1 addition & 1 deletion .travis/custom_release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ releaseProd()
release "prod-beta"
fi

if [[ "${TRAVIS_BRANCH}" = "prod-stable" || "${TRAVIS_BRANCH}" = "master" ]] && [[ $TRAVIS_BUILD_STAGE_NAME != *"Beta"* ]]; then
if [[ "${TRAVIS_BRANCH}" = "prod-stable" || "${TRAVIS_BRANCH}" = "prod" || "${TRAVIS_BRANCH}" = "main" || "${TRAVIS_BRANCH}" = "master" ]] && [[ $TRAVIS_BUILD_STAGE_NAME != *"Beta"* ]]; then
release "prod-stable"
fi
}
Expand Down
10 changes: 10 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,16 @@ This project makes use of reserved DOM attributes used by the QE team.
1. Attribute `data-test`

DOM attributes with `data-test=""` are used by QE as a means to identify specific DOM elements.

### Reserved Files
#### Spandx Config
The configuration file(s) within this directory are utilized primarily during the `$ yarn start:proxy` local development run.

This file(s) has multiple team and build dependencies. **Before relocating/moving this file(s) the appropriate teams should be informed.**
- Development team
- QE team

There is a related integration test snapshot(s), `./tests/platform.test.js` that will need to be updated if this file(s) is updated.

## Testing
To test content you'll need to have Node and Yarn installed.
Expand Down
4 changes: 4 additions & 0 deletions config/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Spandx Config
This file(s) has multiple team and build dependencies. **Before relocating/moving this file(s) the appropriate teams should be informed.**

[See CONTRIBUTING.md for up-to-date information](../CONTRIBUTING.md#spandx-config)
56 changes: 28 additions & 28 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -99,65 +99,65 @@
"test:local": "react-scripts test --env=jsdom --roots=./src"
},
"dependencies": {
"@patternfly/patternfly": "4.23.3",
"@patternfly/react-charts": "6.6.0",
"@patternfly/react-core": "4.32.1",
"@patternfly/react-icons": "4.5.0",
"@patternfly/react-styles": "4.5.0",
"@patternfly/react-table": "4.12.1",
"@patternfly/react-tokens": "4.6.0",
"@redhat-cloud-services/frontend-components": "2.3.13",
"@redhat-cloud-services/frontend-components-notifications": "2.1.1",
"@redhat-cloud-services/frontend-components-utilities": "2.1.0",
"axios": "^0.19.2",
"c3": "^0.7.18",
"@patternfly/patternfly": "4.35.2",
"@patternfly/react-charts": "6.9.6",
"@patternfly/react-core": "4.47.0",
"@patternfly/react-icons": "4.7.4",
"@patternfly/react-styles": "4.7.3",
"@patternfly/react-table": "4.16.7",
"@patternfly/react-tokens": "4.9.6",
"@redhat-cloud-services/frontend-components": "2.4.5",
"@redhat-cloud-services/frontend-components-notifications": "2.2.1",
"@redhat-cloud-services/frontend-components-utilities": "2.2.1",
"axios": "^0.20.0",
"c3": "^0.7.20",
"classnames": "^2.2.6",
"i18next": "^19.6.2",
"i18next": "^19.7.0",
"i18next-xhr-backend": "^3.2.2",
"js-cookie": "^2.2.1",
"locale-code": "^2.0.2",
"lodash": "^4.17.19",
"lodash": "^4.17.20",
"moment": "^2.27.0",
"node-sass": "^4.14.1",
"prop-types": "^15.7.2",
"react": "^16.13.1",
"react-dom": "^16.13.1",
"react-i18next": "^11.7.0",
"react-redux": "^7.2.0",
"react-i18next": "^11.7.2",
"react-redux": "^7.2.1",
"react-router": "^5.2.0",
"react-router-dom": "^5.2.0",
"react-scripts": "3.4.1",
"react-scripts": "3.4.3",
"redux": "^4.0.5",
"redux-logger": "^3.0.6",
"redux-promise-middleware": "^6.1.2",
"redux-thunk": "^2.3.0",
"reselect": "^4.0.0",
"victory": "^35.0.5",
"victory-core": "^35.0.5",
"victory-legend": "^35.0.5"
"victory": "^35.0.9",
"victory-core": "^35.0.8",
"victory-legend": "^35.0.8"
},
"devDependencies": {
"apidoc-mock": "^3.0.2",
"enzyme": "^3.11.0",
"enzyme-adapter-react-16": "^1.15.2",
"enzyme-adapter-react-16": "^1.15.4",
"enzyme-to-json": "^3.5.0",
"eslint-config-airbnb": "^18.2.0",
"eslint-config-prettier": "^6.11.0",
"eslint-plugin-import": "^2.22.0",
"eslint-plugin-jest": "^23.18.0",
"eslint-plugin-jsdoc": "^29.2.0",
"eslint-plugin-json": "^2.1.1",
"eslint-plugin-jest": "^24.0.0",
"eslint-plugin-jsdoc": "^30.4.0",
"eslint-plugin-json": "^2.1.2",
"eslint-plugin-jsx-a11y": "^6.3.1",
"eslint-plugin-prettier": "^3.1.4",
"eslint-plugin-react": "^7.20.3",
"eslint-plugin-react-hooks": "^4.0.8",
"eslint-plugin-react": "^7.20.6",
"eslint-plugin-react-hooks": "^4.1.0",
"express": "^4.17.1",
"glob": "^7.1.6",
"moxios": "^0.4.0",
"npm-run-all": "^4.1.5",
"prettier": "^2.0.5",
"prettier": "^2.1.1",
"redux-mock-store": "^1.5.4",
"standard-version": "^8.0.2",
"standard-version": "^9.0.0",
"swagger-ui-express": "^4.1.4",
"yamljs": "^0.3.0"
},
Expand Down
98 changes: 98 additions & 0 deletions scripts/actions.commit.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
/**
* Breakout individual commits.
*
* @param {string} commits
* @returns {{issueNumber: string, description: string, trimmedMessage: string, hash: string, typeScope: string}[]}
*/
const messages = commits =>
commits
.trim()
.replace(/\n/g, '')
.replace(/\+\s/g, '\n')
.replace(/\n/, '')
.split(/\n/g)
.map(message => {
const [hashTypeScope, ...issueNumberDescription] =
(/:/.test(message) && message.split(/:/)) || message.split(/\s/);

const [hash, typeScope = ''] = hashTypeScope.split(/\s/);
const [issueNumber, ...description] = issueNumberDescription.join(' ').trim().split(/\s/g);

const updatedTypeScope = (typeScope && `${typeScope}:`) || '';
const updatedDescription = description.join(' ');
const [updatedMessage, remainingMessage = ''] = `${updatedTypeScope} ${issueNumber} ${updatedDescription}`.split(
/\(#\d{1,5}\)/
);

return {
trimmedMessage:
(remainingMessage.trim().length === 0 && updatedMessage.trim()) ||
`${updatedTypeScope} ${issueNumber} ${updatedDescription}`,
hash,
typeScope: updatedTypeScope,
issueNumber,
description: updatedDescription
};
});

/**
* Apply valid/invalid checks.
*
* @param {Array} parsedMessages
* @returns {Array}
*/
const messagesList = parsedMessages =>
parsedMessages.map(message => {
const { trimmedMessage = null, typeScope = null, issueNumber = null, description = null } = message;

const issueNumberException =
/(^chore\([\d\D]+\))|(^fix\([\d\D]+\))|(^perf\([\d\D]+\))|(^build\([\d\D]+\))|(^[\d\D]+\(build\))/.test(
typeScope
) || /\(#[\d\D]+\)$/.test(description);

const typeScopeValid = (/(^[\d\D]+\([\d\D]+\):$)|(^[\d\D]+:$)/.test(typeScope) && 'valid') || 'INVALID: type scope';

const issueNumberValid =
(/(^issues\/[\d,]+$)/.test(issueNumber) && 'valid') ||
(issueNumberException && 'valid') ||
'INVALID: issue number';

const descriptionValid =
(/(^[\d\D]+$)/.test(description || (issueNumberException && issueNumber)) && 'valid') ||
(issueNumberException && !description && issueNumber && 'valid') ||
'INVALID: description';

const lengthValid =
(trimmedMessage && trimmedMessage.length <= 65 && 'valid') ||
`INVALID: message length (${trimmedMessage && trimmedMessage.length} > 65)`;

// <type>([scope]): issues/<number> <description> <messageLength>
return `${typeScope}<${typeScopeValid}> ${issueNumber}<${issueNumberValid}> ${description}<${descriptionValid}><${lengthValid}>`;
});

/**
* Remove valid commits.
*
* @param {Array} parsedMessagesList
* @returns {Array}
*/
const filteredMessages = parsedMessagesList =>
parsedMessagesList.filter(value => !/<valid>[\d\D]*<valid>[\d\D]*<valid><valid>/.test(value));

/**
* If commits exist, lint them.
*
* @param {string} commits
* @returns {{resultsArray: Array, resultsString: string}}
*/
module.exports = commits => {
const lintResults = { resultsArray: [], resultsString: '' };

if (commits) {
const parsedResults = filteredMessages(messagesList(messages(commits)));
lintResults.resultsArray = parsedResults;
lintResults.resultsString = JSON.stringify(parsedResults, null, 2);
}

return lintResults;
};
Loading