Skip to content

Commit 83c785b

Browse files
committed
Refactor CI
1 parent 2dc256f commit 83c785b

File tree

3 files changed

+65
-129
lines changed

3 files changed

+65
-129
lines changed

.github/actions/setup-env/action.yml

Lines changed: 0 additions & 45 deletions
This file was deleted.

.github/workflows/lint.yml

Lines changed: 25 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -9,77 +9,53 @@ env:
99

1010

1111
jobs:
12-
syntax:
13-
name: Syntax
12+
agent:
13+
name: Agent Code
1414
runs-on: ubuntu-latest
1515

16-
steps:
17-
- name: Checkout code
18-
uses: actions/checkout@v4
19-
20-
- name: Setup environment
21-
uses: ./.github/actions/setup-env
22-
with:
23-
agent-code: ${{ env.AGENT_CODE }}
24-
mythic-code: ${{ env.MYTHIC_CODE }}
25-
26-
- name: Check Mythic code for errors
27-
working-directory: ${{ env.MYTHIC_CODE }}
28-
run: gofmt -e . 1>/dev/null
29-
30-
- name: Check Agent code for errors
16+
defaults:
17+
run:
3118
working-directory: ${{ env.AGENT_CODE }}
32-
run: |
33-
make .config
34-
sed -i 's/-e //' .config
35-
make genconfig
36-
env CONFIG=$(pwd)/.config.bin cargo check --color always --workspace --exclude genconfig --all-targets --all-features
37-
38-
format:
39-
name: Code Formatting
40-
runs-on: ubuntu-latest
4119

4220
steps:
4321
- name: Checkout code
4422
uses: actions/checkout@v4
4523

46-
- name: Setup environment
47-
uses: ./.github/actions/setup-env
48-
with:
49-
agent-code: ${{ env.AGENT_CODE }}
50-
mythic-code: ${{ env.MYTHIC_CODE }}
24+
- name: Install Clippy
25+
run: rustup component add clippy
5126

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

56-
- name: Check Agent code formatting
57-
working-directory: ${{ env.AGENT_CODE }}
31+
- name: Check agent code formatting
5832
run: cargo fmt --all -- --color always --check
5933

60-
lint:
61-
name: Linting
34+
mythic:
35+
name: Mythic Code
6236
runs-on: ubuntu-latest
6337

38+
defaults:
39+
run:
40+
working-directory: ${{ env.MYTHIC_CODE }}
41+
6442
steps:
6543
- name: Checkout code
6644
uses: actions/checkout@v4
6745

68-
- name: Setup environment
69-
uses: ./.github/actions/setup-env
46+
- name: Install Golang
47+
uses: actions/setup-go@v5
7048
with:
71-
agent-code: ${{ env.AGENT_CODE }}
72-
mythic-code: ${{ env.MYTHIC_CODE }}
49+
go-version: '1.21'
7350

74-
- name: Install Clippy
75-
run: rustup component add clippy
51+
- name: Install Golang modules
52+
run: go mod download
7653

77-
- name: Lint Mythic code with golangci-lint
54+
- name: Lint Mythic code
55+
continue-on-error: true
7856
uses: golangci/golangci-lint-action@v3
7957
with:
8058
version: latest
81-
working-directory: ${{ env.MYTHIC_CODE }}
8259

83-
- name: Lint Agent code with clippy
84-
working-directory: ${{ env.AGENT_CODE }}
85-
run: cargo clippy --color always --all-features --all-targets -- -D warnings
60+
- name: Check Mythic code formatting
61+
run: gofmt -l -d . | diff -u /dev/null -

.github/workflows/test.yml

Lines changed: 40 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -13,56 +13,61 @@ jobs:
1313
name: Agent Tests
1414
runs-on: ubuntu-latest
1515

16-
steps:
17-
- name: Checkout code
18-
uses: actions/checkout@v4
19-
20-
- name: Setup environment
21-
uses: ./.github/actions/setup-env
22-
with:
23-
agent-code: ${{ env.AGENT_CODE }}
24-
mythic-code: ${{ env.MYTHIC_CODE }}
25-
26-
- name: Run agent tests
16+
defaults:
17+
run:
2718
working-directory: ${{ env.AGENT_CODE }}
28-
run: |
29-
make .config
30-
sed -i 's/-e //' .config
31-
make genconfig
32-
env CONFIG=$(pwd)/.config.bin cargo test --color always --workspace --exclude genconfig --all-targets --all-features
33-
34-
commands:
35-
name: Mythic Command Tests
36-
runs-on: ubuntu-latest
3719

3820
steps:
3921
- name: Checkout code
4022
uses: actions/checkout@v4
4123

42-
- name: Setup environment
43-
uses: ./.github/actions/setup-env
24+
- name: Setup cargo cache
25+
uses: actions/cache@v4
4426
with:
45-
agent-code: ${{ env.AGENT_CODE }}
46-
mythic-code: ${{ env.MYTHIC_CODE }}
27+
path: ~/.cargo
28+
key: ${{ runner.os }}-cargo-${{ hashFiles('Cargo.toml') }}
29+
restore-keys: |
30+
${{ runner.os }}-cargo-${{ hashFiles('Cargo.toml') }}
31+
${{ runner.os }}-cargo
4732
48-
- name: Run command tests
49-
working-directory: ${{ env.MYTHIC_CODE }}
50-
run: go test ./commands/...
33+
- name: Setup cargo target cache
34+
uses: actions/cache@v4
35+
with:
36+
path: target
37+
key: ${{ runner.os }}-cargo-target-${{ hashFiles('Cargo.toml') }}
38+
restore-keys: |
39+
${{ runner.os }}-cargo-target-${{ hashFiles('Cargo.toml') }}
40+
${{ runner.os }}-cargo-target
41+
42+
- name: Install system libraries
43+
run: sudo apt-get update -y && sudo apt-get install -y libdbus-1-dev
44+
45+
- name: Agent tests
46+
run: cargo test --color always --workspace --exclude genconfig --all-features
5147

52-
mockbuild:
53-
name: Payload Mock Build Tests
48+
mythic:
49+
name: Mythic Tests
5450
runs-on: ubuntu-latest
5551

52+
defaults:
53+
run:
54+
working-directory: ${{ env.MYTHIC_CODE }}
55+
5656
steps:
5757
- name: Checkout code
5858
uses: actions/checkout@v4
5959

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

66-
- name: Run mockbuild tests
67-
working-directory: ${{ env.MYTHIC_CODE }}
65+
- name: Install Golang modules
66+
run: go mod download
67+
68+
- name: Command tests
69+
continue-on-error: true
70+
run: go test ./commands/...
71+
72+
- name: Mockbuild tests
6873
run: go test -run "^TestPayloadMockBuild/" ./builder

0 commit comments

Comments
 (0)