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

Build Deploy Frontends Jenkinsfile Effort #2593

Closed
wants to merge 59 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
59 commits
Select commit Hold shift + click to select a range
14323c8
Jenkinsfile POC for build deploy
maknop Jul 26, 2023
82f13be
Adding frontend build stage
maknop Aug 4, 2023
16a5ae4
String around curl command
maknop Aug 7, 2023
42fad37
Quotations around command
maknop Aug 7, 2023
a9f761c
Download and source frontend build script
maknop Aug 7, 2023
5383c2e
Adding creds for container build
maknop Aug 7, 2023
fd6c826
Forcing new job run
maknop Aug 8, 2023
6937372
Manually updating job name
maknop Aug 8, 2023
53f3af4
Fixed job name
maknop Aug 8, 2023
35f8011
Remove job name var
maknop Aug 8, 2023
0bdbed3
Adding image to jenkins stage environment vars
maknop Aug 9, 2023
ec4f3d7
Adding node to post block
maknop Aug 9, 2023
8a9a330
Adjusting syntax
maknop Aug 9, 2023
4d5be51
Adjusting syntax
maknop Aug 9, 2023
9940a83
Adjusting syntax
maknop Aug 9, 2023
102a7c4
Adjusting syntax
maknop Aug 9, 2023
41e7a49
Make required dir
maknop Aug 9, 2023
c882f79
Make required dir
maknop Aug 9, 2023
132d7cd
Test file
maknop Aug 9, 2023
f95d0c9
Testing full pipeline
maknop Aug 9, 2023
374d547
Testing artifact archieve in stage
maknop Aug 9, 2023
c3c96f2
Testing one agent for pipeline
maknop Aug 9, 2023
dcf504f
Agent per jenkins stage
maknop Aug 9, 2023
07242fc
Separate build frontend script
maknop Aug 10, 2023
8d3a307
post always for stage
maknop Aug 10, 2023
74b33c9
force a new build
maknop Aug 15, 2023
6e6126a
Force new build
maknop Aug 15, 2023
5a346ec
force new build
maknop Aug 16, 2023
ef66bbe
Forcing a new build
maknop Aug 16, 2023
039dc48
Forcing new build
maknop Aug 16, 2023
f1ede93
Force new build
maknop Aug 16, 2023
c4ed032
forcing new build
maknop Aug 17, 2023
e253713
Forcing a build
maknop Aug 17, 2023
c131847
Forcing build
maknop Aug 17, 2023
86cf87d
Forcing rebuild
maknop Aug 17, 2023
78e262b
Forcing new build
maknop Aug 23, 2023
bc832c8
Forcing a new build
maknop Aug 31, 2023
636f870
Forcing new build
maknop Aug 31, 2023
b20506b
Force new build
maknop Sep 5, 2023
0963caf
Forcing new build
maknop Sep 5, 2023
c10cc36
forcing new build
maknop Sep 15, 2023
8bf3ffa
forcing build
maknop Sep 18, 2023
073ae49
forcing a build
maknop Sep 18, 2023
9fb6c47
forcing build
maknop Sep 18, 2023
5140d76
forcing build
maknop Sep 18, 2023
4f8201f
forcing a build
maknop Sep 18, 2023
f96c38c
forcing build
maknop Sep 19, 2023
502b846
force build
maknop Sep 19, 2023
8a860df
forcing new build
maknop Sep 19, 2023
dfc985a
forcing build
maknop Sep 19, 2023
a325d0c
forcing new build
maknop Sep 20, 2023
933d875
forcing new build
maknop Sep 20, 2023
fff30ca
forcing new build
maknop Sep 20, 2023
b16a643
forcing build
maknop Sep 21, 2023
55962a1
forcing build
maknop Sep 22, 2023
a739834
forcing build
maknop Sep 22, 2023
c4f2af9
forcing build
maknop Sep 22, 2023
349b5d0
forcing build
maknop Sep 22, 2023
3f64977
force new build
maknop Sep 22, 2023
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
157 changes: 153 additions & 4 deletions Jenkinsfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
def secrets = [

[path: params.VAULT_PATH_SVC_ACCOUNT_EPHEMERAL, engineVersion: 1, secretValues: [
[envVar: 'OC_LOGIN_TOKEN', vaultKey: 'oc-login-token'],
[envVar: 'OC_LOGIN_SERVER', vaultKey: 'oc-login-server']]],
Expand All @@ -11,21 +12,169 @@ def secrets = [
[path: params.VAULT_PATH_RHR_PULL, engineVersion: 1, secretValues: [
[envVar: 'RH_REGISTRY_USER', vaultKey: 'user'],
[envVar: 'RH_REGISTRY_TOKEN', vaultKey: 'token']]],
[path: params.VAULT_PATH_CHROME_CYPRESS, engineVersion: 1, secretValues: [
[envVar: 'CHROME_ACCOUNT', vaultKey: 'account'],
[envVar: 'CHROME_PASSWORD', vaultKey: 'password']]],
]

def configuration = [vaultUrl: params.VAULT_ADDRESS, vaultCredentialId: params.VAULT_CREDS_ID, engineVersion: 1]


pipeline {
agent { label 'insights' }
agent none
options {
timestamps()
}
environment {
PROJECT_NAME="insights-chrome"

MASTER_BRANCH="master"
MASTER_STABLE_BRANCH="master-stable"

NODE_BASE_IMAGE="registry.access.redhat.com/ubi9/nodejs-18:1-53"
CYPRESS_TEST_IMAGE="quay.io/cloudservices/cypress-e2e-image:06b70f3"

CICD_URL="https://raw.githubusercontent.com/RedHatInsights/cicd-tools/main"
}

stages {
stage('Placeholder') {
steps {
sh 'echo Placeholder Jenkinsfile'
stage('Tests/Build for Frontends') {
parallel {
stage('Unit Testing') {
agent { label 'insights' }
environment {
IMG_TAG=sh(script: "git rev-parse --short=8 HEAD", returnStdout: true).trim()
TEST_CONT="${PROJECT_NAME}-unit-tests-${IMG_TAG}"
}
steps {
script {
withVault([configuration: configuration, vaultSecrets: secrets]) {
sh '''
./ci/unit_tests.sh
'''
}
}
}
}

stage('Lint') {
agent { label 'insights' }
environment {
IMG_TAG=sh(script: "git rev-parse --short=8 HEAD", returnStdout: true).trim()
TEST_CONT="${PROJECT_NAME}-lint-${IMG_TAG}"
}
steps {
script {
withVault([configuration: configuration, vaultSecrets: secrets]) {
sh '''
./ci/lint.sh
'''
}
}
}
}

stage('Cypress Component Testing') {
agent { label 'insights' }
environment {
IMG_TAG=sh(script: "git rev-parse --short=8 HEAD", returnStdout: true).trim()
TEST_CONT="${PROJECT_NAME}-cypress-component-tests-${IMG_TAG}"
}
steps {
script {
withVault([configuration: configuration, vaultSecrets: secrets]) {
sh '''
./ci/cypress_component_tests.sh
'''
}
}
}
}

stage('Cypress E2E Tests') {
agent { label 'insights' }
environment {
IMG_TAG=sh(script: "git rev-parse --short=8 HEAD", returnStdout: true).trim()
TEST_CONT="${PROJECT_NAME}-cypress-e2e-tests-${IMG_TAG}"

COMPONENT="insights-chrome-frontend"
IMAGE="quay.io/cloudservices/${COMPONENT}"
INCLUDE_CHROME_CONFIG="true"
}
steps {
script {
withVault([configuration: configuration, vaultSecrets: secrets]) {
sh '''
./ci/cypress_e2e_tests.sh
'''
}
}
}
}

stage('IQE Tests') {
agent { label 'insights' }
environment {
IMG_TAG=sh(script: "git rev-parse --short=8 HEAD", returnStdout: true).trim()
TEST_CONT="${PROJECT_NAME}-cypress-e2e-tests-${IMG_TAG}"

// Deploy to an ephemeral namespace for testing
IMAGE="quay.io/cloudservices/rbac"
GIT_COMMIT="master"
IMAGE_TAG="latest"
DEPLOY_FRONTENDS=true

// Run tests with ClowdJobInvocation
IQE_IMAGE_TAG="platform-ui"
IQE_PLUGINS="platform_ui"
IQE_MARKER_EXPRESSION="smoke"
// xclude progressive profile tests
// Exclude APIdocs tests
IQE_FILTER_EXPRESSION="not (test_progressive or test_apidocs)"
IQE_ENV="ephemeral"
IQE_SELENIUM="true"
IQE_CJI_TIMEOUT="30m"
DEPLOY_TIMEOUT="900" // 15min

// Ensure that we deploy the right component for testing
APP_NAME="rbac"
COMPONENT="rbac"
COMPONENT_NAME="rbac"
}

steps {
script {
withVault([configuration: configuration, vaultSecrets: secrets]) {
sh '''
./ci/iqe_tests.sh
'''
}
}
}
post {
always {
archiveArtifacts artifacts: 'artifacts/**/*', fingerprint: true
junit skipPublishingChecks: true, testResults: 'artifacts/junit-*.xml'
}
}
}

stage('Frontend Build') {
agent { label 'insights' }
environment {
COMMON_BUILDER="https://raw.githubusercontent.com/RedHatInsights/insights-frontend-builder-common/master"

COMPONENT="insights-chrome-frontend"
IMAGE="quay.io/cloudservices/${COMPONENT}"
}
steps {
withVault([configuration: configuration, vaultSecrets: secrets]) {
sh '''
./ci/frontend-build.sh
'''
}
}
}
}
}
}
Expand Down
22 changes: 22 additions & 0 deletions ci/cypress_component_tests.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/bin/bash

set -x

docker login -u="$QUAY_USER" -p="$QUAY_TOKEN" quay.io

docker run --name $TEST_CONT -d -i --rm "${CYPRESS_TEST_IMAGE}" /bin/bash

docker cp -a . "${TEST_CONT}:/e2e/"

docker exec -i $TEST_CONT sh -c "npm ci"
docker exec -i $TEST_CONT sh -c "npm run test:ct"

RESULT=$?

if [[ $RESULT -ne 0 ]]; then
exit $RESULT
fi

docker stop $TEST_CONT

exit $RESULT
28 changes: 28 additions & 0 deletions ci/cypress_e2e_tests.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/bin/bash

set -x

docker login -u="$QUAY_USER" -p="$QUAY_TOKEN" quay.io

docker run \
--name $TEST_CONT \
-e CHROME_ACCOUNT=$CHROME_ACCOUNT \
-e CHROME_PASSWORD=$CHROME_PASSWORD \
--add-host stage.foo.redhat.com:127.0.0.1 \
--add-host prod.foo.redhat.com:127.0.0.1 \
-d -i --rm \
--entrypoint bash \
"${CYPRESS_TEST_IMAGE}"

docker cp -a . "${TEST_CONT}:/e2e/"

docker exec -i $TEST_CONT sh -c "npm ci"
docker exec -i $TEST_CONT sh -c "npm run test:e2e"

RESULT=$?

if [[ $RESULT -ne 0 ]]; then
exit $RESULT
fi

docker stop $TEST_CONT
10 changes: 10 additions & 0 deletions ci/frontend-build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/bash

curl -sSL "${COMMON_BUILDER}/src/frontend-build.sh" > .frontend-build.sh
source ./.frontend-build.sh

BUILD_RESULTS=$?

if [[ $BUILD_RESULTS -ne 0 ]]; then
exit $BUILD_RESULTS
fi
27 changes: 27 additions & 0 deletions ci/iqe_tests.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#!/bin/bash

set -x

curl -s $CICD_URL/bootstrap.sh > .cicd_bootstrap.sh
source ./.cicd_bootstrap.sh

GIT_COMMIT="master"
IMAGE_TAG="latest"

source $CICD_ROOT/deploy_ephemeral_env.sh
source $CICD_ROOT/cji_smoke_test.sh

mkdir -p $WORKSPACE/artifacts
cat << EOF > $WORKSPACE/artifacts/junit-dummy.xml
<testsuite tests="1">
<testcase classname="dummy" name="dummytest"/>
</testsuite>
EOF

RESULT=$?

if [[ $RESULT -ne 0 ]]; then
exit $RESULT
fi

exit $RESULT
12 changes: 12 additions & 0 deletions ci/lint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/bin/bash

set -x

docker run --name $TEST_CONT -d -i --rm $NODE_BASE_IMAGE /bin/sh

docker cp . "${TEST_CONT}:/opt/app-root/src/"

docker exec -i -w "/opt/app-root/src/" $TEST_CONT sh -c "npm ci"
docker exec -i -w "/opt/app-root/src/" $TEST_CONT sh -c "npm run lint"

docker stop $TEST_CONT
20 changes: 20 additions & 0 deletions ci/unit_tests.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/bin/bash

set -x

docker run --name $TEST_CONT -d -i --rm "${NODE_BASE_IMAGE}" /bin/sh

docker cp . "${TEST_CONT}:/opt/app-root/src/"

docker exec -i -w "/opt/app-root/src/" $TEST_CONT sh -c "npm ci"
docker exec -i -w "/opt/app-root/src/" $TEST_CONT sh -c "npm run test -- --coverage"

RESULT=$?

if [[ $RESULT -ne 0 ]]; then
exit $RESULT
fi

docker stop $TEST_CONT

exit $RESULT
Loading