From 256be679abcd0d45b0529f49fe5d83476f81d162 Mon Sep 17 00:00:00 2001 From: Matt Ehrnschwender Date: Tue, 30 Jan 2024 22:12:11 -0500 Subject: [PATCH] Add action inputs --- .github/actions/setup-lint/action.yml | 24 +++++++++++++++--------- .github/workflows/lint.yml | 13 +++++++++++-- 2 files changed, 26 insertions(+), 11 deletions(-) diff --git a/.github/actions/setup-lint/action.yml b/.github/actions/setup-lint/action.yml index 6faa79e..dac082c 100644 --- a/.github/actions/setup-lint/action.yml +++ b/.github/actions/setup-lint/action.yml @@ -1,5 +1,13 @@ name: Setup lint environment description: Sets up an environment for running checks +inputs: + python-requirements: + description: Path to the requiremets.txt for python packages + required: true + + agent-code: + description: Path to the agent code + required: true runs: using: "composite" @@ -11,27 +19,25 @@ runs: cache: 'pip' - name: Install Python packages - working-directory: ${{ env.THANATOS_PATH }} + shell: bash run: | - pip install -r requirements.txt + pip install -r ${{ inputs.python-requirements }} pip install pylint black - name: Setup cargo cache uses: actions/cache@v4 - working-directory: ${{ env.AGENT_CODE }} with: path: ~/.cargo - key: ${{ runner.os }}-cargo-${{ hashFiles('Cargo.toml') }} + key: ${{ runner.os }}-cargo-${{ hashFiles(format('{0}/Cargo.toml', inputs.agent-code)) }} restore-keys: | - ${{ runner.os }}-cargo-${{ hashFiles('Cargo.toml') }} + ${{ runner.os }}-cargo-${{ hashFiles(format('{0}/Cargo.toml', inputs.agent-code)) }} ${{ runner.os }}-cargo - name: Setup cargo target cache uses: actions/cache@v4 - working-directory: ${{ env.AGENT_CODE }} with: - path: target - key: ${{ runner.os }}-cargo-target-${{ hashFiles('Cargo.toml') }} + path: ${{ inputs.AGENT_CODE }}/target + key: ${{ runner.os }}-cargo-target-${{ hashFiles(format('{0}/Cargo.toml', inputs.agent-code)) }} restore-keys: | - ${{ runner.os }}-cargo-target-${{ hashFiles('Cargo.toml') }} + ${{ runner.os }}-cargo-target-${{ hashFiles(format('{0}/Cargo.toml', inputs.agent-code)) }} ${{ runner.os }}-cargo-target diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 0a789e4..562a3a9 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -33,6 +33,9 @@ jobs: - name: Setup environment uses: ./.github/actions/setup-lint + with: + python-requirements: ${{ env.THANATOS_PATH }}/requirements.txt + agent-code: ${{ env.AGENT_CODE }} - name: Check Mythic code for errors run: python -m pylint -f colorized --errors-only ${THANATOS_PATH}/*.py ${MYTHIC_CODE}/*.py @@ -57,7 +60,10 @@ jobs: uses: actions/checkout@v4 - name: Setup environment - uses: ./.github/workflows/lint-setup + uses: ./.github/actions/setup-lint + with: + python-requirements: ${{ env.THANATOS_PATH }}/requirements.txt + agent-code: ${{ env.AGENT_CODE }} - name: Check Mythic code formatting run: python -m black --color --diff --check ${THANATOS_PATH}/*.py ${MYTHIC_CODE}/*.py @@ -82,7 +88,10 @@ jobs: uses: actions/checkout@v4 - name: Setup environment - uses: ./.github/workflows/lint-setup + uses: ./.github/actions/setup-lint + with: + python-requirements: ${{ env.THANATOS_PATH }}/requirements.txt + agent-code: ${{ env.AGENT_CODE }} - name: Install Clippy run: rustup component add clippy