Skip to content

Commit

Permalink
feat: toteuta käyttöliittymätestien sekä asennusajojen tulosten rapor…
Browse files Browse the repository at this point in the history
…tointi rocketchatin kautta
  • Loading branch information
haapamakim committed Aug 30, 2022
1 parent 5813108 commit 0feecd4
Show file tree
Hide file tree
Showing 11 changed files with 986 additions and 17 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -66,5 +66,6 @@ migration/~*

cypress/videos
cypress/screenshots
cypress/report
cypress.env.json
cypress/downloads/downloads.html
10 changes: 10 additions & 0 deletions cypress-reporter-config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"reporterEnabled": "list, cypress-mochawesome-reporter, xunit",
"cypressMochawesomeReporterReporterOptions": {
"reportDir": "cypress/report",
"charts": true
},
"xunitReporterOptions": {
"output": "cypress/report/xunit.xml"
}
}
6 changes: 3 additions & 3 deletions cypress.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
"projektiNimi": "HASSU AUTOMAATTITESTIPROJEKTI1",
"oid": "1.2.246.578.5.1.2978288874.2711575506"
},
"reporter": "junit",
"video": false,
"reporter": "cypress-multi-reporters",
"reporterOptions": {
"mochaFile": ".report/e2e-test-output-[hash].xml",
"toConsole": true
"configFile": "cypress-reporter-config.json"
}
}
2 changes: 2 additions & 0 deletions cypress/plugins/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,6 @@ module.exports = (on) => {
return shouldSkip;
},
});

require('cypress-mochawesome-reporter/plugin')(on);
};
1 change: 1 addition & 0 deletions cypress/support/commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,4 +102,5 @@ Cypress.Commands.add("login", (testuser) => {
Cypress.Commands.add("archiveProjekti", (oid) => {
cy.visit(Cypress.env("host") + "/yllapito/projekti/" + oid + "/arkistoi");
cy.get("#result").should("contain", "Arkistoinnin tulos");
cy.wait(2000); // Give some time for search index to update
});
2 changes: 2 additions & 0 deletions cypress/support/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,7 @@
// Import commands.js using ES2015 syntax:
import './commands'

import 'cypress-mochawesome-reporter/register';

// Alternatively you can use CommonJS syntax:
// require('./commands')
28 changes: 28 additions & 0 deletions deployment/bin/reportBuildStatus.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/bin/bash

while getopts t:u:r:m:d: flag; do
case "${flag}" in
t) TOKEN=${OPTARG} ;;
u) USERID=${OPTARG} ;;
r) RESULT=${OPTARG} ;;
m) MESSAGE=${OPTARG} ;;
d) DESCRIPTION=${OPTARG} ;;
*)
esac
done

if [ "$RESULT" -eq "1" ]; then
TEXT="$MESSAGE succeeced"
else
TEXT="$MESSAGE FAILED @all"
fi

if [ -n "$DESCRIPTION" ]; then
TEXT="$TEXT\n$DESCRIPTION"
fi

curl -s -H "X-Auth-Token: $TOKEN" \
-H "X-User-Id: $USERID" \
-H "Content-type:application/json" \
https://rocketchat.vaylapilvi.fi/api/v1/chat.postMessage \
-d "{ \"channel\": \"#Hassu_build_notifications\", \"text\": \"$TEXT\" }"
5 changes: 4 additions & 1 deletion deployment/lib/buildspec/buildspec.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ version: 0.2
env:
parameter-store:
SKIP_VELHO_TESTS: /SkipVelhoTests
ROCKET_CHAT_TOKEN: /RocketChatToken
ROCKET_CHAT_USER_ID: /RocketChatUserId
secrets-manager:
GITHUB_TOKEN: github-token

Expand Down Expand Up @@ -35,10 +37,11 @@ phases:
- npm run deploy:backend
- npm run deploy:frontend
- npm run release
- aws codebuild start-build --project-name Hassu-e2etest-$ENVIRONMENT --source-version $CODEBUILD_SOURCE_VERSION
post_build:
on-failure: ABORT
commands:
- aws codebuild start-build --project-name Hassu-e2etest-$ENVIRONMENT --source-version $CODEBUILD_SOURCE_VERSION
- ./deployment/bin/reportBuildStatus.sh -t "$ROCKET_CHAT_TOKEN" -u "$ROCKET_CHAT_USER_ID" -r "$CODEBUILD_BUILD_SUCCEEDING" -m "$ENVIRONMENT build" -d "CodeBuild $CODEBUILD_BUILD_URL"
cache:
paths:
- "/root/.cache/**/*"
Expand Down
21 changes: 14 additions & 7 deletions deployment/lib/buildspec/e2etest.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
version: 0.2

env:
parameter-store:
ROCKET_CHAT_TOKEN: /RocketChatToken
ROCKET_CHAT_USER_ID: /RocketChatUserId

phases:
install:
commands:
Expand All @@ -8,13 +13,15 @@ phases:
build:
commands:
- npm run e2e:test:run
- echo Test report available at https://$FRONTEND_DOMAIN_NAME_DEV/report/robot-$ENVIRONMENT/$CODEBUILD_BUILD_NUMBER/report.html
post_build:
commands:
- ./deployment/bin/reportBuildStatus.sh -t "$ROCKET_CHAT_TOKEN" -u "$ROCKET_CHAT_USER_ID" -r "$CODEBUILD_BUILD_SUCCEEDING" -m "cypress $ENVIRONMENT test" -d "CodeBuild $CODEBUILD_BUILD_URL\nTest report available at https://$FRONTEND_DOMAIN_NAME_DEV/report/robot-$ENVIRONMENT/$CODEBUILD_BUILD_NUMBER/index.html"
- echo Test report available at https://$FRONTEND_DOMAIN_NAME_DEV/report/robot-$ENVIRONMENT/$CODEBUILD_BUILD_NUMBER/index.html

artifacts:
base-directory: "cypress/report"
files:
- ".report/e2e-test-output-*.xml"
- "cypress/screenshots/**/*"
- "cypress/videos/**/*"
discard-paths: yes
- "**/*"
name: report/robot-$ENVIRONMENT/$CODEBUILD_BUILD_NUMBER

cache:
Expand All @@ -24,6 +31,6 @@ cache:

reports:
unit-tests:
files: "e2e-test-output-*.xml"
base-directory: .report
files: "xunit.xml"
base-directory: cypress/report
discard-paths: true
Loading

0 comments on commit 0feecd4

Please sign in to comment.