-
Notifications
You must be signed in to change notification settings - Fork 14.9k
187 lines (163 loc) · 6.19 KB
/
shared_smb_acceptance.yml
File metadata and controls
187 lines (163 loc) · 6.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
name: Shared SMB Acceptance
on:
workflow_call:
inputs:
# Defaults set as '' will use the current branch as their commit
metasploit_framework_commit:
description: "metasploit-framework commit to build with"
default: ''
required: false
type: string
build_smb:
description: "Whether or not to build ruby_smb"
default: false
required: false
type: boolean
jobs:
smb:
runs-on: ${{ matrix.os }}
timeout-minutes: 60
strategy:
fail-fast: false
matrix:
ruby:
- '3.2'
os:
- ubuntu-latest
env:
RAILS_ENV: test
SMB_USERNAME: acceptance_tests_user
SMB_PASSWORD: acceptance_tests_password
BUNDLE_WITHOUT: "coverage development pcap"
name: SMB Acceptance - ${{ matrix.os }} - Ruby ${{ matrix.ruby }}
steps:
# The job checkout structure is:
# .
# ├── metasploit-framework
# └── ruby_smb
- name: Checkout ruby_smb
uses: actions/checkout@v4
with:
repository: rapid7/ruby_smb
path: ruby_smb
- name: Get ruby_smb version
if: ${{ inputs.build_smb }}
run: |
echo "RUBY_SMB_VERSION=$(grep -oh '[0-9].[0-9].[0-9]*' lib/ruby_smb/version.rb)" | tee -a $GITHUB_ENV
working-directory: ruby_smb
- name: Build ruby_smb gem
if: ${{ inputs.build_smb }}
run: |
gem build ruby_smb.gemspec
working-directory: ruby_smb
- name: Install system dependencies
run: sudo apt-get install -y --no-install-recommends libpcap-dev graphviz
- name: Checkout metasploit-framework code
uses: actions/checkout@v4
with:
repository: rapid7/metasploit-framework
path: metasploit-framework
ref: ${{ inputs.metasploit_framework_commit }}
- name: Run docker container
working-directory: 'metasploit-framework'
run: |
cd test/smb
docker compose build
docker compose up --wait -d
- name: Setup Ruby
run: git config --system core.longpaths true
env:
# Nokogiri doesn't release pre-compiled binaries for preview versions of Ruby; So force compilation with BUNDLE_FORCE_RUBY_PLATFORM
BUNDLE_FORCE_RUBY_PLATFORM: "${{ contains(matrix.ruby, 'preview') && 'true' || 'false' }}"
uses: ruby/setup-ruby@v1
with:
ruby-version: '${{ matrix.ruby }}'
bundler-cache: true
working-directory: 'metasploit-framework'
- name: Copy ruby_smb gem into metasploit-framework
if: ${{ inputs.build_smb }}
run: |
cp ../ruby_smb/ruby_smb-${{ env.RUBY_SMB_VERSION }}.gem .
working-directory: metasploit-framework
- name: Install ruby_smb gem
if: ${{ inputs.build_smb }}
run: |
bundle exec gem install ruby_smb-${{ env.RUBY_SMB_VERSION }}.gem
bundle config unset deployment
bundle update ruby_smb
bundle install
working-directory: metasploit-framework
- name: acceptance
env:
SPEC_HELPER_LOAD_METASPLOIT: false
SPEC_OPTS: "--tag acceptance --require acceptance_spec_helper.rb --color --format documentation --format AllureRspec::RSpecFormatter"
RUNTIME_VERSION: 'latest'
# Unix run command:
# SPEC_HELPER_LOAD_METASPLOIT=false bundle exec ./spec/acceptance
# Windows cmd command:
# set SPEC_HELPER_LOAD_METASPLOIT=false
# bundle exec rspec .\spec\acceptance
# Note: rspec retry is intentionally not used, as it can cause issues with allure's reporting
# Additionally - flakey tests should be fixed or marked as flakey instead of silently retried
run: |
bundle exec rspec spec/acceptance/smb_spec.rb
working-directory: metasploit-framework
- name: Archive results
if: always()
uses: actions/upload-artifact@v4
with:
# Provide a unique artifact for each matrix os, otherwise race conditions can lead to corrupt zips
name: smb_acceptance-${{ matrix.os }}
path: metasploit-framework/tmp/allure-raw-data
# Generate a final report from the previous test results
report:
name: Generate report
needs:
- smb
runs-on: ubuntu-latest
if: always()
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
repository: rapid7/metasploit-framework
path: metasploit-framework
ref: ${{ inputs.metasploit_framework_commit }}
- name: Install system dependencies (Linux)
if: always()
run: sudo apt-get -y --no-install-recommends install libpcap-dev graphviz
- name: Setup Ruby
run: git config --system core.longpaths true
if: always()
env:
BUNDLE_FORCE_RUBY_PLATFORM: true
uses: ruby/setup-ruby@v1
with:
ruby-version: '${{ matrix.ruby }}'
bundler-cache: true
cache-version: 4
working-directory: metasploit-framework
- uses: actions/download-artifact@v4
id: download
if: always()
with:
# Note: Not specifying a name will download all artifacts from the previous workflow jobs
path: raw-data
- name: allure generate
if: always()
run: |
export VERSION=2.22.1
curl -o allure-$VERSION.tgz -Ls https://github.com/allure-framework/allure2/releases/download/$VERSION/allure-$VERSION.tgz
tar -zxvf allure-$VERSION.tgz -C .
ls -la ${{steps.download.outputs.download-path}}
./allure-$VERSION/bin/allure generate ${{steps.download.outputs.download-path}}/* -o ./allure-report
find ${{steps.download.outputs.download-path}}
bundle exec ruby tools/dev/report_generation/support_matrix/generate.rb --allure-data ${{steps.download.outputs.download-path}} > ./allure-report/support_matrix.html
working-directory: metasploit-framework
- name: archive results
if: always()
uses: actions/upload-artifact@v4
with:
name: final-report-${{ github.run_id }}
path: |
./allure-report