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