Skip to content

Commit

Permalink
Merge pull request #95 from abeimler/feature/arch-linux
Browse files Browse the repository at this point in the history
  • Loading branch information
aminya authored Jun 30, 2022
2 parents e11034e + cefca0b commit a4796aa
Show file tree
Hide file tree
Showing 30 changed files with 396 additions and 66 deletions.
4 changes: 4 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
.parcel-cache/
node_modules/
dev/docker/
dev/container-tests/
2 changes: 2 additions & 0 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -84,12 +84,14 @@ jobs:
if: ${{ !contains(github.event.head_commit.message, '[skip ci]') && !contains(github.event.head_commit.message, '[skip docker]') }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os:
- ubuntu-20.04
container:
- "ubuntu_node.dockerfile"
- "ubuntu_20.04_node.dockerfile"
- "arch_node.dockerfile"
node:
- 14
pnpm:
Expand Down
2 changes: 2 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,5 @@ pnpm install
Before running the tests locally, backup your environment variables because faulty code might corrupt the environment.

<https://stackoverflow.com/a/5147185/7910299>

Install [container-structure-test](https://github.com/GoogleContainerTools/container-structure-test) for docker testing.
3 changes: 3 additions & 0 deletions cspell.config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ words:
- msys
- multilib
- mxschmitt
- noconfirm
- noprogressbar
- nothrow
- npmrc
- Opencppcoverage
Expand All @@ -54,6 +56,7 @@ words:
- pypy
- setupcpp
- setx
- Syuu
- terserrc
- tsbuildinfo
- ucrt
Expand Down
44 changes: 44 additions & 0 deletions dev/container-tests/arch.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
schemaVersion: 2.0.0

commandTests:
- name: gcc compiler
command: gcc
args: ["--version"]
expectedOutput: [".*gcc.*GCC.*"]
- name: g++ compiler
command: g++
args: ["--version"]
expectedOutput: [".*g\\+\\+.*GCC.*"]
- name: cmake
command: cmake
args: ["--version"]
expectedOutput: [".*cmake version.*"]
- name: make
command: make
args: ["--version"]
expectedOutput: [".*GNU Make.*"]
- name: ninja
command: ninja
args: ["--version"]
expectedOutput: [".*1.*"]
- name: gcovr
command: gcovr
args: ["--version"]
expectedOutput: [".*gcovr.*"]
- name: ccache
command: ccache
args: ["--version"]
expectedOutput: [".*ccache.*"]
- name: doxygen
command: doxygen
args: ["--version"]
expectedOutput: [".*1.*"]
- name: cppcheck
command: cppcheck
args: ["--version"]
expectedOutput: [".*Cppcheck.*"]

fileExistenceTests:
- name: "vcpkg"
path: "/root/vcpkg"
shouldExist: true
47 changes: 47 additions & 0 deletions dev/container-tests/ubuntu.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
schemaVersion: 2.0.0

commandTests:
- name: gcc compiler
command: gcc
args: ["--version"]
expectedOutput: [".*gcc.*"]
- name: g++ compiler
command: g++
args: ["--version"]
expectedOutput: [".*g\\+\\+.*"]
- name: make
command: make
args: ["--version"]
expectedOutput: [".*GNU Make.*"]
- name: ninja
command: /root/ninja/ninja
args: ["--version"]
expectedOutput: [".*1.*"]
- name: gcovr
command: gcovr
args: ["--version"]
expectedOutput: [".*gcovr.*"]
- name: ccache
command: ccache
args: ["--version"]
expectedOutput: [".*ccache.*"]
- name: doxygen
command: doxygen
args: ["--version"]
expectedOutput: [".*1.*"]
- name: cppcheck
command: cppcheck
args: ["--version"]
expectedOutput: [".*Cppcheck.*"]
- name: clang
command: /root/llvm/bin/clang
args: ["--version"]
expectedOutput: [".*clang.*"]

fileExistenceTests:
- name: "vcpkg"
path: "/root/vcpkg"
shouldExist: true
- name: "llvm"
path: "/root/llvm"
shouldExist: true
48 changes: 48 additions & 0 deletions dev/docker/arch_node.dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
## base image
FROM archlinux as base

RUN pacman -Syuu --noconfirm

# Install packages available from standard repos
RUN pacman-db-upgrade && \
pacman -S --noconfirm --needed \
wget curl pkg-config zip unzip tar git && \
pacman -S --noconfirm \
nodejs && \
pacman -Scc --noconfirm

# install yay
#RUN useradd -m -G nobody -s /bin/bash yay && passwd -d yay && echo "yay ALL=(ALL) ALL" >> /etc/sudoers
#RUN git clone --depth 1 https://aur.archlinux.org/yay.git /opt/yay && cd /opt/yay && \
# chown -R yay:root . && chmod -R 775 . && \
# runuser -l yay -c "cd /opt/yay && makepkg -si --noprogressbar --noconfirm"

# add setup_cpp.js
COPY "./dist/" "/"
WORKDIR "/"

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

# clean up
RUN pacman -Scc --noconfirm
#RUN rm -rf /home/yay/.cache/*
RUN rm -rf /tmp/*

CMD source ~/.cpprc
ENTRYPOINT [ "/bin/bash" ]

#### Building
FROM base AS builder
COPY ./dev/cpp_vcpkg_project /home/app
WORKDIR /home/app
RUN bash -c 'source ~/.cpprc \
&& task build'

### Running environment
# use a distroless image or ubuntu:22.04 if you wish
FROM gcr.io/distroless/cc
# copy the built binaries and their runtime dependencies
COPY --from=builder /home/app/build/my_exe/Release/ /home/app/
WORKDIR /home/app/
ENTRYPOINT ["./my_exe"]
8 changes: 6 additions & 2 deletions dev/docker/ubuntu_node.dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,22 @@ RUN apt-get update -qq
RUN apt-get install -y --no-install-recommends nodejs

# add setup_cpp.js
ADD "./dist/" "/"
COPY "./dist/" "/"
WORKDIR "/"

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

# clean up
RUN apt-get clean && rm -rf /var/lib/apt/lists/*
RUN rm -rf /tmp/*

CMD source ~/.cpprc
ENTRYPOINT [ "/bin/bash" ]

#### Building
FROM base AS builder
ADD ./dev/cpp_vcpkg_project /home/app
COPY ./dev/cpp_vcpkg_project /home/app
WORKDIR /home/app
RUN bash -c 'source ~/.cpprc \
&& task build'
Expand Down
2 changes: 1 addition & 1 deletion dist/setup_cpp.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/setup_cpp.js.map

Large diffs are not rendered by default.

6 changes: 6 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
"scripts": {
"build": "shx rm -rf dist/ && shx mkdir ./dist && run-p test.tsc build.parcel copy.matchers",
"build.docker": "pnpm build && docker build -f ./dev/docker/ubuntu_node.dockerfile -t setup_cpp .",
"build.docker.arch": "pnpm build && docker build -f ./dev/docker/arch_node.dockerfile -t setup_cpp:arch .",
"build.docker.ubuntu": "pnpm build && docker build -f ./dev/docker/ubuntu_node.dockerfile -t setup_cpp:ubuntu .",
"build.parcel": "cross-env NODE_ENV=production parcel build --detailed-report",
"bump": "ncu -u -x execa,numerous && pnpm update",
"clean": "shx rm -rf .parcel-cache dist exe",
Expand All @@ -24,8 +26,12 @@
"pack.exe": "shx rm -rf ./dist/tsconfig.tsbuildinfo && node ./dev/scripts/pack-exe.js",
"prepare": "npm run build",
"start.docker": "docker run -t setup_cpp .",
"start.docker.arch": "docker run -t setup_cpp:arch .",
"start.docker.ubuntu": "docker run -t setup_cpp:ubuntu .",
"test": "run-p test.format test.lint test.cspell test.tsc test.unit",
"test.cspell": "cspell lint --no-progress --show-suggestions",
"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",
"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",
"test.format": "prettier . --check",
"test.lint": "eslint .",
"test.tsc": "tsc --noEmit | loose-ts-check",
Expand Down
Loading

0 comments on commit a4796aa

Please sign in to comment.