Skip to content

Commit 89890eb

Browse files
committed
Changed according ChatGPT recommendations
1 parent 050018a commit 89890eb

4 files changed

Lines changed: 263 additions & 54 deletions

File tree

.github/labeler.yml

Lines changed: 158 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,160 @@
1-
#FIXME: used to test. Can be reworked to automatic labelling (fixes, features ,c , go , ...)
2-
# Add 'AnyChange' label to any changes within the entire repository
1+
2+
# Automatically adds labels to issues or pull requests based on content or file changes.
3+
4+
# .github/labeler.yml
5+
#
6+
# This file configures the GitHub "labeler" action.
7+
# It automatically adds labels to pull requests based on:
8+
# - which files were changed (changed-files)
9+
# - the PR title or description (title, body)
10+
#
11+
# IMPORTANT:
12+
# - All label names used below (e.g. "go", "c", "docs") must exist
13+
# as labels in the GitHub repository settings.
14+
# - This file affects pull requests only (not individual commits).
15+
16+
# --------------------------------------------------------------------
17+
# Label: AnyChange
18+
# --------------------------------------------------------------------
19+
# Purpose:
20+
# - Add a very generic label to any pull request that touches any file.
21+
# - This can be useful if you want to trigger other automations or
22+
# simply mark “this PR changes something”.
23+
#
24+
# When is it applied?
25+
# - Whenever *any* file in the repository is changed.
326
AnyChange:
4-
- changed-files:
5-
- any-glob-to-any-file: '**'
27+
- changed-files:
28+
# Match any file in the repository.
29+
- any-glob-to-any-file: '**'
30+
31+
32+
# --------------------------------------------------------------------
33+
# Label: go
34+
# --------------------------------------------------------------------
35+
# Purpose:
36+
# - Mark pull requests that modify Go source files.
37+
#
38+
# When is it applied?
39+
# - If any *.go file is changed anywhere in the repository.
40+
go:
41+
- changed-files:
42+
- any-glob-to-any-file: '**/*.go'
43+
44+
45+
# --------------------------------------------------------------------
46+
# Label: c
47+
# --------------------------------------------------------------------
48+
# Purpose:
49+
# - Mark pull requests that touch C source or header files.
50+
#
51+
# When is it applied?
52+
# - If any *.c or *.h file is changed in typical C locations.
53+
# - You can adjust the paths below to match your project layout.
54+
c:
55+
- changed-files:
56+
# C sources and headers in src/
57+
- any-glob-to-any-file: 'src/**/*.c'
58+
- any-glob-to-any-file: 'src/**/*.h'
59+
60+
# C sources and headers in examples/
61+
- any-glob-to-any-file: 'examples/**/*.c'
62+
- any-glob-to-any-file: 'examples/**/*.h'
63+
64+
# C sources and headers in the _test directory
65+
- any-glob-to-any-file: '_test/**/*.c'
66+
- any-glob-to-any-file: '_test/**/*.h'
67+
68+
69+
# --------------------------------------------------------------------
70+
# Label: docs
71+
# --------------------------------------------------------------------
72+
# Purpose:
73+
# - Mark pull requests that primarily modify documentation.
74+
#
75+
# When is it applied?
76+
# - If files in docs/ are changed, or *.md files anywhere.
77+
docs:
78+
- changed-files:
79+
# Any file inside the docs/ folder
80+
- any-glob-to-any-file: 'docs/**'
81+
82+
# Any Markdown file (README, guides, etc.)
83+
- any-glob-to-any-file: '**/*.md'
84+
85+
86+
# --------------------------------------------------------------------
87+
# Label: tests
88+
# --------------------------------------------------------------------
89+
# Purpose:
90+
# - Mark pull requests that add or modify tests.
91+
#
92+
# When is it applied?
93+
# - If Go test files or other test-related files are changed.
94+
tests:
95+
- changed-files:
96+
# Go test files
97+
- any-glob-to-any-file: '**/*_test.go'
98+
99+
# Any files inside a _test folder (C tests, configs, etc.)
100+
- any-glob-to-any-file: '_test/**'
101+
102+
103+
# --------------------------------------------------------------------
104+
# Label: ci
105+
# --------------------------------------------------------------------
106+
# Purpose:
107+
# - Mark pull requests that change Continuous Integration (CI)
108+
# or GitHub-related configuration.
109+
#
110+
# When is it applied?
111+
# - If files under .github/ are modified (workflows, templates, etc.).
112+
ci:
113+
- changed-files:
114+
- any-glob-to-any-file: '.github/**'
115+
116+
117+
# --------------------------------------------------------------------
118+
# Label: fix
119+
# --------------------------------------------------------------------
120+
# Purpose:
121+
# - Mark pull requests that appear to fix a bug.
122+
#
123+
# When is it applied?
124+
# - If the PR title or description contains the word "fix".
125+
# (Case-sensitive by default; if needed, you can switch to regex.)
126+
#
127+
# Note:
128+
# - These matchers are very simple on purpose.
129+
# - They work well with conventional commit messages such as:
130+
# "fix: handle empty input"
131+
fix:
132+
# PR title contains "fix"
133+
- title: 'fix'
134+
# PR body (description) contains "fix"
135+
- body: 'fix'
136+
137+
138+
# --------------------------------------------------------------------
139+
# Label: feature
140+
# --------------------------------------------------------------------
141+
# Purpose:
142+
# - Mark pull requests that introduce new features.
143+
#
144+
# When is it applied?
145+
# - If the PR title or description contains "feat" or "feature".
146+
#
147+
# Note:
148+
# - This works nicely with conventional commit style messages like:
149+
# "feat: add new logging options"
150+
# "feature: support additional hardware"
151+
feature:
152+
# PR title contains "feat"
153+
- title: 'feat'
154+
# PR body contains "feat"
155+
- body: 'feat'
6156

157+
# PR title contains "feature"
158+
- title: 'feature'
159+
# PR body contains "feature"
160+
- body: 'feature'

.github/workflows/codeql.yml

Lines changed: 40 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -1,66 +1,56 @@
1-
# For most projects, this workflow file will not need changing; you simply need
2-
# to commit it to your repository.
3-
#
4-
# You may wish to alter this file to override the set of languages analyzed,
5-
# or to provide custom queries or build logic.
6-
#
7-
# ******** NOTE ********
8-
# We have attempted to detect the languages in your repository. Please check
9-
# the `language` matrix defined below to confirm you have the correct set of
10-
# supported CodeQL languages.
11-
#
121
name: "CodeQL"
132

143
on:
154
push:
16-
branches: [ $default-branch, $protected-branches ]
5+
# Run CodeQL on pushes to main (adapt if your default branch is different)
6+
branches: [ "main" ]
177
pull_request:
18-
# The branches below must be a subset of the branches above
19-
branches: [ $default-branch ]
8+
# Analyze pull requests targeting main
9+
branches: [ "main" ]
10+
# Allow manual runs from the GitHub Actions UI
2011
workflow_dispatch:
2112

2213
jobs:
2314
analyze:
24-
name: Analyze
15+
name: Analyze (CodeQL)
2516
runs-on: ubuntu-latest
2617

18+
# We explicitly tell CodeQL which languages to analyze.
19+
# For Trice, we have:
20+
# - Go code -> language: "go"
21+
# - C sources/headers -> language: "cpp" (covers C/C++)
2722
strategy:
2823
fail-fast: false
2924
matrix:
30-
language: [ $detected-codeql-languages ]
31-
# CodeQL supports [ $supported-codeql-languages ]
32-
# Learn more:
33-
# https://docs.github.com/en/free-pro-team@latest/github/finding-security-vulnerabilities-and-errors-in-your-code/configuring-code-scanning#changing-the-languages-that-are-analyzed
25+
language: [ "go", "cpp" ]
3426

3527
steps:
36-
- name: Checkout repository
37-
uses: actions/checkout@v2
38-
39-
# Initializes the CodeQL tools for scanning.
40-
- name: Initialize CodeQL
41-
uses: github/codeql-action/init@v1
42-
with:
43-
languages: ${{ matrix.language }}
44-
# If you wish to specify custom queries, you can do so here or in a config file.
45-
# By default, queries listed here will override any specified in a config file.
46-
# Prefix the list here with "+" to use these queries and those in the config file.
47-
# queries: ./path/to/local/query, your-org/your-repo/queries@main
48-
49-
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
50-
# If this step fails, then you should remove it and run the build manually (see below)
51-
- name: Autobuild
52-
uses: github/codeql-action/autobuild@v1
53-
54-
# ℹ️ Command-line programs to run using the OS shell.
55-
# 📚 https://git.io/JvXDl
56-
57-
# ✏️ If the Autobuild fails above, remove it and uncomment the following three lines
58-
# and modify them (or add more) to build your code if your project
59-
# uses a compiled language
60-
61-
#- run: |
62-
# make bootstrap
63-
# make release
64-
65-
- name: Perform CodeQL Analysis
66-
uses: github/codeql-action/analyze@v1
28+
# Checkout the repository so CodeQL can see the source code.
29+
- name: Checkout repository
30+
uses: actions/checkout@v4
31+
32+
# Initialize the CodeQL tools for the selected language.
33+
- name: Initialize CodeQL
34+
uses: github/codeql-action/init@v3
35+
with:
36+
# Use the current matrix language (go or cpp).
37+
languages: ${{ matrix.language }}
38+
# Optional: specify custom queries or query packs here if needed.
39+
# queries: security-and-quality
40+
41+
# Autobuild step:
42+
# - For "go", CodeQL does not strictly need a traditional build; it can
43+
# analyze the source directly.
44+
# - For "cpp", CodeQL tries to automatically build the project to
45+
# understand the compiled artifacts (C/C++ code).
46+
#
47+
# If autobuild fails for your C parts, you may need to:
48+
# - remove this step, and
49+
# - add a manual build step (e.g. make, cmake, etc.).
50+
- name: Autobuild
51+
uses: github/codeql-action/autobuild@v3
52+
53+
# Perform the actual CodeQL analysis and upload the results to GitHub.
54+
# Results show up under the "Security" -> "Code scanning alerts" tab.
55+
- name: Perform CodeQL Analysis
56+
uses: github/codeql-action/analyze@v3

.github/workflows/shellcheck.yml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
2+
# This workflow will scan all *.sh files and report problems in the PR checks.
3+
# Runs on every push to main and PR targeting main.
4+
# Can be run manually via Actions → “ShellCheck (Bash Linting)” → Run workflow.
5+
6+
name: "ShellCheck (Bash Linting)"
7+
8+
on:
9+
push:
10+
branches: [ "main" ]
11+
pull_request:
12+
branches: [ "main" ]
13+
workflow_dispatch:
14+
15+
jobs:
16+
shellcheck:
17+
name: ShellCheck (Bash)
18+
runs-on: ubuntu-latest
19+
20+
steps:
21+
- name: Checkout repository
22+
uses: actions/checkout@v4
23+
24+
# Install and run ShellCheck using a maintained GitHub Action.
25+
- name: Run ShellCheck
26+
uses: ludeeus/action-shellcheck@v2
27+
with:
28+
# Optional: you can configure which paths to scan. By default,
29+
# the action will look for *.sh files in the repository.
30+
severity: warning

.github/workflows/shfmt.yml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
2+
# This workflow runs on pull requests (and manually),
3+
# fails the check if any shell script isn’t formatted according to shfmt style.
4+
#
5+
# Developers can fix formatting locally by running:
6+
#
7+
# shfmt -w .
8+
9+
name: "shfmt (Shell Formatting)"
10+
11+
on:
12+
pull_request:
13+
branches: [ "main" ]
14+
workflow_dispatch:
15+
16+
jobs:
17+
shfmt:
18+
name: Check shell script formatting (shfmt)
19+
runs-on: ubuntu-latest
20+
21+
steps:
22+
- name: Checkout repository
23+
uses: actions/checkout@v4
24+
25+
- name: Install shfmt
26+
run: |
27+
sudo apt-get update
28+
sudo apt-get install -y shfmt
29+
30+
- name: Run shfmt in diff mode
31+
run: |
32+
# Check formatting of all shell scripts.
33+
# -d prints a diff if formatting does not match.
34+
# This does NOT change files, it only fails the job if formatting is off.
35+
shfmt -d .

0 commit comments

Comments
 (0)