Skip to content

Commit

Permalink
Check out newrelic-java-agent and reference locally
Browse files Browse the repository at this point in the history
  • Loading branch information
elaguerta-nr committed Nov 14, 2023
1 parent a57d1d2 commit 7399846
Showing 1 changed file with 67 additions and 60 deletions.
127 changes: 67 additions & 60 deletions .github/workflows/fossa-gradle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,67 +19,74 @@ jobs:
fail-fast: false

steps:
- uses: actions/checkout@v3
- name: Checkout this repo
uses: actions/checkout@v4
- name: Checkout newrelic/newrelic-java-agent
uses: actions/checkout@v4
with:
repository: newrelic/newrelic-java-agent
path: newrelic-java-agent
- name: Setup java agent environment
uses: newrelic/newrelic-java-agent/.github/actions/setup-environment
- id: fossa-list-targets
name: Run fossa list-targets
run: |
curl -H 'Cache-Control: no-cache' https://raw.githubusercontent.com/fossas/fossa-cli/master/install-latest.sh | bash
export LIST_TARGETS_OUT_FILE=${{ runner.temp }}/list-targets_out.txt
export LIST_TARGETS_ERR_FILE=${{ runner.temp }}/list-targets_err.txt
uses: newrelic-java-agent/.github/actions/setup-environment
run: ls
# - id: fossa-list-targets
# name: Run fossa list-targets
# run: |
# curl -H 'Cache-Control: no-cache' https://raw.githubusercontent.com/fossas/fossa-cli/master/install-latest.sh | bash
# export LIST_TARGETS_OUT_FILE=${{ runner.temp }}/list-targets_out.txt
# export LIST_TARGETS_ERR_FILE=${{ runner.temp }}/list-targets_err.txt

fossa list-targets --format text 1>$LIST_TARGETS_OUT_FILE 2>$LIST_TARGETS_ERR_FILE
# fossa list-targets --format text 1>$LIST_TARGETS_OUT_FILE 2>$LIST_TARGETS_ERR_FILE

if [[ $(grep -i "error" $LIST_TARGETS_ERR_FILE | wc -l) -gt 0 ]]
then
echo "::error::fossa list-targets ran with errors."
cat $LIST_TARGETS_ERR_FILE
echo "HAS_FOSSA_TARGETS=Error" >> "$GITHUB_OUTPUT"
elif [[ $(cat $LIST_TARGETS_OUT_FILE | wc -l) -gt 0 ]]
then
echo "::notice::Fossa found analysis targets."
cat $LIST_TARGETS_OUT_FILE
echo "HAS_FOSSA_TARGETS=True" >> "$GITHUB_OUTPUT"
else
echo "::warning::Fossa did not find any analysis targets."
echo "HAS_FOSSA_TARGETS=False" >> "$GITHUB_OUTPUT"
fi
- name: Set hasFossaTargets custom property
run: |
curl -L \
-X PATCH \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer $ORG_ADMIN_PAT" \
-H "X-GitHub-Api-Version: 2022-11-28" \
https://api.github.com/orgs/$ORG/properties/values \
-d '{"repository_names":["'"${REPO##*/}"'"],"properties":[{"property_name":"hasFossaTargets","value":"'"${{ steps.fossa-list-targets.outputs.HAS_FOSSA_TARGETS }}"'"}]}'
- id: fossa-analyze
name: Run fossa analyze
if: ${{ steps.fossa-list-targets.outputs.HAS_FOSSA_TARGETS == 'True'}}
run: |
export ANALYZE_OUT_FILE=${{ runner.temp }}/analyze_out.txt
export ANALZYE_ERR_FILE=${{ runner.temp }}/analyze_err.txt
fossa analyze --policy='New Relic Public Github' 1>$ANALYZE_OUT_FILE 2>$ANALZYE_ERR_FILE
if [[ $(grep -i "error" $ANALYZE_ERR_FILE | wc -l) -gt 0 ]]
then
echo "::error::fossa analyze ran with errors."
cat $ANALYZE_ERR_FILE
echo "FOSSA_ANALYZE_RESULT=Error" >> "$GITHUB_OUTPUT"
else
cat $ANALYZE_OUT_FILE
echo "FOSSA_ANALYZE_RESULT=Success" >> "$GITHUB_OUTPUT"
fi
- name: Set fossaAnalyzeResult custom property
run: |
curl -L \
-X PATCH \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer $ORG_ADMIN_PAT" \
-H "X-GitHub-Api-Version: 2022-11-28" \
https://api.github.com/orgs/$ORG/properties/values \
-d '{"repository_names":["'"${REPO##*/}"'"],"properties":[{"property_name":"fossaAnalyzeResult","value":"'"${{ steps.fossa-analyze.outputs.FOSSA_ANALYZE_RESULT }}"'"}]}'
- name: Exit
if: ${{ steps.fossa-list-targets.outputs.HAS_FOSSA_TARGETS == 'Error' || steps.fossa-analyze.outputs.FOSSA_ANALYZE_RESULT == 'Error' }}
run: exit 1
# if [[ $(grep -i "error" $LIST_TARGETS_ERR_FILE | wc -l) -gt 0 ]]
# then
# echo "::error::fossa list-targets ran with errors."
# cat $LIST_TARGETS_ERR_FILE
# echo "HAS_FOSSA_TARGETS=Error" >> "$GITHUB_OUTPUT"
# elif [[ $(cat $LIST_TARGETS_OUT_FILE | wc -l) -gt 0 ]]
# then
# echo "::notice::Fossa found analysis targets."
# cat $LIST_TARGETS_OUT_FILE
# echo "HAS_FOSSA_TARGETS=True" >> "$GITHUB_OUTPUT"
# else
# echo "::warning::Fossa did not find any analysis targets."
# echo "HAS_FOSSA_TARGETS=False" >> "$GITHUB_OUTPUT"
# fi
# - name: Set hasFossaTargets custom property
# run: |
# curl -L \
# -X PATCH \
# -H "Accept: application/vnd.github+json" \
# -H "Authorization: Bearer $ORG_ADMIN_PAT" \
# -H "X-GitHub-Api-Version: 2022-11-28" \
# https://api.github.com/orgs/$ORG/properties/values \
# -d '{"repository_names":["'"${REPO##*/}"'"],"properties":[{"property_name":"hasFossaTargets","value":"'"${{ steps.fossa-list-targets.outputs.HAS_FOSSA_TARGETS }}"'"}]}'
# - id: fossa-analyze
# name: Run fossa analyze
# if: ${{ steps.fossa-list-targets.outputs.HAS_FOSSA_TARGETS == 'True'}}
# run: |
# export ANALYZE_OUT_FILE=${{ runner.temp }}/analyze_out.txt
# export ANALZYE_ERR_FILE=${{ runner.temp }}/analyze_err.txt
# fossa analyze --policy='New Relic Public Github' 1>$ANALYZE_OUT_FILE 2>$ANALZYE_ERR_FILE
# if [[ $(grep -i "error" $ANALYZE_ERR_FILE | wc -l) -gt 0 ]]
# then
# echo "::error::fossa analyze ran with errors."
# cat $ANALYZE_ERR_FILE
# echo "FOSSA_ANALYZE_RESULT=Error" >> "$GITHUB_OUTPUT"
# else
# cat $ANALYZE_OUT_FILE
# echo "FOSSA_ANALYZE_RESULT=Success" >> "$GITHUB_OUTPUT"
# fi
# - name: Set fossaAnalyzeResult custom property
# run: |
# curl -L \
# -X PATCH \
# -H "Accept: application/vnd.github+json" \
# -H "Authorization: Bearer $ORG_ADMIN_PAT" \
# -H "X-GitHub-Api-Version: 2022-11-28" \
# https://api.github.com/orgs/$ORG/properties/values \
# -d '{"repository_names":["'"${REPO##*/}"'"],"properties":[{"property_name":"fossaAnalyzeResult","value":"'"${{ steps.fossa-analyze.outputs.FOSSA_ANALYZE_RESULT }}"'"}]}'
# - name: Exit
# if: ${{ steps.fossa-list-targets.outputs.HAS_FOSSA_TARGETS == 'Error' || steps.fossa-analyze.outputs.FOSSA_ANALYZE_RESULT == 'Error' }}
# run: exit 1

0 comments on commit 7399846

Please sign in to comment.