Skip to content

Commit 86ba3d5

Browse files
ci: adding GitHub Actions Workflows linting (#9)
1 parent a07c5f6 commit 86ba3d5

File tree

3 files changed

+34
-64
lines changed

3 files changed

+34
-64
lines changed
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
name: GitHub Actions Workflows
2+
3+
on: pull_request
4+
5+
env:
6+
# Forcing Earthly to use colours, to make reading output easier.
7+
FORCE_COLOR: 1
8+
9+
jobs:
10+
linting:
11+
name: Linting
12+
runs-on: ubuntu-latest
13+
steps:
14+
- name: Download Earthly v0.8.6.
15+
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'"
16+
- name: Checkout code.
17+
uses: actions/checkout@v3
18+
- name: Check GitHub Actions workflows linting.
19+
run: earthly +check-github-actions-workflows-linting

Earthfile

Lines changed: 9 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -1,68 +1,13 @@
1-
VERSION 0.6
1+
VERSION 0.7
22

33

4-
clean-git-history-checking:
5-
FROM rust
6-
RUN cargo install clean_git_history
7-
COPY ".git" "."
8-
ARG from="origin/HEAD"
9-
RUN /usr/local/cargo/bin/clean_git_history --from-reference "${from}"
4+
COPY_CI_DATA:
5+
COMMAND
6+
COPY --dir "ci/" ".github/" "./"
107

118

12-
conventional-commits-linting:
13-
FROM rust
14-
RUN cargo install conventional_commits_linter
15-
COPY ".git" "."
16-
ARG from="origin/HEAD"
17-
RUN /usr/local/cargo/bin/conventional_commits_linter --from-reference "${from}" --allow-angular-type-only
18-
19-
20-
clang-base:
21-
FROM archlinux:base
22-
RUN pacman -Sy --noconfirm
23-
RUN pacman -S clang cunit --noconfirm
24-
COPY "./src" "./src"
25-
COPY "./tests" "./tests"
26-
27-
28-
check-formatting:
29-
FROM +clang-base
30-
RUN find "./src" "./tests" -type f -name "*.c" | xargs -I {} clang-format --dry-run --Werror "{}"
31-
32-
33-
fix-formatting:
34-
FROM +clang-base
35-
RUN find "./src" "./tests" -type f -name "*.c" | xargs -I {} clang-format -i "{}"
36-
SAVE ARTIFACT "./src" AS LOCAL "./src"
37-
SAVE ARTIFACT "./tests" AS LOCAL "./tests"
38-
39-
40-
linting:
41-
FROM +clang-base
42-
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="*" "{}"
43-
44-
45-
archlinux-base:
46-
FROM archlinux:base-devel
47-
RUN pacman -Sy --noconfirm
48-
RUN pacman -S lib32-gcc-libs lib32-glibc cunit --noconfirm
49-
COPY "./src" "./src"
50-
COPY "./tests" "./tests"
51-
52-
53-
compiling:
54-
FROM +archlinux-base
55-
RUN gcc -o "./shellcode-generator" "./src/shellcode-generator.c"
56-
57-
58-
unit-testing:
59-
FROM +archlinux-base
60-
RUN gcc -lcunit -o "./shellcode-generator-tests" "./tests/shellcode-generator-tests.c"
61-
RUN "./shellcode-generator-tests"
62-
63-
64-
payload-compiling:
65-
FROM +archlinux-base
66-
COPY "./output.c" "./output.c"
67-
RUN gcc -o "./output" "./output.c" -m32 -fno-stack-protector -z execstack
68-
RUN "./output"
9+
check-github-actions-workflows-linting:
10+
FROM golang:1.20.13
11+
RUN go install github.com/rhysd/actionlint/cmd/actionlint@v1.6.26
12+
DO +COPY_CI_DATA
13+
RUN ./ci/check-github-actions-workflows-linting.sh
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#!/usr/bin/env sh
2+
3+
set -o errexit
4+
set -o xtrace
5+
6+
actionlint --verbose .github/workflows/*

0 commit comments

Comments
 (0)