diff --git a/.github/workflows/github-actions-workflows.yml b/.github/workflows/github-actions-workflows.yml new file mode 100644 index 0000000..a8816bf --- /dev/null +++ b/.github/workflows/github-actions-workflows.yml @@ -0,0 +1,19 @@ +name: GitHub Actions Workflows + +on: pull_request + +env: + # Forcing Earthly to use colours, to make reading output easier. + FORCE_COLOR: 1 + +jobs: + linting: + name: Linting + runs-on: ubuntu-latest + steps: + - name: Download Earthly v0.8.6. + run: "sudo /bin/sh -c 'wget https://github.com/earthly/earthly/releases/download/v0.8.6/earthly-linux-amd64 -O /usr/local/bin/earthly && chmod +x /usr/local/bin/earthly'" + - name: Checkout code. + uses: actions/checkout@v3 + - name: Check GitHub Actions workflows linting. + run: earthly +check-github-actions-workflows-linting diff --git a/Earthfile b/Earthfile index d456a80..8344424 100644 --- a/Earthfile +++ b/Earthfile @@ -1,68 +1,13 @@ -VERSION 0.6 +VERSION 0.7 -clean-git-history-checking: - FROM rust - RUN cargo install clean_git_history - COPY ".git" "." - ARG from="origin/HEAD" - RUN /usr/local/cargo/bin/clean_git_history --from-reference "${from}" +COPY_CI_DATA: + COMMAND + COPY --dir "ci/" ".github/" "./" -conventional-commits-linting: - FROM rust - RUN cargo install conventional_commits_linter - COPY ".git" "." - ARG from="origin/HEAD" - RUN /usr/local/cargo/bin/conventional_commits_linter --from-reference "${from}" --allow-angular-type-only - - -clang-base: - FROM archlinux:base - RUN pacman -Sy --noconfirm - RUN pacman -S clang cunit --noconfirm - COPY "./src" "./src" - COPY "./tests" "./tests" - - -check-formatting: - FROM +clang-base - RUN find "./src" "./tests" -type f -name "*.c" | xargs -I {} clang-format --dry-run --Werror "{}" - - -fix-formatting: - FROM +clang-base - RUN find "./src" "./tests" -type f -name "*.c" | xargs -I {} clang-format -i "{}" - SAVE ARTIFACT "./src" AS LOCAL "./src" - SAVE ARTIFACT "./tests" AS LOCAL "./tests" - - -linting: - FROM +clang-base - RUN find "./src" "./tests" -type f -name "*.c" | xargs -I {} clang-tidy --checks="*,-llvmlibc-restrict-system-libc-headers,-altera-id-dependent-backward-branch,-altera-unroll-loops,-cert-err33-c" --warnings-as-errors="*" "{}" - - -archlinux-base: - FROM archlinux:base-devel - RUN pacman -Sy --noconfirm - RUN pacman -S lib32-gcc-libs lib32-glibc cunit --noconfirm - COPY "./src" "./src" - COPY "./tests" "./tests" - - -compiling: - FROM +archlinux-base - RUN gcc -o "./shellcode-generator" "./src/shellcode-generator.c" - - -unit-testing: - FROM +archlinux-base - RUN gcc -lcunit -o "./shellcode-generator-tests" "./tests/shellcode-generator-tests.c" - RUN "./shellcode-generator-tests" - - -payload-compiling: - FROM +archlinux-base - COPY "./output.c" "./output.c" - RUN gcc -o "./output" "./output.c" -m32 -fno-stack-protector -z execstack - RUN "./output" +check-github-actions-workflows-linting: + FROM golang:1.20.13 + RUN go install github.com/rhysd/actionlint/cmd/actionlint@v1.6.26 + DO +COPY_CI_DATA + RUN ./ci/check-github-actions-workflows-linting.sh diff --git a/ci/check-github-actions-workflows-linting.sh b/ci/check-github-actions-workflows-linting.sh new file mode 100755 index 0000000..81e88cc --- /dev/null +++ b/ci/check-github-actions-workflows-linting.sh @@ -0,0 +1,6 @@ +#!/usr/bin/env sh + +set -o errexit +set -o xtrace + +actionlint --verbose .github/workflows/*