Skip to content

Commit

Permalink
Simplify CI
Browse files Browse the repository at this point in the history
  • Loading branch information
MEhrn00 committed Aug 5, 2024
1 parent c45b3fa commit 8a3d96b
Show file tree
Hide file tree
Showing 6 changed files with 111 additions and 314 deletions.
1 change: 1 addition & 0 deletions .github/workflows/dependencies/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules/*
68 changes: 68 additions & 0 deletions .github/workflows/dependencies/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
name: "Install dependencies"
description: "Setup dependencies for workflows"

runs:
using: "composite"

steps:
- name: Setup Golang
uses: actions/setup-go@v5
with:
go-version-file: Payload_Type/thanatos/go.mod
cache-dependency-path: Payload_Type/thanatos/go.sum

- name: Setup Linux dependencies
if: ${{ runner.os == 'Linux' }}
shell: bash
run: |
sudo apt-get update -y
sudo apt-get install -y \
make \
curl \
lcov
go install golang.org/x/tools/cmd/cover@latest
go install google.golang.org/protobuf/cmd/protoc-gen-go@latest
curl \
-L https://github.com/protocolbuffers/protobuf/releases/download/v27.3/protoc-27.3-linux-x86_64.zip \
-o /tmp/protoc.zip
sudo unzip /tmp/protoc.zip -x readme.txt -d /usr/local
rm -rf /tmp/protoc.zip
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s - -y --profile minimal -c clippy llvm-tools-preview
. "$HOME/.cargo/env"
rustup toolchain install nightly
rustup component add rust-src --toolchain nightly
curl \
-L https://github.com/mozilla/grcov/releases/download/v0.8.19/grcov-x86_64-unknown-linux-gnu.tar.bz2 \
-o /tmp/grcov.tar.bz2
sudo tar xvf /tmp/grcov.tar.bz2 -C /usr/local/bin
rm -rf /tmp/grcov.tar.bz2
- name: Setup Windows dependencies
if: ${{ runner.os == 'Windows' }}
shell: powershell
run: |
Invoke-WebRequest `
-Uri https://github.com/protocolbuffers/protobuf/releases/download/v25.3/protoc-25.3-win64.zip `
-OutFile $env:TEMP\protoc.zip
Expand-Archive $env:TEMP\protoc.zip
Copy-Item -Path $env:TEMP\protoc\bin\protoc.exe -Destination $env:SYSTEMROOT\System32\protoc.exe
Remove-Item -Recurse $env:TEMP\protoc
Remove-Item $env:TEMP\protoc.zip
Invoke-WebRequest `
-Uri https://github.com/mozilla/grcov/releases/download/v0.8.19/grcov-x86_64-pc-windows-msvc.zip `
-OutFile $env:TEMP\grcov.zip
Expand-Archive $env:TEMP\grcov.zip
Copy-Item -Path $env:TEMP\grcov\grcov.exe -Destination $env:SYSTEMROOT\System32\grcov.exe
Remove-Item -Recurse $env:TEMP\grcov
Remove-Item $env:TEMP\grcov.zip
go install google.golang.org/protobuf/cmd/protoc-gen-go@latest
rustup component add llvm-tools-preview
rustup toolchain install nightly
rustup component add rust-src --toolchain nightly
28 changes: 0 additions & 28 deletions .github/workflows/dev-ci.yml

This file was deleted.

63 changes: 18 additions & 45 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -1,15 +1,20 @@
name: Lint and check code for errors

on:
workflow_call:
push:
branches:
- rewrite
paths:
- "Payload_Type/thanatos/**"
- ".github/workflows/**"

env:
AGENT_CODE: Payload_Type/thanatos/agent
MYTHIC_CODE: Payload_Type/thanatos

jobs:
agent:
name: Agent Code
lint-agent:
name: Lint Agent Code
runs-on: ubuntu-latest

defaults:
Expand All @@ -20,49 +25,17 @@ jobs:
- name: Checkout code
uses: actions/checkout@v4

- name: Setup cargo cache
uses: actions/cache@v4
with:
path: ~/.cargo
key: ${{ runner.os }}-cargo-${{ hashFiles(format('{0}/Cargo.lock', env.AGENT_CODE)) }}
restore-keys: |
${{ runner.os }}-cargo-${{ hashFiles(format('{0}/Cargo.lock', env.AGENT_CODE)) }}
${{ runner.os }}-cargo
- name: Setup cargo target cache
uses: actions/cache@v4
with:
path: ${{ env.AGENT_CODE }}/target
key: ${{ runner.os }}-cargo-target-${{ hashFiles(format('{0}/Cargo.lock', env.AGENT_CODE)) }}
restore-keys: |
${{ runner.os }}-cargo-target-${{ hashFiles(format('{0}/Cargo.lock', env.AGENT_CODE)) }}
${{ runner.os }}-cargo-target
- name: Install protoc
if: ${{ runner.os == 'Linux' }}
run: |
mkdir -p /tmp/protoc
pushd /tmp/protoc
curl -L https://github.com/protocolbuffers/protobuf/releases/download/v25.3/protoc-25.3-linux-x86_64.zip -o protoc.zip
unzip protoc.zip
mv bin/protoc /usr/local/bin
popd
rm -rf /tmp/protoc
- name: Install Clippy
run: rustup component add clippy

- name: Install system libraries
run: sudo apt-get update -y && sudo apt-get install -y make libdbus-1-dev
- name: Install dependencies
uses: ./.github/workflows/dependencies

- name: Lint agent code
run: make lint

- name: Check agent code formatting
run: make checkformat

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

defaults:
Expand All @@ -73,13 +46,13 @@ jobs:
- name: Checkout code
uses: actions/checkout@v4

- name: Install Golang
uses: actions/setup-go@v5
with:
go-version-file: ${{ env.MYTHIC_CODE }}/go.mod
cache-dependency-path: ${{ env.MYTHIC_CODE }}/go.sum
- name: Install dependencies
uses: ./.github/workflows/dependencies

- name: Build protobuf files
run: make protobuf

- name: Lint Mythic code
- name: Run golangci-lint
uses: golangci/golangci-lint-action@v3
with:
version: latest
Expand Down
106 changes: 0 additions & 106 deletions .github/workflows/release-ci.yml

This file was deleted.

Loading

0 comments on commit 8a3d96b

Please sign in to comment.