Skip to content

Commit

Permalink
CodeQL: Add syntax checking for php and lua
Browse files Browse the repository at this point in the history
  • Loading branch information
hbeni committed Mar 20, 2024
1 parent 104da43 commit efad9dc
Showing 1 changed file with 82 additions and 0 deletions.
82 changes: 82 additions & 0 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -94,3 +94,85 @@ jobs:
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v2


#
# Syntax checking
#
analyze-php:
name: Analyze (php)
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@main
with:
# We must fetch at least the immediate parents so that if this is
# a pull request then we can checkout the head.
fetch-depth: 2

- name: Check PHP syntax errors
uses: overtrue/phplint@main
with:
path: server/statuspage/
options: --exclude=vendor

analyze-lua:
name: Analyze (lua)
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@main
with:
# We must fetch at least the immediate parents so that if this is
# a pull request then we can checkout the head.
fetch-depth: 2

- name: Setup programs
run: |
sudo apt-get -y install lua5.1 luajit lua-check
#- name: Check LUA syntax errors
# run: |
# find . -name '*.lua' -print > luacheck.list
# while read file; do echo "LuaLintCheck: $file"; luac -p "$file"; done <luacheck.list

# We need to do it a little more complicated, because we need to intercept RC=1 (only warnings appeared).
# I don't want the workflow to "fail" just because of syntax warnings.
- name: Check LUA syntax errors
# invoke luacheck, but make the run-action return only with errors, not with warnings
continue-on-error: true
run: |
luacheck .
echo "luacheck_r=$?" >> $GITHUB_OUTPUT
- name: Evaluate luacheck return code
run: |
luacheck_r=${{ steps.generate_number.outputs.random_number }}
echo "luacheck returned RC=$luacheck_r"
[[ $luacheck_r -gt 1 ]] && exit 1
# For andymckay/labeler see https://github.com/marketplace/actions/simple-issue-labeler
#- name: Luacheck
# id: luacheck_step_id
# uses: lunarmodules/[email protected]
# continue-on-error: true
#- name: Evalu
#- name: label when luacheck_step_id fails
# if: ${{ steps.luacheck_step_id.outcome == 'failure' }}
# uses: andymckay/[email protected]
# with:
# add-labels: "commit-message-rule-violation"
#- name: label removal when luacheck_step_id succeeds
# if: ${{ steps.luacheck_step_id.outcome == 'success' }}
# uses: andymckay/[email protected]
# with:
# remove-labels: "commit-message-rule-violation"

#- name: Check LUA syntax errors
# # invoke luacheck, but make the run-action return only with errors, not with warnings
# run: |
# luacheck .; echo -n "$?" >luacheck.rc
# luacheck_r=$(cat luacheck.rc)
# echo "luacheck returned RC=$luacheck_r"
# expr $luacheck_r \> 1;

0 comments on commit efad9dc

Please sign in to comment.