diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000000..984088edf3 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,14 @@ +root = true + +[*] +indent_style = tab +indent_size = 4 + +end_of_line = lf +insert_final_newline = true + +trim_trailing_whitespace = true + +[*.{yml,yaml,json}] +indent_style = space +indent_size = 2 diff --git a/.gitattributes b/.gitattributes index 9a8d916de1..a9017f46e7 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,17 +1,2 @@ -*.fgd text -*.json text -*.lua text -*.md text -*.sh text -*.txt text -*.vmt text - -*.jpg binary -*.mdl binary -*.phy binary -*.vtf binary -*.vtx binary -*.vvd binary -*.wav binary - -* text=auto +# Enforce UNIX line endings +* text=auto eol=lf diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md new file mode 100644 index 0000000000..b7e58d25c2 --- /dev/null +++ b/.github/pull_request_template.md @@ -0,0 +1,29 @@ + + +## Issue + + + +Resolves # + +## Changes + + + +## Impact + + + +## Testing + + + +## Helpful Links + +[Discord](https://discord.tasevers.com) diff --git a/.github/workflows/canary.yml b/.github/workflows/canary.yml deleted file mode 100644 index 3506378daf..0000000000 --- a/.github/workflows/canary.yml +++ /dev/null @@ -1,25 +0,0 @@ -name: Deploy Canary to Workshop - -on: - push: - branches: [ master ] - workflow_dispatch: - -jobs: - deploy: - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@master - - - name: Embed version - run: | - echo -e "\ncachedversion = \"Canary ${GITHUB_SHA:0:7}\"" >> lua/wire/server/wirelib.lua - - - uses: wiremod/gmod-upload@master - with: - id: 3066780663 - changelog: ${{ github.event.head_commit.message }} - env: - STEAM_USERNAME: ${{ secrets.WIRETEAM_WORKSHOP_USERNAME }} - STEAM_PASSWORD: ${{ secrets.WIRETEAM_WORKSHOP_PASSWORD }} diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml deleted file mode 100644 index 3f683db030..0000000000 --- a/.github/workflows/deploy.yml +++ /dev/null @@ -1,23 +0,0 @@ -name: Deploy to Workshop - -on: - workflow_dispatch: - -jobs: - deploy: - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@master - - - name: Embed version - run: | - echo -e "\ncachedversion = \"Workshop ${GITHUB_SHA:0:7}\"" >> lua/wire/server/wirelib.lua - - - uses: wiremod/gmod-upload@master - with: - id: 160250458 - changelog: "Deployment via Github to commit ${GITHUB_SHA:0:7}" - env: - STEAM_USERNAME: ${{ secrets.WIRETEAM_WORKSHOP_USERNAME }} - STEAM_PASSWORD: ${{ secrets.WIRETEAM_WORKSHOP_PASSWORD }} diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml deleted file mode 100644 index 1d73022b28..0000000000 --- a/.github/workflows/lint.yml +++ /dev/null @@ -1,37 +0,0 @@ -name: Lint - -on: - pull_request: - paths: - - "lua/**" - workflow_dispatch: - -jobs: - lint: - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@master - - uses: leafo/gh-actions-lua@v10 - with: - luaVersion: "luajit-2.1.0-beta3" - - - name: Get any changed files - id: changed-files - uses: tj-actions/changed-files@v36 - with: - files: | - **.lua - - - name: Run E2 Extension Preprocessor - run: | - lua .github/workflows/preprocess.lua ${{ steps.changed-files.outputs.all_changed_files }} - - - name: Download GluaFixer - run: | - curl -o glualint.zip -L https://github.com/FPtje/GLuaFixer/releases/download/1.24.6/glualint-1.24.6-x86_64-linux.zip - unzip glualint.zip - - - name: Lint Code - run: | - ./glualint ${{ steps.changed-files.outputs.all_changed_files }} diff --git a/.github/workflows/lua.yml b/.github/workflows/lua.yml new file mode 100644 index 0000000000..0a74d1bc57 --- /dev/null +++ b/.github/workflows/lua.yml @@ -0,0 +1,50 @@ +name: Lua CI + +on: + workflow_call: + +jobs: + format: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + + - uses: JohnnyMorganz/stylua-action@v2 + with: + token: ${{ secrets.GITHUB_TOKEN }} + version: latest + args: --check ./lua + + lint: + runs-on: ubuntu-latest + env: + GLUAFIXER_VERSION: 1.26.0 + + steps: + - uses: actions/checkout@v4 + + - uses: leafo/gh-actions-lua@v10 + with: + luaVersion: "luajit-2.1.0-beta3" + + - name: Get any changed files + id: changed-files + uses: tj-actions/changed-files@v41 + with: + files: | + **.lua + + # TODO: Kill this + - name: Run E2 Extension Preprocessor + run: | + lua .github/workflows/preprocess.lua ${{ steps.changed-files.outputs.all_changed_files }} + + - name: Download GLuaFixer + run: | + curl --retry 3 --location https://github.com/FPtje/GLuaFixer/releases/download/$GLUAFIXER_VERSION/glualint-$GLUAFIXER_VERSION-x86_64-linux.zip --output gluafixer.zip + unzip gluafixer.zip + + - name: Lint Code + run: | + ./glualint --output-format github --config .glualint.json lint ./lua diff --git a/.github/workflows/push_feature.yml b/.github/workflows/push_feature.yml new file mode 100644 index 0000000000..381ab85911 --- /dev/null +++ b/.github/workflows/push_feature.yml @@ -0,0 +1,9 @@ +name: Push to non-release branch + +on: + push: + branches-ignore: master + +jobs: + lua: + uses: "./.github/workflows/lua.yml" diff --git a/.github/workflows/push_release.yml b/.github/workflows/push_release.yml new file mode 100644 index 0000000000..abc741e690 --- /dev/null +++ b/.github/workflows/push_release.yml @@ -0,0 +1,22 @@ +name: Push to release branch + +on: + push: + branches: master + +jobs: + lua: + uses: "./.github/workflows/lua.yml" + + deploy: + runs-on: ubuntu-latest + # TODO: Re-enable this once the whole codebase passes the formatter and linter + #needs: [lua] + + environment: production + concurrency: production + + steps: + # TODO: Upgrade this to v2 deployment when bundling added + - name: Post to webhook + run: curl --fail-with-body -X POST ${{ secrets.DEPLOYER_WEBHOOK }}/${{ github.event.repository.name }} diff --git a/.github/workflows/stale.yml b/.github/workflows/stale.yml deleted file mode 100644 index c67325a8df..0000000000 --- a/.github/workflows/stale.yml +++ /dev/null @@ -1,29 +0,0 @@ -# This workflow warns and then closes issues and PRs that have had no activity for a specified amount of time. -# -# You can adjust the behavior by modifying this file. -# For more information, see: -# https://github.com/actions/stale -name: Mark stale issues and pull requests - -on: - schedule: - - cron: '43 19 * * *' - -jobs: - stale: - - runs-on: ubuntu-latest - permissions: - issues: write - pull-requests: write - - steps: - - uses: actions/stale@v5 - with: - repo-token: ${{ secrets.GITHUB_TOKEN }} - days-before-issue-stale: -1 - days-before-issue-close: -1 - stale-pr-message: "This pull request has been marked as stale as there haven't been any changes in the past month. It will be closed in 15 days." - stale-pr-label: "Stale" - days-before-pr-stale: 30 - days-before-pr-close: 45 diff --git a/.glualint.json b/.glualint.json index 22f13bd0c5..f1249c59a1 100644 --- a/.glualint.json +++ b/.glualint.json @@ -1,47 +1,30 @@ { - "lint_maxScopeDepth": 9, - "lint_syntaxErrors": true, - "lint_syntaxInconsistencies": true, - "lint_deprecated": true, - "lint_trailingWhitespace": true, - "lint_whitespaceStyle": false, - "lint_beginnerMistakes": false, - "lint_emptyBlocks": true, - "lint_shadowing": false, - "lint_gotos": true, - "lint_goto_identifier": true, - "lint_doubleNegations": true, - "lint_redundantIfStatements": false, - "lint_redundantParentheses": true, - "lint_duplicateTableKeys": true, - "lint_profanity": true, - "lint_unusedVars": true, - "lint_unusedParameters": false, - "lint_unusedLoopVars": false, - "lint_inconsistentVariableStyle": false, - "lint_spaceBetweenParens": false, - "lint_spaceBetweenBrackets": false, - "lint_spaceBetweenBraces": false, - "lint_ignoreFiles": [], - "lint_spaceBeforeComma": false, - "lint_spaceAfterComma": false, - "lint_maxLineLength": 0, + "lint_maxScopeDepth": 7, + "lint_syntaxErrors": true, + "lint_syntaxInconsistencies": true, + "lint_deprecated": true, + "lint_trailingWhitespace": true, + "lint_whitespaceStyle": true, + "lint_beginnerMistakes": true, + "lint_emptyBlocks": true, + "lint_shadowing": true, + "lint_gotos": true, + "lint_goto_identifier": true, + "lint_doubleNegations": true, + "lint_redundantIfStatements": true, + "lint_redundantParentheses": true, + "lint_duplicateTableKeys": true, + "lint_profanity": true, + "lint_unusedVars": true, + "lint_unusedParameters": true, + "lint_unusedLoopVars": true, + "lint_inconsistentVariableStyle": false, + "lint_spaceBetweenParens": false, + "lint_spaceBetweenBrackets": false, + "lint_spaceBetweenBraces": false, + "lint_ignoreFiles": [], + "lint_spaceBeforeComma": false, + "lint_spaceAfterComma": false, - "prettyprint_spaceBetweenParens": false, - "prettyprint_spaceBetweenBrackets": false, - "prettyprint_spaceBetweenBraces": false, - "prettyprint_spaceEmptyParens": false, - "prettyprint_spaceEmptyBraces": false, - "prettyprint_spaceAfterLabel": false, - "prettyprint_spaceBeforeComma": false, - "prettyprint_spaceAfterComma": true, - "prettyprint_semicolons": false, - "prettyprint_cStyle": false, - "prettyprint_removeRedundantParens": true, - "prettyprint_minimizeParens": false, - "prettyprint_assumeOperatorAssociativity": true, - "prettyprint_rejectInvalidCode": false, - "prettyprint_indentation": " ", - - "log_format": "auto" -} \ No newline at end of file + "log_format": "auto" +} diff --git a/lua/entities/gmod_wire_expression2/core/e2lib.lua b/lua/entities/gmod_wire_expression2/core/e2lib.lua index 1dc22b8fc1..38768987cd 100644 --- a/lua/entities/gmod_wire_expression2/core/e2lib.lua +++ b/lua/entities/gmod_wire_expression2/core/e2lib.lua @@ -915,7 +915,7 @@ hook.Add("InitPostEntity", "e2lib", function() -- check for a CPPI compliant plugin if SERVER and CPPI then - if debug.getregistry().Player.CPPIGetFriends then + if FindMetaTable("Player").CPPIGetFriends then E2Lib.replace_function("isFriend", function(owner, player) if owner == nil then return false end if owner == player then return true end @@ -934,7 +934,7 @@ hook.Add("InitPostEntity", "e2lib", function() end) end - if debug.getregistry().Entity.CPPIGetOwner then + if FindMetaTable("Entity").CPPIGetOwner then local _getOwner = E2Lib.getOwner E2Lib.replace_function("getOwner", function(self, entity) if not IsValid(entity) then return end @@ -1258,4 +1258,4 @@ function E2Lib.compileScript(code, owner) end end end -end \ No newline at end of file +end diff --git a/lua/entities/gmod_wire_expression2/core/hologram.lua b/lua/entities/gmod_wire_expression2/core/hologram.lua index eff492bc5f..e5c1df114a 100644 --- a/lua/entities/gmod_wire_expression2/core/hologram.lua +++ b/lua/entities/gmod_wire_expression2/core/hologram.lua @@ -1224,6 +1224,10 @@ end e2function void holoParent(index, entity ent) if not IsValid(ent) then return end + if not E2Lib.isOwner(self, ent) then + return self:throw("You do not have permission to parent to this entity", nil) + end + local Holo = CheckIndex(self, index) if not Holo then return end @@ -1234,6 +1238,10 @@ end e2function void holoParentAttachment(index, entity ent, string attachmentName) if not IsValid(ent) then return end + if not E2Lib.isOwner(self, ent) then + return self:throw("You do not have permission to parent to this entity", nil) + end + local Holo = CheckIndex(self, index) if not Holo then return end diff --git a/lua/entities/gmod_wire_expression2/core/player.lua b/lua/entities/gmod_wire_expression2/core/player.lua index 91c2c63006..7951ab7a56 100644 --- a/lua/entities/gmod_wire_expression2/core/player.lua +++ b/lua/entities/gmod_wire_expression2/core/player.lua @@ -511,7 +511,7 @@ end __e2setcost(2) -if CPPI and debug.getregistry().Player.CPPIGetFriends then +if CPPI and FindMetaTable("Player").CPPIGetFriends then local function Trusts(ply, whom) if ply == whom then return true end diff --git a/stylua.toml b/stylua.toml new file mode 100644 index 0000000000..4d8c0476b6 --- /dev/null +++ b/stylua.toml @@ -0,0 +1,7 @@ +column_width = 120 +line_endings = "Unix" +indent_type = "Tabs" +indent_width = 4 +quote_style = "AutoPreferDouble" +call_parentheses = "Always" +collapse_simple_statement = "Never"