Skip to content

Commit

Permalink
chore: tweak jest config so it only reports to portal when on CI
Browse files Browse the repository at this point in the history
  • Loading branch information
HendrikThePendric committed Aug 21, 2024
1 parent b71d3f8 commit 6ef7846
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 29 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/dhis2-verify-app.yml
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,9 @@ jobs:
REPORTPORTAL_API_KEY: ${{ secrets.REPORTPORTAL_API_KEY }}
REPORTPORTAL_ENDPOINT: ${{ vars.REPORTPORTAL_ENDPOINT }}
REPORTPORTAL_PROJECT: ${{ vars.REPORTPORTAL_PROJECT }}
CI_BUILD_ID: ${{ github.sha }}-${{ github.workflow }}-${{ github.event_name }}
BRANCH_NAME: ${{ github.head_ref || github.ref_name }}
PR_TITLE: ${{ github.event.pull_request.title }}

call-workflow-e2e-prod:
if: "!contains(github.event.head_commit.message, '[skip ci]')"
Expand Down
69 changes: 40 additions & 29 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,42 @@
console.log('JEST CONFIG', process.env)
const reportPortalConfig = [
'@reportportal/agent-js-jest',
{
apiKey: process.env.REPORTPORTAL_API_KEY,
endpoint: process.env.REPORTPORTAL_ENDPOINT,
project: process.env.REPORTPORTAL_PROJECT,
launch: 'maps_app',
attributes: [
{
key: 'dhis2_version',
value: 'master',
},
{
key: 'app_name',
value: 'data-visualizer-app',
},
{
key: 'test_level',
value: 'unit/integration',
},
{
key: 'BRANCH_NAME',
value: process.env.BRANCH_NAME,
},
{
key: 'CI_BUILD_ID',
value: process.env.CI_BUILD_ID,
},
{
key: 'PR_TITLE',
value: process.env.PR_TITLE,
},
],
description: '',
debug: true,
},
]

const isGithubActionsRun = process.env.CI === 'true'

module.exports = {
transformIgnorePatterns: [
Expand All @@ -7,32 +45,5 @@ module.exports = {
setupFilesAfterEnv: ['./config/testSetup.js'],

testRunner: 'jest-circus/runner',
reporters: [
'github-actions',
[
'@reportportal/agent-js-jest',
{
apiKey: process.env.REPORTPORTAL_API_KEY,
endpoint: process.env.REPORTPORTAL_ENDPOINT,
project: process.env.REPORTPORTAL_PROJECT,
launch: 'data_visualizer_app_master',
attributes: [
{
key: 'version',
value: 'master',
},
{
key: 'app_name',
value: 'data_visualizer_app',
},
{
key: 'test_level',
value: 'unit/integration',
},
],
description: '',
debug: true,
},
],
],
reporters: ['default', ...(isGithubActionsRun ? [reportPortalConfig] : [])],
}

0 comments on commit 6ef7846

Please sign in to comment.