Skip to content

Commit

Permalink
Add release toolkit dictionary (NR-112268) (#13)
Browse files Browse the repository at this point in the history
  • Loading branch information
gsanchezgavier authored May 4, 2023
1 parent 228f8bb commit ca7ab5b
Show file tree
Hide file tree
Showing 7 changed files with 73 additions and 10 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/selftest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ on:
jobs:
test_local:
runs-on: ubuntu-latest
name: Test get config files with local files
name: Test local files are not override by the ones coming from the action
steps:
- uses: actions/checkout@v2
- name: Get test local files
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
/.semgrep.yml
/.semgrep-bck.yml
/.semgrepignore
/.rt-dictionary.yml
test/tmp
semgrep-go
yq
Expand Down
32 changes: 23 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,35 @@

# newrelic-infra-checkers

Default configuration files for the static analysis tools used in New Relic integrations and agent repositories.
Common configuration files for tools used in New Relic integrations and agent repositories.

Action to get those default config files.
Configuration files are placed in hardcoded paths that meets the tools expectations.

If those file already exists in the repo they are not overwritten.


## Supported tools

- semgrep: common configuration for [semgrep](https://semgrep.dev/).
- golangci-lint: common configuration for [golangci-lint](https://golangci-lint.run/).
- golangci-lint limited: contains a limited amount of linters, meant to be added to projects already developed that are not compliant with those removed linters.
- release toolkit dictionary: dictionary used by the [link-dependencies](https://github.com/newrelic/release-toolkit/tree/main/link-dependencies) action.

## Usage

Usage and defaults:
Example of usage:
```yaml
- name: Get default configuration files for NR static analysis tools
uses: newrelic/newrelic-infra-checkers@v1
with:
semgrep-append: false # Optional, if set to true, local semgrep file policies will join the ones in this repository.
golangci-lint-limited: true # Optional, if set to true, `golangci-lint-limited` config will be used instead of `golangci-lint`.
jobs:
static-analysis:
name: Run tools
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: newrelic/newrelic-infra-checkers@v1
# Tools running after will use the configuration obtained from 'newrelic-infra-checkers' action.
- uses: returntocorp/semgrep-action@v1
- uses: golangci/golangci-lint-action@v2
```
If local config file for the linters exist, the ones in this repository won't overwrite them.
## Support
Expand Down
17 changes: 17 additions & 0 deletions action.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ set -o pipefail
[[ -n $GITHUB_ACTION_PATH ]] || GITHUB_ACTION_PATH=$(pwd)
[[ -n $SEMGREP_APPEND ]] || SEMGREP_APPEND="true"
[[ -n $GOLANGCI_LINT_CONFIG ]] || GOLANGCI_LINT_CONFIG="golangci-lint-limited"
[[ -n $RT_DICTIONARY ]] || RT_DICTIONARY="rt-dictionary"

echo "Using $GOLANGCI_LINT_CONFIG golangci-lint configuration folder"

Expand Down Expand Up @@ -43,4 +44,20 @@ do
fi
done


echo "Using $RT_DICTIONARY release toolkit dictionary folder"

find $GITHUB_ACTION_PATH/$RT_DICTIONARY -type f | while read -r file
do
fileBasename=$(basename $file)

if [[ ! -f "$fileBasename" ]]
then
echo "ℹ️ Copying $fileBasename file to repo root directory"
cp "$file" "$fileBasename"
else
echo "ℹ️ Local $fileBasename file detected skipping overwrite"
fi
done

echo "ℹ️ Configuration files correctly copied"
5 changes: 5 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ inputs:
description: Set it to use a different folder for golangci-lint settings, by default it uses golangci-lint-limited.
required: false
default: golangci-lint-limited
rt-dictionary:
description: Set it to use a different folder for release toolkit dictionary, by default it uses rt-dictionary.
required: false
default: rt-dictionary
runs:
using: "composite"
steps:
Expand All @@ -22,3 +26,4 @@ runs:
env:
SEMGREP_APPEND: ${{ inputs.semgrep-append }}
GOLANGCI_LINT_CONFIG: ${{ inputs.golangci-lint-config }}
RT_DICTIONARY: ${{ inputs.rt-dictionary }}
24 changes: 24 additions & 0 deletions rt-dictionary/.rt-dictionary.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# This file is a dictionary used by the [link-dependencies](https://github.com/newrelic/release-toolkit/tree/main/link-dependencies) action.
dictionary:
newrelic/infrastructure: "https://github.com/newrelic/infrastructure-agent/releases/tag/{{.To}}"
newrelic/nri-apache: "https://github.com/newrelic/nri-apache/releases/tag/{{.To}}"
newrelic/nri-cassandra: "https://github.com/newrelic/nri-cassandra/releases/tag/{{.To}}"
newrelic/nri-consul: "https://github.com/newrelic/nri-consul/releases/tag/{{.To}}"
newrelic/nri-couchbase: "https://github.com/newrelic/nri-couchbase/releases/tag/{{.To}}"
newrelic/nri-discovery-kubernetes: "https://github.com/newrelic/nri-discovery-kubernetes/releases/tag/{{.To}}"
newrelic/nri-ecs: "https://github.com/newrelic/nri-ecs/releases/tag/{{.To}}"
newrelic/nri-elasticsearch: "https://github.com/newrelic/nri-elasticsearch/releases/tag/{{.To}}"
newrelic/nri-f5: "https://github.com/newrelic/nri-f5/releases/tag/{{.To}}"
newrelic/nri-haproxy: "https://github.com/newrelic/nri-haproxy/releases/tag/{{.To}}"
newrelic/nri-jmx: "https://github.com/newrelic/nri-jmx/releases/tag/{{.To}}"
newrelic/nri-kafka: "https://github.com/newrelic/nri-kafka/releases/tag/{{.To}}"
newrelic/nri-memcached: "https://github.com/newrelic/nri-memcached/releases/tag/{{.To}}"
newrelic/nri-mongodb: "https://github.com/newrelic/nri-mongodb/releases/tag/{{.To}}"
newrelic/nri-mssql: "https://github.com/newrelic/nri-mssql/releases/tag/{{.To}}"
newrelic/nri-mysql: "https://github.com/newrelic/nri-mysql/releases/tag/{{.To}}"
newrelic/nri-nagios: "https://github.com/newrelic/nri-nagios/releases/tag/{{.To}}"
newrelic/nri-nginx: "https://github.com/newrelic/nri-nginx/releases/tag/{{.To}}"
newrelic/nri-postgresql: "https://github.com/newrelic/nri-postgresql/releases/tag/{{.To}}"
newrelic/nri-rabbitmq: "https://github.com/newrelic/nri-rabbitmq/releases/tag/{{.To}}"
newrelic/nri-redis: "https://github.com/newrelic/nri-redis/releases/tag/{{.To}}"
newrelic/nrjmx: "https://github.com/newrelic/nrjmx/releases/tag/{{.To}}"
2 changes: 2 additions & 0 deletions test/data/rt-dictionary.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
dictionary:
test: "link"

0 comments on commit ca7ab5b

Please sign in to comment.