Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
Maleclypse committed Apr 6, 2022
2 parents 10e1192 + 610fb34 commit 74e6a2a
Show file tree
Hide file tree
Showing 965 changed files with 333,650 additions and 239,164 deletions.
1 change: 1 addition & 0 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
/data/mods/stats_through_kills/ @KorGgenT
/data/mods/Dark-Skies-Above/ @ephemeralstoryteller
/data/mods/No_Hope/ @Night-Pryanik
/data/mods/innawood/ @Light-Wave

magic*.cpp @KorGgenT
magic*.h @KorGgenT
Expand Down
51 changes: 45 additions & 6 deletions .github/labeler.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,26 +11,59 @@
"<Documentation>":
- "**/*.md"
- doc/**/*
- doxygen_doc/**/*

"Code: Tooling":
- tools/**/*
- .github/**/*
- utilities/**/*

"Code: Tests":
- tests/**/*

"Code: Build":
- build-data/**/*
- build-scripts/**/*
- "**/Makefile"
- "**/CMakeLists.txt"
- "**/*.cmake"

"Crafting / Construction / Recipes":
- "**/recipes/**/*"
- data/json/construction.json
- data/json/construction_category.json
- data/json/construction_group.json
- data/json/deconstruction.json

"NPC / Factions":
- data/json/npcs/**/*
- "**/npcs/**/*"

"Appliance/Power Grid":
- "**/appliance**"

"Monsters":
- "**/monsters/**/*"

"Spawn":
- "**/itemgroups/**/*"
- "**/monstergroups/**/*"

"Bionics":
- "data/json/bionics.json"
- "**/bionics.*"

"Map / Mapgen":
- "**/mapgen/**/*"
- "**/mapgen_palettes/**/*"
- "**/overmap/**/*"

"Player Faction Base / Camp":
- "src/basecamp.(cpp|h)"
- "src/basecamp.*"
- "src/faction_camp.*"
- data/json/mapgen/basecamps/**/*

"Items: Ammo / Guns":
- data/json/items/gun/**/*
- data/json/items/ammo/**/*
- "**/gun/**/*"
- "**/ammo/**/*"

"SDL: Tiles / Sound":
- gfx/**/*
Expand All @@ -49,7 +82,7 @@
"Mods: Dark Skies":
- data/mods/Dark-Skies-Above/**/*

"Mods: Dinoclysm":
"Mods: DinoMod":
- data/mods/DinoMod/**/*

"Mods: Generic Guns":
Expand All @@ -61,5 +94,11 @@
"Mods: Magiclysm":
- data/mods/Magiclysm/**/*

"Mods: Innawood 🌲":
- data/mods/innawood/**/*

"Mods: No Hope":
- data/mods/No_Hope/**/*

"Mods":
- data/mods/**/*
4 changes: 3 additions & 1 deletion .github/pull_request_template.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ NOTE: Please grant permission for repository maintainers to edit your PR. It is
#### Summary
Category "Brief description"
<!-- This section should consist of exactly one line, edit the one above.
Category must be one of these: Features, Content, Interface, Mods, Balance, Bugfixes, Performance, Infrastructure, Build, I18N. Or replace the whole line with just the word None for no changelog entry.
1. Replace the word "Category" with one of these words: Features, Content, Interface, Mods, Balance, Bugfixes, Performance, Infrastructure, Build, I18N.
2. Replace the text inside the quotes with a brief description of your changes.
Or if you don't want a changelog entry, replace the whole line with just the word "None" (with no quotes).
For more on the meaning of each category, see:
https://github.com/CleverRaven/Cataclysm-DDA/blob/master/doc/CHANGELOG_GUIDELINES.md
If approved and merged, your summary will be added to the project changelog:
Expand Down
38 changes: 38 additions & 0 deletions .github/summary-labels.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
version: v1

labels:
- label: "<Enhancement / Feature>"
matcher:
body: "(\\s|^)#### Summary\\s*Features +\".+\"\\s*(\n|$)"

- label: "Info / User Interface"
matcher:
body: "(\\s|^)#### Summary\\s*Interface +\".+\"\\s*(\n|$)"

- label: "Mods"
matcher:
body: "(\\s|^)#### Summary\\s*Mods +\".+\"\\s*(\n|$)"

- label: "Game: Balance"
matcher:
body: "(\\s|^)#### Summary\\s*Balance +\".+\"\\s*(\n|$)"

- label: "<Bugfix>"
matcher:
body: "(\\s|^)#### Summary\\s*Bugfixes +\".+\"\\s*(\n|$)"

- label: "Code: Performance"
matcher:
body: "(\\s|^)#### Summary\\s*Performance +\".+\"\\s*(\n|$)"

- label: "Code: Infrastructure / Style / Static Analysis"
matcher:
body: "(\\s|^)#### Summary\\s*Infrastructure +\".+\"\\s*(\n|$)"

- label: "Code: Build"
matcher:
body: "(\\s|^)#### Summary\\s*Build +\".+\"\\s*(\n|$)"

- label: "Translation"
matcher:
body: "(\\s|^)#### Summary\\s*I18N +\".+\"\\s*(\n|$)"
22 changes: 20 additions & 2 deletions .github/workflows/clang-tidy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:
uses: fkirc/skip-duplicate-actions@master
with:
cancel_others: 'true'
paths: '[ "**.cpp", "**.h", "**.c", "**/CMakeLists.txt", "**/Makefile", "**.hpp", "**.cmake" ]'
paths: '[ "**.cpp", "**.h", "**.c", "**/CMakeLists.txt", "**/Makefile", "**.hpp", "**.cmake", ".github/workflows/clang-tidy.yml" ]'
build:
needs: skip-duplicates
if: ${{ needs.skip-duplicates.outputs.should_skip != 'true' }}
Expand Down Expand Up @@ -54,6 +54,24 @@ jobs:
gettext
- name: prepare
run: bash ./build-scripts/requirements.sh
- name: determine changed files
if: ${{ github.event_name == 'pull_request' }}
uses: actions/github-script@v5
with:
script: |
var fs = require('fs');
const response = await github.paginate(github.rest.pulls.listFiles,
{
owner: context.repo.owner,
repo: context.repo.repo,
pull_number: context.issue.number,
}
);
const files = response.map(x => x.filename);
for (const path of files) {
console.log(path);
}
fs.writeFileSync("files_changed", files.join('\n'));
- uses: ammaraskar/gcc-problem-matcher@master
- name: run clang-tidy
run: bash ./build-scripts/build.sh
run: bash ./build-scripts/clang-tidy.sh
17 changes: 13 additions & 4 deletions .github/workflows/post-spell-check-result.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,21 @@ jobs:
issue_number: issue_number
}
);
comments.reverse();
const bot_comments = comments.filter(comment => comment.user.type === 'Bot' && comment.user.login === 'github-actions[bot]');
if (bot_comments.length > 0 && bot_comments[0].body === body) {
console.log("Comment already exists. Exiting.");
const prev_spell_checks = comments.slice(0).reverse()
.filter(comment => comment.user.type === 'Bot' && comment.user.login === 'github-actions[bot]')
.filter(comment => comment.body.startsWith("Spell checker"));
if (prev_spell_checks.some(comment => comment.body === body)) {
console.log("The exact same spell checker comment already exists. Exiting.");
return;
}
for (const comment of prev_spell_checks) {
console.log("Deleting previous spell checker comment (comment id: %i)", comment.id);
await github.rest.issues.deleteComment({
owner: context.repo.owner,
repo: context.repo.repo,
comment_id: comment.id,
});
}
console.log("Posting comment.");
await github.rest.issues.createComment({
owner: context.repo.owner,
Expand Down
15 changes: 15 additions & 0 deletions .github/workflows/summary-labeler.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
name: Summary Labeler

on:
- pull_request_target

jobs:
uses:
name: labeler
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: fuxingloh/multi-labeler@main
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
config-path: '.github/summary-labels.yml'
2 changes: 1 addition & 1 deletion .github/workflows/test_labeler.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ jobs:
id: set-pr-id
run: echo "::set-output name=pr-id::$( cat pull_request_id )"
- name: set-label
if: ${{ github.event.workflow_run.conclusion == 'success' || steps.set-basic-build-success.outputs.basic-build-success == 'true' }}
if: ${{ github.event.workflow_run.conclusion == 'success' && github.event.workflow_run.conclusion != 'skipped' || steps.set-basic-build-success.outputs.basic-build-success == 'true' }}
uses: actions/github-script@v5
with:
script: |
Expand Down
5 changes: 3 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ option(DYNAMIC_LINKING
"Use dynamic linking. Or use static to remove MinGW dependency instead." "ON")
option(JSON_FORMAT "Build JSON formatter" "OFF")
option(CATA_CCACHE "Try to find and build with ccache" "ON")
option(CATA_CLANG_TIDY_PLUGIN "Build Cata's custom clang-tidy plugin" "OFF")
option(CATA_CLANG_TIDY_PLUGIN "Build Cata's custom clang-tidy checks as a plugin" "OFF")
option(CATA_CLANG_TIDY_EXECUTABLE "Build Cata's custom clang-tidy checks as an executable" "OFF")
set(CATA_CLANG_TIDY_INCLUDE_DIR "" CACHE STRING
"Path to internal clang-tidy headers required for plugin (e.g. ClangTidy.h)")
set(CATA_CHECK_CLANG_TIDY "" CACHE STRING "Path to check_clang_tidy.py for plugin tests")
Expand Down Expand Up @@ -354,7 +355,7 @@ add_subdirectory(tests)
if (JSON_FORMAT)
add_subdirectory(tools/format)
endif()
if (CATA_CLANG_TIDY_PLUGIN)
if (CATA_CLANG_TIDY_PLUGIN OR CATA_CLANG_TIDY_EXECUTABLE)
add_subdirectory(tools/clang-tidy-plugin)
endif()

Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ Cataclysm: Dark Days Ahead is a turn-based survival game set in a post-apocalypt
[![Open Source Helpers](https://www.codetriage.com/cleverraven/cataclysm-dda/badges/users.svg)](https://www.codetriage.com/cleverraven/cataclysm-dda)
[![Commit Activity](https://img.shields.io/github/commit-activity/m/CleverRaven/Cataclysm-DDA)](https://github.com/CleverRaven/Cataclysm-DDA/graphs/contributors)
[![Lines of Code](https://tokei.rs/b1/github/CleverRaven/Cataclysm-DDA?category=code)](https://github.com/XAMPPRocky/tokei)
[![TODOs](https://badgen.net/https/api.tickgit.com/badgen/github.com/CleverRaven/Cataclysm-DDA)](https://www.tickgit.com/browse?repo=github.com/CleverRaven/Cataclysm-DDA)

## Downloads

Expand Down
123 changes: 123 additions & 0 deletions build-scripts/clang-tidy.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
#!/bin/bash

# Shell script intended for clang-tidy check

echo "Using bash version $BASH_VERSION"
set -exo pipefail

num_jobs=3

# We might need binaries installed via pip, so ensure that our personal bin dir is on the PATH
export PATH=$HOME/.local/bin:$PATH

if [ "$RELEASE" = "1" ]
then
build_type=MinSizeRel
else
build_type=Debug
fi

cmake_extra_opts=()

if [ "$CATA_CLANG_TIDY" = "plugin" ]
then
cmake_extra_opts+=("-DCATA_CLANG_TIDY_PLUGIN=ON")
# Need to specify the particular LLVM / Clang versions to use, lest it
# use the llvm-7 that comes by default on the Travis Xenial image.
cmake_extra_opts+=("-DLLVM_DIR=/usr/lib/llvm-12/lib/cmake/llvm")
cmake_extra_opts+=("-DClang_DIR=/usr/lib/llvm-12/lib/cmake/clang")
fi

if [ "$COMPILER" = "clang++-12" -a -n "$GITHUB_WORKFLOW" -a -n "$CATA_CLANG_TIDY" ]
then
# This is a hacky workaround for the fact that the custom clang-tidy we are
# using is built for Travis CI, so it's not using the correct include directories
# for GitHub workflows.
cmake_extra_opts+=("-DCMAKE_CXX_FLAGS=-isystem /usr/include/clang/12.0.0/include")
fi

mkdir -p build
cd build
cmake \
-DBACKTRACE=ON \
${COMPILER:+-DCMAKE_CXX_COMPILER=$COMPILER} \
-DCMAKE_EXPORT_COMPILE_COMMANDS=ON \
-DCMAKE_BUILD_TYPE="$build_type" \
-DTILES=${TILES:-0} \
-DSOUND=${SOUND:-0} \
"${cmake_extra_opts[@]}" \
..

if [ "$CATA_CLANG_TIDY" = "plugin" ]
then
make -j$num_jobs CataAnalyzerPlugin
export PATH=$PWD/tools/clang-tidy-plugin/clang-tidy-plugin-support/bin:$PATH
if ! which FileCheck
then
ls -l tools/clang-tidy-plugin/clang-tidy-plugin-support/bin
ls -l /usr/bin
echo "Missing FileCheck"
exit 1
fi
CATA_CLANG_TIDY=clang-tidy
lit -v tools/clang-tidy-plugin/test
fi

"$CATA_CLANG_TIDY" --version

# Show compiler C++ header search path
${COMPILER:-clang++} -v -x c++ /dev/null -c
# And the same for clang-tidy
"$CATA_CLANG_TIDY" ../src/version.cpp -- -v

# Run clang-tidy analysis instead of regular build & test
# We could use CMake to create compile_commands.json, but that's super
# slow, so use compiledb <https://github.com/nickdiego/compiledb>
# instead.
compiledb -n make

cd ..
rm -f compile_commands.json && ln -s build/compile_commands.json

# We want to first analyze all files that changed in this PR, then as
# many others as possible, in a random order.
set +x
all_cpp_files="$( \
grep '"file": "' build/compile_commands.json | \
sed "s+.*$PWD/++;s+\"$++")"
changed_files="$( ( test -f ./files_changed && cat ./files_changed ) || echo unknown )"
changed_cpp_files="$( \
echo "$changed_files" | grep -F "$all_cpp_files" || true )"
if [ -n "$changed_cpp_files" ]
then
remaining_cpp_files="$( \
echo "$all_cpp_files" | grep -v -F "$changed_cpp_files" || true )"
else
remaining_cpp_files="$all_cpp_files"
fi

function analyze_files_in_random_order
{
if [ -n "$1" ]
then
echo "$1" | shuf | \
xargs -P "$num_jobs" -n 1 ./build-scripts/clang-tidy-wrapper.sh -quiet
else
echo "No files to analyze"
fi
}

echo "Analyzing changed files"
analyze_files_in_random_order "$changed_cpp_files"

# Check for changes to any files that would require us to run clang-tidy across everything
changed_global_files="$( \
echo "$changed_files" | \
egrep -i "\.h$|clang-tidy|build-scripts|cmake|unknown" || true )"
if [ -n "$changed_global_files" ]
then
first_changed_file="$(echo "$changed_global_files" | head -n 1)"
echo "Analyzing remaining files because $first_changed_file was changed"
analyze_files_in_random_order "$remaining_cpp_files"
fi
set -x
Loading

0 comments on commit 74e6a2a

Please sign in to comment.