Skip to content
This repository has been archived by the owner on Sep 12, 2024. It is now read-only.

Commit

Permalink
Merge pull request #46 from GreenMeteor/develop
Browse files Browse the repository at this point in the history
Update codacy.yml
  • Loading branch information
ArchBlood authored Jun 27, 2024
2 parents 8c44de2 + 899ad08 commit d9a4466
Show file tree
Hide file tree
Showing 3 changed files with 263 additions and 34 deletions.
94 changes: 61 additions & 33 deletions .github/workflows/codacy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,21 @@
# separate terms of service, privacy policy, and support
# documentation.

# This workflow checks out code, performs a Codacy security scan
# and integrates the results with the
# GitHub Advanced Security code scanning feature. For more information on
# the Codacy security scan action usage and parameters, see
# https://github.com/codacy/codacy-analysis-cli-action.
# This workflow checks out code, runs tests, generates a coverage report,
# performs a Codacy security scan, and integrates the results with GitHub
# Advanced Security for code scanning. For more information on the Codacy
# security scan action usage and parameters, see
# https://github.com/codacy/codacy-coverage-reporter-action.
# For more information on Codacy Analysis CLI in general, see
# https://github.com/codacy/codacy-analysis-cli.
# https://github.com/codacy/codacy-coverage-reporter-action.

name: Codacy Security Scan
name: Codacy

on:
push:
branches: [ "main" ]
branches: [ main ]
pull_request:
# The branches below must be a subset of the branches above
branches: [ "main" ]
branches: [ main ]
schedule:
- cron: '43 23 * * 5'

Expand All @@ -28,34 +27,63 @@ permissions:
jobs:
codacy-security-scan:
permissions:
contents: read # for actions/checkout to fetch code
security-events: write # for github/codeql-action/upload-sarif to upload SARIF results
actions: read # only required for a private repository by github/codeql-action/upload-sarif to get the Action run status
contents: read
security-events: write
actions: read
name: Codacy Security Scan
runs-on: ubuntu-latest
steps:
# Checkout the repository to the GitHub Actions runner
- name: Checkout code
uses: actions/checkout@v4

# Execute Codacy Analysis CLI and generate a SARIF output with the security issues identified during the analysis
- name: Run Codacy Analysis CLI
uses: codacy/codacy-analysis-cli-action@d840f886c4bd4edc059706d09c6a1586111c540b
- name: Install Codacy Analysis CLI
run: |
sudo apt-get update && sudo apt-get install -y curl make
curl -L https://github.com/codacy/codacy-analysis-cli/releases/download/3.0.0/codacy-analysis-cli-3.0.0-linux-x86_64.tar.gz --output codacy-analysis-cli.tar.gz
tar xvzf codacy-analysis-cli.tar.gz
sudo mv codacy-analysis-cli-3.0.0/bin/codacy-analysis-cli /usr/local/bin/
codacy-analysis-cli --version # Verify installation
- name: Create coverage directory (ensure it exists)
run: mkdir -p ${{ github.workspace }}/tests/coverage

- name: Run tests and generate coverage reports
run: |
docker run --rm -v ${{ github.workspace }}:/workspace codacy/codacy-analysis-cli:stable analyze --directory /workspace/src --format sarif --output /workspace/tests/coverage/results_dockerfile.sarif
- name: Upload coverage reports to Codacy
env:
CODACY_PROJECT_TOKEN: ${{ secrets.CODACY_PROJECT_TOKEN }}
run: |
codacy-coverage-reporter report -l <format> -r ${{ github.workspace }}/tests/coverage/results_dockerfile.sarif
upload-sarif:
name: Upload SARIF results
runs-on: ubuntu-latest
needs: codacy-security-scan
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Create coverage directory (ensure it exists)
run: mkdir -p ${{ github.workspace }}/tests/coverage

- name: List files in coverage directory (debugging step)
run: ls -al ${{ github.workspace }}/tests/coverage

- name: Wait for SARIF file to be created
run: |
echo "Waiting for SARIF file to be created..."
sleep 10
# Upload Dockerfile SARIF results to GitHub
- name: Upload Dockerfile SARIF results to GitHub
uses: github/codeql-action/upload-sarif@v3
with:
# Check https://github.com/codacy/codacy-analysis-cli#project-token to get your project token from your Codacy repository
# You can also omit the token and run the tools that support default configurations
project-token: ${{ secrets.CODACY_PROJECT_TOKEN }}
verbose: true
output: results.sarif
format: sarif
# Adjust severity of non-security issues
gh-code-scanning-compat: true
# Force 0 exit code to allow SARIF file generation
# This will handover control about PR rejection to the GitHub side
max-allowed-issues: 2147483647

# Upload the SARIF file generated in the previous step
- name: Upload SARIF results file
uses: github/codeql-action/upload-sarif@v2
sarif_file: ${{ github.workspace }}/tests/coverage/results_dockerfile.sarif

# Upload codebase SARIF results to GitHub
- name: Upload codebase SARIF results to GitHub
uses: github/codeql-action/upload-sarif@v3
with:
sarif_file: results.sarif
sarif_file: ${{ github.workspace }}/tests/coverage/results_codebase.sarif
2 changes: 1 addition & 1 deletion src/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ RUN apt-get update && \
pecl install apcu && \
docker-php-ext-enable apcu && \
docker-php-ext-configure gd --with-freetype --with-jpeg && \
docker-php-ext-install -j$(nproc) gd mysqli pdo pdo_mysql zip intl ldap pgsql pdo_pgsql && \
docker-php-ext-install -j$(nproc) gd mysqli pdo pdo_mysql zip intl ldap pgsql pdo_pgsql mbstring && \
a2enmod rewrite && \
a2enmod deflate && \
apt-get clean && rm -rf /var/lib/apt/lists/*
Expand Down
Loading

0 comments on commit d9a4466

Please sign in to comment.