From a833766f8fdb22d3b5137bb3a8fb484a26af6872 Mon Sep 17 00:00:00 2001 From: MDW Date: Tue, 16 Jan 2024 02:29:25 +0100 Subject: [PATCH] Create github action --- .github/workflows/pre-commit.yml | 11 +++++++++-- Dockerfile | 10 ++++++++++ action.yml | 23 +++++++++++++++++++++++ entrypoint.sh | 3 +++ 4 files changed, 45 insertions(+), 2 deletions(-) create mode 100644 Dockerfile create mode 100644 action.yml create mode 100755 entrypoint.sh diff --git a/.github/workflows/pre-commit.yml b/.github/workflows/pre-commit.yml index 033bab2..bc441ae 100644 --- a/.github/workflows/pre-commit.yml +++ b/.github/workflows/pre-commit.yml @@ -30,10 +30,17 @@ jobs: set -o pipefail pre-commit gc pre-commit run --show-diff-on-failure --color=always --all-files | tee ${RAW_LOG} - - name: Convert Raw Log to CheckStyle format - if: ${{ failure() }} + - name: Convert Raw Log to CheckStyle format (launch script) + # if: ${{ failure() }} + if: false run: | python ${LOG_TO_CS} ${RAW_LOG} ${CS_XML} + - name: Convert Raw Log to Checkstyle format (launch action) + uses: mdeweerd/logToCheckStyle@v2024.1.5 + if: ${{ failure() }} + with: + in: ${{ env.RAW_LOG }} + out: ${{ env.CS_XML }} - name: Annotate Source Code with Messages uses: staabm/annotate-pull-request-from-checkstyle-action@v1 if: ${{ failure() }} diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..796dd46 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,10 @@ +# Container running the action +FROM python:3.11-slim-bookworm + +RUN pip install regex +# Copy entry point +COPY entrypoint.sh /entrypoint.sh +COPY logToCs.py /logToCs.py + +# Code file to execute when the docker container starts up (`entrypoint.sh`) +ENTRYPOINT ["/entrypoint.sh"] diff --git a/action.yml b/action.yml new file mode 100644 index 0000000..2842341 --- /dev/null +++ b/action.yml @@ -0,0 +1,23 @@ +--- +# action.yml +# +name: logToCheckStyle +description: Convert text log to CheckStyle xml format +inputs: + in: + description: Source log path (Textual input log) + required: true + out: + description: Target log path (CheckStyle xml format log) + required: true + root: + description: Prefix to remove from paths in log + required: false + default: +# outputs: +# outpath: # id of output +# description: The output path +runs: + using: docker + image: Dockerfile + args: ['${{ inputs.in }}', '${{ inputs.out }}', '${{ inputs.root }}'] diff --git a/entrypoint.sh b/entrypoint.sh new file mode 100755 index 0000000..7da9287 --- /dev/null +++ b/entrypoint.sh @@ -0,0 +1,3 @@ +#!/bin/bash -l +[ "$3" = "" ] && python /logToCs.py "$1" "$2" --root "$PWD" && exit 0 +[ "$3" != "" ] && python /logToCs.py "$1" "$2" --root "$3" && exit 0