mssql_acceptance.yml 5.8 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. - '**/**mssql**'
  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. mssql:
  41. runs-on: ${{ matrix.os }}
  42. timeout-minutes: 40
  43. services:
  44. mssql:
  45. image: ${{ matrix.docker_image }}
  46. ports: ["1433:1433"]
  47. env:
  48. MSSQL_SA_PASSWORD: yourStrong(!)Password
  49. ACCEPT_EULA: 'Y'
  50. options: >-
  51. --health-cmd "/opt/mssql-tools/bin/sqlcmd -U sa -P 'yourStrong(!)Password' -Q 'select 1' -b -o /dev/null"
  52. --health-interval 10s
  53. --health-timeout 5s
  54. --health-retries 5
  55. strategy:
  56. fail-fast: true
  57. matrix:
  58. ruby:
  59. - '3.2'
  60. os:
  61. - ubuntu-latest
  62. docker_image:
  63. - mcr.microsoft.com/mssql/server:2022-latest
  64. - mcr.microsoft.com/mssql/server:2019-latest
  65. env:
  66. RAILS_ENV: test
  67. name: ${{ matrix.docker_image }} - ${{ matrix.os }} - Ruby ${{ matrix.ruby }}
  68. steps:
  69. - name: Install system dependencies
  70. run: sudo apt-get install -y --no-install-recommends libpcap-dev graphviz
  71. - name: Checkout code
  72. uses: actions/checkout@v4
  73. - name: Setup Ruby
  74. env:
  75. BUNDLE_WITHOUT: "coverage development pcap"
  76. # Nokogiri doesn't release pre-compiled binaries for preview versions of Ruby; So force compilation with BUNDLE_FORCE_RUBY_PLATFORM
  77. BUNDLE_FORCE_RUBY_PLATFORM: "${{ contains(matrix.ruby, 'preview') && 'true' || 'false' }}"
  78. uses: ruby/setup-ruby@v1
  79. with:
  80. ruby-version: '${{ matrix.ruby }}'
  81. bundler-cache: true
  82. - name: Extract runtime version
  83. run: |
  84. echo "RUNTIME_VERSION=$(echo $DOCKER_IMAGE | awk -F: '{ print $2 }')" >> $GITHUB_ENV
  85. echo "DOCKER_IMAGE_FILENAME=$(echo $DOCKER_IMAGE | tr -d '/:')" >> $GITHUB_ENV
  86. env:
  87. DOCKER_IMAGE: ${{ matrix.docker_image }}
  88. OS: ${{ matrix.os }}
  89. - name: acceptance
  90. env:
  91. SPEC_HELPER_LOAD_METASPLOIT: false
  92. SPEC_OPTS: "--tag acceptance --require acceptance_spec_helper.rb --color --format documentation --format AllureRspec::RSpecFormatter"
  93. RUNTIME_VERSION: ${{ env.RUNTIME_VERSION }}
  94. # Unix run command:
  95. # SPEC_HELPER_LOAD_METASPLOIT=false bundle exec ./spec/acceptance
  96. # Windows cmd command:
  97. # set SPEC_HELPER_LOAD_METASPLOIT=false
  98. # bundle exec rspec .\spec\acceptance
  99. # Note: rspec retry is intentionally not used, as it can cause issues with allure's reporting
  100. # Additionally - flakey tests should be fixed or marked as flakey instead of silently retried
  101. run: |
  102. bundle exec rspec spec/acceptance/mssql_spec.rb
  103. - name: Archive results
  104. if: always()
  105. uses: actions/upload-artifact@v4
  106. with:
  107. # Provide a unique artifact for each matrix os, otherwise race conditions can lead to corrupt zips
  108. name: ${{ env.DOCKER_IMAGE_FILENAME }}-${{ matrix.os }}
  109. path: tmp/allure-raw-data
  110. # Generate a final report from the previous test results
  111. report:
  112. name: Generate report
  113. needs:
  114. - mssql
  115. runs-on: ubuntu-latest
  116. if: always()
  117. steps:
  118. - name: Checkout code
  119. uses: actions/checkout@v4
  120. if: always()
  121. - name: Install system dependencies (Linux)
  122. if: always()
  123. run: sudo apt-get -y --no-install-recommends install libpcap-dev graphviz
  124. - name: Setup Ruby
  125. if: always()
  126. env:
  127. BUNDLE_WITHOUT: "coverage development"
  128. BUNDLE_FORCE_RUBY_PLATFORM: true
  129. uses: ruby/setup-ruby@v1
  130. with:
  131. ruby-version: '${{ matrix.ruby }}'
  132. bundler-cache: true
  133. cache-version: 4
  134. # Github actions with Ruby requires Bundler 2.2.18+
  135. # https://github.com/ruby/setup-ruby/tree/d2b39ad0b52eca07d23f3aa14fdf2a3fcc1f411c#windows
  136. bundler: 2.2.33
  137. - uses: actions/download-artifact@v4
  138. id: download
  139. if: always()
  140. with:
  141. # Note: Not specifying a name will download all artifacts from the previous workflow jobs
  142. path: raw-data
  143. - name: allure generate
  144. if: always()
  145. run: |
  146. export VERSION=2.22.1
  147. curl -o allure-$VERSION.tgz -Ls https://github.com/allure-framework/allure2/releases/download/$VERSION/allure-$VERSION.tgz
  148. tar -zxvf allure-$VERSION.tgz -C .
  149. ls -la ${{steps.download.outputs.download-path}}
  150. ./allure-$VERSION/bin/allure generate ${{steps.download.outputs.download-path}}/* -o ./allure-report
  151. find ${{steps.download.outputs.download-path}}
  152. bundle exec ruby tools/dev/report_generation/support_matrix/generate.rb --allure-data ${{steps.download.outputs.download-path}} > ./allure-report/support_matrix.html
  153. - name: archive results
  154. if: always()
  155. uses: actions/upload-artifact@v4
  156. with:
  157. name: final-report-${{ github.run_id }}
  158. path: |
  159. ./allure-report