Skip to content

Commit 0dc9f27

Browse files
build: replacing Earthly with Makefile & Docker build/run (#102)
1 parent f7556a0 commit 0dc9f27

18 files changed

+100
-269
lines changed

.github/renovate.json

Lines changed: 11 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
"automerge": true,
77
"dockerfile": {
88
"managerFilePatterns": [
9-
"/(^|/)Earthfile$/",
109
"/(^|/|\\.)Dockerfile$/",
1110
"/(^|/)Dockerfile[^/]*$/"
1211
]
@@ -15,7 +14,8 @@
1514
{
1615
"customType": "regex",
1716
"managerFilePatterns": [
18-
"/^Earthfile$/"
17+
"/(^|/|\\.)Dockerfile$/",
18+
"/(^|/)Dockerfile[^/]*$/"
1919
],
2020
"matchStrings": [
2121
"# renovate: datasource=(?<datasource>.*?) depName=(?<depName>.*?)( versioning=(?<versioning>.*?))?\\s.+_VERSION=\"(?<currentValue>.*?)\"\\s"
@@ -24,27 +24,18 @@
2424
{
2525
"customType": "regex",
2626
"managerFilePatterns": [
27-
"/^Earthfile$/"
27+
"/(^|/|\\.)Dockerfile$/",
28+
"/(^|/)Dockerfile[^/]*$/"
2829
],
30+
"matchStringsStrategy": "recursive",
2931
"matchStrings": [
30-
"# renovate: datasource=repology depName=alpine_(?<currentValue>\\d+[._]\\d+)"
32+
"FROM\\s*.*?alpine[.:]?(?<alpineMajor>\\d+)\\.(?<alpineMinor>\\d+)(?:\\n|.)*",
33+
"apk\\s+add\\s+(?:\\n|.)*?[^\\\\]\\n",
34+
"(?<name>[^\\s=~]+)~?=(?<currentValue>[^\\s=]+)"
3135
],
32-
"currentValueTemplate": "{{{ replace '_' '.' currentValue }}}",
33-
"datasourceTemplate": "docker",
34-
"depNameTemplate": "alpine",
35-
"versioningTemplate": "regex:^(?<major>\\d+)[._](?<minor>\\d+)$",
36-
"autoReplaceStringTemplate": "# renovate: datasource=repology depName=alpine_{{{newMajor}}}_{{{newMinor}}}"
37-
},
38-
{
39-
"customType": "regex",
40-
"managerFilePatterns": [
41-
"/^[.]github/workflows//"
42-
],
43-
"matchStrings": [
44-
".*version: (?<currentValue>.*?)\\s"
45-
],
46-
"datasourceTemplate": "github-tags",
47-
"depNameTemplate": "earthly/earthly"
36+
"datasourceTemplate": "repology",
37+
"depNameTemplate": "alpine_{{alpineMajor}}_{{alpineMinor}}/{{name}}",
38+
"versioningTemplate": "loose"
4839
}
4940
]
5041
}

.github/workflows/continuous-integration.yml

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,17 @@ jobs:
1818
- name: Checkout code.
1919
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
2020
- name: Compile.
21-
run: earthly --ci +compile
21+
run: make compile
22+
unit-test:
23+
name: Unit Test
24+
runs-on: ubuntu-latest
25+
steps:
26+
- name: Download Earthly.
27+
uses: earthly/actions-setup@43211c7a0eae5344d6d79fb4aaf209c8f8866203 # v1.0.13
28+
with:
29+
version: v0.8.15
30+
- name: Checkout code.
31+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
32+
- name: Unit Test.
33+
run: make unit-test
34+

.github/workflows/conventional-commits.yml

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,23 +2,15 @@ name: Conventional Commits
22

33
on: pull_request
44

5-
env:
6-
# Forcing Earthly to use colours, to make reading output easier.
7-
FORCE_COLOR: 1
8-
95
jobs:
106
linting:
117
name: Linting
128
runs-on: ubuntu-latest
139
steps:
14-
- name: Download Earthly.
15-
uses: earthly/actions-setup@43211c7a0eae5344d6d79fb4aaf209c8f8866203 # v1.0.13
16-
with:
17-
version: v0.8.15
1810
- name: Checkout code.
1911
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
2012
with:
2113
ref: ${{ github.event.pull_request.head.sha }}
2214
fetch-depth: 0
2315
- name: Check Conventional Commits linting.
24-
run: earthly --ci +check-conventional-commits-linting --from_reference "origin/${{ github.base_ref }}"
16+
run: make check-conventional-commits-linting FROM="origin/${{ github.base_ref }}"

.github/workflows/git-history.yml

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,23 +2,15 @@ name: Git History
22

33
on: pull_request
44

5-
env:
6-
# Forcing Earthly to use colours, to make reading output easier.
7-
FORCE_COLOR: 1
8-
95
jobs:
106
clean:
117
name: Clean
128
runs-on: ubuntu-latest
139
steps:
14-
- name: Download Earthly.
15-
uses: earthly/actions-setup@43211c7a0eae5344d6d79fb4aaf209c8f8866203 # v1.0.13
16-
with:
17-
version: v0.8.15
1810
- name: Checkout code.
1911
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
2012
with:
2113
ref: ${{ github.event.pull_request.head.sha }}
2214
fetch-depth: 0
2315
- name: Check clean Git history.
24-
run: earthly --ci +check-clean-git-history --from "origin/${{ github.base_ref }}"
16+
run: make check-clean-git-history FROM="origin/${{ github.base_ref }}"

.github/workflows/github-actions-workflows.yml

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,32 +2,20 @@ name: GitHub Actions Workflows
22

33
on: pull_request
44

5-
env:
6-
# Forcing Earthly to use colours, to make reading output easier.
7-
FORCE_COLOR: 1
8-
95
jobs:
106
linting:
117
name: Linting
128
runs-on: ubuntu-latest
139
steps:
14-
- name: Download Earthly.
15-
uses: earthly/actions-setup@43211c7a0eae5344d6d79fb4aaf209c8f8866203 # v1.0.13
16-
with:
17-
version: v0.8.15
1810
- name: Checkout code.
1911
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
2012
- name: Check GitHub Actions workflows linting.
21-
run: earthly +check-github-actions-workflows-linting
13+
run: make check-github-actions-workflows-linting
2214
formatting:
2315
name: Formatting
2416
runs-on: ubuntu-latest
2517
steps:
26-
- name: Download Earthly.
27-
uses: earthly/actions-setup@43211c7a0eae5344d6d79fb4aaf209c8f8866203 # v1.0.13
28-
with:
29-
version: v0.8.15
3018
- name: Checkout code.
3119
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
3220
- name: Check formatting.
33-
run: earthly +check-yaml-formatting
21+
run: make check-yaml-formatting

.github/workflows/mirroring.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,6 @@ jobs:
1212
- name: Checkout code.
1313
run: git clone --mirror "https://github.com/${GITHUB_REPOSITORY}.git" "${GITHUB_WORKSPACE}"
1414
- name: Get GitLab repository.
15-
run: echo "REPOSITORY_NAME=$(echo "${GITHUB_REPOSITORY}" | sed "s|^${GITHUB_REPOSITORY_OWNER}/||g")" >> "${GITHUB_ENV}"
15+
run: echo "REPOSITORY_NAME=${GITHUB_REPOSITORY/${GITHUB_REPOSITORY_OWNER}/}" >> "${GITHUB_ENV}"
1616
- name: Mirroring.
1717
run: git push --mirror "https://oauth2:${{ secrets.GITLAB_PERSONAL_ACCESS_TOKEN }}@gitlab.com/DeveloperC/${REPOSITORY_NAME}"

Earthfile

Lines changed: 0 additions & 91 deletions
This file was deleted.

Makefile

Lines changed: 31 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,46 @@
1-
# linux-x86-shellcode-generator
2-
# See LICENSE file for copyright and license details.
3-
.POSIX:
1+
# So new files are owned by the user.
2+
UID := $(shell id -u)
3+
GID := $(shell id -g)
44

5-
CC=gcc
5+
.PHONY: check-clean-git-history check-conventional-commits-linting check-yaml-formatting fix-yaml-formatting check-github-actions-workflows-linting compile unit-test payload
66

7-
SOURCE=src/shellcode-generator.c
8-
OBJECT=shellcode-generator
9-
CFLAGS=
7+
check-clean-git-history:
8+
docker build -t check-clean-git-history -f ci/check-clean-git-history.Dockerfile .
9+
docker run --rm -v $(PWD):/workspace -u $(UID):$(GID) check-clean-git-history $(FROM)
1010

11-
TEST_SOURCE=tests/shellcode-generator-tests.c
12-
TEST_OBJECT=shellcode-generator-tests
13-
TEST_CFLAGS=-lcunit
11+
check-conventional-commits-linting:
12+
docker build -t check-conventional-commits-linting -f ci/check-conventional-commits-linting.Dockerfile .
13+
docker run --rm -v $(PWD):/workspace -u $(UID):$(GID) check-conventional-commits-linting $(FROM)
1414

15-
PAYLOAD_SOURCE=output.c
16-
PAYLOAD_OBJECT=output
17-
PAYLOAD_CFLAGS=-m32 -fno-stack-protector -z execstack
15+
check-yaml-formatting:
16+
docker pull ghcr.io/google/yamlfmt:0.17.0
17+
docker run --rm -v $(PWD):/workspace -u $(UID):$(GID) ghcr.io/google/yamlfmt:0.17.0 -verbose -lint -dstar .github/workflows/*
1818

19-
.PHONY: all
20-
all: $(OBJECT)
19+
fix-yaml-formatting:
20+
docker pull ghcr.io/google/yamlfmt:0.17.0
21+
docker run --rm -v $(PWD):/workspace -u $(UID):$(GID) ghcr.io/google/yamlfmt:0.17.0 -verbose -dstar .github/workflows/*
2122

22-
$(OBJECT): $(SOURCE)
23-
$(CC) -o $(OBJECT) $(SOURCE) $(CFLAGS)
23+
check-github-actions-workflows-linting:
24+
docker pull rhysd/actionlint:1.7.7
25+
docker run --rm -v $(PWD):/workspace -w /workspace -u $(UID):$(GID) rhysd/actionlint:1.7.7 -verbose -color
2426

25-
.PHONY: clean
26-
clean:
27-
rm -f $(OBJECT)
28-
rm -f $(TEST_OBJECT)
29-
rm -f $(PAYLOAD_OBJECT)
27+
compile:
28+
docker build -t compile -f ci/compile.Dockerfile .
29+
docker run --rm -v $(PWD):/workspace -u $(UID):$(GID) compile
3030

31-
.PHONY: test
32-
test: $(TEST_OBJECT)
33-
./$(TEST_OBJECT)
31+
unit-test:
32+
docker build -t unit-test -f ci/unit-test.Dockerfile .
33+
docker run --rm -v $(PWD):/workspace -u $(UID):$(GID) unit-test
3434

35-
$(TEST_OBJECT): $(TEST_SOURCE)
36-
$(CC) -o $(TEST_OBJECT) $(TEST_SOURCE) $(TEST_CFLAGS)
35+
PAYLOAD_SOURCE=output.c
36+
PAYLOAD_OBJECT=output
37+
PAYLOAD_CFLAGS=-m32 -fno-stack-protector -z execstack
3738

38-
.PHONY: payload
3939
payload: $(PAYLOAD_OBJECT)
4040
./$(PAYLOAD_OBJECT)
4141

4242
$(PAYLOAD_OBJECT): $(PAYLOAD_SOURCE)
4343
$(CC) -o $(PAYLOAD_OBJECT) $(PAYLOAD_SOURCE) $(PAYLOAD_CFLAGS)
44+
45+
46+

ci/check-clean-git-history.Dockerfile

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
FROM rust:1.87.0-alpine3.21@sha256:fa7c28576553c431224a85c897c38f3a6443bd831be37061ab3560d9e797dc82
2+
3+
# renovate: datasource=github-releases depName=DeveloperC286/clean_git_history
4+
ENV CLEAN_GIT_HISTORY_VERSION="v1.0.3"
5+
RUN wget -O - "https://github.com/DeveloperC286/clean_git_history/releases/download/${CLEAN_GIT_HISTORY_VERSION}/x86_64-unknown-linux-musl.tar.gz" | tar xz --directory "/usr/bin/"
6+
7+
WORKDIR /workspace
8+
9+
ENTRYPOINT ["clean_git_history"]
10+
CMD ["origin/HEAD"]

ci/check-clean-git-history.sh

Lines changed: 0 additions & 11 deletions
This file was deleted.

0 commit comments

Comments
 (0)