mysql_acceptance.yml 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183
  1. name: Acceptance
  2. # Optional, enabling concurrency limits: https://docs.github.com/en/actions/using-jobs/using-concurrency
  3. #concurrency:
  4. # group: ${{ github.ref }}-${{ github.workflow }}
  5. # cancel-in-progress: ${{ github.ref != 'refs/heads/main' }}
  6. # https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#permissions
  7. permissions:
  8. actions: none
  9. checks: none
  10. contents: none
  11. deployments: none
  12. id-token: none
  13. issues: none
  14. discussions: none
  15. packages: none
  16. pages: none
  17. pull-requests: none
  18. repository-projects: none
  19. security-events: none
  20. statuses: none
  21. on:
  22. push:
  23. branches-ignore:
  24. - gh-pages
  25. - metakitty
  26. pull_request:
  27. branches:
  28. - '*'
  29. paths:
  30. - 'metsploit-framework.gemspec'
  31. - 'Gemfile.lock'
  32. - '**/**mysql**'
  33. - 'spec/acceptance/**'
  34. - 'spec/support/acceptance/**'
  35. - 'spec/acceptance_spec_helper.rb'
  36. # Example of running as a cron, to weed out flaky tests
  37. # schedule:
  38. # - cron: '*/15 * * * *'
  39. jobs:
  40. mysql:
  41. runs-on: ${{ matrix.os }}
  42. timeout-minutes: 40
  43. services:
  44. mysql:
  45. image: ${{ matrix.target.version }}
  46. ports: ["3306:3306"]
  47. env:
  48. MYSQL_ROOT_PASSWORD: password
  49. options: >-
  50. --health-cmd "${{ matrix.target.health_cmd }}"
  51. --health-interval 10s
  52. --health-timeout 10s
  53. --health-retries 5
  54. strategy:
  55. fail-fast: true
  56. matrix:
  57. ruby:
  58. - '3.2'
  59. os:
  60. - ubuntu-latest
  61. target:
  62. - { version: "mariadb:latest", health_cmd: "mariadb -uroot -ppassword -e 'SELECT version()'" }
  63. - { version: "mariadb:5.5.42", health_cmd: "mysql -uroot -ppassword -e 'SELECT version()'" }
  64. - { version: "mysql:latest", health_cmd: "mysql -uroot -ppassword -e 'SELECT version()'" }
  65. - { version: "mysql:5.5.42", health_cmd: "mysql -uroot -ppassword -e 'SELECT version()'" }
  66. env:
  67. RAILS_ENV: test
  68. name: ${{ matrix.target.version }} - ${{ matrix.os }} - Ruby ${{ matrix.ruby }}
  69. steps:
  70. - name: Install system dependencies
  71. run: sudo apt-get install -y --no-install-recommends libpcap-dev graphviz
  72. - name: Checkout code
  73. uses: actions/checkout@v4
  74. - name: Setup Ruby
  75. env:
  76. BUNDLE_WITHOUT: "coverage development pcap"
  77. # Nokogiri doesn't release pre-compiled binaries for preview versions of Ruby; So force compilation with BUNDLE_FORCE_RUBY_PLATFORM
  78. BUNDLE_FORCE_RUBY_PLATFORM: "${{ contains(matrix.ruby, 'preview') && 'true' || 'false' }}"
  79. uses: ruby/setup-ruby@v1
  80. with:
  81. ruby-version: '${{ matrix.ruby }}'
  82. bundler-cache: true
  83. - name: Extract runtime version
  84. run: |
  85. echo "RUNTIME_VERSION=$(echo $DOCKER_IMAGE | awk -F: '{ print $2 }')" >> $GITHUB_ENV
  86. echo "DOCKER_IMAGE_FILENAME=$(echo $DOCKER_IMAGE | tr -d ':')" >> $GITHUB_ENV
  87. env:
  88. DOCKER_IMAGE: ${{ matrix.target.version }}
  89. OS: ${{ matrix.os }}
  90. - name: acceptance
  91. env:
  92. SPEC_HELPER_LOAD_METASPLOIT: false
  93. SPEC_OPTS: "--tag acceptance --require acceptance_spec_helper.rb --color --format documentation --format AllureRspec::RSpecFormatter"
  94. RUNTIME_VERSION: ${{ env.RUNTIME_VERSION }}
  95. # Unix run command:
  96. # SPEC_HELPER_LOAD_METASPLOIT=false bundle exec ./spec/acceptance
  97. # Windows cmd command:
  98. # set SPEC_HELPER_LOAD_METASPLOIT=false
  99. # bundle exec rspec .\spec\acceptance
  100. # Note: rspec retry is intentionally not used, as it can cause issues with allure's reporting
  101. # Additionally - flakey tests should be fixed or marked as flakey instead of silently retried
  102. run: |
  103. bundle exec rspec spec/acceptance/mysql_spec.rb
  104. - name: Archive results
  105. if: always()
  106. uses: actions/upload-artifact@v4
  107. with:
  108. # Provide a unique artifact for each matrix os, otherwise race conditions can lead to corrupt zips
  109. name: ${{ env.DOCKER_IMAGE_FILENAME }}-${{ matrix.os }}
  110. path: tmp/allure-raw-data
  111. # Generate a final report from the previous test results
  112. report:
  113. name: Generate report
  114. needs:
  115. - mysql
  116. runs-on: ubuntu-latest
  117. if: always()
  118. steps:
  119. - name: Checkout code
  120. uses: actions/checkout@v4
  121. if: always()
  122. - name: Install system dependencies (Linux)
  123. if: always()
  124. run: sudo apt-get -y --no-install-recommends install libpcap-dev graphviz
  125. - name: Setup Ruby
  126. if: always()
  127. env:
  128. BUNDLE_WITHOUT: "coverage development"
  129. BUNDLE_FORCE_RUBY_PLATFORM: true
  130. uses: ruby/setup-ruby@v1
  131. with:
  132. ruby-version: '${{ matrix.ruby }}'
  133. bundler-cache: true
  134. cache-version: 4
  135. # Github actions with Ruby requires Bundler 2.2.18+
  136. # https://github.com/ruby/setup-ruby/tree/d2b39ad0b52eca07d23f3aa14fdf2a3fcc1f411c#windows
  137. bundler: 2.2.33
  138. - uses: actions/download-artifact@v4
  139. id: download
  140. if: always()
  141. with:
  142. # Note: Not specifying a name will download all artifacts from the previous workflow jobs
  143. path: raw-data
  144. - name: allure generate
  145. if: always()
  146. run: |
  147. export VERSION=2.22.1
  148. curl -o allure-$VERSION.tgz -Ls https://github.com/allure-framework/allure2/releases/download/$VERSION/allure-$VERSION.tgz
  149. tar -zxvf allure-$VERSION.tgz -C .
  150. ls -la ${{steps.download.outputs.download-path}}
  151. ./allure-$VERSION/bin/allure generate ${{steps.download.outputs.download-path}}/* -o ./allure-report
  152. find ${{steps.download.outputs.download-path}}
  153. bundle exec ruby tools/dev/report_generation/support_matrix/generate.rb --allure-data ${{steps.download.outputs.download-path}} > ./allure-report/support_matrix.html
  154. - name: archive results
  155. if: always()
  156. uses: actions/upload-artifact@v4
  157. with:
  158. name: final-report-${{ github.run_id }}
  159. path: |
  160. ./allure-report