Skip to content

Commit aecb4b3

Browse files
committed
feat: add pacman support (#31)
* add `setupPacmanPack` * add arch linux docker image * add container tests
1 parent e11034e commit aecb4b3

File tree

24 files changed

+375
-61
lines changed

24 files changed

+375
-61
lines changed

.dockerignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
.parcel-cache/
2+
node_modules/
3+
dev/docker/
4+
dev/container-tests/

CONTRIBUTING.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,7 @@ pnpm install
99
Before running the tests locally, backup your environment variables because faulty code might corrupt the environment.
1010

1111
<https://stackoverflow.com/a/5147185/7910299>
12+
13+
14+
Install [container-structure-test](https://github.com/GoogleContainerTools/container-structure-test) for docker testing.
15+

dev/container-tests/arch.yml

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
schemaVersion: 2.0.0
2+
3+
commandTests:
4+
- name: gcc compiler
5+
command: gcc
6+
args: ["--version"]
7+
expectedOutput: [".*gcc.*GCC.*"]
8+
- name: g++ compiler
9+
command: g++
10+
args: ["--version"]
11+
expectedOutput: [".*g\\+\\+.*GCC.*"]
12+
- name: cmake
13+
command: cmake
14+
args: ["--version"]
15+
expectedOutput: [".*cmake version.*"]
16+
- name: make
17+
command: make
18+
args: ["--version"]
19+
expectedOutput: [".*GNU Make.*"]
20+
- name: ninja
21+
command: ninja
22+
args: ["--version"]
23+
expectedOutput: [".*1.*"]
24+
- name: gcovr
25+
command: gcovr
26+
args: ["--version"]
27+
expectedOutput: [".*gcovr.*"]
28+
- name: ccache
29+
command: ccache
30+
args: ["--version"]
31+
expectedOutput: [".*ccache.*"]
32+
- name: doxygen
33+
command: doxygen
34+
args: ["--version"]
35+
expectedOutput: [".*1.*"]
36+
- name: cppcheck
37+
command: cppcheck
38+
args: ["--version"]
39+
expectedOutput: [".*Cppcheck.*"]
40+
41+
42+
fileExistenceTests:
43+
- name: 'vcpkg'
44+
path: '/root/vcpkg'
45+
shouldExist: true

dev/container-tests/ubuntu.yml

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
schemaVersion: 2.0.0
2+
3+
commandTests:
4+
- name: gcc compiler
5+
command: gcc
6+
args: ["--version"]
7+
expectedOutput: [".*gcc.*"]
8+
- name: g++ compiler
9+
command: g++
10+
args: ["--version"]
11+
expectedOutput: [".*g\\+\\+.*"]
12+
- name: make
13+
command: make
14+
args: ["--version"]
15+
expectedOutput: [".*GNU Make.*"]
16+
- name: ninja
17+
command: /root/ninja/ninja
18+
args: ["--version"]
19+
expectedOutput: [".*1.*"]
20+
- name: gcovr
21+
command: gcovr
22+
args: ["--version"]
23+
expectedOutput: [".*gcovr.*"]
24+
- name: ccache
25+
command: ccache
26+
args: ["--version"]
27+
expectedOutput: [".*ccache.*"]
28+
- name: doxygen
29+
command: doxygen
30+
args: ["--version"]
31+
expectedOutput: [".*1.*"]
32+
- name: cppcheck
33+
command: cppcheck
34+
args: ["--version"]
35+
expectedOutput: [".*Cppcheck.*"]
36+
- name: clang
37+
command: /root/llvm/bin/clang
38+
args: ["--version"]
39+
expectedOutput: [".*clang.*"]
40+
41+
42+
fileExistenceTests:
43+
- name: 'vcpkg'
44+
path: '/root/vcpkg'
45+
shouldExist: true
46+
- name: 'llvm'
47+
path: '/root/llvm'
48+
shouldExist: true

dev/docker/arch_node.dockerfile

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
## base image
2+
FROM archlinux as base
3+
4+
RUN pacman -Syuu --noconfirm
5+
6+
# Install packages available from standard repos
7+
RUN pacman-db-upgrade && \
8+
pacman -S --noconfirm --needed \
9+
wget curl pkg-config zip unzip tar git && \
10+
pacman -S --noconfirm \
11+
nodejs && \
12+
pacman -Scc --noconfirm
13+
14+
# install yay
15+
#RUN useradd -m -G nobody -s /bin/bash yay && passwd -d yay && echo "yay ALL=(ALL) ALL" >> /etc/sudoers
16+
#RUN git clone --depth 1 https://aur.archlinux.org/yay.git /opt/yay && cd /opt/yay && \
17+
# chown -R yay:root . && chmod -R 775 . && \
18+
# runuser -l yay -c "cd /opt/yay && makepkg -si --noprogressbar --noconfirm"
19+
20+
# add setup_cpp.js
21+
COPY "./dist/" "/"
22+
WORKDIR "/"
23+
24+
# run installation
25+
RUN node ./setup_cpp.js --compiler llvm --cmake true --ninja true --cppcheck true --ccache true --vcpkg true --doxygen true --gcovr true --task true
26+
27+
# clean up
28+
RUN pacman -Scc --noconfirm
29+
#RUN rm -rf /home/yay/.cache/*
30+
RUN rm -rf /tmp/*
31+
32+
CMD source ~/.cpprc
33+
ENTRYPOINT [ "/bin/bash" ]
34+
35+
#### Building
36+
FROM base AS builder
37+
COPY ./dev/cpp_vcpkg_project /home/app
38+
WORKDIR /home/app
39+
RUN bash -c 'source ~/.cpprc \
40+
&& task build'
41+
42+
### Running environment
43+
# use a distroless image or ubuntu:22.04 if you wish
44+
FROM gcr.io/distroless/cc
45+
# copy the built binaries and their runtime dependencies
46+
COPY --from=builder /home/app/build/my_exe/Release/ /home/app/
47+
WORKDIR /home/app/
48+
ENTRYPOINT ["./my_exe"]

dev/docker/ubuntu_node.dockerfile

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,22 @@ RUN apt-get update -qq
44
RUN apt-get install -y --no-install-recommends nodejs
55

66
# add setup_cpp.js
7-
ADD "./dist/" "/"
7+
COPY "./dist/" "/"
88
WORKDIR "/"
99

1010
# run installation
1111
RUN node ./setup_cpp.js --compiler llvm --cmake true --ninja true --cppcheck true --ccache true --vcpkg true --doxygen true --gcovr true --task true
1212

13+
# clean up
14+
RUN apt-get clean && rm -rf /var/lib/apt/lists/*
15+
RUN rm -rf /tmp/*
16+
1317
CMD source ~/.cpprc
1418
ENTRYPOINT [ "/bin/bash" ]
1519

1620
#### Building
1721
FROM base AS builder
18-
ADD ./dev/cpp_vcpkg_project /home/app
22+
COPY ./dev/cpp_vcpkg_project /home/app
1923
WORKDIR /home/app
2024
RUN bash -c 'source ~/.cpprc \
2125
&& task build'

dist/setup_cpp.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/setup_cpp.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
"scripts": {
1515
"build": "shx rm -rf dist/ && shx mkdir ./dist && run-p test.tsc build.parcel copy.matchers",
1616
"build.docker": "pnpm build && docker build -f ./dev/docker/ubuntu_node.dockerfile -t setup_cpp .",
17+
"build.docker.ubuntu": "pnpm build && docker build -f ./dev/docker/ubuntu_node.dockerfile -t setup_cpp:ubuntu .",
18+
"build.docker.arch": "pnpm build && docker build -f ./dev/docker/arch_node.dockerfile -t setup_cpp:arch .",
1719
"build.parcel": "cross-env NODE_ENV=production parcel build --detailed-report",
1820
"bump": "ncu -u -x execa,numerous && pnpm update",
1921
"clean": "shx rm -rf .parcel-cache dist exe",
@@ -24,6 +26,10 @@
2426
"pack.exe": "shx rm -rf ./dist/tsconfig.tsbuildinfo && node ./dev/scripts/pack-exe.js",
2527
"prepare": "npm run build",
2628
"start.docker": "docker run -t setup_cpp .",
29+
"start.docker.ubuntu": "docker run -t setup_cpp:ubuntu .",
30+
"start.docker.arch": "docker run -t setup_cpp:arch .",
31+
"test.docker.ubuntu": "docker build -f ./dev/docker/ubuntu_node.dockerfile --target base -t setup_cpp:ubuntu-base . && container-structure-test test --image setup_cpp:ubuntu-base --config ./dev/container-tests/ubuntu.yml",
32+
"test.docker.arch": "docker build -f ./dev/docker/arch_node.dockerfile --target base -t setup_cpp:arch-base . && container-structure-test test --image setup_cpp:arch-base --config ./dev/container-tests/arch.yml",
2733
"test": "run-p test.format test.lint test.cspell test.tsc test.unit",
2834
"test.cspell": "cspell lint --no-progress --show-suggestions",
2935
"test.format": "prettier . --check",

0 commit comments

Comments
 (0)