Skip to content

Commit

Permalink
Merge pull request #13 from leaver2000/development
Browse files Browse the repository at this point in the history
Development
  • Loading branch information
leaver2000 authored Jun 7, 2024
2 parents e387da9 + 86d1987 commit 6581492
Show file tree
Hide file tree
Showing 45 changed files with 66,755 additions and 1,360 deletions.
20 changes: 10 additions & 10 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# Use clang-format -dump-config -style=google to get the base configuration
---
Language: Cpp
AccessModifierOffset: -2 # MARK: Adjustable
AccessModifierOffset: -2 # MARK: Adjustable
AlignAfterOpenBracket: BlockIndent
AlignArrayOfStructures: None # MARK: Adjustable
AlignArrayOfStructures: None # MARK: Adjustable
AlignConsecutiveAssignments:
Enabled: false
AcrossEmptyLines: false
Expand Down Expand Up @@ -31,7 +31,7 @@ AlignConsecutiveMacros:
AlignEscapedNewlines: Left
AlignOperands: DontAlign
AlignTrailingComments:
Kind: Never # MARK: Adjustable
Kind: Never # MARK: Adjustable
OverEmptyLines: 0
AllowAllArgumentsOnNextLine: true
AllowAllParametersOfDeclarationOnNextLine: true
Expand Down Expand Up @@ -78,11 +78,11 @@ BreakBeforeTernaryOperators: true
BreakConstructorInitializers: BeforeColon
BreakInheritanceList: BeforeColon
BreakStringLiterals: false
ColumnLimit: 99 # MARK: Adjustable
ColumnLimit: 99 # MARK: Adjustable
CommentPragmas: "^ IWYU pragma:"
CompactNamespaces: false
ConstructorInitializerIndentWidth: 4 # MARK: Adjustable
ContinuationIndentWidth: 2 # MARK: Adjustable
ConstructorInitializerIndentWidth: 4 # MARK: Adjustable
ContinuationIndentWidth: 2 # MARK: Adjustable
Cpp11BracedListStyle: true
DerivePointerAlignment: false
DisableFormat: false
Expand Down Expand Up @@ -122,7 +122,7 @@ IndentExternBlock: AfterExternBlock
IndentGotoLabels: true
IndentPPDirectives: None
IndentRequiresClause: true
IndentWidth: 2 # MARK: Adjustable
IndentWidth: 4 # MARK: Adjustable
IndentWrappedFunctionNames: false
InsertBraces: false
InsertNewlineAtEOF: false
Expand Down Expand Up @@ -191,14 +191,14 @@ RawStringFormats:
CanonicalDelimiter: pb
BasedOnStyle: google
ReferenceAlignment: Pointer
ReflowComments: false # MARK: Adjustable
ReflowComments: false # MARK: Adjustable
RemoveBracesLLVM: false
RemoveSemicolon: false
RequiresClausePosition: OwnLine
RequiresExpressionIndentation: OuterScope
SeparateDefinitionBlocks: Leave
ShortNamespaceLines: 1
SortIncludes: Never # MARK: Adjustable
SortIncludes: Never # MARK: Adjustable
SortJavaStaticImport: Before
SortUsingDeclarations: LexicographicNumeric
SpaceAfterCStyleCast: false
Expand Down Expand Up @@ -248,4 +248,4 @@ WhitespaceSensitiveMacros:
- CF_SWIFT_NAME
- NS_SWIFT_NAME
- PP_STRINGIZE
- STRINGIZE
- STRINGIZE
22 changes: 22 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Ignore everything
*

# Allow files and directories
!pyproject.toml
!setup.py
!/src/nzthermo/
!/src/include/
!/src/lib/
!/tests/
!/.git/
# !/src

# Ignore unnecessary files inside allowed directories
# This should go after the allowed directories
# **/*~
**/*.pyc
**/_version.py
**/__pycache__/
**/*.so
# **/.DS_Store
# **/Thumbs.db
42 changes: 20 additions & 22 deletions .github/workflows/python-app.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,34 +5,32 @@ name: Python application

on:
push:
branches: [ "master" ]
branches: ["master"]
pull_request:
branches: [ "master" ]
branches: ["master"]

permissions:
contents: read

jobs:
build:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- name: Set up Python 3.11
uses: actions/setup-python@v3
with:
python-version: "3.11"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.dev.txt
- name: Lint with flake8
run: |
# stop the build if there are Python syntax errors or undefined names
ruff check . --exit-zero
- name: Test with pytest
run: |
python setup.py build_ext --inplace --coverage
coverage run -m pytest
coverage report -m
- uses: actions/checkout@v4
- name: Set up Python 3.11
uses: actions/setup-python@v3
with:
python-version: "3.11"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.dev.txt
- name: Lint with flake8
run: |
# stop the build if there are Python syntax errors or undefined names
ruff check . --exit-zero
- name: Test with pytest
run: |
python setup.py build_ext --inplace --coverage
coverage run -m pytest
coverage report -m
14 changes: 8 additions & 6 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,15 @@
.venv/
build/
**/__pycache__/
**/*.pyc
**/*.so
src/nzthermo/*.c
.egg/
*.pyc
*.so
*.egg-info/
*.dist-info/
src/**/_ufunc.cpp
src/**/_core.cpp
src/**/_version.py
.egg/
.vscode/
.coverage
.reports/
.trash/
src/nzthermo/_version.py
.trash/
64 changes: 64 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
cmake_minimum_required(VERSION 3.14)
project(libthermo)

# # Set the compiler options
# # The --coverage compiler flag is an alternative to -fprofile-arcs -ftest-coverage for recent version of gcc.
# # In versions 3.13 and later of cmake, the target_link_libraries command can be
# # removed and add_link_options("--coverage") added after the add_compile_options command.
# # GoogleTest requires at least C++14
# set(CMAKE_CXX_STANDARD 20)
# set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_REQUIRED_FLAGS -fconcepts)
# set(CMAKE_CXX_FLAGS "-g -O0 -Wall --coverage")
# set(CMAKE_C_FLAGS --coverage)

# include(FetchContent)
# FetchContent_Declare(
# googletest
# URL https://github.com/google/googletest/archive/03597a01ee50ed33e9dfd640b249b4be3799d395.zip
# )

# # For Windows: Prevent overriding the parent project's compiler/linker settings
# set(gtest_force_shared_crt ON CACHE BOOL "" FORCE)
# FetchContent_MakeAvailable(googletest)
add_compile_options(
"$<$<COMPILE_LANGUAGE:CXX>:-Ofast;-DNDEBUG;-fconcepts;-std=c++2a;-march=native;-fpic;-ftree-vectorize>"
)
# # -------------------------------------------------------------------------------------------------
# # GTest
# # -------------------------------------------------------------------------------------------------
# enable_testing()
include_directories(src/include/)
add_executable(
slac_test
# src/lib/_C.cpp
src/lib/functional.cpp
# src/include/_C.hpp
# src/include/common.hpp
src/include/functional.hpp
)

# # link everything together
# target_link_libraries(slac_test GTest::gtest_main)

# if(CMAKE_BUILD_TYPE STREQUAL "DEBUG")
# add_test(
# NAME slac_test
# COMMAND slac_test --gtest_output=xml:gtest-output.xml
# )
# add_test(
# NAME Coverage
# COMMAND gcovr --exclude-directories build/CMakeFiles/slac_test.dir/src/lib/tests --cobertura coverage.cobertura.xml
# WORKING_DIRECTORY ..
# )
# else()
# add_test(
# NAME slac_test
# COMMAND slac_test --gtest_output=xml:/app/gtest-output.xml
# )
# add_test(
# NAME Coverage
# COMMAND gcovr --exclude-directories build/CMakeFiles/slac_test.dir/src/lib/tests --cobertura coverage.cobertura.xml
# WORKING_DIRECTORY ..
# )
# endif()
51 changes: 51 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# syntax=docker/dockerfile:1

# .................................................................................................
# FROM python:3.10.14 AS py310
# USER root
# WORKDIR /

# ENV PATH="/opt/venv/bin:$PATH"
# RUN python3 -m venv /opt/venv
# COPY tests/requirements.txt .
# RUN pip install --no-cache-dir -r requirements.txt

# COPY . .
# ENV NZTHERMO_BUILD_COVERAGE 1
# RUN pip install --no-cache-dir --no-deps --upgrade --target src/ .

# USER 1001

# .................................................................................................
FROM python:3.11.9 AS py311
USER root
WORKDIR /

ENV PATH="/opt/venv/bin:$PATH"
RUN python3 -m venv /opt/venv
COPY tests/requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt

COPY . .
ENV NZTHERMO_BUILD_COVERAGE 1
RUN pip install --no-cache-dir --no-deps --upgrade --target src/ . \
&& pytest tests

USER 1001

# .................................................................................................
FROM python:3.12.3 AS py312
USER root
WORKDIR /

ENV PATH="/opt/venv/bin:$PATH"
RUN python3 -m venv /opt/venv
COPY tests/requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt

COPY . .
ENV NZTHERMO_BUILD_COVERAGE 1
RUN pip install --no-cache-dir --no-deps --upgrade --target src/ . \
&& pytest tests

USER 1001
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@

clean:
rm -rf dist/ build/ .pytest_cache/ .coverage *.egg-info/ src/*.egg-info/ src/nzthermo/_version.py src/nzthermo/*.so src/nzthermo/__pycache__/
Loading

0 comments on commit 6581492

Please sign in to comment.