Skip to content

ci: adding GitHub Actions Workflows linting #9

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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/*