generated from ETSInitiative/PETSIRDUseCaseTemplate
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 2d55cce
Showing
21 changed files
with
711 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
--- | ||
BasedOnStyle : GNU | ||
--- | ||
Language : Cpp | ||
FixNamespaceComments: true | ||
AlwaysBreakAfterReturnType: TopLevelDefinitions | ||
AlwaysBreakTemplateDeclarations: true | ||
# Set BraceWrapping. Most of these are GNU but not all. | ||
# Sadly, apparently we need to give all of them though, as when using BreakBeforeBraces=GNU, | ||
# customisations get ignored. | ||
BreakBeforeBraces: Custom | ||
BraceWrapping: | ||
AfterClass: true | ||
AfterControlStatement: true | ||
AfterEnum: true | ||
AfterFunction: true | ||
AfterNamespace: true | ||
AfterObjCDeclaration: true | ||
AfterStruct: true | ||
AfterUnion: true | ||
AfterExternBlock: true | ||
BeforeCatch: true | ||
BeforeElse: true | ||
IndentBraces: true | ||
SplitEmptyFunction: false | ||
SplitEmptyRecord: true | ||
SplitEmptyNamespace: true | ||
# non-standard GNU | ||
SplitEmptyFunction: false | ||
ColumnLimit: 130 | ||
IndentPPDirectives: AfterHash | ||
PointerAlignment: Left | ||
SortIncludes: false | ||
SortUsingDeclarations: false | ||
SpaceBeforeParens: ControlStatements | ||
Standard: Cpp11 | ||
... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
ARG DEVCONTAINER_BASE=mcr.microsoft.com/devcontainers/base:1.0.9-ubuntu-22.04 | ||
|
||
######################################################### | ||
# file-normalizer stage | ||
# In order to use BuildKit remote caching, input files must have | ||
# not only the right content hash, but also the right permissions. | ||
# Git only tracks whether the owner can execute a file. | ||
# Here we bring in all files that are going to be used in the | ||
# subsequent stage and normalize the permissions. | ||
######################################################### | ||
|
||
FROM --platform=linux/amd64 ${DEVCONTAINER_BASE} as file-normalizer | ||
|
||
COPY environment.yml \ | ||
.devcontainer/devcontainer.bashrc \ | ||
/data/ | ||
|
||
RUN chmod -R 555 /data/ | ||
|
||
######################################################### | ||
# devcontainer stage | ||
# Installs all dependencies and tooling for development. | ||
######################################################### | ||
|
||
FROM --platform=linux/amd64 ${DEVCONTAINER_BASE} AS devcontainer | ||
|
||
# Install needed packages and setup non-root user. | ||
ARG USERNAME="vscode" | ||
ARG USER_UID=1000 | ||
ARG USER_GID=$USER_UID | ||
ARG CONDA_GID=900 | ||
ARG CONDA_ENVIRONMENT_NAME=prd | ||
ARG VSCODE_DEV_CONTAINERS_SCRIPT_LIBRARY_VERSION=v0.229.0 | ||
|
||
RUN apt-get update && apt-get install -y \ | ||
libc6-dbg \ | ||
&& rm -rf /var/lib/apt/lists/* | ||
|
||
# Enable non-root Docker access in container | ||
ARG ENABLE_NONROOT_DOCKER="true" | ||
# Use the OSS Moby CLI instead of the licensed Docker CLI | ||
ARG USE_MOBY="false" | ||
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}" | ||
|
||
# Setting the ENTRYPOINT to docker-init.sh will configure non-root access to | ||
# the Docker socket if "overrideCommand": false is set in devcontainer.json. | ||
# The script will also execute CMD if you need to alter startup behaviors. | ||
ENTRYPOINT [ "/usr/local/share/docker-init.sh" ] | ||
CMD [ "sleep", "infinity" ] | ||
|
||
ARG MAMBAFORGE_VERSION=22.9.0-2 | ||
|
||
# Based on https://github.com/conda-forge/miniforge-images/blob/master/ubuntu/Dockerfile | ||
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 \ | ||
&& /bin/bash /tmp/miniforge.sh -b -p /opt/conda \ | ||
&& rm /tmp/miniforge.sh \ | ||
&& /opt/conda/bin/conda clean --tarballs --index-cache --packages --yes \ | ||
&& find /opt/conda -follow -type f -name '*.a' -delete \ | ||
&& find /opt/conda -follow -type f -name '*.pyc' -delete \ | ||
&& /opt/conda/bin/conda clean --force-pkgs-dirs --all --yes \ | ||
&& groupadd -r conda --gid ${CONDA_GID} \ | ||
&& usermod -aG conda ${USERNAME} \ | ||
&& chown -R :conda /opt/conda \ | ||
&& chmod -R g+w /opt/conda \ | ||
&& find /opt -type d | xargs -n 1 chmod g+s | ||
|
||
# Create a conda environment from the environment file in the repo root. | ||
COPY --from=file-normalizer --chown=$USER_UID:conda /data/environment.yml /tmp/build/ | ||
RUN umask 0002 \ | ||
&& /opt/conda/bin/mamba env create -f /tmp/build/environment.yml \ | ||
&& /opt/conda/bin/mamba clean -fy \ | ||
&& sudo chown -R :conda /opt/conda/envs | ||
|
||
# Add a file that is to be sourced from .bashrc and from the devops pipeline stages | ||
COPY --from=file-normalizer /data/devcontainer.bashrc /opt/devcontainer/ | ||
|
||
# Add a section to /etc/bash.bashrc that ensures that a section is present at the end of ~/.bashrc. | ||
# We can't just write to .bashrc from here because it will be overwritten if the devcontainer user has | ||
# opted to use their own dotfiles repo. The dotfiles repo is cloned after the postCreateCommand | ||
# in the devcontainer.json file is executed. | ||
RUN echo "\n\ | ||
if ! grep -q \"^source /opt/devcontainer/devcontainer.bashrc\" \${HOME}/.bashrc; then\n\ | ||
echo \"source /opt/devcontainer/devcontainer.bashrc\" >> \${HOME}/.bashrc\n\ | ||
fi\n" >> /etc/bash.bashrc | ||
|
||
ENV CMAKE_GENERATOR=Ninja | ||
|
||
# Create a kits file for the VSCode CMake Tools extension, so you are not prompted for which kit to select whenever you open VSCode | ||
RUN mkdir -p /home/vscode/.local/share/CMakeTools \ | ||
&& 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 \ | ||
&& chown vscode:conda /home/vscode/.local/share/CMakeTools/cmake-tools-kits.json | ||
|
||
# Install the yardl tool | ||
ARG YARDL_VERSION=0.3.2 | ||
RUN wget --quiet "https://github.com/microsoft/yardl/releases/download/v${YARDL_VERSION}/yardl_${YARDL_VERSION}_linux_x86_64.tar.gz" \ | ||
&& tar -xzf "yardl_${YARDL_VERSION}_linux_x86_64.tar.gz" \ | ||
&& mv yardl "/opt/conda/envs/${CONDA_ENVIRONMENT_NAME}/bin/" \ | ||
&& rm "yardl_${YARDL_VERSION}_linux_x86_64.tar.gz" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#! /bin/bash | ||
# shellcheck source=/dev/null | ||
|
||
source /opt/conda/etc/profile.d/conda.sh | ||
conda activate prd | ||
source <(yardl completion bash) | ||
|
||
if [[ "${BASH_ENV:-}" == "$(readlink -f "${BASH_SOURCE[0]:-}")" ]]; then | ||
# We don't want subshells to unnecessarily source this again. | ||
unset BASH_ENV | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,126 @@ | ||
// For format details, see https://aka.ms/devcontainer.json. For config options, see the README at: | ||
// https://github.com/microsoft/vscode-dev-containerdevcotns/tree/v0.238.0/containers/go | ||
{ | ||
"name": "prd", | ||
"build": { | ||
"dockerfile": "Dockerfile", | ||
"context": ".." | ||
}, | ||
"runArgs": [ | ||
"--cap-add=SYS_PTRACE", | ||
"--security-opt", | ||
"seccomp=unconfined", | ||
"--platform=linux/amd64" | ||
], | ||
|
||
"postStartCommand": "git submodule update --init --recursive", | ||
|
||
// Configure tool-specific properties. | ||
"customizations": { | ||
// Configure properties specific to VS Code. | ||
"vscode": { | ||
// Set *default* container specific settings.json values on container create. | ||
"settings": { | ||
"files.trimFinalNewlines": true, | ||
"files.trimTrailingWhitespace": true, | ||
"files.insertFinalNewline": true, | ||
|
||
"[cpp]": { | ||
"editor.formatOnSave": true | ||
}, | ||
|
||
"[json]": { | ||
"editor.defaultFormatter": "esbenp.prettier-vscode", | ||
"editor.formatOnSave": true | ||
}, | ||
|
||
"[jsonc]": { | ||
"editor.defaultFormatter": "esbenp.prettier-vscode", | ||
"editor.formatOnSave": true | ||
}, | ||
|
||
"[python]": { | ||
"editor.defaultFormatter": "ms-python.black-formatter", | ||
"editor.formatOnSave": true | ||
}, | ||
|
||
"cmake.sourceDirectory": "${workspaceFolder}/cpp", | ||
"cmake.buildDirectory": "${workspaceFolder}/cpp/build", | ||
"cmake.configureOnOpen": false, | ||
|
||
"python.defaultInterpreterPath": "/opt/conda/envs/prd/bin/python", | ||
"python.analysis.typeCheckingMode": "strict", | ||
"python.analysis.diagnosticMode": "workspace", | ||
"python.analysis.diagnosticSeverityOverrides": { | ||
"reportUnknownArgumentType": "none", | ||
"reportUnknownLambdaType": "none", | ||
"reportUnknownMemberType": "none", | ||
"reportUnknownParameterType": "none", | ||
"reportUnknownVariableType": "none", | ||
"reportUnnecessaryIsInstance": "none", | ||
"reportUnusedImport": "none" | ||
}, | ||
"python.terminal.activateEnvironment": false, // Disable the extension calling activate when the integrated terminal launches. We take care of this in ~/.bashrc. | ||
|
||
"testMate.cpp.test.executables": "cpp/{build,Build,BUILD,out,Out,OUT}/**/*{test,Test,TEST}*", | ||
|
||
// enable pretty printing when debugging C++ tests | ||
"testMate.cpp.debug.configTemplate": { | ||
"type": "cppvsdbg", | ||
"linux": { "type": "cppdbg", "MIMode": "gdb" }, | ||
"darwin": { "type": "cppdbg", "MIMode": "lldb" }, | ||
"win32": { "type": "cppvsdbg" }, | ||
"program": "${exec}", | ||
"args": "${argsArray}", | ||
"cwd": "${cwd}", | ||
"env": "${envObj}", | ||
"environment": "${envObjArray}", | ||
"sourceFileMap": "${sourceFileMapObj}", | ||
"setupCommands": [ | ||
{ | ||
"description": "Enable pretty-printing for gdb", | ||
"text": "-enable-pretty-printing", | ||
"ignoreFailures": true | ||
} | ||
], | ||
|
||
"gitlens.showWelcomeOnInstall": false, | ||
"gitlens.showWhatsNewAfterUpgrades": false | ||
}, | ||
|
||
"gcovViewer.gcovBinary": "/opt/conda/envs/prd/bin/x86_64-conda-linux-gnu-gcov", | ||
"gcovViewer.buildDirectories": ["${workspaceFolder}/cpp/build"], | ||
|
||
"search.useIgnoreFiles": false, | ||
"search.exclude": { | ||
"**/cpp/build": true | ||
} | ||
}, | ||
|
||
// Add the IDs of extensions you want installed when the container is created. | ||
"extensions": [ | ||
"cschlosser.doxdocgen", | ||
"eamodio.gitlens", | ||
"esbenp.prettier-vscode", | ||
"JacquesLucke.gcov-viewer", | ||
"matepek.vscode-catch2-test-adapter", | ||
"mhutchie.git-graph", | ||
"ms-python.black-formatter", | ||
"ms-python.python", | ||
"ms-vscode.cmake-tools", | ||
"ms-vscode.cpptools", | ||
"timonwong.shellcheck", | ||
"twxs.cmake" | ||
] | ||
} | ||
}, | ||
|
||
// Use 'forwardPorts' to make a list of ports inside the container available locally. | ||
// "forwardPorts": [], | ||
|
||
// Use 'postCreateCommand' to run commands after the container is created. | ||
// "postCreateCommand": "go version", | ||
|
||
// Comment out to connect as root instead. More info: https://aka.ms/vscode-remote/containers/non-root. | ||
"remoteUser": "vscode" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# Shell scripts should have LF | ||
*.bashrc text eol=lf | ||
*.sh text eol=lf | ||
*.csh text eol=lf |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
## Changes in this pull request | ||
|
||
|
||
## Testing performed | ||
|
||
|
||
## Related issues | ||
<!-- 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 --> | ||
|
||
|
||
## Checklist before requesting a review | ||
|
||
- [ ] I have performed a self-review of my code | ||
- [ ] I have added docstrings/doxygen in line with the guidance in the developer guide | ||
- [ ] The code builds and runs on my machine | ||
|
||
## Contribution Notes | ||
|
||
Please read and adhere to the [contribution guidelines](https://github.com/ETSInitiative/PRDdefinition/blob/master/CONTRIBUTING.md). | ||
|
||
Please tick the following: | ||
|
||
- [ ] 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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
name: Configure Environment | ||
description: Configures the conda environment | ||
runs: | ||
using: composite | ||
steps: | ||
|
||
- name: Initial setup | ||
shell: bash | ||
run: | | ||
# filter conda environment file | ||
cat environment.yml | grep -v "#.*\<\local\>" > ci-environment.yml | ||
- uses: conda-incubator/setup-miniconda@v2 | ||
with: | ||
activate-environment: yardl | ||
environment-file: ci-environment.yml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
name: CI | ||
|
||
on: | ||
push: | ||
branches: [main] | ||
paths-ignore: | ||
- '**/*.md' | ||
pull_request: | ||
branches: [main] | ||
|
||
defaults: | ||
run: | ||
# See https://github.com/marketplace/actions/setup-miniconda#important | ||
shell: bash -el {0} | ||
|
||
jobs: | ||
validate: | ||
strategy: | ||
matrix: | ||
cppVersion: [17] | ||
|
||
name: Run tests | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v3 | ||
with: | ||
submodules: recursive | ||
|
||
- name: Configure environment | ||
uses: ./.github/actions/configure-environment | ||
|
||
- name: Install yardl | ||
run: | | ||
YARDL_DIR=${{github.workspace}}/yardl | ||
mkdir ${YARDL_DIR} | ||
cd ${YARDL_DIR} | ||
echo "${{github.workspace}}/yardl" >> $GITHUB_PATH | ||
YARDL_VERSION=0.3.2 | ||
wget --quiet "https://github.com/microsoft/yardl/releases/download/v${YARDL_VERSION}/yardl_${YARDL_VERSION}_linux_x86_64.tar.gz" | ||
tar -xzf "yardl_${YARDL_VERSION}_linux_x86_64.tar.gz" | ||
rm "yardl_${YARDL_VERSION}_linux_x86_64.tar.gz" | ||
- name: Build model | ||
run: | | ||
cd PETSIRD/model | ||
yardl generate | ||
- name: Python | ||
run: | | ||
cd python | ||
python start.py | ||
- name: Cpp | ||
run: | | ||
cd cpp && mkdir -p build && cd build | ||
cmake -G Ninja -S .. -DHDF5_ROOT="$CONDA_PREFIX" | ||
ninja |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
**/build/ | ||
**/__pycache__/ | ||
|
||
# Common editor backups | ||
~$* | ||
*~ | ||
*.bak |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
[submodule "PETSIRD"] | ||
path = PETSIRD | ||
url = https://github.com/ETSInitiative/PRDdefinition |
Oops, something went wrong.