Skip to content

Commit

Permalink
feat: build for release
Browse files Browse the repository at this point in the history
  • Loading branch information
github-actions[bot] committed Mar 7, 2023
1 parent d43127f commit 5cc54a7
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 51 deletions.
33 changes: 21 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@

[![Codacy Badge](https://app.codacy.com/project/badge/Grade/946b78614f154f81b1c9c0514fd9f35c)](https://www.codacy.com/gh/codacy/codacy-analysis-cli-action/dashboard?utm_source=github.com&utm_medium=referral&utm_content=codacy/codacy-analysis-cli-action&utm_campaign=Badge_Grade)

GitHub Action for running Codacy static analysis on [over 30 supported languages](https://docs.codacy.com/getting-started/supported-languages-and-tools/) and returning identified issues in the code.
GitHub Action for running Codacy static analysis on [over 40 supported languages](https://docs.codacy.com/getting-started/supported-languages-and-tools/) and returning identified issues in the code.

<br/>

<a href="https://www.codacy.com" target="_blank"><img src="images/codacy-logo.svg" alt="Codacy" width="400"/></a>

<br/>

[Codacy](https://www.codacy.com/) is an automated code review tool that makes it easy to ensure your team is writing high-quality code by analyzing more than 30 programming languages such as PHP, JavaScript, Python, Java, and Ruby. Codacy allows you to define your own quality rules, code patterns and quality settings you'd like to enforce to prevent issues on your codebase.
[Codacy](https://www.codacy.com/) is an automated code review tool that makes it easy to ensure your team is writing high-quality code by analyzing more than 40 programming languages such as PHP, JavaScript, Python, Java, and Ruby. Codacy allows you to define your own quality rules, code patterns and quality settings you'd like to enforce to prevent issues on your codebase.

The Codacy GitHub Action supports the following scenarios:

Expand Down Expand Up @@ -85,7 +85,7 @@ jobs:
# 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
# This will hand over control about PR rejection to the GitHub side
max-allowed-issues: 2147483647
# Upload the SARIF file generated in the previous step
Expand All @@ -97,7 +97,7 @@ jobs:

## Integration with Codacy for client-side tools

Use the GitHub Action to run any of the [containerized Codacy client-side tools](https://docs.codacy.com/related-tools/local-analysis/client-side-tools/) and upload the results of the analysis to Codacy.
Use the GitHub Action to run any of the [**containerized** client-side tools supported by Codacy](https://docs.codacy.com/related-tools/local-analysis/client-side-tools/) and upload the results of the analysis to Codacy.

In this scenario, the GitHub action:

Expand All @@ -110,6 +110,8 @@ After this, Codacy displays the results of the analysis of your commits and pull

To use the GitHub Action with Codacy integration:

1. On Codacy, [enable the containerized client-side tool](../../repositories-configure/configuring-code-patterns.md) and configure the corresponding code patterns on your repository **Code patterns** page.

1. On Codacy, enable **Run analysis through build server** in your repository **Settings**, tab **General**, **Repository analysis**.

This setting enables Codacy to wait for the results of the local analysis before resuming the analysis of your commits.
Expand All @@ -119,9 +121,9 @@ To use the GitHub Action with Codacy integration:
- **If you're setting up one repository**, [obtain a project API token](https://docs.codacy.com/codacy-api/api-tokens/#project-api-tokens) and store it as an [encrypted secret for your **repository**](https://docs.github.com/actions/reference/encrypted-secrets#creating-encrypted-secrets-for-a-repository) with the name `CODACY_PROJECT_TOKEN`.
- **If you're setting up multiple repositories**, [obtain an account API token](https://docs.codacy.com/codacy-api/api-tokens/#account-api-tokens) and store it as an [encrypted secret for your **organization**](https://docs.github.com/en/actions/reference/encrypted-secrets#creating-encrypted-secrets-for-an-organization) with the name `CODACY_API_TOKEN`.

> ⚠️ **Never write API tokens on your configuration files** and keep your API tokens well protected, as they grant owner permissions to your projects on Codacy.
> ⚠️ **Never write API tokens to your configuration files** and keep your API tokens well protected, as they grant owner permissions to your projects on Codacy.

3. Add the following to a file `.github/workflows/codacy-analysis.yaml` in your repository, where `<CLIENT_SIDE_TOOL_NAME>` is the name of the [**containerized** client-side tool](https://docs.codacy.com/related-tools/local-analysis/client-side-tools/) that the Codacy Analysis CLI will run locally, or don't specify this parameter to run all tools supported by Codacy:
3. Add the following to a file `.github/workflows/codacy-analysis.yaml` in your repository, where `<CLIENT_SIDE_TOOL_NAME>` is the name of the [containerized client-side tool](https://docs.codacy.com/related-tools/local-analysis/client-side-tools/) that the Codacy Analysis CLI will run locally, or don't specify this parameter to run all tools supported by Codacy:

```yaml
name: Codacy Analysis CLI
Expand Down Expand Up @@ -154,7 +156,7 @@ To use the GitHub Action with Codacy integration:
uses: actions/setup-go@v3
with:
# Go version currently supported by Codacy
go-version: 1.17.13
go-version: 1.19.1
```

4. Optionally, specify the following parameters to run [**standalone** client-side tools](https://docs.codacy.com/related-tools/local-analysis/client-side-tools/):
Expand All @@ -164,7 +166,7 @@ To use the GitHub Action with Codacy integration:
run-staticcheck: "true"
```

Due to the complex orchestration of the tools Clang-Tidy and Faux Pas, in this case the action can receive instead the output files of the tools and uploads them to Codacy:
Due to the complex orchestration of the tools Clang-Tidy and Faux Pas, the action can receive instead the output files of the tools and upload them to Codacy:

```yaml
clang-tidy-output: "path/to/output"
Expand All @@ -179,12 +181,19 @@ To use the GitHub Action with Codacy integration:

5. Optionally, [enable the GitHub integration](https://docs.codacy.com/repositories-configure/integrations/github-integration/) on Codacy to have information about the analysis of the changed files directly on your pull requests.

## Extra configurations
## Parameters

The Codacy GitHub Action is a wrapper for running the [Codacy Analysis CLI](https://github.com/codacy/codacy-analysis-cli). For a list of supported input parameters, see [`action.yml`](./action.yml). To pass input parameters to the action, [update the associated `with` map](https://docs.github.com/en/actions/creating-actions/metadata-syntax-for-github-actions#runsstepswith).

The Codacy GitHub Action is a wrapper for running the [Codacy Analysis CLI](https://github.com/codacy/codacy-analysis-cli) and supports [the same parameters as the command `analyze`](https://github.com/codacy/codacy-analysis-cli#commands-and-configuration), with the following exceptions:
The following example limits analysis to a `src` directory and provides additional details by setting `verbose` to `true`.

- `--commit-uuid` (the action always analyzes the commit that triggered it)
- `--username` and `--project` (the action automatically uses the owner and name of the repository when you specify the parameter `api-token`)
```yaml
- name: Run Codacy Analysis CLI
uses: codacy/codacy-analysis-cli-action@master
with:
directory: src
verbose: true
```

## Contributing

Expand Down
67 changes: 28 additions & 39 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,32 +17,34 @@ inputs:
description: "API account token to retrieve your remote Codacy configuration for the project being analyzed"
codacy-api-base-url:
required: false
description: "Codacy's API URL, to retrieve your remote Codacy configuration"
description: "Codacy API URL to retrieve your remote Codacy configuration"
format:
required: false
description: "Format of the output file"
description: "Output file format"
output:
required: false
description: "Send analysis results to an output file"
description: "Path to a file to save the analysis results"
directory:
required: false
description: "The directory to be analyzed"
description: "Directory to analyze"
parallel:
required: false
description: "Number of tools to run in parallel"
max-tool-memory:
required: false
description: "Maximum of allowed memory for each tool execution"
description: "Maximum allowed memory for running each tool (bytes)"
max-allowed-issues:
required: false
default: "2147483647"
description: "Maximum number of issues allowed for the analysis to succeed"
tool:
required: false
description: "The name of the tool to analyze the code"
description: >-
Only run a specific tool or tool category (metrics, issues, duplication).
For the full list of tools, see https://docs.codacy.com/repositories-configure/codacy-configuration-file/#which-tools-can-be-configured-and-which-name-should-i-use
tool-timeout:
required: false
description: "Maximum time each tool has to execute"
description: "Tool execution timeout (e.g. 15minutes, 1hour)"
upload:
required: false
description: "Upload analysis results to Codacy"
Expand All @@ -54,41 +56,36 @@ inputs:
description: "Fail the analysis if any tool fails to run"
allow-network:
required: false
description: "Allow network access for tools"
description: "Allow the tools to access the network"
force-file-permissions:
required: false
description: "Force files to be readable by changing the permissions before running the analysis"
gh-code-scanning-compat:
required: false
description: >-
Reduce issue severity by one level, for non-security issues, for compatibility with GitHub's code scanning feature.
This option will only have an effect when used in conjunction with '--format sarif'.
Reduce issue severity by one level for non-security issues, for compatibility with GitHub's code scanning feature.
This option only has an effect when used with 'format: sarif'.
run-docker-tools:
required: false
default: "true"
description: >-
Run dockerized tools. Possible values (true|false)
Check the full list in https://docs.codacy.com/repositories-configure/codacy-configuration-file/#which-tools-can-be-configured-and-which-name-should-i-use
Run all dockerized tools supported by Codacy.
For the full list of tools, see https://docs.codacy.com/repositories-configure/codacy-configuration-file/#which-tools-can-be-configured-and-which-name-should-i-use
run-gosec:
required: false
description: >-
Run GoSec. Possible values (true|false)
description: "Run Gosec"
run-staticcheck:
required: false
description: >-
Run StaticCheck. Possible values (true|false)
description: "Run Staticcheck"
clang-tidy-output:
required: false
description: >-
Path to a file containing the output of Clang Tidy.
description: "Path to a file containing the output of Clang-Tidy."
faux-pas-output:
required: false
description: >-
Path to a file containing the output of Faux Pas.
description: "Path to a file containing the output of Faux Pas."
skip-uncommitted-files-check:
required: false
description: >-
Skip validation on uncommitted changes
description: "Skip validation of uncommitted changes"
runs:
using: "composite"
steps:
Expand Down Expand Up @@ -120,12 +117,10 @@ runs:
if [ "${{ inputs.run-gosec }}" == "true" ]; then
cd /tmp
curl -sfL https://raw.githubusercontent.com/securego/gosec/master/install.sh | sh -s v2.7.0
curl -sfL https://raw.githubusercontent.com/securego/gosec/master/install.sh | sh -s v2.13.1
chmod +x ./bin/gosec
curl -fsSL https://api.github.com/repos/codacy/codacy-gosec/releases/latest \
| grep "browser_download_url" | grep -v "browser_download_url.*jar" \
| cut -d '"' -f 4 \
| xargs -L 1 curl -fsSL -o /tmp/codacy-gosec
CODACY_GOSEC_VERSION=$(curl -SL "https://artifacts.codacy.com/bin/codacy-gosec/latest" -o-)
curl -fsSL "https://artifacts.codacy.com/bin/codacy-gosec/$CODACY_GOSEC_VERSION/codacy-gosec-$CODACY_GOSEC_VERSION" -o /tmp/codacy-gosec
chmod +x /tmp/codacy-gosec
cd -
Expand Down Expand Up @@ -155,10 +150,8 @@ runs:
| xargs -L 1 curl -fsSL -o /tmp/staticcheck_linux_amd64.tar.gz
tar -xvf /tmp/staticcheck_linux_amd64.tar.gz staticcheck/staticcheck
chmod +x ./staticcheck/staticcheck
curl -fsSL https://api.github.com/repos/codacy/codacy-staticcheck/releases/latest \
| grep "browser_download_url" | grep -v "browser_download_url.*jar" \
| cut -d '"' -f 4 \
| xargs -L 1 curl -fsSL -o /tmp/codacy-staticcheck
CODACY_STATICCHECK_VERSION=$(curl -SL "https://artifacts.codacy.com/bin/codacy-staticcheck/latest" -o-)
curl -fsSL "https://artifacts.codacy.com/bin/codacy-staticcheck/$CODACY_STATICCHECK_VERSION/codacy-staticcheck-$CODACY_STATICCHECK_VERSION" -o /tmp/codacy-staticcheck
chmod +x /tmp/codacy-staticcheck
cd -
Expand All @@ -182,10 +175,8 @@ runs:
if [ -n "${{ inputs.clang-tidy-output }}" ]; then
cd /tmp
curl -fsSL https://api.github.com/repos/codacy/codacy-clang-tidy/releases/latest \
| grep "browser_download_url" | grep -v "browser_download_url.*jar" \
| cut -d '"' -f 4 \
| xargs -L 1 curl -fsSL -o /tmp/codacy-clang-tidy
CODACY_CLANG_TIDY_VERSION=$(curl -SL "https://artifacts.codacy.com/bin/codacy-clang-tidy/latest" -o-)
curl -fsSL "https://artifacts.codacy.com/bin/codacy-clang-tidy/$CODACY_CLANG_TIDY_VERSION/codacy-clang-tidy-linux-$CODACY_CLANG_TIDY_VERSION" -o /tmp/codacy-clang-tidy
chmod +x /tmp/codacy-clang-tidy
cd -
Expand All @@ -208,10 +199,8 @@ runs:
if [ -n "${{ inputs.faux-pas-output }}" ]; then
cd /tmp
curl -fsSL https://api.github.com/repos/codacy/codacy-faux-pas/releases/latest \
| grep "browser_download_url" | grep -v "browser_download_url.*jar" \
| cut -d '"' -f 4 \
| xargs -L 1 curl -fsSL -o /tmp/codacy-faux-pas
CODACY_FAUX_PAS_VERSION=$(curl -SL "https://artifacts.codacy.com/bin/codacy-faux-pas/latest" -o-)
curl -fsSL "https://artifacts.codacy.com/bin/codacy-faux-pas/$CODACY_FAUX_PAS_VERSION/codacy-faux-pas-$CODACY_FAUX_PAS_VERSION" -o /tmp/codacy-faux-pas
chmod +x /tmp/codacy-faux-pas
cd -
Expand Down

0 comments on commit 5cc54a7

Please sign in to comment.