Skip to content

Commit bb2e729

Browse files
authored
Merge pull request #266 from cgranleese-r7/adds-acceptance-testing-reusable-pipeline
Adds a reusable pipeline for acceptance testing
2 parents 03217b8 + b3c6fc9 commit bb2e729

File tree

1 file changed

+5
-191
lines changed

1 file changed

+5
-191
lines changed

.github/workflows/metasploit-framework_acceptance.yml

Lines changed: 5 additions & 191 deletions
Original file line numberDiff line numberDiff line change
@@ -52,194 +52,8 @@ on:
5252
# - cron: '*/15 * * * *'
5353

5454
jobs:
55-
# Run all test individually, note there is a separate final job for aggregating the test results
56-
test:
57-
if: always()
58-
59-
strategy:
60-
fail-fast: false
61-
matrix:
62-
os:
63-
- macos-13
64-
- ubuntu-20.04
65-
ruby:
66-
- 3.0.2
67-
include:
68-
- { meterpreter: { name: mettle }, os: macos-13 }
69-
- { meterpreter: { name: mettle }, os: ubuntu-20.04 }
70-
71-
runs-on: ${{ matrix.os }}
72-
73-
timeout-minutes: 50
74-
75-
env:
76-
RAILS_ENV: test
77-
metasploitFrameworkCommit: ${{ github.event.inputs.metasploitFrameworkCommit || 'master' }}
78-
HOST_RUNNER_IMAGE: ${{ matrix.os }}
79-
SESSION: 'meterpreter/${{ matrix.meterpreter.name }}'
80-
SESSION_RUNTIME_VERSION: ${{ matrix.meterpreter.runtime_version }}
81-
BUNDLE_WITHOUT: "coverage development"
82-
83-
name: ${{ matrix.meterpreter.name }} ${{ matrix.meterpreter.runtime_version }} ${{ matrix.os }}
84-
steps:
85-
- name: Install system dependencies (Linux)
86-
if: runner.os == 'Linux'
87-
run: sudo apt-get -y --no-install-recommends install libpcap-dev graphviz
88-
89-
- uses: shivammathur/setup-php@c541c155eee45413f5b09a52248675b1a2575231
90-
if: ${{ matrix.meterpreter.name == 'php' }}
91-
with:
92-
php-version: ${{ matrix.meterpreter.runtime_version }}
93-
tools: none
94-
95-
# The job checkout structure is:
96-
# .
97-
# ├── metasploit-framework
98-
# └── mettle
99-
- name: Checkout mettle
100-
uses: actions/checkout@v4
101-
with:
102-
repository: rapid7/mettle
103-
path: mettle
104-
105-
- name: Get mettle version
106-
run: |
107-
echo "METTLE_VERSION=$(grep -oh '[0-9].[0-9].[0-9]*' lib/metasploit_payloads/mettle/version.rb)" | tee -a $GITHUB_ENV
108-
working-directory: mettle
109-
110-
- name: Prerequisite mettle gem setup
111-
run: |
112-
set -x
113-
ruby -pi.bak -e "gsub(/${{ env.METTLE_VERSION }}/, '${{ env.METTLE_VERSION }}-dev')" lib/metasploit_payloads/mettle/version.rb
114-
working-directory: mettle
115-
116-
- name: Compile mettle payloads
117-
if: ${{ runner.os != 'macos' }}
118-
run: |
119-
docker run --rm=true --tty --volume=$(pwd):/mettle --workdir=/mettle rapid7/build:mettle rake mettle:build mettle:check
120-
rake build
121-
working-directory: mettle
122-
123-
- name: Compile mettle payloads - macOS
124-
if: ${{ runner.os == 'macos' }}
125-
run: |
126-
make TARGET=x86_64-apple-darwin
127-
rake build
128-
working-directory: mettle
129-
130-
- name: Checkout metasploit-framework code
131-
uses: actions/checkout@v4
132-
with:
133-
repository: rapid7/metasploit-framework
134-
path: metasploit-framework
135-
ref: ${{ env.metasploitFrameworkCommit }}
136-
137-
- name: Setup Ruby
138-
env:
139-
BUNDLE_FORCE_RUBY_PLATFORM: true
140-
# Required for macos13 pg gem compilation
141-
PKG_CONFIG_PATH: "/usr/local/opt/libpq/lib/pkgconfig"
142-
uses: ruby/setup-ruby@v1
143-
with:
144-
ruby-version: ${{ matrix.ruby }}
145-
bundler-cache: true
146-
cache-version: 5
147-
working-directory: metasploit-framework
148-
149-
- name: Move mettle gem into framework
150-
run: |
151-
cp ../mettle/pkg/metasploit_payloads-mettle-${{ env.METTLE_VERSION }}.pre.dev.gem .
152-
working-directory: metasploit-framework
153-
154-
- name: Install mettle gem
155-
run: |
156-
set -x
157-
bundle exec gem install metasploit_payloads-mettle-${{ env.METTLE_VERSION }}.pre.dev.gem
158-
ruby -pi.bak -e "gsub(/'metasploit_payloads-mettle', '.*'/, '\'metasploit_payloads-mettle\', \'${{ env.METTLE_VERSION }}.pre.dev\'')" metasploit-framework.gemspec
159-
bundle config unset deployment
160-
bundle update metasploit_payloads-mettle
161-
bundle install
162-
working-directory: metasploit-framework
163-
164-
- name: Acceptance
165-
env:
166-
SPEC_HELPER_LOAD_METASPLOIT: false
167-
SPEC_OPTS: "--tag acceptance --require acceptance_spec_helper.rb --color --format documentation --format AllureRspec::RSpecFormatter"
168-
# Unix run command:
169-
# SPEC_HELPER_LOAD_METASPLOIT=false bundle exec ./spec/acceptance
170-
# Windows cmd command:
171-
# set SPEC_HELPER_LOAD_METASPLOIT=false
172-
# bundle exec rspec .\spec\acceptance
173-
# Note: rspec retry is intentionally not used, as it can cause issues with allure's reporting
174-
# Additionally - flakey tests should be fixed or marked as flakey instead of silently retried
175-
run: |
176-
bundle exec rspec spec/acceptance/meterpreter_spec.rb
177-
working-directory: metasploit-framework
178-
179-
- name: Archive results
180-
if: always()
181-
uses: actions/upload-artifact@v4
182-
with:
183-
# Provide a unique artifact for each matrix os, otherwise race conditions can lead to corrupt zips
184-
name: raw-data-${{ matrix.meterpreter.name }}-${{ matrix.meterpreter.runtime_version }}-${{ matrix.os }}
185-
path: metasploit-framework/tmp/allure-raw-data
186-
187-
# Generate a final report from the previous test results
188-
report:
189-
name: Generate report
190-
needs: [test]
191-
runs-on: ubuntu-latest
192-
if: always() && needs.test.result != 'skipped'
193-
194-
steps:
195-
- name: Checkout code
196-
uses: actions/checkout@v4
197-
with:
198-
repository: rapid7/metasploit-framework
199-
path: metasploit-framework
200-
ref: ${{ env.metasploitFrameworkCommit }}
201-
202-
- name: Install system dependencies (Linux)
203-
if: always()
204-
run: sudo apt-get -y --no-install-recommends install libpcap-dev graphviz
205-
206-
- name: Setup Ruby
207-
if: always()
208-
env:
209-
BUNDLE_FORCE_RUBY_PLATFORM: true
210-
uses: ruby/setup-ruby@v1
211-
with:
212-
ruby-version: '3.3'
213-
bundler-cache: true
214-
cache-version: 5
215-
working-directory: metasploit-framework
216-
217-
- uses: actions/download-artifact@v4
218-
id: raw_report_data
219-
if: always()
220-
with:
221-
# Note: Not specifying a name will download all artifacts from the previous workflow jobs
222-
path: raw-data
223-
224-
- name: allure generate
225-
if: always()
226-
run: |
227-
export VERSION=2.22.1
228-
229-
curl -o allure-$VERSION.tgz -Ls https://github.com/allure-framework/allure2/releases/download/$VERSION/allure-$VERSION.tgz
230-
tar -zxvf allure-$VERSION.tgz -C .
231-
232-
ls -la ${{steps.raw_report_data.outputs.download-path}}
233-
./allure-$VERSION/bin/allure generate ${{steps.raw_report_data.outputs.download-path}}/* -o ./allure-report
234-
235-
find ${{steps.raw_report_data.outputs.download-path}}
236-
bundle exec ruby tools/dev/report_generation/support_matrix/generate.rb --allure-data ${{steps.raw_report_data.outputs.download-path}} > ./allure-report/support_matrix.html
237-
working-directory: metasploit-framework
238-
239-
- name: archive results
240-
if: always()
241-
uses: actions/upload-artifact@v4
242-
with:
243-
name: final-report-${{ github.run_id }}
244-
path: |
245-
./allure-report
55+
build:
56+
uses: rapid7/metasploit-framework/.github/workflows/shared_meterpreter_acceptance.yml@master
57+
with:
58+
metasploit-framework_commit: ${{ github.event.inputs.metasploitFrameworkCommit }}
59+
build_mettle: true

0 commit comments

Comments
 (0)