1
0

add MegaLinter, .editorconfig and style fixes

This commit is contained in:
GenZmeY 2023-05-10 02:53:03 +03:00
parent e8ec59a852
commit 01497d35ca
12 changed files with 291 additions and 197 deletions

31
.editorconfig Normal file
View File

@ -0,0 +1,31 @@
root = true
# Global
[*]
indent_style = unset
indent_size = 4
tab_width = 4
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = unset
# Source
[*.{sh,bash,dash,ksh}]
indent_style = tab
insert_final_newline = true
[builder]
insert_final_newline = true
# Other
[*.md]
trim_trailing_whitespace = false
[*.yml]
indent_style = space
indent_size = 2
insert_final_newline = true
[*.{txt,cfg,conf}]
indent_style = tab

View File

@ -1,5 +1,9 @@
---
name: docs-autoupdate
# checkov:skip=CKV2_GHA_1:Write permission is needed to push changes to the repository
permissions: write-all
on:
push:
branches:
@ -19,13 +23,15 @@ jobs:
mkdir tools
cp ./builder ./tools/
chmod +x ./tools/builder
echo '# KF2-BuildTools' >> USAGE.md
echo '[![title](https://img.shields.io/badge/Help-Page-w)](https://github.com/GenZmeY/KF2-BuildTools)' >> USAGE.md
echo '[![version](https://img.shields.io/github/v/tag/genzmey/KF2-BuildTools)](https://github.com/GenZmeY/KF2-BuildTools/tags)' >> USAGE.md
echo '[![docs-autoupdate](https://github.com/GenZmeY/KF2-BuildTools/actions/workflows/docs-autoupdate.yml/badge.svg)](https://github.com/GenZmeY/KF2-BuildTools/actions/workflows/docs-autoupdate.yml)' >> USAGE.md
echo '```' >> USAGE.md
./tools/builder -nch >> USAGE.md
echo '```' >> USAGE.md
{
echo '# KF2-BuildTools'
echo '[![title](https://img.shields.io/badge/Help-Page-w)](https://github.com/GenZmeY/KF2-BuildTools)'
echo '[![version](https://img.shields.io/github/v/tag/genzmey/KF2-BuildTools)](https://github.com/GenZmeY/KF2-BuildTools/tags)'
echo '[![docs-autoupdate](https://github.com/GenZmeY/KF2-BuildTools/actions/workflows/docs-autoupdate.yml/badge.svg)](https://github.com/GenZmeY/KF2-BuildTools/actions/workflows/docs-autoupdate.yml)'
echo '```text'
./tools/builder -nch
echo '```'
} >> USAGE.md
if ! cmp -s USAGE.md USAGE.md.old; then
git config --local user.email "github-actions[bot]@users.noreply.github.com"
git config --local user.name "github-actions"

73
.github/workflows/mega-linter.yml vendored Normal file
View File

@ -0,0 +1,73 @@
---
name: MegaLinter
permissions: read-all
on:
push:
pull_request:
branches: [master]
env:
APPLY_FIXES: none
APPLY_FIXES_EVENT: pull_request
APPLY_FIXES_MODE: commit
DISABLE: SPELL
DISABLE_ERRORS_LINTERS: REPOSITORY_CHECKOV # Barks at write-permission on docs-autoupdate.yml which I need
concurrency:
group: ${{ github.ref }}-${{ github.workflow }}
cancel-in-progress: true
jobs:
build:
name: MegaLinter
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@v3
with:
token: ${{ secrets.PAT || secrets.GITHUB_TOKEN }}
- name: MegaLinter
id: ml
uses: oxsecurity/megalinter@v6
env:
VALIDATE_ALL_CODEBASE: true
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Archive production artifacts
if: ${{ success() }} || ${{ failure() }}
uses: actions/upload-artifact@v3
with:
name: MegaLinter reports
path: |
megalinter-reports
mega-linter.log
- name: Create Pull Request with applied fixes
id: cpr
if: steps.ml.outputs.has_updated_sources == 1 && (env.APPLY_FIXES_EVENT == 'all' || env.APPLY_FIXES_EVENT == github.event_name) && env.APPLY_FIXES_MODE == 'pull_request' && (github.event_name == 'push' || github.event.pull_request.head.repo.full_name == github.repository)
uses: peter-evans/create-pull-request@v5
with:
token: ${{ secrets.PAT || secrets.GITHUB_TOKEN }}
commit-message: "[MegaLinter] Apply linters automatic fixes"
title: "[MegaLinter] Apply linters automatic fixes"
labels: bot
- name: Create PR output
if: steps.ml.outputs.has_updated_sources == 1 && (env.APPLY_FIXES_EVENT == 'all' || env.APPLY_FIXES_EVENT == github.event_name) && env.APPLY_FIXES_MODE == 'pull_request' && (github.event_name == 'push' || github.event.pull_request.head.repo.full_name == github.repository)
run: |
echo "Pull Request Number - ${{ steps.cpr.outputs.pull-request-number }}"
echo "Pull Request URL - ${{ steps.cpr.outputs.pull-request-url }}"
- name: Prepare commit
if: steps.ml.outputs.has_updated_sources == 1 && (env.APPLY_FIXES_EVENT == 'all' || env.APPLY_FIXES_EVENT == github.event_name) && env.APPLY_FIXES_MODE == 'commit' && github.ref != 'refs/heads/main' && (github.event_name == 'push' || github.event.pull_request.head.repo.full_name == github.repository)
run: sudo chown -Rc $UID .git/
- name: Commit and push applied linter fixes
if: steps.ml.outputs.has_updated_sources == 1 && (env.APPLY_FIXES_EVENT == 'all' || env.APPLY_FIXES_EVENT == github.event_name) && env.APPLY_FIXES_MODE == 'commit' && github.ref != 'refs/heads/main' && (github.event_name == 'push' || github.event.pull_request.head.repo.full_name == github.repository)
uses: stefanzweifel/git-auto-commit-action@v4
with:
branch: ${{ github.event.pull_request.head.ref || github.head_ref || github.ref }}
commit_message: "[MegaLinter] Apply linters fixes"
commit_user_name: megalinter-bot
commit_user_email: nicolas.vuillamy@ox.security

View File

@ -1,20 +0,0 @@
name: shellcheck-dev
on:
push:
branches:
- '*'
- '!master'
jobs:
shellcheck:
name: shellcheck
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Run ShellCheck
uses: ludeeus/action-shellcheck@master
env:
SHELLCHECK_OPTS: -x
with:
additional_files: 'builder'

View File

@ -1,19 +0,0 @@
name: shellcheck
on:
push:
branches:
- master
jobs:
shellcheck:
name: shellcheck
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Run ShellCheck
uses: ludeeus/action-shellcheck@master
env:
SHELLCHECK_OPTS: -x
with:
additional_files: 'builder'

22
.github/workflows/shellcheck.yml vendored Normal file
View File

@ -0,0 +1,22 @@
---
name: shellcheck
permissions: read-all
on:
push:
branches:
- master
jobs:
shellcheck:
name: shellcheck
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Run ShellCheck
uses: ludeeus/action-shellcheck@master
env:
SHELLCHECK_OPTS: -x
with:
additional_files: 'builder'

View File

@ -1,26 +1,27 @@
# KF2-BuildTools
[![version](https://img.shields.io/github/v/tag/genzmey/KF2-BuildTools)](https://github.com/GenZmeY/KF2-BuildTools/tags)
[![shellcheck](https://github.com/GenZmeY/KF2-BuildTools/actions/workflows/shellcheck-master.yml/badge.svg)](https://github.com/GenZmeY/KF2-BuildTools/actions/workflows/shellcheck-master.yml)
[![MegaLinter](https://github.com/GenZmeY/KF2-BuildTools/actions/workflows/mega-linter.yml/badge.svg?branch=master)](https://github.com/GenZmeY/KF2-BuildTools/actions/workflows/mega-linter.yml)
[![docs-autoupdate](https://github.com/GenZmeY/KF2-BuildTools/actions/workflows/docs-autoupdate.yml/badge.svg)](https://github.com/GenZmeY/KF2-BuildTools/actions/workflows/docs-autoupdate.yml)
[![license](https://img.shields.io/github/license/GenZmeY/KF2-Server-Extension)](LICENSE)
# Features:
## Features
- Build, brew, test and upload to Steam Workshop;
- No need to edit KFEditor.ini at all;
- Sources can be stored in any path;
- Easily switch between different projects.
# Requirements
## Requirements
- [Killing Floor 2](https://store.steampowered.com/app/232090/Killing_Floor_2/);
- Killing Floor 2 - SDK;
- [git-bash](https://git-scm.com/download/win).
# Add to your project
## Add to your project
Make sure that the location of folders and files in your project as follows (Correct it if it's not):
`/<PackageName>/Classes/*.uc`
**There are two ways to add KF2-BuildTools to your project:**
## 1. As [git submodule](https://git-scm.com/book/en/v2/Git-Tools-Submodules)
### 1. As [git submodule](https://git-scm.com/book/en/v2/Git-Tools-Submodules)
Open git-bash and go to your project: `cd <your_project_path>`
Add submodule: `git submodule add https://github.com/GenZmeY/KF2-BuildTools tools`
@ -28,18 +29,18 @@ Add submodule: `git submodule add https://github.com/GenZmeY/KF2-BuildTools tool
Get updates: `pushd tools && git pull && popd`
Commit the changes: `git add tools && git commit -m 'update tools'`
## 2. As standalone script
### 2. As standalone script
Just create a `tools` folder and put [builder](builder) there.
Now you can use the script in the same way as in the first case, but you will have to update it yourself.
# Usage
## Usage
Available commands can be found here: [USAGE.md](USAGE.md)
If you have a simple mutator or game mode, then the usage is also simple: just use [the commands](USAGE.md) to compile, test and upload to the steam workshop.
![demo](example.gif)
## The result can be found here:
### The result can be found here
**Compiled packages:**
`C:\Users\<username>\Documents\My Games\KillingFloor2\KFGame\Unpublished\`
@ -49,20 +50,20 @@ If you have a simple mutator or game mode, then the usage is also simple: just u
**Uploaded packages:**
your steam workshop 🙃
# Usage (Advanced)
## Usage (Advanced)
If your project contains several mutators, *.upk files, external dependencies, or you want to customize the whole process in more details, then this section is for you.
## Setup
### Setup
When you run compilation for the first time or do `./tools/builder --init` `builder.cfg` appears in your project folder.
Edit it to set build/test/upload options. The config contains the necessary comments inside.
Edit the files in the `PublicationContent` folder - they are responsible for the description in the Steam Workshop.
## Project filesystem
### Project filesystem
If you have *.upk or localization files, they must be in a specific location.
Change the filesystem of the project to such a form that everything works correctly:
```
```text
/SomePackageName1
*.upk
/Classes
@ -93,7 +94,7 @@ builder.cfg
**Note:** Use the `BrewedPC` folder for additional content such as sound files for your weapons or other stuff. This will be copied to the final BrewedPC before being uploaded to the workshop.
By the way, this allows you to use a script to upload maps (although this was not its original purpose). Just put the map(s) in `BrewedPC` (don't forget to edit the `PublicationContent`) and run `./tools/builder -u`.
## Examples (Projects that use KF2-BuildTools)
### Examples (Projects that use KF2-BuildTools)
**Simplest case (one mutator):**
- [AdminAutoLogin](https://github.com/GenZmeY/KF2-AdminAutoLogin)
- [StartWave](https://github.com/GenZmeY/KF2-StartWave)
@ -112,5 +113,5 @@ By the way, this allows you to use a script to upload maps (although this was no
**two mutators are uploaded to the steam workshop:**
- [UnofficialMod](https://github.com/GenZmeY/UnofficialMod)
# License
## License
[GNU GPLv3](LICENSE)

View File

@ -1,2 +1,2 @@
# TODO:
# TODO
- [ ] improve error parser (class vs name mismatch, etc...)

View File

@ -2,7 +2,7 @@
[![title](https://img.shields.io/badge/Help-Page-w)](https://github.com/GenZmeY/KF2-BuildTools)
[![version](https://img.shields.io/github/v/tag/genzmey/KF2-BuildTools)](https://github.com/GenZmeY/KF2-BuildTools/tags)
[![docs-autoupdate](https://github.com/GenZmeY/KF2-BuildTools/actions/workflows/docs-autoupdate.yml/badge.svg)](https://github.com/GenZmeY/KF2-BuildTools/actions/workflows/docs-autoupdate.yml)
```
```text
Usage: ./tools/builder OPTIONS
Compile, brew, test and upload your kf2 packages to the Steam Workshop.