smb_acceptance.yml 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167
  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. - '**/**smb**'
  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. smb:
  41. runs-on: ${{ matrix.os }}
  42. timeout-minutes: 40
  43. strategy:
  44. fail-fast: true
  45. matrix:
  46. ruby:
  47. - '3.2'
  48. os:
  49. - ubuntu-latest
  50. env:
  51. RAILS_ENV: test
  52. SMB_USERNAME: acceptance_tests_user
  53. SMB_PASSWORD: acceptance_tests_password
  54. name: SMB Acceptance - ${{ matrix.os }} - Ruby ${{ matrix.ruby }}
  55. steps:
  56. - name: Install system dependencies
  57. run: sudo apt-get install -y --no-install-recommends libpcap-dev graphviz
  58. - name: Checkout code
  59. uses: actions/checkout@v4
  60. - name: Run docker container
  61. working-directory: 'test/smb'
  62. run: |
  63. docker compose build
  64. docker compose up --wait -d
  65. - name: Setup Ruby
  66. env:
  67. BUNDLE_WITHOUT: "coverage development pcap"
  68. # Nokogiri doesn't release pre-compiled binaries for preview versions of Ruby; So force compilation with BUNDLE_FORCE_RUBY_PLATFORM
  69. BUNDLE_FORCE_RUBY_PLATFORM: "${{ contains(matrix.ruby, 'preview') && 'true' || 'false' }}"
  70. uses: ruby/setup-ruby@v1
  71. with:
  72. ruby-version: '${{ matrix.ruby }}'
  73. bundler-cache: true
  74. - name: acceptance
  75. env:
  76. SPEC_HELPER_LOAD_METASPLOIT: false
  77. SPEC_OPTS: "--tag acceptance --require acceptance_spec_helper.rb --color --format documentation --format AllureRspec::RSpecFormatter"
  78. RUNTIME_VERSION: 'latest'
  79. # Unix run command:
  80. # SPEC_HELPER_LOAD_METASPLOIT=false bundle exec ./spec/acceptance
  81. # Windows cmd command:
  82. # set SPEC_HELPER_LOAD_METASPLOIT=false
  83. # bundle exec rspec .\spec\acceptance
  84. # Note: rspec retry is intentionally not used, as it can cause issues with allure's reporting
  85. # Additionally - flakey tests should be fixed or marked as flakey instead of silently retried
  86. run: |
  87. bundle exec rspec spec/acceptance/smb_spec.rb
  88. - name: Archive results
  89. if: always()
  90. uses: actions/upload-artifact@v4
  91. with:
  92. # Provide a unique artifact for each matrix os, otherwise race conditions can lead to corrupt zips
  93. name: smb_acceptance-${{ matrix.os }}
  94. path: tmp/allure-raw-data
  95. # Generate a final report from the previous test results
  96. report:
  97. name: Generate report
  98. needs:
  99. - smb
  100. runs-on: ubuntu-latest
  101. if: always()
  102. steps:
  103. - name: Checkout code
  104. uses: actions/checkout@v4
  105. if: always()
  106. - name: Install system dependencies (Linux)
  107. if: always()
  108. run: sudo apt-get -y --no-install-recommends install libpcap-dev graphviz
  109. - name: Setup Ruby
  110. if: always()
  111. env:
  112. BUNDLE_WITHOUT: "coverage development"
  113. BUNDLE_FORCE_RUBY_PLATFORM: true
  114. uses: ruby/setup-ruby@v1
  115. with:
  116. ruby-version: '${{ matrix.ruby }}'
  117. bundler-cache: true
  118. cache-version: 4
  119. # Github actions with Ruby requires Bundler 2.2.18+
  120. # https://github.com/ruby/setup-ruby/tree/d2b39ad0b52eca07d23f3aa14fdf2a3fcc1f411c#windows
  121. bundler: 2.2.33
  122. - uses: actions/download-artifact@v4
  123. id: download
  124. if: always()
  125. with:
  126. # Note: Not specifying a name will download all artifacts from the previous workflow jobs
  127. path: raw-data
  128. - name: allure generate
  129. if: always()
  130. run: |
  131. export VERSION=2.22.1
  132. curl -o allure-$VERSION.tgz -Ls https://github.com/allure-framework/allure2/releases/download/$VERSION/allure-$VERSION.tgz
  133. tar -zxvf allure-$VERSION.tgz -C .
  134. ls -la ${{steps.download.outputs.download-path}}
  135. ./allure-$VERSION/bin/allure generate ${{steps.download.outputs.download-path}}/* -o ./allure-report
  136. find ${{steps.download.outputs.download-path}}
  137. bundle exec ruby tools/dev/report_generation/support_matrix/generate.rb --allure-data ${{steps.download.outputs.download-path}} > ./allure-report/support_matrix.html
  138. - name: archive results
  139. if: always()
  140. uses: actions/upload-artifact@v4
  141. with:
  142. name: final-report-${{ github.run_id }}
  143. path: |
  144. ./allure-report