Add config section to CodeQL workflow with query filters and paths-ignore #30
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: "CodeQL Analysis" | |
on: | |
push: | |
branches: [ "main", "master" ] | |
pull_request: | |
branches: [ "main", "master" ] | |
schedule: | |
- cron: '15 2 * * 1' # Weekly on Mondays at 2:15 AM | |
jobs: | |
analyze: | |
name: Analyze Java Code | |
runs-on: ubuntu-latest | |
permissions: | |
actions: read | |
contents: read | |
security-events: write | |
strategy: | |
fail-fast: false | |
matrix: | |
language: [ 'java' ] | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Set up JDK 11 | |
uses: actions/setup-java@v3 | |
with: | |
java-version: '11' | |
distribution: 'temurin' | |
# Initialize CodeQL with custom configuration | |
# - Excludes specific queries that may generate noise | |
# - Ignores test paths to focus on production code | |
- name: Initialize CodeQL | |
uses: github/codeql-action/init@v3 | |
with: | |
languages: ${{ matrix.language }} | |
queries: +security-and-quality | |
build-mode: none | |
dependency-caching: true | |
config: | | |
query-filters: | |
- exclude: | |
id: java/missing-call-to-super-finalize | |
- exclude: | |
id: java/unread-local-variable | |
paths-ignore: | |
- '**/test/**' | |
- '**/tests/**' | |
- '**/*Test.java' | |
- '**/*Tests.java' | |
# Autobuild attempts to build any compiled languages (Java, C#, Go, etc.) | |
# If this step fails, remove it and run the build manually instead | |
#- name: Autobuild | |
# uses: github/codeql-action/autobuild@v3 | |
- name: Perform CodeQL Analysis | |
uses: github/codeql-action/analyze@v3 | |
with: | |
category: "/language:${{matrix.language}}" |