Skip to content

Commit

Permalink
ci: Update cxx xmake example
Browse files Browse the repository at this point in the history
  • Loading branch information
pplmx committed Jan 8, 2025
0 parents commit 98660b8
Show file tree
Hide file tree
Showing 37 changed files with 14,652 additions and 0 deletions.
54 changes: 54 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
---
# Base Style
BasedOnStyle: Google # Based on Google style guidelines
Language: Cpp # Explicitly specify C++
Standard: c++17 # Use C++17 standard

# Code Layout
ColumnLimit: 180 # Recommended maximum line length
IndentWidth: 4 # 4-space indentation
InsertNewlineAtEOF: true # Ensure newline at end of file
UseTab: Never # Exclusively use spaces for indentation

# Code Structure
AllowShortIfStatementsOnASingleLine: Never # Prevent single-line if statements
AllowShortFunctionsOnASingleLine: Inline # Allow short functions on single line
AllowShortLoopsOnASingleLine: false # Prevent single-line loops
BinPackArguments: false
BinPackParameters: OnePerLine
BreakBeforeBraces: Attach # Attach braces to code block
BreakBeforeBinaryOperators: NonAssignment # Break before non-assignment operators
BreakBeforeTernaryOperators: true # Break before ternary operators
BreakConstructorInitializers: BeforeColon # Break constructor initializers before colon
BreakInheritanceList: BeforeColon # Break inheritance list before colon
InsertBraces: true # Automatically insert braces for clarity
PackConstructorInitializers: Never

# Language Features
AccessModifierOffset: -4 # Offset for access modifiers
CompactNamespaces: false # Keep namespaces readable
FixNamespaceComments: true # Properly format namespace comments
IndentCaseLabels: true # Indent switch case labels
NamespaceIndentation: All # Indent inside namespaces

# Pointers and References
DerivePointerAlignment: false # Manually set pointer alignment
PointerAlignment: Left # Left-align pointers and references

# Spacing and Alignment
SpaceAroundPointerQualifiers: Default # Consistent space around pointer qualifiers
SpaceBeforeParens: ControlStatements # Space before parentheses in control statements
SpaceBeforeCtorInitializerColon: true # Space before constructor initializer colon
SpaceBeforeInheritanceColon: true # Space before inheritance colon
SpaceBeforeRangeBasedForLoopColon: true # Space before range-based for loop colon
SpacesBeforeTrailingComments: 2 # Two spaces before trailing comments
SpacesInContainerLiterals: false # No extra spaces in container literals
SpacesInParensOptions:
InEmptyParentheses: false # No spaces in empty parentheses
SpacesInSquareBrackets: false # No extra spaces in square brackets

# Comments and Includes
AlignTrailingComments:
Kind: Always # Strictly align trailing comments
ReflowComments: true # Reflow comments to fit column limit
SortIncludes: CaseSensitive # Sort includes in case-sensitive manner
79 changes: 79 additions & 0 deletions .clang-tidy
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
Checks: >
-*, # Disable all checks by default
bugprone-*,
readability-*,
performance-*,
modernize-*,
cppcoreguidelines-*,
clang-analyzer-*,
portability-*,
security-*,
misc-*,
google-*,
CheckOptions:
# Naming conventions
- key: readability-identifier-naming.ClassCase
value: CamelCase
- key: readability-identifier-naming.StructCase
value: CamelCase
- key: readability-identifier-naming.EnumCase
value: CamelCase
- key: readability-identifier-naming.MethodCase
value: lower_case
- key: readability-identifier-naming.FunctionCase
value: lower_case
- key: readability-identifier-naming.VariableCase
value: lower_case
- key: readability-identifier-naming.ParameterCase
value: lower_case
- key: readability-identifier-naming.MemberCase
value: m_camelBack
- key: readability-identifier-naming.StaticMemberCase
value: s_camelBack
- key: readability-identifier-naming.GlobalVariableCase
value: g_lower_case
- key: readability-identifier-naming.NamespaceCase
value: lower_case

# Function complexity
- key: readability-function-cognitive-complexity.Threshold
value: 35

# Bug detection
- key: bugprone-argument-comment
value: 1
- key: bugprone-branch-clone
value: 1
- key: bugprone-use-after-move
value: 1

# Modern practices
- key: modernize-use-nullptr.NullMacros
value: 'NULL'
- key: modernize-use-auto
value: 1
- key: modernize-avoid-bind
value: 1

# Core guidelines
- key: cppcoreguidelines-no-malloc
value: 1
- key: cppcoreguidelines-pro-type-cstyle-cast
value: 1
- key: cppcoreguidelines-special-member-functions
value: 1

# Security
- key: security-undefined-bool-conversion
value: 1
- key: security-implicit-int-float-conversion
value: 1

# Performance
- key: performance-unnecessary-copy-initialization
value: 1
- key: performance-for-range-copy
value: 1
- key: performance-move-const-arg
value: 1
9 changes: 9 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# all start with .(dot), including directories and files
.*
CHANGELOG.md
CODE_OF_CONDUCT.md
CONTRIBUTING.md
compose.yml
LICENSE*
Makefile
README.md
14 changes: 14 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
root = true

[*]
charset = utf-8
end_of_line = lf
indent_size = 4
indent_style = space
insert_final_newline = true
max_line_length = 120
tab_width = 4
trim_trailing_whitespace = true

[Makefile]
indent_style = tab
44 changes: 44 additions & 0 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
---
name: Bug report
about: Create a report to help us improve
title: 'bug: '
labels: bug
assignees: ''

---

## Bug description

<!-- A clear and concise description of what the bug is. -->

- Would you like to work on a fix? [y/n]

## To Reproduce

Steps to reproduce the behavior:

1. ...
2. ...
3. ...
4. ...

<!-- Make sure you are able to reproduce the bug in the main branch, too. -->

## Expected behavior

<!-- A clear and concise description of what you expected to happen. -->

## Screenshots

<!-- If applicable, add screenshots to help explain your problem. -->

## Environment

<!-- Please fill the following information. -->

- OS: [e.g. Ubuntu 20.04]
- example-cxx-xmake version: [e.g. 0.1.0]

## Additional context

<!-- Add any other context about the problem here. -->
1 change: 1 addition & 0 deletions .github/ISSUE_TEMPLATE/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
blank_issues_enabled: true
28 changes: 28 additions & 0 deletions .github/ISSUE_TEMPLATE/feature_request.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
---
name: Feature request
about: Suggest an idea for this project
title: 'Feature Request: '
labels: enhancement
assignees: ''

---

## Motivations

<!--
If your feature request is related to a problem, please describe it.
-->

- Would you like to implement this feature? [y/n]

## Solution

<!-- Describe the solution you'd like. -->

## Alternatives

<!-- Describe any alternative solutions or features you've considered. -->

## Additional context

<!-- Add any other context or screenshots about the feature request here. -->
9 changes: 9 additions & 0 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<!-- Please explain the changes you made -->

<!--
Please make sure:
- you have read the contributing guidelines:
https://github.com/x-pt/example-cxx-xmake/blob/main/docs/CONTRIBUTING.md
- you have updated the changelog (if needed):
https://github.com/x-pt/example-cxx-xmake/blob/main/CHANGELOG.md
-->
63 changes: 63 additions & 0 deletions .github/configs/labeler.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
version: 1

labels:
# Type: Build-related changes
- label: "@type/build"
title: '^build(?:\(.+\))?\!?:'

# Type: CI-related changes
- label: "@type/ci"
title: '^ci(?:\(.+\))?\!?:'
files:
- '\.github/.+'

# Type: Documentation changes
- label: "@type/docs"
title: '^docs(?:\(.+\))?\!?:'
files:
- "docs/.+"
- "**/*.md"

# Type: New feature
- label: "@type/feature"
title: '^feat(?:\(.+\))?\!?:'

# Type: Bug fix
- label: "@type/fix"
title: '^fix(?:\(.+\))?\!?:'

# Type: Improvements such as style changes, refactoring, or performance improvements
- label: "@type/improve"
title: '^(style|refactor|perf)(?:\(.+\))?\!?:'

# Type: Dependency changes
- label: "@type/dependency"
title: '^(chore|build)(?:\(deps\))?\!?:'

# Type: Test-related changes
- label: "@type/test"
title: '^test(?:\(.+\))?\!?:'
files:
- "tests/.+"
- "spec/.+"

# Type: Security-related changes
- label: "@type/security"
title: '^security(?:\(.+\))?\!?:'
files:
- "**/security/.+"

# Issue Type Only: Feature Request
- label: "Feature Request"
type: issue
title: "^Feature Request:"

# Issue Type Only: Documentation
- label: "Documentation"
type: issue
title: "^.*(\b[Dd]ocumentation|doc(s)?\b).*"

# Issue Type Only: Bug Report
- label: "Bug Report"
type: issue
title: "^.*(\b[Bb]ug|b(u)?g(s)?\b).*"
8 changes: 8 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
version: 2
updates:
- package-ecosystem: "github-actions"
directory: "/"
# Check for updates every Monday
schedule:
interval: "weekly"
open-pull-requests-limit: 10
6 changes: 6 additions & 0 deletions .github/renovate.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
"extends": [
"config:base"
]
}
14 changes: 14 additions & 0 deletions .github/workflows/cd.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
name: CD # Continuous Deployment or Delivery

on:
push:
# e.g. 1.0.0, v2.0.0, v0.1.0, v0.2.0-alpha, v0.3.0+build-71edf32
tags:
- '[v]?[0-9]+\.[0-9]+\.[0-9]+.*'

jobs:
dd:
name: Deploy or Delivery
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
31 changes: 31 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: CI # Continuous Integration

on:
push:
branches:
- main
pull_request:

jobs:
build-and-test:
strategy:
matrix:
os:
- ubuntu-latest
- windows-latest
name: ${{ matrix.os }}
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4

- uses: xmake-io/github-action-setup-xmake@v1
with:
xmake-version: latest

- name: Build
run: make build

- name: Test
run: |
make run
make test
Loading

0 comments on commit 98660b8

Please sign in to comment.