diff --git a/.github/actions/setup-lint/action.yml b/.github/actions/setup-env/action.yml similarity index 100% rename from .github/actions/setup-lint/action.yml rename to .github/actions/setup-env/action.yml diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index f2843c1..6d5762a 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -36,7 +36,7 @@ jobs: uses: actions/checkout@v4 - name: Setup environment - uses: ./.github/actions/setup-lint + uses: ./.github/actions/setup-env with: agent-code: ${{ env.AGENT_CODE }} mythic-code: ${{ env.MYTHIC_CODE }} @@ -60,7 +60,7 @@ jobs: uses: actions/checkout@v4 - name: Setup environment - uses: ./.github/actions/setup-lint + uses: ./.github/actions/setup-env with: agent-code: ${{ env.AGENT_CODE }} mythic-code: ${{ env.MYTHIC_CODE }} @@ -82,7 +82,7 @@ jobs: uses: actions/checkout@v4 - name: Setup environment - uses: ./.github/actions/setup-lint + uses: ./.github/actions/setup-env with: agent-code: ${{ env.AGENT_CODE }} mythic-code: ${{ env.MYTHIC_CODE }} diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..fa7ee2d --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,76 @@ +name: Run tests + +on: + push: + branches: + - main + - dev + - test/** + paths: + - Payload_Type/thanatos/agent/** + - Payload_Type/thanatos/mythic/** + - .github/** + + workflow_call: + +env: + AGENT_CODE: Payload_Type/thanatos/agent + MYTHIC_CODE: Payload_Type/thanatos/mythic + + +jobs: + agent: + 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 + working-directory: ${{ env.AGENT_CODE }} + run: | + make genconfig + env CONFIG=$(pwd)/.config.bin cargo test --color always --workspace --exclude genconfig --all-targets --all-features + + commands: + name: Run Mythic command tests + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Setup environment + uses: ./.github/actions/setup-lint + with: + agent-code: ${{ env.AGENT_CODE }} + mythic-code: ${{ env.MYTHIC_CODE }} + + - name: Run command tests + working-directory: ${{ env.MYTHIC_CODE }} + run: go test ./commands/... + + mockbuild: + name: Run payload mock build tests + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Setup environment + uses: ./.github/actions/setup-lint + with: + agent-code: ${{ env.AGENT_CODE }} + mythic-code: ${{ env.MYTHIC_CODE }} + + - name: Run mockbuild tests + working-directory: ${{ env.MYTHIC_CODE }} + run: go test -run "^TestPayloadMockBuild/" ./builder diff --git a/Payload_Type/thanatos/agent/Makefile b/Payload_Type/thanatos/agent/Makefile index 1d3d7d5..53d9541 100644 --- a/Payload_Type/thanatos/agent/Makefile +++ b/Payload_Type/thanatos/agent/Makefile @@ -40,7 +40,7 @@ endef $(SRC_CONFIG): - @echo '$(subst $(newline),\n,${DEFAULT_CONFIG})' > $(SRC_CONFIG) + @echo -e '$(subst $(newline),\n,${DEFAULT_CONFIG})' > $(SRC_CONFIG) $(CONFIG): $(SRC_CONFIG) SRC_CONFIG=$(SRC_CONFIG) CONFIG=$(CONFIG) cargo build -p genconfig