Skip to content

Commit 2d55cce

Browse files
authored
Initial commit
0 parents  commit 2d55cce

21 files changed

+711
-0
lines changed

.clang-format

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
---
2+
BasedOnStyle : GNU
3+
---
4+
Language : Cpp
5+
FixNamespaceComments: true
6+
AlwaysBreakAfterReturnType: TopLevelDefinitions
7+
AlwaysBreakTemplateDeclarations: true
8+
# Set BraceWrapping. Most of these are GNU but not all.
9+
# Sadly, apparently we need to give all of them though, as when using BreakBeforeBraces=GNU,
10+
# customisations get ignored.
11+
BreakBeforeBraces: Custom
12+
BraceWrapping:
13+
AfterClass: true
14+
AfterControlStatement: true
15+
AfterEnum: true
16+
AfterFunction: true
17+
AfterNamespace: true
18+
AfterObjCDeclaration: true
19+
AfterStruct: true
20+
AfterUnion: true
21+
AfterExternBlock: true
22+
BeforeCatch: true
23+
BeforeElse: true
24+
IndentBraces: true
25+
SplitEmptyFunction: false
26+
SplitEmptyRecord: true
27+
SplitEmptyNamespace: true
28+
# non-standard GNU
29+
SplitEmptyFunction: false
30+
ColumnLimit: 130
31+
IndentPPDirectives: AfterHash
32+
PointerAlignment: Left
33+
SortIncludes: false
34+
SortUsingDeclarations: false
35+
SpaceBeforeParens: ControlStatements
36+
Standard: Cpp11
37+
...

.devcontainer/Dockerfile

+98
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
ARG DEVCONTAINER_BASE=mcr.microsoft.com/devcontainers/base:1.0.9-ubuntu-22.04
2+
3+
#########################################################
4+
# file-normalizer stage
5+
# In order to use BuildKit remote caching, input files must have
6+
# not only the right content hash, but also the right permissions.
7+
# Git only tracks whether the owner can execute a file.
8+
# Here we bring in all files that are going to be used in the
9+
# subsequent stage and normalize the permissions.
10+
#########################################################
11+
12+
FROM --platform=linux/amd64 ${DEVCONTAINER_BASE} as file-normalizer
13+
14+
COPY environment.yml \
15+
.devcontainer/devcontainer.bashrc \
16+
/data/
17+
18+
RUN chmod -R 555 /data/
19+
20+
#########################################################
21+
# devcontainer stage
22+
# Installs all dependencies and tooling for development.
23+
#########################################################
24+
25+
FROM --platform=linux/amd64 ${DEVCONTAINER_BASE} AS devcontainer
26+
27+
# Install needed packages and setup non-root user.
28+
ARG USERNAME="vscode"
29+
ARG USER_UID=1000
30+
ARG USER_GID=$USER_UID
31+
ARG CONDA_GID=900
32+
ARG CONDA_ENVIRONMENT_NAME=prd
33+
ARG VSCODE_DEV_CONTAINERS_SCRIPT_LIBRARY_VERSION=v0.229.0
34+
35+
RUN apt-get update && apt-get install -y \
36+
libc6-dbg \
37+
&& rm -rf /var/lib/apt/lists/*
38+
39+
# Enable non-root Docker access in container
40+
ARG ENABLE_NONROOT_DOCKER="true"
41+
# Use the OSS Moby CLI instead of the licensed Docker CLI
42+
ARG USE_MOBY="false"
43+
RUN script=$(curl -fsSL "https://raw.githubusercontent.com/microsoft/vscode-dev-containers/${VSCODE_DEV_CONTAINERS_SCRIPT_LIBRARY_VERSION}/script-library/docker-debian.sh") && bash -c "$script" -- "${ENABLE_NONROOT_DOCKER}" "/var/run/docker-host.sock" "/var/run/docker.sock" "${USERNAME}" "${USE_MOBY}"
44+
45+
# Setting the ENTRYPOINT to docker-init.sh will configure non-root access to
46+
# the Docker socket if "overrideCommand": false is set in devcontainer.json.
47+
# The script will also execute CMD if you need to alter startup behaviors.
48+
ENTRYPOINT [ "/usr/local/share/docker-init.sh" ]
49+
CMD [ "sleep", "infinity" ]
50+
51+
ARG MAMBAFORGE_VERSION=22.9.0-2
52+
53+
# Based on https://github.com/conda-forge/miniforge-images/blob/master/ubuntu/Dockerfile
54+
RUN wget --no-hsts --quiet https://github.com/conda-forge/miniforge/releases/download/${MAMBAFORGE_VERSION}/Mambaforge-${MAMBAFORGE_VERSION}-Linux-$(uname -m).sh -O /tmp/miniforge.sh \
55+
&& /bin/bash /tmp/miniforge.sh -b -p /opt/conda \
56+
&& rm /tmp/miniforge.sh \
57+
&& /opt/conda/bin/conda clean --tarballs --index-cache --packages --yes \
58+
&& find /opt/conda -follow -type f -name '*.a' -delete \
59+
&& find /opt/conda -follow -type f -name '*.pyc' -delete \
60+
&& /opt/conda/bin/conda clean --force-pkgs-dirs --all --yes \
61+
&& groupadd -r conda --gid ${CONDA_GID} \
62+
&& usermod -aG conda ${USERNAME} \
63+
&& chown -R :conda /opt/conda \
64+
&& chmod -R g+w /opt/conda \
65+
&& find /opt -type d | xargs -n 1 chmod g+s
66+
67+
# Create a conda environment from the environment file in the repo root.
68+
COPY --from=file-normalizer --chown=$USER_UID:conda /data/environment.yml /tmp/build/
69+
RUN umask 0002 \
70+
&& /opt/conda/bin/mamba env create -f /tmp/build/environment.yml \
71+
&& /opt/conda/bin/mamba clean -fy \
72+
&& sudo chown -R :conda /opt/conda/envs
73+
74+
# Add a file that is to be sourced from .bashrc and from the devops pipeline stages
75+
COPY --from=file-normalizer /data/devcontainer.bashrc /opt/devcontainer/
76+
77+
# Add a section to /etc/bash.bashrc that ensures that a section is present at the end of ~/.bashrc.
78+
# We can't just write to .bashrc from here because it will be overwritten if the devcontainer user has
79+
# opted to use their own dotfiles repo. The dotfiles repo is cloned after the postCreateCommand
80+
# in the devcontainer.json file is executed.
81+
RUN echo "\n\
82+
if ! grep -q \"^source /opt/devcontainer/devcontainer.bashrc\" \${HOME}/.bashrc; then\n\
83+
echo \"source /opt/devcontainer/devcontainer.bashrc\" >> \${HOME}/.bashrc\n\
84+
fi\n" >> /etc/bash.bashrc
85+
86+
ENV CMAKE_GENERATOR=Ninja
87+
88+
# Create a kits file for the VSCode CMake Tools extension, so you are not prompted for which kit to select whenever you open VSCode
89+
RUN mkdir -p /home/vscode/.local/share/CMakeTools \
90+
&& echo '[{"name":"GCC-10","compilers":{"C":"/opt/conda/envs/prd/bin/x86_64-conda_cos6-linux-gnu-gcc","CXX":"/opt/conda/envs/prd/bin/x86_64-conda_cos6-linux-gnu-g++"}}]' > /home/vscode/.local/share/CMakeTools/cmake-tools-kits.json \
91+
&& chown vscode:conda /home/vscode/.local/share/CMakeTools/cmake-tools-kits.json
92+
93+
# Install the yardl tool
94+
ARG YARDL_VERSION=0.3.2
95+
RUN wget --quiet "https://github.com/microsoft/yardl/releases/download/v${YARDL_VERSION}/yardl_${YARDL_VERSION}_linux_x86_64.tar.gz" \
96+
&& tar -xzf "yardl_${YARDL_VERSION}_linux_x86_64.tar.gz" \
97+
&& mv yardl "/opt/conda/envs/${CONDA_ENVIRONMENT_NAME}/bin/" \
98+
&& rm "yardl_${YARDL_VERSION}_linux_x86_64.tar.gz"

.devcontainer/devcontainer.bashrc

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#! /bin/bash
2+
# shellcheck source=/dev/null
3+
4+
source /opt/conda/etc/profile.d/conda.sh
5+
conda activate prd
6+
source <(yardl completion bash)
7+
8+
if [[ "${BASH_ENV:-}" == "$(readlink -f "${BASH_SOURCE[0]:-}")" ]]; then
9+
# We don't want subshells to unnecessarily source this again.
10+
unset BASH_ENV
11+
fi

.devcontainer/devcontainer.json

+126
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,126 @@
1+
// For format details, see https://aka.ms/devcontainer.json. For config options, see the README at:
2+
// https://github.com/microsoft/vscode-dev-containerdevcotns/tree/v0.238.0/containers/go
3+
{
4+
"name": "prd",
5+
"build": {
6+
"dockerfile": "Dockerfile",
7+
"context": ".."
8+
},
9+
"runArgs": [
10+
"--cap-add=SYS_PTRACE",
11+
"--security-opt",
12+
"seccomp=unconfined",
13+
"--platform=linux/amd64"
14+
],
15+
16+
"postStartCommand": "git submodule update --init --recursive",
17+
18+
// Configure tool-specific properties.
19+
"customizations": {
20+
// Configure properties specific to VS Code.
21+
"vscode": {
22+
// Set *default* container specific settings.json values on container create.
23+
"settings": {
24+
"files.trimFinalNewlines": true,
25+
"files.trimTrailingWhitespace": true,
26+
"files.insertFinalNewline": true,
27+
28+
"[cpp]": {
29+
"editor.formatOnSave": true
30+
},
31+
32+
"[json]": {
33+
"editor.defaultFormatter": "esbenp.prettier-vscode",
34+
"editor.formatOnSave": true
35+
},
36+
37+
"[jsonc]": {
38+
"editor.defaultFormatter": "esbenp.prettier-vscode",
39+
"editor.formatOnSave": true
40+
},
41+
42+
"[python]": {
43+
"editor.defaultFormatter": "ms-python.black-formatter",
44+
"editor.formatOnSave": true
45+
},
46+
47+
"cmake.sourceDirectory": "${workspaceFolder}/cpp",
48+
"cmake.buildDirectory": "${workspaceFolder}/cpp/build",
49+
"cmake.configureOnOpen": false,
50+
51+
"python.defaultInterpreterPath": "/opt/conda/envs/prd/bin/python",
52+
"python.analysis.typeCheckingMode": "strict",
53+
"python.analysis.diagnosticMode": "workspace",
54+
"python.analysis.diagnosticSeverityOverrides": {
55+
"reportUnknownArgumentType": "none",
56+
"reportUnknownLambdaType": "none",
57+
"reportUnknownMemberType": "none",
58+
"reportUnknownParameterType": "none",
59+
"reportUnknownVariableType": "none",
60+
"reportUnnecessaryIsInstance": "none",
61+
"reportUnusedImport": "none"
62+
},
63+
"python.terminal.activateEnvironment": false, // Disable the extension calling activate when the integrated terminal launches. We take care of this in ~/.bashrc.
64+
65+
"testMate.cpp.test.executables": "cpp/{build,Build,BUILD,out,Out,OUT}/**/*{test,Test,TEST}*",
66+
67+
// enable pretty printing when debugging C++ tests
68+
"testMate.cpp.debug.configTemplate": {
69+
"type": "cppvsdbg",
70+
"linux": { "type": "cppdbg", "MIMode": "gdb" },
71+
"darwin": { "type": "cppdbg", "MIMode": "lldb" },
72+
"win32": { "type": "cppvsdbg" },
73+
"program": "${exec}",
74+
"args": "${argsArray}",
75+
"cwd": "${cwd}",
76+
"env": "${envObj}",
77+
"environment": "${envObjArray}",
78+
"sourceFileMap": "${sourceFileMapObj}",
79+
"setupCommands": [
80+
{
81+
"description": "Enable pretty-printing for gdb",
82+
"text": "-enable-pretty-printing",
83+
"ignoreFailures": true
84+
}
85+
],
86+
87+
"gitlens.showWelcomeOnInstall": false,
88+
"gitlens.showWhatsNewAfterUpgrades": false
89+
},
90+
91+
"gcovViewer.gcovBinary": "/opt/conda/envs/prd/bin/x86_64-conda-linux-gnu-gcov",
92+
"gcovViewer.buildDirectories": ["${workspaceFolder}/cpp/build"],
93+
94+
"search.useIgnoreFiles": false,
95+
"search.exclude": {
96+
"**/cpp/build": true
97+
}
98+
},
99+
100+
// Add the IDs of extensions you want installed when the container is created.
101+
"extensions": [
102+
"cschlosser.doxdocgen",
103+
"eamodio.gitlens",
104+
"esbenp.prettier-vscode",
105+
"JacquesLucke.gcov-viewer",
106+
"matepek.vscode-catch2-test-adapter",
107+
"mhutchie.git-graph",
108+
"ms-python.black-formatter",
109+
"ms-python.python",
110+
"ms-vscode.cmake-tools",
111+
"ms-vscode.cpptools",
112+
"timonwong.shellcheck",
113+
"twxs.cmake"
114+
]
115+
}
116+
},
117+
118+
// Use 'forwardPorts' to make a list of ports inside the container available locally.
119+
// "forwardPorts": [],
120+
121+
// Use 'postCreateCommand' to run commands after the container is created.
122+
// "postCreateCommand": "go version",
123+
124+
// Comment out to connect as root instead. More info: https://aka.ms/vscode-remote/containers/non-root.
125+
"remoteUser": "vscode"
126+
}

.gitattributes

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# Shell scripts should have LF
2+
*.bashrc text eol=lf
3+
*.sh text eol=lf
4+
*.csh text eol=lf

.github/PULL_REQUEST_TEMPLATE.md

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
## Changes in this pull request
2+
3+
4+
## Testing performed
5+
6+
7+
## Related issues
8+
<!-- Use keywords such as "fixes", "closes", see https://docs.github.com/en/issues/tracking-your-work-with-issues/linking-a-pull-request-to-an-issue -->
9+
10+
11+
## Checklist before requesting a review
12+
13+
- [ ] I have performed a self-review of my code
14+
- [ ] I have added docstrings/doxygen in line with the guidance in the developer guide
15+
- [ ] The code builds and runs on my machine
16+
17+
## Contribution Notes
18+
19+
Please read and adhere to the [contribution guidelines](https://github.com/ETSInitiative/PRDdefinition/blob/master/CONTRIBUTING.md).
20+
21+
Please tick the following:
22+
23+
- [ ] The content of this Pull Request (the Contribution) is intentionally submitted for inclusion in the ETSI software (the Work) under the terms and conditions of the [Apache-2.0](https://www.apache.org/licenses/LICENSE-2.0) License.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
name: Configure Environment
2+
description: Configures the conda environment
3+
runs:
4+
using: composite
5+
steps:
6+
7+
- name: Initial setup
8+
shell: bash
9+
run: |
10+
# filter conda environment file
11+
cat environment.yml | grep -v "#.*\<\local\>" > ci-environment.yml
12+
13+
- uses: conda-incubator/setup-miniconda@v2
14+
with:
15+
activate-environment: yardl
16+
environment-file: ci-environment.yml

.github/workflows/ci.yml

+58
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [main]
6+
paths-ignore:
7+
- '**/*.md'
8+
pull_request:
9+
branches: [main]
10+
11+
defaults:
12+
run:
13+
# See https://github.com/marketplace/actions/setup-miniconda#important
14+
shell: bash -el {0}
15+
16+
jobs:
17+
validate:
18+
strategy:
19+
matrix:
20+
cppVersion: [17]
21+
22+
name: Run tests
23+
runs-on: ubuntu-latest
24+
25+
steps:
26+
- uses: actions/checkout@v3
27+
with:
28+
submodules: recursive
29+
30+
- name: Configure environment
31+
uses: ./.github/actions/configure-environment
32+
33+
- name: Install yardl
34+
run: |
35+
YARDL_DIR=${{github.workspace}}/yardl
36+
mkdir ${YARDL_DIR}
37+
cd ${YARDL_DIR}
38+
echo "${{github.workspace}}/yardl" >> $GITHUB_PATH
39+
YARDL_VERSION=0.3.2
40+
wget --quiet "https://github.com/microsoft/yardl/releases/download/v${YARDL_VERSION}/yardl_${YARDL_VERSION}_linux_x86_64.tar.gz"
41+
tar -xzf "yardl_${YARDL_VERSION}_linux_x86_64.tar.gz"
42+
rm "yardl_${YARDL_VERSION}_linux_x86_64.tar.gz"
43+
44+
- name: Build model
45+
run: |
46+
cd PETSIRD/model
47+
yardl generate
48+
49+
- name: Python
50+
run: |
51+
cd python
52+
python start.py
53+
54+
- name: Cpp
55+
run: |
56+
cd cpp && mkdir -p build && cd build
57+
cmake -G Ninja -S .. -DHDF5_ROOT="$CONDA_PREFIX"
58+
ninja

.gitignore

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
**/build/
2+
**/__pycache__/
3+
4+
# Common editor backups
5+
~$*
6+
*~
7+
*.bak

.gitmodules

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[submodule "PETSIRD"]
2+
path = PETSIRD
3+
url = https://github.com/ETSInitiative/PRDdefinition

0 commit comments

Comments
 (0)