Skip to content

Commit

Permalink
ci: adding GitHub Actions Workflows linting
Browse files Browse the repository at this point in the history
  • Loading branch information
DeveloperC286 committed Apr 17, 2024
1 parent a07c5f6 commit 8d214e0
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 64 deletions.
19 changes: 19 additions & 0 deletions .github/workflows/github-actions-workflows.yml
Original file line number Diff line number Diff line change
@@ -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
73 changes: 9 additions & 64 deletions Earthfile
Original file line number Diff line number Diff line change
@@ -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/[email protected]
DO +COPY_CI_DATA
RUN ./ci/check-github-actions-workflows-linting.sh
6 changes: 6 additions & 0 deletions ci/check-github-actions-workflows-linting.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/usr/bin/env sh

set -o errexit
set -o xtrace

actionlint --verbose .github/workflows/*

0 comments on commit 8d214e0

Please sign in to comment.