From d6950a396f47e2469ebce218d150aae5cdfb5975 Mon Sep 17 00:00:00 2001 From: Amin Yahyaabadi Date: Sun, 24 Mar 2024 00:20:20 -0700 Subject: [PATCH 1/6] feat: build and publish docker images --- .github/workflows/CI.yml | 30 +++++++---- README.md | 4 +- dev/docker/__tests__/arch-mingw.dockerfile | 53 ------------------- .../arch-llvm.dockerfile} | 17 ------ .../{__tests__/arch.yml => ci/arch-llvm.yml} | 0 dev/docker/ci/arch-mingw.dockerfile | 29 ++++++++++ dev/docker/{__tests__ => ci}/arch-mingw.yml | 0 .../docker-ci.mjs} | 15 ++---- .../fedora-llvm.dockerfile} | 17 ------ .../fedora.yml => ci/fedora-llvm.yml} | 0 .../{__tests__ => ci}/fedora-mingw.dockerfile | 8 --- dev/docker/{__tests__ => ci}/fedora-mingw.yml | 0 .../ubuntu-llvm.dockerfile} | 17 ------ .../ubuntu.yml => ci/ubuntu-llvm.yml} | 0 .../{__tests__ => ci}/ubuntu-mingw.dockerfile | 8 --- dev/docker/{__tests__ => ci}/ubuntu-mingw.yml | 0 .../{ => examples}/arch-mingw.dockerfile | 0 dev/docker/{ => examples}/arch.dockerfile | 0 .../{ => examples}/fedora-mingw.dockerfile | 0 dev/docker/{ => examples}/fedora.dockerfile | 0 .../{ => examples}/ubuntu-mingw.dockerfile | 0 dev/docker/{ => examples}/ubuntu.dockerfile | 0 .../setup-cpp-arch-llvm.dockerfile} | 0 .../setup-cpp-arch-mingw.dockerfile | 0 .../setup-cpp-fedora-llvm.dockerfile} | 0 .../setup-cpp-fedora-mingw.dockerfile | 0 .../setup-cpp-ubuntu-20.0.4-llvm.dockerfile} | 0 .../setup-cpp-ubuntu-llvm.dockerfile} | 0 .../setup-cpp-ubuntu-mingw.dockerfile | 0 package.json | 14 +---- tsconfig.json | 2 +- 31 files changed, 58 insertions(+), 156 deletions(-) delete mode 100644 dev/docker/__tests__/arch-mingw.dockerfile rename dev/docker/{__tests__/arch.dockerfile => ci/arch-llvm.dockerfile} (63%) rename dev/docker/{__tests__/arch.yml => ci/arch-llvm.yml} (100%) create mode 100644 dev/docker/ci/arch-mingw.dockerfile rename dev/docker/{__tests__ => ci}/arch-mingw.yml (100%) rename dev/docker/{__tests__/generate-docker-tests.mjs => ci/docker-ci.mjs} (51%) rename dev/docker/{__tests__/fedora.dockerfile => ci/fedora-llvm.dockerfile} (58%) rename dev/docker/{__tests__/fedora.yml => ci/fedora-llvm.yml} (100%) rename dev/docker/{__tests__ => ci}/fedora-mingw.dockerfile (75%) rename dev/docker/{__tests__ => ci}/fedora-mingw.yml (100%) rename dev/docker/{__tests__/ubuntu.dockerfile => ci/ubuntu-llvm.dockerfile} (65%) rename dev/docker/{__tests__/ubuntu.yml => ci/ubuntu-llvm.yml} (100%) rename dev/docker/{__tests__ => ci}/ubuntu-mingw.dockerfile (80%) rename dev/docker/{__tests__ => ci}/ubuntu-mingw.yml (100%) rename dev/docker/{ => examples}/arch-mingw.dockerfile (100%) rename dev/docker/{ => examples}/arch.dockerfile (100%) rename dev/docker/{ => examples}/fedora-mingw.dockerfile (100%) rename dev/docker/{ => examples}/fedora.dockerfile (100%) rename dev/docker/{ => examples}/ubuntu-mingw.dockerfile (100%) rename dev/docker/{ => examples}/ubuntu.dockerfile (100%) rename dev/docker/{setup-cpp-arch.dockerfile => setup-cpp/setup-cpp-arch-llvm.dockerfile} (100%) rename dev/docker/{ => setup-cpp}/setup-cpp-arch-mingw.dockerfile (100%) rename dev/docker/{setup-cpp-fedora.dockerfile => setup-cpp/setup-cpp-fedora-llvm.dockerfile} (100%) rename dev/docker/{ => setup-cpp}/setup-cpp-fedora-mingw.dockerfile (100%) rename dev/docker/{setup-cpp-ubuntu-20.0.4.dockerfile => setup-cpp/setup-cpp-ubuntu-20.0.4-llvm.dockerfile} (100%) rename dev/docker/{setup-cpp-ubuntu.dockerfile => setup-cpp/setup-cpp-ubuntu-llvm.dockerfile} (100%) rename dev/docker/{ => setup-cpp}/setup-cpp-ubuntu-mingw.dockerfile (100%) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 72ee9bc0..5c2791d7 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -229,12 +229,12 @@ jobs: pnpm: - 8 container: - - "ubuntu.dockerfile" - - "fedora.dockerfile" - - "arch.dockerfile" - - "ubuntu-mingw.dockerfile" - # - "fedora-mingw.dockerfile" - # - "arch-mingw.dockerfile" + - { file: "./dev/docker/ci/ubuntu-llvm.dockerfile", image: "setup-cpp-ubuntu-llvm", tag: "22.04-17" } + - { file: "./dev/docker/ci/fedora-llvm.dockerfile", image: "setup-cpp-fedora-llvm", tag: "40-17" } + - { file: "./dev/docker/ci/arch-llvm.dockerfile", image: "setup-cpp-arch-llvm", tag: "base-17" } + - { file: "./dev/docker/ci/ubuntu-mingw.dockerfile", image: "setup-cpp-ubuntu-mingw", tag: "22.04-13" } + # - { file: "./dev/docker/ci/fedora-mingw.dockerfile", image: "setup-cpp-fedora-mingw", tag: "40-13" } + # - { file: "./dev/docker/ci/arch-mingw.dockerfile", image: "setup-cpp-arch-mingw", tag: "base-13" } steps: - uses: actions/checkout@v4 with: @@ -245,10 +245,20 @@ jobs: with: name: dist - - name: Build - id: docker_build - run: | - docker build -f ./dev/docker/__tests__/${{ matrix.container }} -t setup-cpp . + - name: Login to Docker Hub + uses: docker/login-action@v3 + if: ${{ github.event_name != 'pull_request' }} + with: + username: ${{ vars.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + + - name: Build and push + uses: docker/build-push-action@v5 + with: + context: . + file: ${{ matrix.container.file }} + push: ${{ github.event_name != 'pull_request' }} + tags: ${{ vars.DOCKERHUB_USERNAME }}/${{ matrix.container.image }}:${{ matrix.container.tag }} Release: if: startsWith(github.ref, 'refs/tags/') diff --git a/README.md b/README.md index 7a57e460..b9051418 100644 --- a/README.md +++ b/README.md @@ -211,7 +211,7 @@ If you want to build the ones included, then run: ```shell git clone --recurse-submodules https://github.com/aminya/setup-cpp cd ./setup-cpp -docker build -f ./dev/docker/setup-cpp-ubuntu.dockerfile -t setup-cpp-ubuntu . +docker build -f ./dev/docker/setup-cpp/setup-cpp-ubuntu.dockerfile -t setup-cpp-ubuntu-llvm:22.04-17 ./ ``` Where you should use the path to the dockerfile after `-f`. @@ -219,7 +219,7 @@ Where you should use the path to the dockerfile after `-f`. After build, run the following to start an interactive shell in your container ```shell -docker run -it setup-cpp +docker run -it setup-cpp-ubuntu-llvm:22.04-17 ``` ### Inside Docker inside GitHub Actions diff --git a/dev/docker/__tests__/arch-mingw.dockerfile b/dev/docker/__tests__/arch-mingw.dockerfile deleted file mode 100644 index 03eff050..00000000 --- a/dev/docker/__tests__/arch-mingw.dockerfile +++ /dev/null @@ -1,53 +0,0 @@ -## base image -FROM archlinux:base-devel as setup-cpp-arch-mingw - -COPY "./dist/legacy" "/usr/lib/setup-cpp/" - -# install git -RUN pacman -Syuu --noconfirm && \ - pacman-db-upgrade && \ - pacman -S --noconfirm --needed git -# 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 -WORKDIR /opt/yay -RUN chown -R yay:root . && chmod -R 775 . -USER yay -WORKDIR /opt/yay -RUN makepkg -si --noprogressbar --noconfirm -## clean up -USER root -WORKDIR / -RUN rm -rf /opt/yay - -RUN pacman -Syuu --noconfirm && \ - pacman-db-upgrade && \ - # install nodejs - pacman -S --noconfirm --needed nodejs npm && \ - # install the compiler and tools - node /usr/lib/setup-cpp/setup-cpp.js \ - --compiler mingw \ - --cmake true \ - --ninja true \ - --task true \ - --vcpkg true \ - --python true \ - --make true \ - --cppcheck true \ - --gcovr true \ - --doxygen true \ - --ccache true && \ - # arch cleanup - pacman -Scc --noconfirm && \ - rm -rf /var/cache/pacman/pkg/* && \ - rm -rf /tmp/* - -ENTRYPOINT ["/bin/bash"] - -#### Cross Building (example) -FROM setup-cpp-arch-mingw AS builder-mingw - -COPY ./dev/cpp_vcpkg_project /home/app -WORKDIR /home/app -RUN bash -c 'source ~/.cpprc \ - && task build_cross_mingw' diff --git a/dev/docker/__tests__/arch.dockerfile b/dev/docker/ci/arch-llvm.dockerfile similarity index 63% rename from dev/docker/__tests__/arch.dockerfile rename to dev/docker/ci/arch-llvm.dockerfile index 3b6bc740..e5ff0cd4 100644 --- a/dev/docker/__tests__/arch.dockerfile +++ b/dev/docker/ci/arch-llvm.dockerfile @@ -27,20 +27,3 @@ RUN pacman -Syuu --noconfirm && \ rm -rf /tmp/* ENTRYPOINT ["/bin/bash"] - -#### Building (example) -FROM setup-cpp-arch AS builder - -COPY ./dev/cpp_vcpkg_project /home/app -WORKDIR /home/app -RUN bash -c 'source ~/.cpprc \ - && task build' - -#### Running environment -# use a fresh image as the runner -FROM archlinux:base as runner - -# 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"] diff --git a/dev/docker/__tests__/arch.yml b/dev/docker/ci/arch-llvm.yml similarity index 100% rename from dev/docker/__tests__/arch.yml rename to dev/docker/ci/arch-llvm.yml diff --git a/dev/docker/ci/arch-mingw.dockerfile b/dev/docker/ci/arch-mingw.dockerfile new file mode 100644 index 00000000..fc816d8a --- /dev/null +++ b/dev/docker/ci/arch-mingw.dockerfile @@ -0,0 +1,29 @@ +## base image +FROM archlinux:base as setup-cpp-arch-mingw + +COPY "./dist/legacy" "/usr/lib/setup-cpp/" + +RUN pacman -Syuu --noconfirm && \ + pacman-db-upgrade && \ + # install nodejs + pacman -S --noconfirm --needed nodejs npm && \ + + # install the compiler and tools + node /usr/lib/setup-cpp/setup-cpp.js \ + --compiler mingw \ + --cmake true \ + --ninja true \ + --task true \ + --vcpkg true \ + --python true \ + --make true \ + --cppcheck true \ + --gcovr true \ + --doxygen true \ + --ccache true && \ + # arch cleanup + pacman -Scc --noconfirm && \ + rm -rf /var/cache/pacman/pkg/* && \ + rm -rf /tmp/* + +ENTRYPOINT ["/bin/bash"] diff --git a/dev/docker/__tests__/arch-mingw.yml b/dev/docker/ci/arch-mingw.yml similarity index 100% rename from dev/docker/__tests__/arch-mingw.yml rename to dev/docker/ci/arch-mingw.yml diff --git a/dev/docker/__tests__/generate-docker-tests.mjs b/dev/docker/ci/docker-ci.mjs similarity index 51% rename from dev/docker/__tests__/generate-docker-tests.mjs rename to dev/docker/ci/docker-ci.mjs index c138b00b..b273f6ec 100644 --- a/dev/docker/__tests__/generate-docker-tests.mjs +++ b/dev/docker/ci/docker-ci.mjs @@ -1,12 +1,10 @@ import { readFile, writeFile } from "fs/promises" async function main() { - const dockerFiles = ["ubuntu", "arch", "fedora", "ubuntu-mingw", "arch-mingw", "fedora-mingw"] + const names = ["ubuntu-llvm", "arch-llvm", "fedora-llvm", "ubuntu-mingw", "arch-mingw", "fedora-mingw"] await Promise.all( - dockerFiles.map(async (dockerFile) => { - const dockerFileContent = await readFile(`./dev/docker/setup-cpp-${dockerFile}.dockerfile`, "utf-8") - const builderExample = await readFile(`./dev/docker/${dockerFile}.dockerfile`, "utf-8") - + names.map(async (name) => { + const dockerFileContent = await readFile(`./dev/docker/setup-cpp/setup-cpp-${name}.dockerfile`, "utf-8") const modifiedDockerFile = dockerFileContent // load the externally built setup-cpp .replace(/FROM (.*)/g, `FROM $1\n\nCOPY "./dist/legacy" "/usr/lib/setup-cpp/"`) @@ -14,11 +12,8 @@ async function main() { // remove the npm install line .replace(/# install setup-cpp\n\s*npm install -g setup-cpp.*/, "") - // concat the two files - const newDockerFileContent = `${modifiedDockerFile}\n${builderExample}` - - // write the new file in dev/docker/__tests__ - await writeFile(`./dev/docker/__tests__/${dockerFile}.dockerfile`, newDockerFileContent) + // write the new file in dev/docker/ci + await writeFile(`./dev/docker/ci/${name}.dockerfile`, modifiedDockerFile) }), ) } diff --git a/dev/docker/__tests__/fedora.dockerfile b/dev/docker/ci/fedora-llvm.dockerfile similarity index 58% rename from dev/docker/__tests__/fedora.dockerfile rename to dev/docker/ci/fedora-llvm.dockerfile index 21b13828..58249a5f 100644 --- a/dev/docker/__tests__/fedora.dockerfile +++ b/dev/docker/ci/fedora-llvm.dockerfile @@ -24,20 +24,3 @@ RUN dnf -y install nodejs npm && \ rm -rf /tmp/* ENTRYPOINT ["/bin/bash"] - -#### Building (example) -FROM setup-cpp-fedora AS builder - -COPY ./dev/cpp_vcpkg_project /home/app -WORKDIR /home/app -RUN bash -c 'source ~/.cpprc \ - && task build' - -#### Running environment -# use a fresh image as the runner -FROM fedora:40 as runner - -# 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"] diff --git a/dev/docker/__tests__/fedora.yml b/dev/docker/ci/fedora-llvm.yml similarity index 100% rename from dev/docker/__tests__/fedora.yml rename to dev/docker/ci/fedora-llvm.yml diff --git a/dev/docker/__tests__/fedora-mingw.dockerfile b/dev/docker/ci/fedora-mingw.dockerfile similarity index 75% rename from dev/docker/__tests__/fedora-mingw.dockerfile rename to dev/docker/ci/fedora-mingw.dockerfile index bb2c9f97..b1c1bedb 100644 --- a/dev/docker/__tests__/fedora-mingw.dockerfile +++ b/dev/docker/ci/fedora-mingw.dockerfile @@ -25,11 +25,3 @@ RUN dnf -y install nodejs npm && \ rm -rf /tmp/* ENTRYPOINT ["/bin/bash"] - -#### Cross Building (example) -FROM setup-cpp-fedora-mingw AS builder-mingw - -COPY ./dev/cpp_vcpkg_project /home/app -WORKDIR /home/app -RUN bash -c 'source ~/.cpprc \ - && task build_cross_mingw' diff --git a/dev/docker/__tests__/fedora-mingw.yml b/dev/docker/ci/fedora-mingw.yml similarity index 100% rename from dev/docker/__tests__/fedora-mingw.yml rename to dev/docker/ci/fedora-mingw.yml diff --git a/dev/docker/__tests__/ubuntu.dockerfile b/dev/docker/ci/ubuntu-llvm.dockerfile similarity index 65% rename from dev/docker/__tests__/ubuntu.dockerfile rename to dev/docker/ci/ubuntu-llvm.dockerfile index 4e0ffd80..aed4d2b1 100644 --- a/dev/docker/__tests__/ubuntu.dockerfile +++ b/dev/docker/ci/ubuntu-llvm.dockerfile @@ -30,20 +30,3 @@ RUN apt-get update -qq && \ rm -rf /tmp/* ENTRYPOINT ["/bin/bash"] - -#### Building (example) -FROM setup-cpp-ubuntu AS builder - -COPY ./dev/cpp_vcpkg_project /home/app -WORKDIR /home/app -RUN bash -c 'source ~/.cpprc \ - && task build' - -#### Running environment -# use a fresh image as the runner -FROM ubuntu:22.04 as runner - -# 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"] diff --git a/dev/docker/__tests__/ubuntu.yml b/dev/docker/ci/ubuntu-llvm.yml similarity index 100% rename from dev/docker/__tests__/ubuntu.yml rename to dev/docker/ci/ubuntu-llvm.yml diff --git a/dev/docker/__tests__/ubuntu-mingw.dockerfile b/dev/docker/ci/ubuntu-mingw.dockerfile similarity index 80% rename from dev/docker/__tests__/ubuntu-mingw.dockerfile rename to dev/docker/ci/ubuntu-mingw.dockerfile index 9737e97a..6cba82a1 100644 --- a/dev/docker/__tests__/ubuntu-mingw.dockerfile +++ b/dev/docker/ci/ubuntu-mingw.dockerfile @@ -31,11 +31,3 @@ RUN apt-get update -qq && \ rm -rf /tmp/* ENTRYPOINT ["/bin/bash"] - -#### Cross Building (example) -FROM setup-cpp-ubuntu-mingw AS builder-mingw - -COPY ./dev/cpp_vcpkg_project /home/app -WORKDIR /home/app -RUN bash -c 'source ~/.cpprc \ - && task build_cross_mingw' diff --git a/dev/docker/__tests__/ubuntu-mingw.yml b/dev/docker/ci/ubuntu-mingw.yml similarity index 100% rename from dev/docker/__tests__/ubuntu-mingw.yml rename to dev/docker/ci/ubuntu-mingw.yml diff --git a/dev/docker/arch-mingw.dockerfile b/dev/docker/examples/arch-mingw.dockerfile similarity index 100% rename from dev/docker/arch-mingw.dockerfile rename to dev/docker/examples/arch-mingw.dockerfile diff --git a/dev/docker/arch.dockerfile b/dev/docker/examples/arch.dockerfile similarity index 100% rename from dev/docker/arch.dockerfile rename to dev/docker/examples/arch.dockerfile diff --git a/dev/docker/fedora-mingw.dockerfile b/dev/docker/examples/fedora-mingw.dockerfile similarity index 100% rename from dev/docker/fedora-mingw.dockerfile rename to dev/docker/examples/fedora-mingw.dockerfile diff --git a/dev/docker/fedora.dockerfile b/dev/docker/examples/fedora.dockerfile similarity index 100% rename from dev/docker/fedora.dockerfile rename to dev/docker/examples/fedora.dockerfile diff --git a/dev/docker/ubuntu-mingw.dockerfile b/dev/docker/examples/ubuntu-mingw.dockerfile similarity index 100% rename from dev/docker/ubuntu-mingw.dockerfile rename to dev/docker/examples/ubuntu-mingw.dockerfile diff --git a/dev/docker/ubuntu.dockerfile b/dev/docker/examples/ubuntu.dockerfile similarity index 100% rename from dev/docker/ubuntu.dockerfile rename to dev/docker/examples/ubuntu.dockerfile diff --git a/dev/docker/setup-cpp-arch.dockerfile b/dev/docker/setup-cpp/setup-cpp-arch-llvm.dockerfile similarity index 100% rename from dev/docker/setup-cpp-arch.dockerfile rename to dev/docker/setup-cpp/setup-cpp-arch-llvm.dockerfile diff --git a/dev/docker/setup-cpp-arch-mingw.dockerfile b/dev/docker/setup-cpp/setup-cpp-arch-mingw.dockerfile similarity index 100% rename from dev/docker/setup-cpp-arch-mingw.dockerfile rename to dev/docker/setup-cpp/setup-cpp-arch-mingw.dockerfile diff --git a/dev/docker/setup-cpp-fedora.dockerfile b/dev/docker/setup-cpp/setup-cpp-fedora-llvm.dockerfile similarity index 100% rename from dev/docker/setup-cpp-fedora.dockerfile rename to dev/docker/setup-cpp/setup-cpp-fedora-llvm.dockerfile diff --git a/dev/docker/setup-cpp-fedora-mingw.dockerfile b/dev/docker/setup-cpp/setup-cpp-fedora-mingw.dockerfile similarity index 100% rename from dev/docker/setup-cpp-fedora-mingw.dockerfile rename to dev/docker/setup-cpp/setup-cpp-fedora-mingw.dockerfile diff --git a/dev/docker/setup-cpp-ubuntu-20.0.4.dockerfile b/dev/docker/setup-cpp/setup-cpp-ubuntu-20.0.4-llvm.dockerfile similarity index 100% rename from dev/docker/setup-cpp-ubuntu-20.0.4.dockerfile rename to dev/docker/setup-cpp/setup-cpp-ubuntu-20.0.4-llvm.dockerfile diff --git a/dev/docker/setup-cpp-ubuntu.dockerfile b/dev/docker/setup-cpp/setup-cpp-ubuntu-llvm.dockerfile similarity index 100% rename from dev/docker/setup-cpp-ubuntu.dockerfile rename to dev/docker/setup-cpp/setup-cpp-ubuntu-llvm.dockerfile diff --git a/dev/docker/setup-cpp-ubuntu-mingw.dockerfile b/dev/docker/setup-cpp/setup-cpp-ubuntu-mingw.dockerfile similarity index 100% rename from dev/docker/setup-cpp-ubuntu-mingw.dockerfile rename to dev/docker/setup-cpp/setup-cpp-ubuntu-mingw.dockerfile diff --git a/package.json b/package.json index a3f24e7c..2b1844a8 100644 --- a/package.json +++ b/package.json @@ -55,19 +55,7 @@ "test.lint.eslint": "eslint **/*.{ts,tsx,js,jsx,cjs,mjs,json,yaml} --no-error-on-unmatched-pattern --cache --cache-location ./.cache/eslint/", "test.lint.prettier": "prettier . --check", "test": "jest --runInBand --forceExit --coverage", - "build.docker_tests": "node ./dev/docker/__tests__/generate-docker-tests.mjs", - "build.docker.arch": "pnpm build.docker_tests && docker build -f ./dev/docker/__tests__/arch.dockerfile -t setup-cpp:arch .", - "build.docker.fedora": "pnpm build.docker_tests && docker build -f ./dev/docker/__tests__/fedora.dockerfile -t setup-cpp:fedora .", - "build.docker.ubuntu": "pnpm build.docker_tests && docker build -f ./dev/docker/__tests__/ubuntu.dockerfile -t setup-cpp:ubuntu .", - "build.docker.arch.mingw": "pnpm build.docker_tests && docker build -f ./dev/docker/__tests__/arch-mingw.dockerfile -t setup-cpp:arch-mingw .", - "build.docker.fedora.mingw": "pnpm build.docker_tests && docker build -f ./dev/docker/__tests__/fedora-mingw.dockerfile -t setup-cpp:fedora-mingw .", - "build.docker.ubuntu.mingw": "pnpm build.docker_tests && docker build -f ./dev/docker/__tests__/ubuntu-mingw.dockerfile -t setup-cpp:ubuntu-mingw .", - "test.docker.arch": "pnpm build.docker.arch && container-structure-test test --image setup-cpp:arch --config ./dev/docker/__tests__/arch.yml", - "test.docker.fedora": "pnpm build.docker.fedora && container-structure-test test --image setup-cpp:fedora --config ./dev/docker/__tests__/fedora.yml", - "test.docker.ubuntu": "pnpm build.docker.ubuntu && container-structure-test test --image setup-cpp:ubuntu --config ./dev/docker/__tests__/ubuntu.yml", - "test.docker.arch.mingw": "pnpm build.docker.arch.mingw && container-structure-test test --image setup-cpp:arch-mingw --config ./dev/docker/__tests__/arch-mingw.yml", - "test.docker.fedora.mingw": "pnpm build.docker.fedora.mingw && container-structure-test test --image setup-cpp:fedora-mingw --config ./dev/docker/__tests__/fedora-mingw.yml", - "test.docker.ubuntu.mingw": "pnpm build.docker.ubuntu.mingw && container-structure-test test --image setup-cpp:ubuntu-mingw --config ./dev/docker/__tests__/ubuntu-mingw.yml" + "build.docker-ci": "node ./dev/docker/ci/docker-ci.mjs" }, "prettier": "prettier-config-atomic", "devDependencies": { diff --git a/tsconfig.json b/tsconfig.json index f0b2d449..8eb64bfa 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -33,7 +33,7 @@ "./src", "dev/scripts", "packages/untildify-user/untildify.ts", - "dev/docker/__tests__/generate-docker-tests.mjs", + "dev/docker/ci/docker-ci.mjs", "./jest.config.ts" ] } From 85853d5f3a7b23ab3ab7c2c83c61f2bd01e831a0 Mon Sep 17 00:00:00 2001 From: Amin Yahyaabadi Date: Sun, 24 Mar 2024 00:23:24 -0700 Subject: [PATCH 2/6] ci: test the built images --- .github/workflows/CI.yml | 24 ++++++++++++++++-------- dev/docker/examples/arch.dockerfile | 2 +- dev/docker/examples/fedora.dockerfile | 2 +- dev/docker/examples/ubuntu.dockerfile | 2 +- 4 files changed, 19 insertions(+), 11 deletions(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 5c2791d7..9fac978e 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -55,7 +55,7 @@ jobs: - name: Build run: | pnpm build - pnpm build.docker_tests + pnpm build.docker-ci - name: Lint run: | @@ -229,12 +229,12 @@ jobs: pnpm: - 8 container: - - { file: "./dev/docker/ci/ubuntu-llvm.dockerfile", image: "setup-cpp-ubuntu-llvm", tag: "22.04-17" } - - { file: "./dev/docker/ci/fedora-llvm.dockerfile", image: "setup-cpp-fedora-llvm", tag: "40-17" } - - { file: "./dev/docker/ci/arch-llvm.dockerfile", image: "setup-cpp-arch-llvm", tag: "base-17" } - - { file: "./dev/docker/ci/ubuntu-mingw.dockerfile", image: "setup-cpp-ubuntu-mingw", tag: "22.04-13" } - # - { file: "./dev/docker/ci/fedora-mingw.dockerfile", image: "setup-cpp-fedora-mingw", tag: "40-13" } - # - { file: "./dev/docker/ci/arch-mingw.dockerfile", image: "setup-cpp-arch-mingw", tag: "base-13" } + - { file: "ubuntu-llvm.dockerfile", image: "setup-cpp-ubuntu-llvm", tag: "22.04-17" } + - { file: "fedora-llvm.dockerfile", image: "setup-cpp-fedora-llvm", tag: "40-17" } + - { file: "arch-llvm.dockerfile", image: "setup-cpp-arch-llvm", tag: "base-17" } + - { file: "ubuntu-mingw.dockerfile", image: "setup-cpp-ubuntu-mingw", tag: "22.04-13" } + # - { file: "fedora-mingw.dockerfile", image: "setup-cpp-fedora-mingw", tag: "40-13" } + # - { file: "arch-mingw.dockerfile", image: "setup-cpp-arch-mingw", tag: "base-13" } steps: - uses: actions/checkout@v4 with: @@ -256,10 +256,18 @@ jobs: uses: docker/build-push-action@v5 with: context: . - file: ${{ matrix.container.file }} + file: ./dev/docker/ci/${{ matrix.container.file }} push: ${{ github.event_name != 'pull_request' }} tags: ${{ vars.DOCKERHUB_USERNAME }}/${{ matrix.container.image }}:${{ matrix.container.tag }} + - name: Test + uses: docker/build-push-action@v5 + with: + context: . + file: ./dev/docker/examples/${{ matrix.container.file }} + push: false + tags: ${{ vars.DOCKERHUB_USERNAME }}/test-${{ matrix.container.image }}:${{ matrix.container.tag }} + Release: if: startsWith(github.ref, 'refs/tags/') needs: [Build, BuildExecutable, Test, Docker] diff --git a/dev/docker/examples/arch.dockerfile b/dev/docker/examples/arch.dockerfile index 2516313f..d648a095 100644 --- a/dev/docker/examples/arch.dockerfile +++ b/dev/docker/examples/arch.dockerfile @@ -1,5 +1,5 @@ #### Building (example) -FROM setup-cpp-arch AS builder +FROM setup-cpp-arch-llvm AS builder COPY ./dev/cpp_vcpkg_project /home/app WORKDIR /home/app diff --git a/dev/docker/examples/fedora.dockerfile b/dev/docker/examples/fedora.dockerfile index 3e287132..4fbf8e5c 100644 --- a/dev/docker/examples/fedora.dockerfile +++ b/dev/docker/examples/fedora.dockerfile @@ -1,5 +1,5 @@ #### Building (example) -FROM setup-cpp-fedora AS builder +FROM setup-cpp-fedora-llvm AS builder COPY ./dev/cpp_vcpkg_project /home/app WORKDIR /home/app diff --git a/dev/docker/examples/ubuntu.dockerfile b/dev/docker/examples/ubuntu.dockerfile index d1ad6264..4d1f7dfd 100644 --- a/dev/docker/examples/ubuntu.dockerfile +++ b/dev/docker/examples/ubuntu.dockerfile @@ -1,5 +1,5 @@ #### Building (example) -FROM setup-cpp-ubuntu AS builder +FROM setup-cpp-ubuntu-llvm AS builder COPY ./dev/cpp_vcpkg_project /home/app WORKDIR /home/app From 7a90df073244215a817e47533914996f76a31160 Mon Sep 17 00:00:00 2001 From: Amin Yahyaabadi Date: Sun, 24 Mar 2024 00:33:04 -0700 Subject: [PATCH 3/6] ci: add the scope for the test images --- .github/workflows/CI.yml | 2 +- dev/docker/examples/arch-mingw.dockerfile | 2 +- dev/docker/examples/arch.dockerfile | 2 +- dev/docker/examples/fedora-mingw.dockerfile | 2 +- dev/docker/examples/fedora.dockerfile | 2 +- dev/docker/examples/ubuntu-mingw.dockerfile | 2 +- dev/docker/examples/ubuntu.dockerfile | 2 +- 7 files changed, 7 insertions(+), 7 deletions(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 9fac978e..b8864204 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -215,7 +215,7 @@ jobs: node ./dist/actions/setup-cpp.js --help Docker: - name: Test-${{ matrix.container }} + name: Docker-${{ matrix.container.image }} if: ${{ !contains(github.event.head_commit.message, '[skip ci]') }} needs: [Build] runs-on: ${{ matrix.os }} diff --git a/dev/docker/examples/arch-mingw.dockerfile b/dev/docker/examples/arch-mingw.dockerfile index ddbd080e..eea44012 100644 --- a/dev/docker/examples/arch-mingw.dockerfile +++ b/dev/docker/examples/arch-mingw.dockerfile @@ -1,5 +1,5 @@ #### Cross Building (example) -FROM setup-cpp-arch-mingw AS builder-mingw +FROM aminya/setup-cpp-arch-mingw AS builder-mingw COPY ./dev/cpp_vcpkg_project /home/app WORKDIR /home/app diff --git a/dev/docker/examples/arch.dockerfile b/dev/docker/examples/arch.dockerfile index d648a095..3661315b 100644 --- a/dev/docker/examples/arch.dockerfile +++ b/dev/docker/examples/arch.dockerfile @@ -1,5 +1,5 @@ #### Building (example) -FROM setup-cpp-arch-llvm AS builder +FROM aminya/setup-cpp-arch-llvm AS builder COPY ./dev/cpp_vcpkg_project /home/app WORKDIR /home/app diff --git a/dev/docker/examples/fedora-mingw.dockerfile b/dev/docker/examples/fedora-mingw.dockerfile index 1511924c..b7fbb43b 100644 --- a/dev/docker/examples/fedora-mingw.dockerfile +++ b/dev/docker/examples/fedora-mingw.dockerfile @@ -1,5 +1,5 @@ #### Cross Building (example) -FROM setup-cpp-fedora-mingw AS builder-mingw +FROM aminya/setup-cpp-fedora-mingw AS builder-mingw COPY ./dev/cpp_vcpkg_project /home/app WORKDIR /home/app diff --git a/dev/docker/examples/fedora.dockerfile b/dev/docker/examples/fedora.dockerfile index 4fbf8e5c..510b6056 100644 --- a/dev/docker/examples/fedora.dockerfile +++ b/dev/docker/examples/fedora.dockerfile @@ -1,5 +1,5 @@ #### Building (example) -FROM setup-cpp-fedora-llvm AS builder +FROM aminya/setup-cpp-fedora-llvm AS builder COPY ./dev/cpp_vcpkg_project /home/app WORKDIR /home/app diff --git a/dev/docker/examples/ubuntu-mingw.dockerfile b/dev/docker/examples/ubuntu-mingw.dockerfile index 0325aef5..220046c7 100644 --- a/dev/docker/examples/ubuntu-mingw.dockerfile +++ b/dev/docker/examples/ubuntu-mingw.dockerfile @@ -1,5 +1,5 @@ #### Cross Building (example) -FROM setup-cpp-ubuntu-mingw AS builder-mingw +FROM aminya/setup-cpp-ubuntu-mingw AS builder-mingw COPY ./dev/cpp_vcpkg_project /home/app WORKDIR /home/app diff --git a/dev/docker/examples/ubuntu.dockerfile b/dev/docker/examples/ubuntu.dockerfile index 4d1f7dfd..04eff6ea 100644 --- a/dev/docker/examples/ubuntu.dockerfile +++ b/dev/docker/examples/ubuntu.dockerfile @@ -1,5 +1,5 @@ #### Building (example) -FROM setup-cpp-ubuntu-llvm AS builder +FROM aminya/setup-cpp-ubuntu-llvm AS builder COPY ./dev/cpp_vcpkg_project /home/app WORKDIR /home/app From 1f53bd746ad628f114123dd5edba4efb62782f09 Mon Sep 17 00:00:00 2001 From: Amin Yahyaabadi Date: Sun, 24 Mar 2024 00:52:14 -0700 Subject: [PATCH 4/6] ci: tag as latest after using exact versions --- .github/workflows/CI.yml | 17 +++++++++++------ .../{arch.dockerfile => arch-llvm.dockerfile} | 0 ...fedora.dockerfile => fedora-llvm.dockerfile} | 0 ...ubuntu.dockerfile => ubuntu-llvm.dockerfile} | 0 4 files changed, 11 insertions(+), 6 deletions(-) rename dev/docker/examples/{arch.dockerfile => arch-llvm.dockerfile} (100%) rename dev/docker/examples/{fedora.dockerfile => fedora-llvm.dockerfile} (100%) rename dev/docker/examples/{ubuntu.dockerfile => ubuntu-llvm.dockerfile} (100%) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index b8864204..19097ff3 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -229,12 +229,12 @@ jobs: pnpm: - 8 container: - - { file: "ubuntu-llvm.dockerfile", image: "setup-cpp-ubuntu-llvm", tag: "22.04-17" } - - { file: "fedora-llvm.dockerfile", image: "setup-cpp-fedora-llvm", tag: "40-17" } - - { file: "arch-llvm.dockerfile", image: "setup-cpp-arch-llvm", tag: "base-17" } - - { file: "ubuntu-mingw.dockerfile", image: "setup-cpp-ubuntu-mingw", tag: "22.04-13" } - # - { file: "fedora-mingw.dockerfile", image: "setup-cpp-fedora-mingw", tag: "40-13" } - # - { file: "arch-mingw.dockerfile", image: "setup-cpp-arch-mingw", tag: "base-13" } + - { file: "ubuntu-llvm.dockerfile", image: "setup-cpp-ubuntu-llvm", tag: "22.04-0.37.0" } + - { file: "fedora-llvm.dockerfile", image: "setup-cpp-fedora-llvm", tag: "40-0.37.0" } + - { file: "arch-llvm.dockerfile", image: "setup-cpp-arch-llvm", tag: "base-0.37.0" } + - { file: "ubuntu-mingw.dockerfile", image: "setup-cpp-ubuntu-mingw", tag: "22.04-0.37.0" } + # - { file: "fedora-mingw.dockerfile", image: "setup-cpp-fedora-mingw", tag: "40-0.37.0" } + # - { file: "arch-mingw.dockerfile", image: "setup-cpp-arch-mingw", tag: "base-0.37.0" } steps: - uses: actions/checkout@v4 with: @@ -260,6 +260,11 @@ jobs: push: ${{ github.event_name != 'pull_request' }} tags: ${{ vars.DOCKERHUB_USERNAME }}/${{ matrix.container.image }}:${{ matrix.container.tag }} + - name: Tag + run: | + docker tag ${{ vars.DOCKERHUB_USERNAME }}/${{ matrix.container.image }}:${{ matrix.container.tag }} ${{ vars.DOCKERHUB_USERNAME }}/${{ matrix.container.image }}:latest + docker push ${{ vars.DOCKERHUB_USERNAME }}/${{ matrix.container.image }}:latest + - name: Test uses: docker/build-push-action@v5 with: diff --git a/dev/docker/examples/arch.dockerfile b/dev/docker/examples/arch-llvm.dockerfile similarity index 100% rename from dev/docker/examples/arch.dockerfile rename to dev/docker/examples/arch-llvm.dockerfile diff --git a/dev/docker/examples/fedora.dockerfile b/dev/docker/examples/fedora-llvm.dockerfile similarity index 100% rename from dev/docker/examples/fedora.dockerfile rename to dev/docker/examples/fedora-llvm.dockerfile diff --git a/dev/docker/examples/ubuntu.dockerfile b/dev/docker/examples/ubuntu-llvm.dockerfile similarity index 100% rename from dev/docker/examples/ubuntu.dockerfile rename to dev/docker/examples/ubuntu-llvm.dockerfile From 526d06e31f82ba3abbd23fefe0e136044333944e Mon Sep 17 00:00:00 2001 From: Amin Yahyaabadi Date: Sun, 24 Mar 2024 00:58:14 -0700 Subject: [PATCH 5/6] ci: push the latest only on master [skip test] --- .github/workflows/CI.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 19097ff3..41b3994e 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -263,6 +263,11 @@ jobs: - name: Tag run: | docker tag ${{ vars.DOCKERHUB_USERNAME }}/${{ matrix.container.image }}:${{ matrix.container.tag }} ${{ vars.DOCKERHUB_USERNAME }}/${{ matrix.container.image }}:latest + + - name: Push Latest + if: ${{ github.event_name != 'pull_request' }} + run: | + docker login -u ${{ vars.DOCKERHUB_USERNAME }} -p ${{ secrets.DOCKERHUB_TOKEN }} docker push ${{ vars.DOCKERHUB_USERNAME }}/${{ matrix.container.image }}:latest - name: Test From c8e2110f697958367e282a4019a197c162ddef1e Mon Sep 17 00:00:00 2001 From: Amin Yahyaabadi Date: Sun, 24 Mar 2024 01:06:41 -0700 Subject: [PATCH 6/6] ci: tag latest in the same step [skip ci] --- .github/workflows/CI.yml | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 41b3994e..056846d6 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -258,17 +258,7 @@ jobs: context: . file: ./dev/docker/ci/${{ matrix.container.file }} push: ${{ github.event_name != 'pull_request' }} - tags: ${{ vars.DOCKERHUB_USERNAME }}/${{ matrix.container.image }}:${{ matrix.container.tag }} - - - name: Tag - run: | - docker tag ${{ vars.DOCKERHUB_USERNAME }}/${{ matrix.container.image }}:${{ matrix.container.tag }} ${{ vars.DOCKERHUB_USERNAME }}/${{ matrix.container.image }}:latest - - - name: Push Latest - if: ${{ github.event_name != 'pull_request' }} - run: | - docker login -u ${{ vars.DOCKERHUB_USERNAME }} -p ${{ secrets.DOCKERHUB_TOKEN }} - docker push ${{ vars.DOCKERHUB_USERNAME }}/${{ matrix.container.image }}:latest + tags: ${{ vars.DOCKERHUB_USERNAME }}/${{ matrix.container.image }}:${{ matrix.container.tag }},${{ vars.DOCKERHUB_USERNAME }}/${{ matrix.container.image }}:latest - name: Test uses: docker/build-push-action@v5