diff --git a/.github/workflows/ci-cd.yml b/.github/workflows/ci-cd.yml index 684ee5ebf..44e6f7052 100644 --- a/.github/workflows/ci-cd.yml +++ b/.github/workflows/ci-cd.yml @@ -60,6 +60,15 @@ jobs: - name: RSpec run: bin/knapsack_pro_rspec - uses: codecov/codecov-action@v3 + - name: Upload test results to BuildPulse for flaky test detection + if: '!cancelled()' # Run this step even when the tests fail. Skip if the workflow is cancelled. + uses: Workshop64/buildpulse-action@master + with: + account: ${{ secrets.BUILDPULSE_ACCOUNT }} + repository: ${{ secrets.BUILDPULSE_REPOSITORY }} + path: spec/reports + key: ${{ secrets.BUILDPULSE_ACCESS_KEY_ID }} + secret: ${{ secrets.BUILDPULSE_SECRET_ACCESS_KEY }} Jest: runs-on: ubuntu-latest @@ -82,6 +91,15 @@ jobs: - run: yarn install --frozen-lockfile - run: yarn lint:frontend - run: yarn test --colors + - name: Upload test results to BuildPulse for flaky test detection + if: '!cancelled()' # Run this step even when the tests fail. Skip if the workflow is cancelled. + uses: Workshop64/buildpulse-action@master + with: + account: ${{ secrets.BUILDPULSE_ACCOUNT }} + repository: ${{ secrets.BUILDPULSE_REPOSITORY }} + path: /junit.xml + key: ${{ secrets.BUILDPULSE_ACCESS_KEY_ID }} + secret: ${{ secrets.BUILDPULSE_SECRET_ACCESS_KEY }} - uses: codecov/codecov-action@v3 - run: yarn build-storybook @@ -188,6 +206,16 @@ jobs: - name: cypress non-seed run: CREATOR_ONBOARDING_SEED_DATA=1 E2E_FOLDER=creatorOnboardingFlows E2E=true bin/rails cypress:run if: ${{ matrix.ci_node_index == 'non-seed' }} + - name: Upload test results to BuildPulse for flaky test detection + if: '!cancelled()' # Run this step even when the tests fail. Skip if the workflow is cancelled. + uses: Workshop64/buildpulse-action@master + with: + account: ${{ secrets.BUILDPULSE_ACCOUNT }} + repository: ${{ secrets.BUILDPULSE_REPOSITORY }} + path: cypress/results + key: ${{ secrets.BUILDPULSE_ACCESS_KEY_ID }} + secret: ${{ secrets.BUILDPULSE_SECRET_ACCESS_KEY }} + CI-status-report: runs-on: ubuntu-latest diff --git a/.gitignore b/.gitignore index da1c6a2eb..9208a15c9 100644 --- a/.gitignore +++ b/.gitignore @@ -92,6 +92,7 @@ app/javascript/generated_stories/ cypress/videos cypress/screenshots cypress/logs +cypress/results # PostCSS error log postcss_error.log @@ -108,3 +109,7 @@ dump.rdb # generated yarddoc doc/ + +# spec reports +/spec/reports +/junit.xml diff --git a/.rspec b/.rspec index 2559e39fc..922a7a5fb 100644 --- a/.rspec +++ b/.rspec @@ -1,3 +1,5 @@ --color --format progress --require spec_helper +--format RspecJunitFormatter +--out spec/reports/rspec.xml diff --git a/Gemfile b/Gemfile index eb14bba56..4ecc009ad 100644 --- a/Gemfile +++ b/Gemfile @@ -144,6 +144,7 @@ group :development, :test do gem "pry", "~> 0.14" # An IRB alternative and runtime developer console gem "pry-rails", "~> 0.3" # Use Pry as your rails console gem "rspec-rails", "~> 5.1" # rspec-rails is a testing framework for Rails 3+ + gem "rspec_junit_formatter", "~> 0.6" # RSpec formatter for JUnit XML output gem "rswag-specs", "~> 2.5.1" # RSwag - Swagger-based DSL for rspec & accompanying rake task for generating Swagger files gem "rubocop", "~> 1.33", require: false # Automatic Ruby code style checking tool gem "rubocop-performance", "~> 1.14", require: false # A collection of RuboCop cops to check for performance optimizations in Ruby code diff --git a/Gemfile.lock b/Gemfile.lock index d3b2c9eac..a6baaebe9 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -734,6 +734,8 @@ GEM rspec-retry (0.6.2) rspec-core (> 3.3) rspec-support (3.11.1) + rspec_junit_formatter (0.6.0) + rspec-core (>= 2, < 4, != 2.12.0) rss (0.2.9) rexml rswag-specs (2.5.1) @@ -1064,6 +1066,7 @@ DEPENDENCIES rpush-redis (~> 1.1) rspec-rails (~> 5.1) rspec-retry (~> 0.6) + rspec_junit_formatter (~> 0.6) rss (~> 0.2.9) rswag-specs (~> 2.5.1) rubocop (~> 1.33) diff --git a/cypress.config.js b/cypress.config.js index 33f5e0c82..32238b1d3 100644 --- a/cypress.config.js +++ b/cypress.config.js @@ -10,5 +10,9 @@ module.exports = defineConfig({ trashAssetsBeforeRuns: false, video: false, retries: 3, + reporter: 'junit', + reporterOptions: { + mochaFile: 'cypress/results/results-[hash].xml', + }, }, }); diff --git a/jest.config.js b/jest.config.js index 33fc0e34c..74861528e 100644 --- a/jest.config.js +++ b/jest.config.js @@ -59,4 +59,16 @@ module.exports = { transformIgnorePatterns: [ '/node_modules/(?!(preact|react-colorful|i18n-js)/)', ], + reporters: [ + 'default', + [ + 'jest-junit', + { + addFileAttribute: 'true', + ancestorSeparator: ' › ', + classNameTemplate: '{classname}', + titleTemplate: '{title}', + }, + ], + ], }; diff --git a/package.json b/package.json index be5ce1df8..2732189b8 100644 --- a/package.json +++ b/package.json @@ -127,6 +127,7 @@ "he": "^1.2.0", "i18n-js": "^4.1.1", "intersection-observer": "^0.12.2", + "jest-junit": "^14.0.1", "linkstate": "^2.0.1", "lodash.debounce": "4.0.8", "moment": "^2.29.4", diff --git a/vendor/cache/rspec_junit_formatter-0.6.0.gem b/vendor/cache/rspec_junit_formatter-0.6.0.gem new file mode 100644 index 000000000..e128b1caa Binary files /dev/null and b/vendor/cache/rspec_junit_formatter-0.6.0.gem differ diff --git a/yarn.lock b/yarn.lock index cdb1d3050..db221299b 100644 --- a/yarn.lock +++ b/yarn.lock @@ -10411,6 +10411,16 @@ jest-haste-map@^28.1.3: optionalDependencies: fsevents "^2.3.2" +jest-junit@^14.0.1: + version "14.0.1" + resolved "https://registry.yarnpkg.com/jest-junit/-/jest-junit-14.0.1.tgz#5b357d6f5d333459585d628a24cd48b5bbc92ba2" + integrity sha512-h7/wwzPbllgpQhhVcRzRC76/cc89GlazThoV1fDxcALkf26IIlRsu/AcTG64f4nR2WPE3Cbd+i/sVf+NCUHrWQ== + dependencies: + mkdirp "^1.0.4" + strip-ansi "^6.0.1" + uuid "^8.3.2" + xml "^1.0.1" + jest-leak-detector@^28.1.3: version "28.1.3" resolved "https://registry.yarnpkg.com/jest-leak-detector/-/jest-leak-detector-28.1.3.tgz#a6685d9b074be99e3adee816ce84fd30795e654d" @@ -17307,6 +17317,11 @@ xml-name-validator@^4.0.0: resolved "https://registry.yarnpkg.com/xml-name-validator/-/xml-name-validator-4.0.0.tgz#79a006e2e63149a8600f15430f0a4725d1524835" integrity sha512-ICP2e+jsHvAj2E2lIHxa5tjXRlKDJo4IdvPvCXbXQGdzSfmSpNVyIKMvoZHjDY9DP0zV17iI85o90vRFXNccRw== +xml@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/xml/-/xml-1.0.1.tgz#78ba72020029c5bc87b8a81a3cfcd74b4a2fc1e5" + integrity sha512-huCv9IH9Tcf95zuYCsQraZtWnJvBtLVE0QHMOs8bWyZAFZNDcYjsPq1nEx8jKA9y+Beo9v+7OBPRisQTjinQMw== + xmlchars@^2.2.0: version "2.2.0" resolved "https://registry.yarnpkg.com/xmlchars/-/xmlchars-2.2.0.tgz#060fe1bcb7f9c76fe2a17db86a9bc3ab894210cb"