Skip to content

Commit 46206d9

Browse files
authored
chore: local docker container dev (#7)
1 parent f5e0f9c commit 46206d9

6 files changed

Lines changed: 81 additions & 21 deletions

File tree

.github/workflows/ci.yml

Lines changed: 8 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -23,34 +23,23 @@ jobs:
2323
DEBUGINFOD_URLS: "https://debuginfod.archlinux.org" # profile thus debuginfod.sh is not executed
2424

2525
steps:
26+
- uses: actions/checkout@v4
27+
2628
- name: create user
2729
shell: sh -e {0}
2830
# magic numbers and names not available in environment
2931
run: |
3032
groupadd --gid 118 docker
3133
useradd -m -s /bin/sh --uid 1001 --gid docker runner
3234
33-
- name: install packages
34-
shell: sh -e {0}
35-
run: |
36-
pacman --noconfirm -Sy \
37-
clang \
38-
cmake \
39-
cmocka \
40-
cppcheck \
41-
git \
42-
lib32-cmocka \
43-
llvm \
44-
llvm-libs \
45-
ninja \
46-
valgrind
47-
48-
- uses: actions/checkout@v4
49-
5035
- name: set source permissions
5136
run: chown -R runner:docker .
5237
shell: sh -e {0}
5338

39+
- name: install packages
40+
shell: sh -e {0}
41+
run: .github/workflows/packages/base/install.sh
42+
5443
- run: make CC=gcc clean test
5544
- run: make CC=clang clean test
5645
- run: make clean cppcheck
@@ -62,11 +51,9 @@ jobs:
6251
- run: make CC=clang MFLAGS=-m32 clean test-vg
6352

6453
- name: build include-what-you-use package
65-
run: |
66-
git clone https://aur.archlinux.org/include-what-you-use.git /tmp/include-what-you-use
67-
makepkg OPTIONS=-debug PKGEXT='.pkg.tar' --dir /tmp/include-what-you-use
54+
run: .github/workflows/packages/include-what-you-use/build.sh
6855
- name: install include-what-you-use package
69-
run: pacman -U --noconfirm /tmp/include-what-you-use/*.pkg.tar
56+
run: .github/workflows/packages/include-what-you-use/install.sh
7057
shell: sh -e {0}
7158

7259
- run: make clean iwyu
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#!/bin/sh
2+
3+
pacman --noconfirm -Syu \
4+
clang \
5+
cmake \
6+
cmocka \
7+
cppcheck \
8+
git \
9+
lib32-cmocka \
10+
llvm \
11+
llvm-libs \
12+
ninja \
13+
valgrind
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#!/bin/sh
2+
3+
# must be run as a user
4+
5+
rm -rf /tmp/include-what-you-use
6+
7+
git clone https://aur.archlinux.org/include-what-you-use.git /tmp/include-what-you-use
8+
9+
makepkg OPTIONS=-debug PKGEXT='.pkg.tar' --dir /tmp/include-what-you-use
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/bin/sh
2+
3+
pacman -U --noconfirm /tmp/include-what-you-use/*.pkg.tar

Dockerfile

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# docker image for local dev
2+
# Keep this in sync with ci.yml
3+
# GH CI doesn't allow use of a Dockerfile, hence we maintain this separately
4+
5+
FROM archlinux:multilib-devel
6+
7+
COPY .github/workflows/packages/base/install.sh /usr/local/bin/packages-base-install.sh
8+
9+
RUN packages-base-install.sh
10+
11+
ENV DEBUGINFOD_URLS="https://debuginfod.archlinux.org"
12+
ENV DEBUGINFOD_CACHE_PATH="/tmp/debuginfod_client"
13+
14+
ENTRYPOINT [ "sleep", "infinity" ]

GNUmakefile

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@ $(TST_E): $(SRC_O) $(TST_O)
2121
clean:
2222
rm -f $(SRC_O) $(TST_O) $(TST_E)
2323

24+
#
25+
# valgrind
26+
#
2427
%-vg: VALGRIND = valgrind \
2528
--error-exitcode=1 \
2629
--leak-check=full \
@@ -29,12 +32,18 @@ clean:
2932
--gen-suppressions=all
3033
%-vg: % ;
3134

35+
#
36+
# test
37+
#
3238
test: $(TST_T)
3339
test-vg: $(TST_T)
3440

3541
$(TST_T): $(TST_E)
3642
$(VALGRIND) ./$(patsubst test-%,tst-%,$(@))
3743

44+
#
45+
# iwyu
46+
#
3847
IWYU = include-what-you-use \
3948
-Xiwyu --no_fwd_decls \
4049
-Xiwyu --error=1 \
@@ -43,6 +52,9 @@ IWYU = include-what-you-use \
4352
iwyu: CC = $(IWYU) -Xiwyu --check_also="inc/*h"
4453
iwyu: clean $(SRC_O) $(TST_O)
4554

55+
#
56+
# cppcheck
57+
#
4658
cppcheck: $(INC_H) $(SRC_C) $(TST_H) $(TST_C)
4759
cppcheck $(^) \
4860
--enable=warning,unusedFunction,performance,portability \
@@ -51,6 +63,28 @@ cppcheck: $(INC_H) $(SRC_C) $(TST_H) $(TST_C)
5163
--error-exitcode=1 \
5264
$(CPPFLAGS)
5365

66+
#
67+
# local docker dev
68+
#
69+
docker-build:
70+
docker build --tag "alex-c-collections:latest" .
71+
72+
docker-stop:
73+
docker rm -f alex-c-collections || true
74+
75+
docker-run: docker-stop
76+
docker run \
77+
--name="alex-c-collections" \
78+
--volume "${PWD}:/alex-c-collections" \
79+
--workdir="/alex-c-collections" \
80+
--user "`id -u`:`id -g`" \
81+
--detach \
82+
"alex-c-collections:latest"
83+
84+
docker-packages:
85+
docker exec alex-c-collections .github/workflows/packages/include-what-you-use/build.sh
86+
docker exec --user "root:root" alex-c-collections .github/workflows/packages/include-what-you-use/install.sh
87+
5488
.PHONY: all clean test test-vg $(TST_T) iwyu cppcheck
5589

5690
.NOTPARALLEL: iwyu test test-vg

0 commit comments

Comments
 (0)