Skip to content

Commit 2fa9d80

Browse files
committed
build: replacing Earthly with Makefile & Docker build/run
1 parent f7556a0 commit 2fa9d80

16 files changed

+79
-254
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: makeunit-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: 29 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,27 @@
1-
# linux-x86-shellcode-generator
2-
# See LICENSE file for copyright and license details.
31
.POSIX:
2+
# So new files are owned by the user.
3+
UID := $(shell id -u)
4+
GID := $(shell id -g)
5+
6+
check-clean-git-history:
7+
docker build -t check-clean-git-history -f ci/check-clean-git-history.Dockerfile .
8+
docker run --rm -v $(PWD):/workspace -u $(UID):$(GID) check-clean-git-history $(FROM)
9+
10+
check-conventional-commits-linting:
11+
docker build -t check-conventional-commits-linting -f ci/check-conventional-commits-linting.Dockerfile .
12+
docker run --rm -v $(PWD):/workspace -u $(UID):$(GID) check-conventional-commits-linting $(FROM)
13+
14+
check-yaml-formatting:
15+
docker pull ghcr.io/google/yamlfmt:0.17.0
16+
docker run --rm -v $(PWD):/workspace -u $(UID):$(GID) ghcr.io/google/yamlfmt:0.17.0 -verbose -lint -dstar .github/workflows/*
17+
18+
fix-yaml-formatting:
19+
docker pull ghcr.io/google/yamlfmt:0.17.0
20+
docker run --rm -v $(PWD):/workspace -u $(UID):$(GID) ghcr.io/google/yamlfmt:0.17.0 -verbose -dstar .github/workflows/*
21+
22+
check-github-actions-workflows-linting:
23+
docker pull rhysd/actionlint:1.7.7
24+
docker run --rm -v $(PWD):/workspace -w /workspace -u $(UID):$(GID) rhysd/actionlint:1.7.7 -verbose -color
425

526
CC=gcc
627

@@ -16,28 +37,23 @@ PAYLOAD_SOURCE=output.c
1637
PAYLOAD_OBJECT=output
1738
PAYLOAD_CFLAGS=-m32 -fno-stack-protector -z execstack
1839

19-
.PHONY: all
20-
all: $(OBJECT)
40+
compile: $(OBJECT)
2141

2242
$(OBJECT): $(SOURCE)
2343
$(CC) -o $(OBJECT) $(SOURCE) $(CFLAGS)
2444

25-
.PHONY: clean
26-
clean:
27-
rm -f $(OBJECT)
28-
rm -f $(TEST_OBJECT)
29-
rm -f $(PAYLOAD_OBJECT)
30-
31-
.PHONY: test
32-
test: $(TEST_OBJECT)
45+
unit-test: $(TEST_OBJECT)
3346
./$(TEST_OBJECT)
3447

3548
$(TEST_OBJECT): $(TEST_SOURCE)
3649
$(CC) -o $(TEST_OBJECT) $(TEST_SOURCE) $(TEST_CFLAGS)
3750

38-
.PHONY: payload
3951
payload: $(PAYLOAD_OBJECT)
4052
./$(PAYLOAD_OBJECT)
4153

4254
$(PAYLOAD_OBJECT): $(PAYLOAD_SOURCE)
4355
$(CC) -o $(PAYLOAD_OBJECT) $(PAYLOAD_SOURCE) $(PAYLOAD_CFLAGS)
56+
57+
58+
59+

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)