Skip to content

Commit fac79af

Browse files
authored
Merge pull request #3949 from devgateway/develop
AMP-30352 3.5.5 release
2 parents f3261b1 + 5de62ef commit fac79af

File tree

226 files changed

+157636
-16987
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

226 files changed

+157636
-16987
lines changed

.gitignore

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,7 @@
11
amp/TEMPLATE/ampTemplate/node_modules/amp-settings/dist/
22
amp/TEMPLATE/ampTemplate/node_modules/amp-settings/src/compiled-css/amp-settings.css
33
amp/TEMPLATE/ampTemplate/node_modules/amp-settings/src/compiled-js/amp-settings.js
4-
amp/TEMPLATE/reamp/modules/gpi-reports/script.min.js
5-
amp/TEMPLATE/reamp/modules/gpi-data/script.min.js
6-
amp/TEMPLATE/reamp/modules/admin/resource-manager-admin/script.min.js
7-
amp/TEMPLATE/reamp/modules/admin/data-freeze-manager/script.min.js
8-
amp/TEMPLATE/reamp/modules/admin/dashboard/script.min.js
9-
amp/TEMPLATE/reamp/modules/admin/currency/deflator/script.min.js
104
amp/TEMPLATE/ampTemplate/node_modules/amp-boilerplate/src/compiled-js/amp-boilerplate.js
11-
amp/TEMPLATE/reamp/node/
125
amp/TEMPLATE/ampTemplate/node_modules_10/
136
amp/TEMPLATE/ampTemplate/node_modules/amp-filter/node/node_modules/
147
amp/TEMPLATE/ampTemplate/node_modules/amp-filter/node/
@@ -18,7 +11,6 @@ amp/TEMPLATE/ampTemplate/node_modules/amp-filter/dist/amp-filter.css
1811
amp/TEMPLATE/ampTemplate/node_modules/amp-filter/src/compiled-css/amp-filter.css
1912
amp/TEMPLATE/ampTemplate/node_modules/amp-filter/src/compiled-js/amp-filter.js
2013
amp/TEMPLATE/ampTemplate/node_modules/amp-filter/dist/amp-filter.js
21-
amp/TEMPLATE/reamp/modules/admin/performance-alert-manager/script.min.js
2214
amp/TEMPLATE/ampTemplate/node_modules/amp-state/node/
2315
amp/TEMPLATE/ampTemplate/node_modules/amp-translate/node/
2416
amp/TEMPLATE/ampTemplate/node_modules/amp-translate/node_modules/

Jenkinsfile

Lines changed: 43 additions & 119 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,10 @@ println "Pull request: ${pr}"
2222
println "Tag: ${tag}"
2323

2424
def dbVersion
25+
def pgVersion = 14
2526
def country
2627
def ampUrl
28+
def dockerRepo = "registry.developmentgateway.org/"
2729

2830
def updateGitHubCommitStatus(context, message, state) {
2931
repoUrl = sh(returnStdout: true, script: "git config --get remote.origin.url").trim()
@@ -45,42 +47,11 @@ def updateGitHubCommitStatus(context, message, state) {
4547
])
4648
}
4749

48-
// Run checkstyle only for PR builds
49-
stage('Checkstyle') {
50-
when (branch == null) {
51-
node {
52-
try {
53-
checkout scm
54-
55-
updateGitHubCommitStatus('jenkins/checkstyle', 'Checkstyle in progress', 'PENDING')
56-
57-
withEnv(["PATH+MAVEN=${tool 'M339'}/bin"]) {
58-
sh "cd amp && mvn inccheckstyle:check -DbaseBranch=remotes/origin/${CHANGE_TARGET}"
59-
}
60-
61-
updateGitHubCommitStatus('jenkins/checkstyle', 'Checkstyle success', 'SUCCESS')
62-
} catch(e) {
63-
updateGitHubCommitStatus('jenkins/checkstyle', 'Checkstyle found violations', 'ERROR')
64-
}
65-
}
66-
}
67-
}
68-
69-
def legacyMvnOptions = "-Djdbc.user=amp " +
70-
"-Djdbc.password=amp122006 " +
71-
"-Djdbc.db=amp " +
72-
"-Djdbc.host=db " +
73-
"-Djdbc.port=5432 " +
74-
"-DdbName=postgresql " +
75-
"-Djdbc.driverClassName=org.postgresql.Driver"
76-
77-
def launchedByUser = currentBuild.getBuildCauses('hudson.model.Cause$UserIdCause').size() > 0
7850
def codeVersion
7951
def countries
8052

81-
// Run fail fast tests
82-
stage('Quick Test') {
83-
// Find list of countries which have database dumps compatible with ${codeVersion}
53+
stage('Build') {
54+
8455
node {
8556
checkout scm
8657

@@ -89,108 +60,61 @@ stage('Quick Test') {
8960
println "AMP Version: ${codeVersion}"
9061

9162
countries = sh(returnStdout: true,
92-
script: "ssh sulfur.migrated.devgateway.org 'cd /opt/amp_dbs && amp-db ls ${codeVersion} | sort'")
63+
script: "ssh boad.aws.devgateway.org 'cd /opt/amp_dbs && amp-db ls ${codeVersion} | sort'")
9364
.trim()
9465
if (countries == "") {
9566
println "There are no database backups compatible with ${codeVersion}"
9667
currentBuild.result = 'FAILURE'
9768
}
9869
}
9970

100-
// Allow user to specify country before tests are run
101-
if (launchedByUser) {
102-
timeout(15) {
103-
milestone()
104-
country = input(
105-
message: "Proceed with test, build and deploy?",
106-
parameters: [choice(choices: countries, name: 'country')])
107-
milestone()
108-
}
71+
timeout(15) {
72+
milestone()
73+
country = input(
74+
message: "Proceed with build and deploy?",
75+
parameters: [choice(choices: countries, name: 'country')])
76+
milestone()
10977
}
11078

111-
node {
112-
try {
113-
checkout scm
114-
115-
updateGitHubCommitStatus('jenkins/failfasttests', 'Testing in progress', 'PENDING')
116-
117-
withEnv(["PATH+MAVEN=${tool 'M339'}/bin"]) {
118-
def testStatus = sh returnStatus: true, script: "cd amp && mvn clean test -Dskip.npm -Dskip.gulp ${legacyMvnOptions}"
119-
120-
// Archive unit test report
121-
junit 'amp/target/surefire-reports/TEST-*.xml'
122-
123-
if (testStatus != 0) {
124-
error "Tests command returned an error code!"
125-
}
126-
}
127-
128-
updateGitHubCommitStatus('jenkins/failfasttests', 'Fail fast tests: success', 'SUCCESS')
129-
} catch (e) {
130-
updateGitHubCommitStatus('jenkins/failfasttests', 'Fail fast tests: error', 'ERROR')
131-
132-
throw e
133-
}
134-
}
135-
}
136-
137-
stage('Build') {
138-
139-
if (country == null) {
140-
timeout(15) {
141-
milestone()
142-
country = input(
143-
message: "Proceed with build and deploy?",
144-
parameters: [choice(choices: countries, name: 'country')])
145-
milestone()
146-
}
147-
}
148-
149-
ampUrl = "http://amp-${country}-${tag}-tc9.ampsite.net/"
79+
ampUrl = "http://amp-${country}-${tag}.stg.ampsite.net/"
15080

15181
node {
15282
checkout scm
15383

84+
def image = "${dockerRepo}amp-webapp:${tag}"
15485
def format = branch != null ? "%H" : "%P"
15586
def hash = sh(returnStdout: true, script: "git log --pretty=${format} -n 1").trim()
156-
sh(returnStatus: true, script: "docker pull phosphorus.migrated.devgateway.org:5000/amp-webapp:${tag} > /dev/null")
87+
sh(returnStatus: true, script: "docker pull ${image} > /dev/null")
15788
def imageIds = sh(returnStdout: true, script: "docker images -q -f \"label=git-hash=${hash}\"").trim()
158-
sh(returnStatus: true, script: "docker rmi phosphorus.migrated.devgateway.org:5000/amp-webapp:${tag} > /dev/null")
89+
sh(returnStatus: true, script: "docker rmi ${image} > /dev/null")
15990

16091
if (imageIds.equals("")) {
161-
withEnv(["PATH+MAVEN=${tool 'M339'}/bin"]) {
162-
try {
163-
sh returnStatus: true, script: 'tar -xf ../amp-node-cache.tar'
164-
165-
// Build AMP
166-
sh "cd amp && mvn -T 4 clean compile war:exploded ${legacyMvnOptions} -DskipTests -DbuildSource=${tag} -e"
167-
168-
// Build Docker images & push it
169-
sh "docker build -q -t phosphorus.migrated.devgateway.org:5000/amp-webapp:${tag} --build-arg AMP_EXPLODED_WAR=target/amp --build-arg AMP_PULL_REQUEST='${pr}' --build-arg AMP_BRANCH='${branch}' --build-arg AMP_REGISTRY_PRIVATE_KEY='${registryKey}' --label git-hash='${hash}' amp"
170-
sh "docker push phosphorus.migrated.devgateway.org:5000/amp-webapp:${tag} > /dev/null"
171-
} finally {
172-
173-
// Cleanup after Docker & Maven
174-
sh returnStatus: true, script: "docker rmi phosphorus.migrated.devgateway.org:5000/amp-webapp:${tag}"
175-
sh returnStatus: true, script: "cd amp && mvn clean -Djdbc.db=dummy"
176-
sh returnStatus: true, script: "tar -cf ../amp-node-cache.tar --remove-files" +
177-
" amp/TEMPLATE/ampTemplate/node_modules/amp-boilerplate/node" +
178-
" amp/TEMPLATE/ampTemplate/node_modules/amp-boilerplate/node_modules" +
179-
" amp/TEMPLATE/ampTemplate/node_modules/gis-layers-manager/node" +
180-
" amp/TEMPLATE/ampTemplate/node_modules/gis-layers-manager/node_modules" +
181-
" amp/TEMPLATE/ampTemplate/node_modules/amp-settings/node" +
182-
" amp/TEMPLATE/ampTemplate/node_modules/amp-settings/node_modules" +
183-
" amp/TEMPLATE/ampTemplate/node_modules/amp-translate/node" +
184-
" amp/TEMPLATE/ampTemplate/node_modules/amp-translate/node_modules" +
185-
" amp/TEMPLATE/ampTemplate/node_modules/amp-state/node" +
186-
" amp/TEMPLATE/ampTemplate/node_modules/amp-state/node_modules" +
187-
" amp/TEMPLATE/ampTemplate/gisModule/dev/node" +
188-
" amp/TEMPLATE/ampTemplate/gisModule/dev/node_modules" +
189-
" amp/TEMPLATE/ampTemplate/dashboard/dev/node" +
190-
" amp/TEMPLATE/ampTemplate/dashboard/dev/node_modules" +
191-
" amp/TEMPLATE/reamp/node" +
192-
" amp/TEMPLATE/reamp/node_modules"
92+
try {
93+
updateGitHubCommitStatus('jenkins/build', 'Build in progress', 'PENDING')
94+
95+
sshagent(credentials: ['GitHubDgReadOnlyKey']) {
96+
withEnv(['DOCKER_BUILDKIT=1']) {
97+
sh "docker build " +
98+
"--progress=plain " +
99+
"--ssh default " +
100+
"-t ${image} " +
101+
"--build-arg BUILD_SOURCE='${tag}' " +
102+
"--build-arg AMP_PULL_REQUEST='${pr}' " +
103+
"--build-arg AMP_BRANCH='${branch}' " +
104+
"--build-arg AMP_REGISTRY_PRIVATE_KEY='${registryKey}' " +
105+
"--label git-hash='${hash}' " +
106+
"amp"
107+
}
193108
}
109+
sh "docker push ${image} > /dev/null"
110+
111+
updateGitHubCommitStatus('jenkins/build', 'Built successfully', 'SUCCESS')
112+
} catch (e) {
113+
updateGitHubCommitStatus('jenkins/build', 'Build failed', 'ERROR')
114+
throw e
115+
} finally {
116+
// Cleanup after Docker & Maven
117+
sh returnStatus: true, script: "docker rmi ${image}"
194118
}
195119
}
196120
}
@@ -203,10 +127,10 @@ stage('Deploy') {
203127
node {
204128
try {
205129
// Find latest database version compatible with ${codeVersion}
206-
dbVersion = sh(returnStdout: true, script: "ssh sulfur.migrated.devgateway.org 'cd /opt/amp_dbs && amp-db find ${codeVersion} ${country}'").trim()
130+
dbVersion = sh(returnStdout: true, script: "ssh boad.aws.devgateway.org 'cd /opt/amp_dbs && amp-db find ${codeVersion} ${country}'").trim()
207131

208132
// Deploy AMP
209-
sh "ssh sulfur.migrated.devgateway.org 'cd /opt/docker/amp && ./up.sh ${tag} ${country} ${dbVersion}'"
133+
sh "ssh boad.aws.devgateway.org 'amp-up ${tag} ${country} ${dbVersion} ${pgVersion}'"
210134

211135
slackSend(channel: 'amp-ci', color: 'good', message: "Deploy AMP - Success\nDeployed ${changePretty} will be ready for testing at ${ampUrl} in about 3 minutes")
212136

@@ -231,7 +155,7 @@ stage('Deploy again') {
231155
}
232156
node {
233157
try {
234-
sh "ssh sulfur.migrated.devgateway.org 'cd /opt/docker/amp && ./up.sh ${tag} ${country} ${dbVersion}'"
158+
sh "ssh boad.aws.devgateway.org 'amp-up ${tag} ${country} ${dbVersion} ${pgVersion}'"
235159

236160
slackSend(channel: 'amp-ci', color: 'good', message: "Deploy AMP - Success\nDeployed ${changePretty} will be ready for testing at ${ampUrl} in about 3 minutes")
237161

amp/.dockerignore

Lines changed: 31 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,31 @@
1-
*
2-
!META-INF
3-
!Dockerfile
4-
!docker
5-
!target/amp*
1+
.idea
2+
*.iml
3+
target
4+
gen-src
5+
META-INF
6+
WEB-INF/classes
7+
WEB-INF/lib
8+
jackrabbit
9+
lucene
10+
api-docs
11+
Dockerfile
12+
TEMPLATE/ampTemplate/node_modules/amp-boilerplate/node
13+
TEMPLATE/ampTemplate/node_modules/amp-boilerplate/node_modules
14+
TEMPLATE/ampTemplate/node_modules/gis-layers-manager/node
15+
TEMPLATE/ampTemplate/node_modules/gis-layers-manager/node_modules
16+
TEMPLATE/ampTemplate/node_modules/amp-settings/node
17+
TEMPLATE/ampTemplate/node_modules/amp-settings/node_modules
18+
TEMPLATE/ampTemplate/node_modules/amp-translate/node
19+
TEMPLATE/ampTemplate/node_modules/amp-translate/node_modules
20+
TEMPLATE/ampTemplate/node_modules/amp-state/node
21+
TEMPLATE/ampTemplate/node_modules/amp-state/node_modules
22+
TEMPLATE/ampTemplate/node_modules/amp-filter/node
23+
TEMPLATE/ampTemplate/node_modules/amp-filter/node_modules
24+
TEMPLATE/ampTemplate/gisModule/dev/node
25+
TEMPLATE/ampTemplate/gisModule/dev/node_modules
26+
TEMPLATE/ampTemplate/dashboard/dev/node
27+
TEMPLATE/ampTemplate/dashboard/dev/node_modules
28+
TEMPLATE/reamp/node
29+
TEMPLATE/reamp/node_modules
30+
TEMPLATE/reampv2/node
31+
TEMPLATE/reampv2/node_modules

amp/Dockerfile

Lines changed: 56 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,65 @@
1-
FROM tomcat:7.0-jdk8
1+
FROM maven:3.8.4-jdk-8 as base
2+
WORKDIR /tmp/amp
3+
COPY . .
4+
5+
FROM base as compile
6+
ARG BUILD_SOURCE
7+
RUN mkdir -p -m 0600 ~/.ssh && ssh-keyscan github.com >> ~/.ssh/known_hosts
8+
RUN --mount=type=ssh \
9+
--mount=type=cache,target=/root/.m2 \
10+
--mount=type=cache,target=/root/.npm \
11+
mvn -B test war:exploded \
12+
-DbuildSource=$BUILD_SOURCE \
13+
-Djdbc.user=amp -Djdbc.password=amp122006 -Djdbc.db=amp -Djdbc.host=db \
14+
-Djdbc.port=5432 -DdbName=postgresql -Djdbc.driverClassName=org.postgresql.Driver \
15+
&& mv target/amp exploded \
16+
&& rm -rf target \
17+
TEMPLATE/ampTemplate/node_modules/amp-boilerplate/node \
18+
TEMPLATE/ampTemplate/node_modules/amp-boilerplate/node_modules \
19+
TEMPLATE/ampTemplate/node_modules/gis-layers-manager/node \
20+
TEMPLATE/ampTemplate/node_modules/gis-layers-manager/node_modules \
21+
TEMPLATE/ampTemplate/node_modules/amp-settings/node \
22+
TEMPLATE/ampTemplate/node_modules/amp-settings/node_modules \
23+
TEMPLATE/ampTemplate/node_modules/amp-translate/node \
24+
TEMPLATE/ampTemplate/node_modules/amp-translate/node_modules \
25+
TEMPLATE/ampTemplate/node_modules/amp-state/node \
26+
TEMPLATE/ampTemplate/node_modules/amp-state/node_modules \
27+
TEMPLATE/ampTemplate/node_modules/amp-filter/node \
28+
TEMPLATE/ampTemplate/node_modules/amp-filter/node_modules \
29+
TEMPLATE/ampTemplate/gisModule/dev/node \
30+
TEMPLATE/ampTemplate/gisModule/dev/node_modules \
31+
TEMPLATE/ampTemplate/dashboard/dev/node \
32+
TEMPLATE/ampTemplate/dashboard/dev/node_modules \
33+
TEMPLATE/reamp/node \
34+
TEMPLATE/reamp/node_modules \
35+
TEMPLATE/reampv2/node \
36+
TEMPLATE/reampv2/node_modules
37+
38+
FROM tomcat:8.5.79-jdk8
39+
40+
RUN apt-get update \
41+
&& apt-get install -y apt-transport-https ca-certificates curl gnupg --no-install-recommends \
42+
&& curl -sSL https://dl.google.com/linux/linux_signing_key.pub | apt-key add - \
43+
&& echo "deb https://dl.google.com/linux/chrome/deb/ stable main" > /etc/apt/sources.list.d/google-chrome.list \
44+
&& apt-get update \
45+
&& apt-get install -y google-chrome-stable fontconfig fonts-ipafont-gothic fonts-wqy-zenhei fonts-thai-tlwg fonts-kacst fonts-symbola fonts-noto fonts-freefont-ttf --no-install-recommends \
46+
&& apt-get purge --auto-remove -y curl gnupg \
47+
&& rm -rf /var/lib/apt/lists/*
48+
49+
ENV CHROME_PATH /opt/google/chrome
50+
ENV CHROME_NO_SANDBOX 1
51+
52+
COPY docker/wait-for-it.sh docker/setenv.sh bin/
53+
COPY docker/server.xml docker/tomcat-users.xml conf/
254

3-
ARG AMP_EXPLODED_WAR
455
ARG AMP_PULL_REQUEST
556
ARG AMP_BRANCH
657
ARG AMP_REGISTRY_PRIVATE_KEY
758

859
LABEL "pull-request"=$AMP_PULL_REQUEST
960
LABEL "branch"=$AMP_BRANCH
1061

11-
ADD docker/wait-for-it.sh bin/
12-
ADD docker/setenv.sh bin/
13-
ADD docker/server.xml conf/
14-
ADD docker/tomcat-users.xml conf/
15-
16-
RUN rm -fr /usr/local/tomcat/webapps/ROOT && mkdir /usr/local/tomcat/webapps/ROOT
17-
ADD $AMP_EXPLODED_WAR /usr/local/tomcat/webapps/ROOT
18-
ADD META-INF/context.xml /usr/local/tomcat/webapps/ROOT/META-INF/
19-
2062
ENV AMP_REGISTRY_PRIVATE_KEY $AMP_REGISTRY_PRIVATE_KEY
63+
64+
RUN rm -fr /usr/local/tomcat/webapps/ROOT
65+
COPY --from=compile /tmp/amp/exploded /usr/local/tomcat/webapps/ROOT/

amp/TEMPLATE/ampTemplate/.gitignore

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,2 @@
1-
# first, ignore everything in node modules, so we don't track build deps
2-
node_modules/*
3-
# then, unignore our own libraries that we want to have available on the `require` search path
4-
!node_modules/amp-*
1+
node_modules/*/node
2+
node_modules/*/node_modules
Loading

amp/TEMPLATE/ampTemplate/dashboard/dev/app/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,6 @@ <h2><small>Loading...</small></h2>
2626
<div id="amp-footer">
2727
</div>
2828
<script src="/TEMPLATE/ampTemplate/commonJs/common.min.js"></script>
29-
<script src="compiled-js/app.js"></script>
29+
<script src="compiled-js/app.js"></script>
3030
</body>
3131
</html>

0 commit comments

Comments
 (0)