Skip to content

Commit

Permalink
Merge pull request #1226 from topcoder-platform/develop
Browse files Browse the repository at this point in the history
[PROD] Milestone Management
  • Loading branch information
RishiRajSahu authored Aug 16, 2021
2 parents b1f397e + 2cd8f6b commit ec46a86
Show file tree
Hide file tree
Showing 41 changed files with 4,226 additions and 58 deletions.
103 changes: 95 additions & 8 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -1,20 +1,44 @@
version: 2
version: 2.1
parameters:
run_basedeployment:
default: true
type: boolean
run_smoketesting:
default: false
type: boolean

defaults: &defaults
docker:
- image: circleci/python:2.7-stretch-browsers

test_defaults: &test_defaults
docker:
- image: docker:17.11.0-ce-git

install_dependency: &install_dependency
name: Installation of build and deployment dependencies.
command: |
sudo apt install jq
sudo pip install awscli --upgrade
sudo pip install docker-compose
install_test_dependency: &install_test_dependency
name: Installation of build and deployment dependencies.
command: |
apk update
apk add --no-cache bash openssl curl
apk upgrade
apk add --no-cache jq py-pip sudo
sudo pip install awscli --upgrade
install_deploysuite: &install_deploysuite
name: Installation of install_deploysuite.
command: |
git clone --branch v1.4 https://github.com/topcoder-platform/tc-deploy-scripts ../buildscript
cp ./../buildscript/master_deploy.sh .
cp ./../buildscript/buildenv.sh .
cp ./../buildscript/awsconfiguration.sh .
restore_cache_settings_for_build: &restore_cache_settings_for_build
key: docker-node-modules-28-10-2020-{{ checksum "package-lock.json" }}

Expand All @@ -35,7 +59,7 @@ builddeploy_steps: &builddeploy_steps
./buildenv.sh -e $DEPLOY_ENV -b ${LOGICAL_ENV}-${APPNAME}-buildvar
echo awsenvconf >.dockerignore
echo buildenvvar >>.dockerignore
- run:
- run:
name: "building image"
command: |
source buildenvvar
Expand All @@ -48,7 +72,35 @@ builddeploy_steps: &builddeploy_steps
./buildenv.sh -e $DEPLOY_ENV -b ${LOGICAL_ENV}-${APPNAME}-deployvar
source buildenvvar
./master_deploy.sh -d ECS -e $DEPLOY_ENV -t latest -s ${LOGICAL_ENV}-global-appvar,${LOGICAL_ENV}-${APPNAME}-appvar -i ${APPNAME}
curl --request POST \
--url https://circleci.com/api/v2/project/github/$CIRCLE_PROJECT_USERNAME/$CIRCLE_PROJECT_REPONAME/pipeline \
--header "Circle-Token: ${CIRCLE_TOKEN}" \
--header 'content-type: application/json' \
--data '{"branch":"'"$CIRCLE_BRANCH"'","parameters":{"run_smoketesting":true, "run_basedeployment": false}}'
# Automated Smoke Testing
smoke_testing: &smoke_testing
# Initialization.
- checkout
- setup_remote_docker
- run: *install_test_dependency
- run: *install_deploysuite
# Restoration of node_modules from cache.
- restore_cache: *restore_cache_settings_for_build
- run:
name: "configuring environment"
command: |
./awsconfiguration.sh $DEPLOY_ENV
./buildenv.sh -e $DEPLOY_ENV -b ${LOGICAL_ENV}-${APPNAME}-buildvar
- run:
name: "Run automation"
no_output_timeout: 20m
command: |
source awsenvconf
source buildenvvar
./test-automation/smoketest.sh
- store_artifacts:
path: ./test-automation/test-results

jobs:
# Build & Deploy against development backend
Expand All @@ -59,34 +111,69 @@ jobs:
LOGICAL_ENV: "dev"
NODE_ENV: "development"
BABEL_ENV: "development"
APPNAME: "challenge-engine-ui"
APPNAME: "challenge-engine-ui"
steps: *builddeploy_steps

"build-prod":
<<: *defaults
environment:
DEPLOY_ENV: "PROD"
LOGICAL_ENV: "prod"
LOGICAL_ENV: "prod"
NODE_ENV: "production"
BABEL_ENV: "production"
APPNAME: "challenge-engine-ui"
APPNAME: "challenge-engine-ui"
steps: *builddeploy_steps

"smoke-testing-dev":
<<: *test_defaults
environment:
DEPLOY_ENV: "DEV"
LOGICAL_ENV: "dev"
APPNAME: "challenge-engine-ui"
steps: *smoke_testing

"smoke-testing-prod":
<<: *test_defaults
environment:
DEPLOY_ENV: "PROD"
LOGICAL_ENV: "prod"
APPNAME: "challenge-engine-ui"
steps: *smoke_testing

workflows:
version: 2
build:
when: << pipeline.parameters.run_basedeployment >>
jobs:
# Development builds are executed on "develop" branch only.
- "build-dev":
context : org-global
filters:
filters: &filters-dev
branches:
only: ['develop', 'feature/bug-bash-july']
only: ['develop', 'feature/linking-challenge-milestone']

# Production builds are exectuted only on tagged commits to the
# master branch.
- "build-prod":
context : org-global
filters:
filters: &filters-prod
branches:
only: master

Smoke Testing:
when: << pipeline.parameters.run_smoketesting >>
jobs:
- Hold [Smoke-Testing]:
type: approval
- smoke-testing-dev:
context : org-global
requires:
- Hold [Smoke-Testing]
filters:
<<: *filters-dev
- smoke-testing-prod:
context : org-global
requires:
- Hold [Smoke-Testing]
filters:
<<: *filters-prod
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.

# dependencies
/node_modules
node_modules
/.pnp
.pnp.js
.idea
Expand All @@ -27,3 +27,7 @@ yarn-error.log*
*.env

*.vscode

# e2e test case
test-automation/temp
test-automation/test-results
92 changes: 71 additions & 21 deletions src/actions/challenges.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ import {
LOAD_CHALLENGE_RESOURCES
} from '../config/constants'
import { loadProject } from './projects'
import { removeChallengeFromPhaseProduct, saveChallengeAsPhaseProduct } from '../services/projects'

/**
* Member challenges related redux actions
Expand Down Expand Up @@ -203,16 +204,34 @@ export function loadGroupDetails (groupIds) {
*
* @param {String} challengeId challenge id
* @param {Object} challengeDetails challenge data
*
* @param {String} projectId project id
* @returns {Promise<{ type: string, challengeDetails: object }>} action object
*/
export function updateChallengeDetails (challengeId, challengeDetails) {
export function updateChallengeDetails (challengeId, challengeDetails, projectId) {
return async (dispatch) => {
dispatch({
type: UPDATE_CHALLENGE_DETAILS_PENDING
})

return updateChallenge(challengeId, challengeDetails).then((challenge) => {
const milestoneId = challengeDetails.milestoneId
// Check if milestone is deleted or updated
const hasMilestone = _.has(challengeDetails, 'milestoneId')

if (hasMilestone) {
delete challengeDetails.milestoneId
}
return updateChallenge(challengeId, challengeDetails).then(async challenge => {
if (hasMilestone) {
if (milestoneId && milestoneId !== -1) {
await saveChallengeAsPhaseProduct(projectId, milestoneId, challengeId)
challenge.milestoneId = milestoneId
} else {
await removeChallengeFromPhaseProduct(projectId, challengeId)
challenge.milestoneId = milestoneId
}
}
return challenge
}).then((challenge) => {
return dispatch({
type: UPDATE_CHALLENGE_DETAILS_SUCCESS,
challengeDetails: challenge
Expand All @@ -231,26 +250,39 @@ export function updateChallengeDetails (challengeId, challengeDetails) {
* Create a new challenge
*
* @param {Object} challengeDetails challenge data
* @param {String} projectId project id
*
* @returns {Promise<{ type: string, challengeDetails: object }>} action object
*/
export function createChallenge (challengeDetails) {
export function createChallenge (challengeDetails, projectId) {
console.log(challengeDetails)
return async (dispatch) => {
dispatch({
type: CREATE_CHALLENGE_PENDING
})

return createChallengeAPI(challengeDetails).then((challenge) => {
return dispatch({
type: CREATE_CHALLENGE_SUCCESS,
challengeDetails: challenge
const milestoneId = challengeDetails.milestoneId
if (milestoneId) {
delete challengeDetails.milestoneId
}
return createChallengeAPI(challengeDetails)
.then(async challenge => {
if (milestoneId && milestoneId !== -1) {
await saveChallengeAsPhaseProduct(projectId, milestoneId, challenge.id, true)
challenge.milestoneId = milestoneId
}
return challenge
})
}).catch((e) => {
dispatch({
type: CREATE_CHALLENGE_FAILURE,
error: e
.then((challenge) => {
return dispatch({
type: CREATE_CHALLENGE_SUCCESS,
challengeDetails: challenge
})
}).catch((e) => {
dispatch({
type: CREATE_CHALLENGE_FAILURE,
error: e
})
})
})
}
}

Expand All @@ -261,16 +293,32 @@ export function createChallenge (challengeDetails) {
*
* @param {String} challengeId challenge id
* @param {Object} partialChallengeDetails partial challenge data
*
* @param {String} projectId project id
* @returns {Promise<{ type: string, challengeDetails: object }>} action object
*/
export function partiallyUpdateChallengeDetails (challengeId, partialChallengeDetails) {
export function partiallyUpdateChallengeDetails (challengeId, partialChallengeDetails, projectId) {
return async (dispatch) => {
dispatch({
type: UPDATE_CHALLENGE_DETAILS_PENDING
})

return patchChallenge(challengeId, partialChallengeDetails).then((challenge) => {
const milestoneId = partialChallengeDetails.milestoneId
// Check if milestone is deleted or updated
const hasMilestone = _.has(partialChallengeDetails, 'milestoneId')
if (hasMilestone) {
delete partialChallengeDetails.milestoneId
}
return patchChallenge(challengeId, partialChallengeDetails).then(async challenge => {
if (hasMilestone) {
if (milestoneId && milestoneId !== -1) {
await saveChallengeAsPhaseProduct(projectId, milestoneId, challenge.id)
challenge.milestoneId = milestoneId
} else {
await removeChallengeFromPhaseProduct(projectId, challengeId)
challenge.milestoneId = milestoneId
}
}
return challenge
}).then((challenge) => {
return dispatch({
type: UPDATE_CHALLENGE_DETAILS_SUCCESS,
challengeDetails: challenge
Expand All @@ -284,13 +332,15 @@ export function partiallyUpdateChallengeDetails (challengeId, partialChallengeDe
}
}

export function deleteChallenge (challengeId) {
export function deleteChallenge (challengeId, projectId) {
return async (dispatch) => {
dispatch({
type: DELETE_CHALLENGE_PENDING
})

return deleteChallengeAPI(challengeId).then((challenge) => {
return deleteChallengeAPI(challengeId).then(async challenge => {
await removeChallengeFromPhaseProduct(projectId, challengeId)
return challenge
}).then((challenge) => {
return dispatch({
type: DELETE_CHALLENGE_SUCCESS,
challengeDetails: challenge
Expand Down
11 changes: 9 additions & 2 deletions src/actions/projects.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import {
LOAD_PROJECT_BILLING_ACCOUNT,
LOAD_CHALLENGE_MEMBERS_SUCCESS,
LOAD_PROJECT_DETAILS
LOAD_PROJECT_DETAILS,
LOAD_PROJECT_PHASES
} from '../config/constants'
import { fetchProjectById, fetchBillingAccount } from '../services/projects'
import { fetchProjectById, fetchBillingAccount, fetchProjectPhases } from '../services/projects'

/**
* Loads project details
Expand All @@ -27,6 +28,12 @@ export function loadProject (projectId) {
payload: fetchBillingAccount(projectId)
})

// Loads project phases
dispatch({
type: LOAD_PROJECT_PHASES,
payload: fetchProjectPhases(projectId)
})

return project
})
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,15 @@
}
}

&.successDark {
@include roboto-bold;
background-color: $tc-green-50;
&:disabled {
cursor: default;
background-color: $inactive;
}
}

/* this style just visually simulates the disable status of the button */
&.disabled {
cursor: default;
Expand Down
Loading

0 comments on commit ec46a86

Please sign in to comment.