Skip to content
Permalink

Comparing changes

This is a direct comparison between two commits made in this repository or its related repositories. View the default comparison for this range or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: aminya/setup-cpp
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: e6f6b7c8cf8da655320c7044ea1788e45f567756
Choose a base ref
..
head repository: aminya/setup-cpp
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 0487e80610c88014504fe364e3f939baa70edb17
Choose a head ref
Showing with 100 additions and 164 deletions.
  1. +30 −12 .github/workflows/CI.yml
  2. +28 −2 README.md
  3. +0 −53 dev/docker/__tests__/arch-mingw.dockerfile
  4. +0 −17 dev/docker/{__tests__/arch.dockerfile → ci/arch-llvm.dockerfile}
  5. 0 dev/docker/{__tests__/arch.yml → ci/arch-llvm.yml}
  6. +29 −0 dev/docker/ci/arch-mingw.dockerfile
  7. 0 dev/docker/{__tests__ → ci}/arch-mingw.yml
  8. +5 −10 dev/docker/{__tests__/generate-docker-tests.mjs → ci/docker-ci.mjs}
  9. +0 −17 dev/docker/{__tests__/fedora.dockerfile → ci/fedora-llvm.dockerfile}
  10. 0 dev/docker/{__tests__/fedora.yml → ci/fedora-llvm.yml}
  11. +0 −8 dev/docker/{__tests__ → ci}/fedora-mingw.dockerfile
  12. 0 dev/docker/{__tests__ → ci}/fedora-mingw.yml
  13. +0 −17 dev/docker/{__tests__/ubuntu.dockerfile → ci/ubuntu-llvm.dockerfile}
  14. 0 dev/docker/{__tests__/ubuntu.yml → ci/ubuntu-llvm.yml}
  15. +0 −8 dev/docker/{__tests__ → ci}/ubuntu-mingw.dockerfile
  16. 0 dev/docker/{__tests__ → ci}/ubuntu-mingw.yml
  17. +1 −1 dev/docker/{arch.dockerfile → examples/arch-llvm.dockerfile}
  18. +1 −1 dev/docker/{ → examples}/arch-mingw.dockerfile
  19. +1 −1 dev/docker/{fedora.dockerfile → examples/fedora-llvm.dockerfile}
  20. +1 −1 dev/docker/{ → examples}/fedora-mingw.dockerfile
  21. +1 −1 dev/docker/{ubuntu.dockerfile → examples/ubuntu-llvm.dockerfile}
  22. +1 −1 dev/docker/{ → examples}/ubuntu-mingw.dockerfile
  23. 0 dev/docker/{setup-cpp-arch.dockerfile → setup-cpp/setup-cpp-arch-llvm.dockerfile}
  24. 0 dev/docker/{ → setup-cpp}/setup-cpp-arch-mingw.dockerfile
  25. 0 dev/docker/{setup-cpp-fedora.dockerfile → setup-cpp/setup-cpp-fedora-llvm.dockerfile}
  26. 0 dev/docker/{ → setup-cpp}/setup-cpp-fedora-mingw.dockerfile
  27. 0 dev/docker/{setup-cpp-ubuntu-20.0.4.dockerfile → setup-cpp/setup-cpp-ubuntu-20.0.4-llvm.dockerfile}
  28. 0 dev/docker/{setup-cpp-ubuntu.dockerfile → setup-cpp/setup-cpp-ubuntu-llvm.dockerfile}
  29. 0 dev/docker/{ → setup-cpp}/setup-cpp-ubuntu-mingw.dockerfile
  30. +1 −13 package.json
  31. +1 −1 tsconfig.json
42 changes: 30 additions & 12 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
@@ -55,7 +55,7 @@ jobs:
- name: Build
run: |
pnpm build
pnpm build.docker_tests
pnpm build.docker-ci
- name: Lint
run: |
@@ -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 }}
@@ -229,12 +229,12 @@ jobs:
pnpm:
- 8
container:
- "ubuntu.dockerfile"
- "fedora.dockerfile"
- "arch.dockerfile"
- "ubuntu-mingw.dockerfile"
# - "fedora-mingw.dockerfile"
# - "arch-mingw.dockerfile"
- { 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:
@@ -245,10 +245,28 @@ 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: ./dev/docker/ci/${{ matrix.container.file }}
push: ${{ github.event_name != 'pull_request' }}
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
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/')
30 changes: 28 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -149,6 +149,32 @@ jobs:
# ...
```

### Prebuilt Docker Images

To provide fast development environments, `setup-cpp` provides several prebuilt docker images that have the tools you need (e.g. `llvm, cmake, ninja, task, vcpkg, python, make, cppcheck, gcovr, doxygen, ccache`).

You can use these images as a base image for your project.

```dockerfile
FROM aminya/setup-cpp-ubuntu-llvm:22.04-0.37.0 AS builder
```

```dockerfile
FROM aminya/setup-cpp-ubuntu-mingw:22.04-0.37.0 AS builder
```

```dockerfile
FROM aminya/setup-cpp-fedora-llvm:40-0.37.0 AS builder
```

```dockerfile
FROM aminya/setup-cpp-arch-llvm:base-0.37.0 AS builder
```

The names are in the format `aminya/setup-cpp-<platform>-<compiler>:<platform_version>-<setup_cpp_version>`.

If you need to install the tools selectively, see the next section.

### Inside Docker

Here is an example for using setup-cpp to make a builder image that has the Cpp tools you need.
@@ -211,15 +237,15 @@ 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`.

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
53 changes: 0 additions & 53 deletions dev/docker/__tests__/arch-mingw.dockerfile

This file was deleted.

Original file line number Diff line number Diff line change
@@ -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"]
File renamed without changes.
29 changes: 29 additions & 0 deletions dev/docker/ci/arch-mingw.dockerfile
Original file line number Diff line number Diff line change
@@ -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"]
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,24 +1,19 @@
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/"`)
.replace("setup-cpp ", "node /usr/lib/setup-cpp/setup-cpp.js ")
// 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)
}),
)
}
Original file line number Diff line number Diff line change
@@ -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"]
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -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'
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -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"]
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -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'
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#### Building (example)
FROM setup-cpp-arch AS builder
FROM aminya/setup-cpp-arch-llvm AS builder

COPY ./dev/cpp_vcpkg_project /home/app
WORKDIR /home/app
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#### Building (example)
FROM setup-cpp-fedora AS builder
FROM aminya/setup-cpp-fedora-llvm AS builder

COPY ./dev/cpp_vcpkg_project /home/app
WORKDIR /home/app
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#### Building (example)
FROM setup-cpp-ubuntu AS builder
FROM aminya/setup-cpp-ubuntu-llvm AS builder

COPY ./dev/cpp_vcpkg_project /home/app
WORKDIR /home/app
Original file line number Diff line number Diff line change
@@ -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
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
14 changes: 1 addition & 13 deletions package.json
Original file line number Diff line number Diff line change
@@ -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": {
2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
@@ -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"
]
}