Skip to content

Commit

Permalink
Refactor CI
Browse files Browse the repository at this point in the history
  • Loading branch information
MEhrn00 committed Feb 10, 2024
1 parent 2dc256f commit 83c785b
Show file tree
Hide file tree
Showing 3 changed files with 65 additions and 129 deletions.
45 changes: 0 additions & 45 deletions .github/actions/setup-env/action.yml

This file was deleted.

74 changes: 25 additions & 49 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,77 +9,53 @@ env:


jobs:
syntax:
name: Syntax
agent:
name: Agent Code
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Setup environment
uses: ./.github/actions/setup-env
with:
agent-code: ${{ env.AGENT_CODE }}
mythic-code: ${{ env.MYTHIC_CODE }}

- name: Check Mythic code for errors
working-directory: ${{ env.MYTHIC_CODE }}
run: gofmt -e . 1>/dev/null

- name: Check Agent code for errors
defaults:
run:
working-directory: ${{ env.AGENT_CODE }}
run: |
make .config
sed -i 's/-e //' .config
make genconfig
env CONFIG=$(pwd)/.config.bin cargo check --color always --workspace --exclude genconfig --all-targets --all-features
format:
name: Code Formatting
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Setup environment
uses: ./.github/actions/setup-env
with:
agent-code: ${{ env.AGENT_CODE }}
mythic-code: ${{ env.MYTHIC_CODE }}
- name: Install Clippy
run: rustup component add clippy

- name: Check Mythic code formatting
working-directory: ${{ env.MYTHIC_CODE }}
run: gofmt -l -d . | diff -u /dev/null -
- name: Lint agent code
continue-on-error: true
run: cargo clippy --color always --all-features --all-targets -- -D warnings

- name: Check Agent code formatting
working-directory: ${{ env.AGENT_CODE }}
- name: Check agent code formatting
run: cargo fmt --all -- --color always --check

lint:
name: Linting
mythic:
name: Mythic Code
runs-on: ubuntu-latest

defaults:
run:
working-directory: ${{ env.MYTHIC_CODE }}

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Setup environment
uses: ./.github/actions/setup-env
- name: Install Golang
uses: actions/setup-go@v5
with:
agent-code: ${{ env.AGENT_CODE }}
mythic-code: ${{ env.MYTHIC_CODE }}
go-version: '1.21'

- name: Install Clippy
run: rustup component add clippy
- name: Install Golang modules
run: go mod download

- name: Lint Mythic code with golangci-lint
- name: Lint Mythic code
continue-on-error: true
uses: golangci/golangci-lint-action@v3
with:
version: latest
working-directory: ${{ env.MYTHIC_CODE }}

- name: Lint Agent code with clippy
working-directory: ${{ env.AGENT_CODE }}
run: cargo clippy --color always --all-features --all-targets -- -D warnings
- name: Check Mythic code formatting
run: gofmt -l -d . | diff -u /dev/null -
75 changes: 40 additions & 35 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,56 +13,61 @@ jobs:
name: Agent Tests
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Setup environment
uses: ./.github/actions/setup-env
with:
agent-code: ${{ env.AGENT_CODE }}
mythic-code: ${{ env.MYTHIC_CODE }}

- name: Run agent tests
defaults:
run:
working-directory: ${{ env.AGENT_CODE }}
run: |
make .config
sed -i 's/-e //' .config
make genconfig
env CONFIG=$(pwd)/.config.bin cargo test --color always --workspace --exclude genconfig --all-targets --all-features
commands:
name: Mythic Command Tests
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Setup environment
uses: ./.github/actions/setup-env
- name: Setup cargo cache
uses: actions/cache@v4
with:
agent-code: ${{ env.AGENT_CODE }}
mythic-code: ${{ env.MYTHIC_CODE }}
path: ~/.cargo
key: ${{ runner.os }}-cargo-${{ hashFiles('Cargo.toml') }}
restore-keys: |
${{ runner.os }}-cargo-${{ hashFiles('Cargo.toml') }}
${{ runner.os }}-cargo
- name: Run command tests
working-directory: ${{ env.MYTHIC_CODE }}
run: go test ./commands/...
- name: Setup cargo target cache
uses: actions/cache@v4
with:
path: target
key: ${{ runner.os }}-cargo-target-${{ hashFiles('Cargo.toml') }}
restore-keys: |
${{ runner.os }}-cargo-target-${{ hashFiles('Cargo.toml') }}
${{ runner.os }}-cargo-target
- name: Install system libraries
run: sudo apt-get update -y && sudo apt-get install -y libdbus-1-dev

- name: Agent tests
run: cargo test --color always --workspace --exclude genconfig --all-features

mockbuild:
name: Payload Mock Build Tests
mythic:
name: Mythic Tests
runs-on: ubuntu-latest

defaults:
run:
working-directory: ${{ env.MYTHIC_CODE }}

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Setup environment
uses: ./.github/actions/setup-env
- name: Install Golang
uses: actions/setup-go@v5
with:
agent-code: ${{ env.AGENT_CODE }}
mythic-code: ${{ env.MYTHIC_CODE }}
go-version: '1.21'

- name: Run mockbuild tests
working-directory: ${{ env.MYTHIC_CODE }}
- name: Install Golang modules
run: go mod download

- name: Command tests
continue-on-error: true
run: go test ./commands/...

- name: Mockbuild tests
run: go test -run "^TestPayloadMockBuild/" ./builder

0 comments on commit 83c785b

Please sign in to comment.