Skip to content

Unit-Testing using contentctl #39

Unit-Testing using contentctl

Unit-Testing using contentctl #39

Workflow file for this run

name: unit-testing
on:
push:
pull_request:
types: [opened, reopened]
jobs:
contentctl-unit-testing:
runs-on: ubuntu-latest
if: "!contains(github.ref, 'refs/tags/')" #don't run on tags - future steps won't run either since they depend on this job
# needs: [validate-tag-if-present, quit-for-dependabot]
steps:
- name: Check out the repository code
uses: actions/checkout@v3
with:
ref: develop
- uses: actions/setup-python@v4
with:
python-version: '3.11' #Available versions here - https://github.com/actions/python-versions/releases easy to change/make a matrix/use pypy
architecture: 'x64' # optional x64 or x86. Defaults to x64 if not specified
- name: Install System Packages
run: |
sudo apt update -qq
sudo apt install jq -qq
- name: Install Python Dependencies
run: |
python3.11 -m venv .venv
source .venv/bin/activate
pip install contentctl
git clone --depth=1 --single-branch --branch=master https://github.com/redcanaryco/atomic-red-team.git
- name: Run ContentCTL test for changes against develop
run: |
git pull
source .venv/bin/activate
git checkout ${GITHUB_REF#refs/heads/}
# cat summary.yml
# contentctl test --post-test-behavior never_pause mode:changes --mode.target-branch develop
mkdir artifacts
mkdir test_results
cp summary.yml test_results/
cp test_results/summary.yml artifacts/
cat test_results/summary.yml
continue-on-error: true
- name: store_artifacts
uses: actions/upload-artifact@v3
with:
name: content-latest
path: |
artifacts/summary.yml
- name: Install JQ
run: sudo apt-get install -y jq
- name: Print entire test_results/summary.yml
run: cat test_results/summary.yml
- name: Formatted Final Report
run: |
chmod +x .github/workflows/format_test_summary.sh
./.github/workflows/format_test_summary.sh