Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ ARG DEBIAN_VERSION=forky

FROM debian:${DEBIAN_VERSION}-slim

ARG CLANG_VERSION
ARG CMAKE_VERSION
ARG CPPCHECK_VERSION
ARG CLANG_VERSION=21
ARG CMAKE_VERSION=4.2.1
ARG CPPCHECK_VERSION=2.18.0

# install base packages

Expand Down
7 changes: 1 addition & 6 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,7 @@
{
"name": "C++ Devcontainer",
"build": {
"dockerfile": "Dockerfile",
"args": {
"CLANG_VERSION": "21",
"CMAKE_VERSION": "4.2.1",
"CPPCHECK_VERSION": "2.18.0"
}
"dockerfile": "Dockerfile"
},
"remoteUser": "user"
}
84 changes: 84 additions & 0 deletions .github/workflows/sanity-checks.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
name: Sanity Checks
on:
push:
branches:
- main
pull_request:
branches:
- main
env:
GHCR_URL_WITH_UPPERCASE: ghcr.io/${{ github.repository }}
jobs:
build-devcontainer-image:
name: Build devcontainer
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: Checkout repository
uses: actions/checkout@v6
- name: Convert GHCR url to lower case
run: echo "GHCR_URL=${GHCR_URL_WITH_UPPERCASE@L}" >> ${GITHUB_ENV}
- name: Login to Github Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Pre-build dev container image
uses: devcontainers/[email protected]
with:
imageName: ${{ env.GHCR_URL }}
cacheFrom: ${{ env.GHCR_URL }}
push: always
check-tools-installed:
name: Check if all tools are installed
needs: build-devcontainer-image
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v6
- name: Convert GHCR url to lower case
run: echo "GHCR_URL=${GHCR_URL_WITH_UPPERCASE@L}" >> ${GITHUB_ENV}
- name: Login to Github Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Check tools
uses: devcontainers/[email protected]
with:
cacheFrom: ${{ env.GHCR_URL }}
push: never
runCmd: |
clang --version
cmake --version
cppcheck --version
vcpkg --version
build-test-project:
name: Build test project
needs: build-devcontainer-image
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v6
- name: Convert GHCR url to lower case
run: echo "GHCR_URL=${GHCR_URL_WITH_UPPERCASE@L}" >> ${GITHUB_ENV}
- name: Login to Github Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build test project
uses: devcontainers/[email protected]
with:
cacheFrom: ${{ env.GHCR_URL }}
push: never
runCmd: |
cd test
cmake --preset clang-debug
cmake --build --preset clang-debug-build
./build/clang-debug/hello_world
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
build/
15 changes: 15 additions & 0 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
cmake_minimum_required(VERSION 4.2 FATAL_ERROR)

# workaround clang bug
set(CMAKE_CXX_STDLIB_MODULES_JSON "/usr/lib/llvm-21/lib/libc++.modules.json")

set(CMAKE_EXPERIMENTAL_CXX_IMPORT_STD "d0edc3af-4c50-42ea-a356-e2862fe7a444")
set(CMAKE_CXX_MODULE_STD ON)
set(CMAKE_CXX_STANDARD 26)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)

project(TestCppDevcontainer LANGUAGES CXX)

add_executable(hello_world)
target_sources(hello_world PRIVATE "main.cpp")
26 changes: 26 additions & 0 deletions test/CMakePresets.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"version": 6,
"cmakeMinimumRequired": {
"major": 4,
"minor": 2,
"patch": 0
},
"configurePresets": [
{
"name": "clang-debug",
"generator": "Ninja",
"binaryDir": "${sourceDir}/build/${presetName}",
"cacheVariables": {
"CMAKE_CXX_COMPILER": "/usr/bin/clang++",
"CMAKE_CXX_FLAGS": "-stdlib=libc++",
"CMAKE_BUILD_TYPE": "Debug"
}
}
],
"buildPresets": [
{
"name": "clang-debug-build",
"configurePreset": "clang-debug"
}
]
}
6 changes: 6 additions & 0 deletions test/main.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import std;

int main()
{
std::println("Hello, world!");
}