Skip to content

Commit c71bc7e

Browse files
author
Doug Toppin
committed
Add pipeline related configuration files
1 parent d0ead90 commit c71bc7e

File tree

3 files changed

+183
-0
lines changed

3 files changed

+183
-0
lines changed

buildspec.yml

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
version: 0.2
2+
3+
phases:
4+
install:
5+
runtime-versions:
6+
nodejs: 16
7+
pre_build:
8+
commands:
9+
- npm install -g [email protected]
10+
- echo "Installing dependencies and executing unit tests - `pwd`"
11+
- cd deployment && chmod +x ./run-unit-tests.sh && ./run-unit-tests.sh
12+
- echo "Installing dependencies and executing unit tests completed `date`"
13+
build:
14+
commands:
15+
- echo "Starting build `date` in `pwd`"
16+
- chmod +x ./build-s3-dist.sh && ./build-s3-dist.sh $DIST_OUTPUT_BUCKET $SOLUTION_NAME $VERSION
17+
- echo "Build completed `date`"
18+
- echo "Starting open-source-dist `date` in `pwd`"
19+
- chmod +x ./build-open-source-dist.sh && ./build-open-source-dist.sh $SOLUTION_NAME
20+
- echo "Open Source Dist completed `date`"
21+
post_build:
22+
commands:
23+
- echo "Retrieving next stage buildspec `date` in `pwd`"
24+
- aws s3 cp s3://solutions-build-assets/changelog-spec.yml ../buildspec.yml
25+
- echo "Retrieving next stage buildspec complete"
26+
- echo "Post build completed on `date`"
27+
28+
artifacts:
29+
files:
30+
- deployment/**/*
31+
- source/**/*
32+
- CHANGELOG.md
33+
- buildspec.yml
34+
- sonar-project.properties
35+
- .gitignore

deployment/build-open-source-dist.sh

+78
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
#!/bin/bash
2+
#
3+
# This assumes all of the OS-level configuration has been completed and git repo has already been cloned
4+
#
5+
# This script should be run from the repo's deployment directory
6+
# cd deployment
7+
# ./build-open-source-dist.sh solution-name
8+
#
9+
# Parameters:
10+
# - solution-name: name of the solution for consistency
11+
12+
# Check to see if input has been provided:
13+
if [ -z "$1" ]; then
14+
echo "Please provide the trademark approved solution name for the open source package."
15+
echo "For example: ./build-open-source-dist.sh trademarked-solution-name"
16+
exit 1
17+
fi
18+
19+
# Get reference for all important folders
20+
source_template_dir="$PWD"
21+
dist_dir="$source_template_dir/open-source"
22+
dist_template_dir="$dist_dir/deployment"
23+
source_dir="$source_template_dir/../source"
24+
25+
echo "------------------------------------------------------------------------------"
26+
echo "[Init] Clean old open-source folder"
27+
echo "------------------------------------------------------------------------------"
28+
rm -rf $dist_dir
29+
mkdir -p $dist_dir
30+
mkdir -p $dist_template_dir
31+
32+
echo "------------------------------------------------------------------------------"
33+
echo "[Packing] Build Script"
34+
echo "------------------------------------------------------------------------------"
35+
cp $source_template_dir/build-s3-dist.sh $dist_template_dir
36+
cp $source_template_dir/run-unit-tests.sh $dist_template_dir
37+
38+
echo "------------------------------------------------------------------------------"
39+
echo "[Packing] Architecture diagram"
40+
echo "------------------------------------------------------------------------------"
41+
cp $source_template_dir/../architecture.png $dist_dir
42+
43+
echo "------------------------------------------------------------------------------"
44+
echo "[Packing] Source folder and clean up the pacakge"
45+
echo "------------------------------------------------------------------------------"
46+
rsync -avq --progress $source_dir $dist_dir --exclude node_modules
47+
find $dist_dir -iname "dist" -type d -exec rm -rf "{}" \; 2>/dev/null
48+
find $dist_dir -iname "node_modules" -type d -exec rm -rf "{}" \; 2>/dev/null
49+
find $dist_dir -iname "coverage" -type d -exec rm -rf "{}" \; 2>/dev/null
50+
find $dist_dir -type f -name 'package-lock.json' -delete
51+
find $dist_dir/source/constructs -iname "cdk.out" -type d -exec rm -rf "{}" \; 2>/dev/null
52+
find $dist_dir -type f -name '.DS_Store' -delete
53+
54+
echo "------------------------------------------------------------------------------"
55+
echo "Removing unit test coverage files used by SonarQube"
56+
echo "------------------------------------------------------------------------------"
57+
rm -rf $dist_dir/source/test
58+
59+
echo "------------------------------------------------------------------------------"
60+
echo "[Packing] Root files"
61+
echo "------------------------------------------------------------------------------"
62+
cp $source_template_dir/../LICENSE.txt $dist_dir
63+
cp $source_template_dir/../NOTICE.txt $dist_dir
64+
cp $source_template_dir/../README.md $dist_dir
65+
cp $source_template_dir/../CODE_OF_CONDUCT.md $dist_dir
66+
cp $source_template_dir/../CONTRIBUTING.md $dist_dir
67+
cp $source_template_dir/../CHANGELOG.md $dist_dir
68+
cp $source_template_dir/../.gitignore $dist_dir
69+
cp -r $source_template_dir/../.github $dist_dir
70+
71+
echo "------------------------------------------------------------------------------"
72+
echo "Creating GitHub (open-source) zip file"
73+
echo "------------------------------------------------------------------------------"
74+
cd $dist_dir
75+
zip -q -r9 ../$1.zip * .github .gitignore
76+
rm -rf * .github .gitignore
77+
mv ../$1.zip .
78+
echo "Completed building $1.zip"

sonar-project.properties

+70
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
# Customize sonar.sources, sonar.exclusions, sonar.coverage.exclusions, sonar.tests and sonar
2+
# unit test coverage reports based on your solutions
3+
4+
# Refer to https://docs.sonarqube.org/latest/project-administration/narrowing-the-focus/
5+
# for details on sources and exclusions. Note also .gitignore
6+
#
7+
sonar.sources=source, deployment
8+
9+
# Focusing sonarqube analysis on non test code first and reducing noise from analysis of test code. Projects
10+
# can customize the exclusions to include analyzing of test code if desired
11+
sonar.exclusions= **/dist/**, \
12+
deployment/**
13+
14+
# Code coverage Specific Properties
15+
sonar.coverage.exclusions= **/jest.config.js, \
16+
**/test/**, \
17+
**/test*, \
18+
source/demo-ui/**, \
19+
source/constructs/bin/constructs.ts
20+
21+
# Ignoring duplications
22+
sonar.cpd.exclusions=source/image-handler/test/**/*.ts, \
23+
source/custom-resource/test/*.ts
24+
25+
# Ignoring following issues, false warnings
26+
sonar.issue.ignore.multicriteria=e1, e2, e3, e4, e5, e6, e7, e8
27+
28+
# Enabling Cross-Origin Resource Sharing is security-sensitive.
29+
sonar.issue.ignore.multicriteria.e1.ruleKey=typescript:S5122
30+
sonar.issue.ignore.multicriteria.e1.resourceKey=source/image-handler/test/index.spec.ts
31+
32+
# Enabling Cross-Origin Resource Sharing is security-sensitive.
33+
sonar.issue.ignore.multicriteria.e2.ruleKey=typescript:S5122
34+
sonar.issue.ignore.multicriteria.e2.resourceKey=source/constructs/lib/serverless-image-stack.ts
35+
36+
# Enabling Cross-Origin Resource Sharing is security-sensitive.
37+
sonar.issue.ignore.multicriteria.e3.ruleKey=typescript:S5122
38+
sonar.issue.ignore.multicriteria.e3.resourceKey=source/image-handler/index.ts
39+
40+
# Using regular expressions is security-sensitive.
41+
sonar.issue.ignore.multicriteria.e4.ruleKey=typescript:S4784
42+
sonar.issue.ignore.multicriteria.e4.resourceKey=source/image-handler/thumbor-mapper.ts
43+
44+
# Hashing data is security-sensitive
45+
sonar.issue.ignore.multicriteria.e5.ruleKey=typescript:S4790
46+
sonar.issue.ignore.multicriteria.e5.resourceKey=source/custom-resource/index.ts
47+
48+
# Hashing data is security-sensitive
49+
sonar.issue.ignore.multicriteria.e6.ruleKey=typescript:S4790
50+
sonar.issue.ignore.multicriteria.e6.resourceKey=source/demo-ui/scripts.js
51+
52+
# Using regular expressions is security-sensitive.
53+
sonar.issue.ignore.multicriteria.e7.ruleKey=typescript:S4784
54+
sonar.issue.ignore.multicriteria.e7.resourceKey=source/image-handler/image-request.ts
55+
56+
# Using regular expressions is security-sensitive.
57+
sonar.issue.ignore.multicriteria.e8.ruleKey=javascript:S4784
58+
sonar.issue.ignore.multicriteria.e8.resourceKey=source/demo-ui/scripts.js
59+
60+
# Sensor SonarJS Coverage [javascript] was not allowing globbing
61+
# for sonar.javascript.lcov.reportPaths such as this
62+
# source/test/coverage-reports/jest/*/lcov.info
63+
# so we have to provide an explicit list of reportPaths
64+
sonar.javascript.lcov.reportPaths= \
65+
source/test/coverage-reports/jest/constructs/lcov.info, \
66+
source/test/coverage-reports/jest/custom-resource/lcov.info, \
67+
source/test/coverage-reports/jest/image-handler/lcov.info
68+
69+
# Encoding of the source files
70+
sonar.sourceEncoding=UTF-8

0 commit comments

Comments
 (0)