-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ci: adding clean Git history checking (#12)
- Loading branch information
1 parent
0b5f6a8
commit a4c1ce4
Showing
3 changed files
with
102 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
name: Git History | ||
|
||
on: pull_request | ||
|
||
env: | ||
# Forcing Earthly to use colours, to make reading output easier. | ||
FORCE_COLOR: 1 | ||
|
||
jobs: | ||
clean: | ||
name: Clean | ||
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 | ||
with: | ||
ref: ${{ github.event.pull_request.head.sha }} | ||
fetch-depth: 0 | ||
- name: Check clean Git history. | ||
run: earthly --ci +check-clean-git-history --from_reference "origin/${{ github.base_ref }}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,6 +6,25 @@ COPY_CI_DATA: | |
COPY --dir "ci/" ".github/" "./" | ||
|
||
|
||
COPY_METADATA: | ||
COMMAND | ||
DO +COPY_CI_DATA | ||
COPY --dir ".git/" "./" | ||
|
||
|
||
rust-base: | ||
FROM rust:1.70.0 | ||
WORKDIR "/nasm-x86-shellcode-generator" | ||
|
||
|
||
check-clean-git-history: | ||
FROM +rust-base | ||
RUN cargo install clean_git_history --version 0.1.2 --locked | ||
DO +COPY_METADATA | ||
ARG from_reference="origin/HEAD" | ||
RUN ./ci/check-clean-git-history.sh --from-reference "${from_reference}" | ||
|
||
|
||
check-github-actions-workflows-linting: | ||
FROM golang:1.20.13 | ||
RUN go install github.com/rhysd/actionlint/cmd/[email protected] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
#!/usr/bin/env bash | ||
|
||
# ARG_OPTIONAL_SINGLE([from-reference],[],[],[origin/HEAD]) | ||
# ARGBASH_GO() | ||
# needed because of Argbash --> m4_ignore([ | ||
### START OF CODE GENERATED BY Argbash v2.9.0 one line above ### | ||
# Argbash is a bash code generator used to get arguments parsing right. | ||
# Argbash is FREE SOFTWARE, see https://argbash.io for more info | ||
# Generated online by https://argbash.io/generate | ||
|
||
die() { | ||
local _ret="${2:-1}" | ||
test "${_PRINT_HELP:-no}" = yes && print_help >&2 | ||
echo "$1" >&2 | ||
exit "${_ret}" | ||
} | ||
|
||
begins_with_short_option() { | ||
local first_option all_short_options='' | ||
first_option="${1:0:1}" | ||
test "$all_short_options" = "${all_short_options/$first_option/}" && return 1 || return 0 | ||
} | ||
|
||
# THE DEFAULTS INITIALIZATION - OPTIONALS | ||
_arg_from_reference="origin/HEAD" | ||
|
||
print_help() { | ||
printf 'Usage: %s [--from-reference <arg>]\n' "$0" | ||
} | ||
|
||
parse_commandline() { | ||
while test $# -gt 0; do | ||
_key="$1" | ||
case "$_key" in | ||
--from-reference) | ||
test $# -lt 2 && die "Missing value for the optional argument '$_key'." 1 | ||
_arg_from_reference="$2" | ||
shift | ||
;; | ||
--from-reference=*) | ||
_arg_from_reference="${_key##--from-reference=}" | ||
;; | ||
*) | ||
_PRINT_HELP=yes die "FATAL ERROR: Got an unexpected argument '$1'" 1 | ||
;; | ||
esac | ||
shift | ||
done | ||
} | ||
|
||
parse_commandline "$@" | ||
|
||
# OTHER STUFF GENERATED BY Argbash | ||
|
||
### END OF CODE GENERATED BY Argbash (sortof) ### ]) | ||
# [ <-- needed because of Argbash | ||
set -o errexit | ||
set -o xtrace | ||
|
||
"${CARGO_HOME}/bin/clean_git_history" --from-reference "${_arg_from_reference}" | ||
# ] <-- needed because of Argbash |