From 5169af65e48905c618780af62dacc7d2b1df7083 Mon Sep 17 00:00:00 2001 From: Elaine Laguerta Date: Tue, 31 Oct 2023 11:44:24 -0700 Subject: [PATCH 01/72] Add basic fossa workflow --- .github/fossa.yml | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 .github/fossa.yml diff --git a/.github/fossa.yml b/.github/fossa.yml new file mode 100644 index 0000000..08f2b13 --- /dev/null +++ b/.github/fossa.yml @@ -0,0 +1,25 @@ +name: FOSSA CLI Analysis +on: + push: + branches: [ $default-branch ] + pull_request: + branches: [ $default-branch ] + workflow_dispatch: + +jobs: + fossa: + runs-on: ubuntu-latest + env: + FOSSA_API_KEY: ${{secrets.FOSSA_API_KEY}} + + strategy: + fail-fast: false + + steps: + - uses: actions/checkout@v3 + + - name: Running FOSSA CLI + run: | + curl -H 'Cache-Control: no-cache' https://raw.githubusercontent.com/fossas/fossa-cli/master/install-latest.sh | bash + fossa --version + fossa analyze From 02e6d0c51c9e099a71b529100207d35c2d0dd988 Mon Sep 17 00:00:00 2001 From: Elaine Laguerta Date: Tue, 31 Oct 2023 11:48:26 -0700 Subject: [PATCH 02/72] fixup: move fossa workflow into .github/workflows --- .github/workflows/fossa.yml | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 .github/workflows/fossa.yml diff --git a/.github/workflows/fossa.yml b/.github/workflows/fossa.yml new file mode 100644 index 0000000..08f2b13 --- /dev/null +++ b/.github/workflows/fossa.yml @@ -0,0 +1,25 @@ +name: FOSSA CLI Analysis +on: + push: + branches: [ $default-branch ] + pull_request: + branches: [ $default-branch ] + workflow_dispatch: + +jobs: + fossa: + runs-on: ubuntu-latest + env: + FOSSA_API_KEY: ${{secrets.FOSSA_API_KEY}} + + strategy: + fail-fast: false + + steps: + - uses: actions/checkout@v3 + + - name: Running FOSSA CLI + run: | + curl -H 'Cache-Control: no-cache' https://raw.githubusercontent.com/fossas/fossa-cli/master/install-latest.sh | bash + fossa --version + fossa analyze From c12cceeaf92cdf1f52af1d9ed9f5e6c45c2d6f72 Mon Sep 17 00:00:00 2001 From: elaguerta-nr <148913307+elaguerta-nr@users.noreply.github.com> Date: Wed, 1 Nov 2023 09:37:38 -0700 Subject: [PATCH 03/72] Delete .github/fossa.yml This file was moved into .github/workflows --- .github/fossa.yml | 25 ------------------------- 1 file changed, 25 deletions(-) delete mode 100644 .github/fossa.yml diff --git a/.github/fossa.yml b/.github/fossa.yml deleted file mode 100644 index 08f2b13..0000000 --- a/.github/fossa.yml +++ /dev/null @@ -1,25 +0,0 @@ -name: FOSSA CLI Analysis -on: - push: - branches: [ $default-branch ] - pull_request: - branches: [ $default-branch ] - workflow_dispatch: - -jobs: - fossa: - runs-on: ubuntu-latest - env: - FOSSA_API_KEY: ${{secrets.FOSSA_API_KEY}} - - strategy: - fail-fast: false - - steps: - - uses: actions/checkout@v3 - - - name: Running FOSSA CLI - run: | - curl -H 'Cache-Control: no-cache' https://raw.githubusercontent.com/fossas/fossa-cli/master/install-latest.sh | bash - fossa --version - fossa analyze From 10154ef93d93cbf6586ab210f02b9ddbc48e87b3 Mon Sep 17 00:00:00 2001 From: elaguerta-nr <148913307+elaguerta-nr@users.noreply.github.com> Date: Wed, 1 Nov 2023 09:44:00 -0700 Subject: [PATCH 04/72] Check for fossa targets before running fossa analyze --- .github/workflows/fossa.yml | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/.github/workflows/fossa.yml b/.github/workflows/fossa.yml index 08f2b13..28cdbf0 100644 --- a/.github/workflows/fossa.yml +++ b/.github/workflows/fossa.yml @@ -15,11 +15,12 @@ jobs: strategy: fail-fast: false - steps: - - uses: actions/checkout@v3 - - - name: Running FOSSA CLI + steps: + - name: Run fossa run: | curl -H 'Cache-Control: no-cache' https://raw.githubusercontent.com/fossas/fossa-cli/master/install-latest.sh | bash - fossa --version - fossa analyze + if [[ $(fossa list-targets --format=text) ]]; then + fossa analyze + else + exit 0 + fi From 80ff43106441c6d08a9b8172a7d81055040a4798 Mon Sep 17 00:00:00 2001 From: elaguerta-nr <148913307+elaguerta-nr@users.noreply.github.com> Date: Wed, 1 Nov 2023 11:08:17 -0700 Subject: [PATCH 05/72] Fixup: capture output as text --- .github/workflows/fossa.yml | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/.github/workflows/fossa.yml b/.github/workflows/fossa.yml index 28cdbf0..224a725 100644 --- a/.github/workflows/fossa.yml +++ b/.github/workflows/fossa.yml @@ -19,8 +19,10 @@ jobs: - name: Run fossa run: | curl -H 'Cache-Control: no-cache' https://raw.githubusercontent.com/fossas/fossa-cli/master/install-latest.sh | bash - if [[ $(fossa list-targets --format=text) ]]; then - fossa analyze + output="$(fossa list-targets --format=text)" + if [[ -n $output ]] + then + printf -- "%s\n" "$output" else - exit 0 + printf -- "Fossa did not find any analysis targets.\n" fi From 433e611c84612497aa33c04119acb0ce70f02f76 Mon Sep 17 00:00:00 2001 From: elaguerta-nr <148913307+elaguerta-nr@users.noreply.github.com> Date: Wed, 1 Nov 2023 11:16:33 -0700 Subject: [PATCH 06/72] Try adding checkout action as context --- .github/workflows/fossa.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/fossa.yml b/.github/workflows/fossa.yml index 224a725..31e517c 100644 --- a/.github/workflows/fossa.yml +++ b/.github/workflows/fossa.yml @@ -16,6 +16,7 @@ jobs: fail-fast: false steps: + - uses: actions/checkout@v3 - name: Run fossa run: | curl -H 'Cache-Control: no-cache' https://raw.githubusercontent.com/fossas/fossa-cli/master/install-latest.sh | bash From 3b784d3fa5d10016216cc25907fc4b4a61d3f859 Mon Sep 17 00:00:00 2001 From: elaguerta-nr <148913307+elaguerta-nr@users.noreply.github.com> Date: Wed, 1 Nov 2023 12:10:59 -0700 Subject: [PATCH 07/72] Add fossa analyze step --- .github/workflows/fossa.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/fossa.yml b/.github/workflows/fossa.yml index 31e517c..435f601 100644 --- a/.github/workflows/fossa.yml +++ b/.github/workflows/fossa.yml @@ -24,6 +24,7 @@ jobs: if [[ -n $output ]] then printf -- "%s\n" "$output" + fossa analyze else printf -- "Fossa did not find any analysis targets.\n" fi From 49dae3ed81497afb4622443276d22cbdd7692de8 Mon Sep 17 00:00:00 2001 From: Elaine Laguerta Date: Thu, 2 Nov 2023 11:41:25 -0700 Subject: [PATCH 08/72] Try setting zeroFossaTargets property if no targets found --- .github/workflows/fossa.yml | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/.github/workflows/fossa.yml b/.github/workflows/fossa.yml index 435f601..3d4e537 100644 --- a/.github/workflows/fossa.yml +++ b/.github/workflows/fossa.yml @@ -26,5 +26,12 @@ jobs: printf -- "%s\n" "$output" fossa analyze else + curl -L \ + -X PATCH \ + -H "Accept: application/vnd.github+json" \ + -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \ + -H "X-GitHub-Api-Version: 2022-11-28" \ + https://api.github.com/orgs/${{ github.repository_owner }}/properties/values \ + -d '{"repository_names":[${{ github.repository }}],"properties":[{"property_name":"zeroFossaTargets","value":"True"}]}' printf -- "Fossa did not find any analysis targets.\n" - fi + fi From 0a9a82357f16526b061d4fbaf02dfc6438c2192c Mon Sep 17 00:00:00 2001 From: elaguerta-nr <148913307+elaguerta-nr@users.noreply.github.com> Date: Thu, 2 Nov 2023 11:45:52 -0700 Subject: [PATCH 09/72] Fixup: indentation --- .github/workflows/fossa.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/fossa.yml b/.github/workflows/fossa.yml index 3d4e537..632930e 100644 --- a/.github/workflows/fossa.yml +++ b/.github/workflows/fossa.yml @@ -34,4 +34,4 @@ jobs: https://api.github.com/orgs/${{ github.repository_owner }}/properties/values \ -d '{"repository_names":[${{ github.repository }}],"properties":[{"property_name":"zeroFossaTargets","value":"True"}]}' printf -- "Fossa did not find any analysis targets.\n" - fi + fi From fe24cf52bfb7d2d425efa05881a9030f63cec90a Mon Sep 17 00:00:00 2001 From: elaguerta-nr <148913307+elaguerta-nr@users.noreply.github.com> Date: Thu, 2 Nov 2023 11:52:43 -0700 Subject: [PATCH 10/72] If targets found, remove zeroFossaTargets custom property --- .github/workflows/fossa.yml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/.github/workflows/fossa.yml b/.github/workflows/fossa.yml index 632930e..0b8aa79 100644 --- a/.github/workflows/fossa.yml +++ b/.github/workflows/fossa.yml @@ -25,6 +25,13 @@ jobs: then printf -- "%s\n" "$output" fossa analyze + curl -L \ + -X PATCH \ + -H "Accept: application/vnd.github+json" \ + -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \ + -H "X-GitHub-Api-Version: 2022-11-28" \ + https://api.github.com/orgs/${{ github.repository_owner }}/properties/values \ + -d '{"repository_names":[${{ github.repository }}],"properties":[{"property_name":"zeroFossaTargets","value":"null"}]}' else curl -L \ -X PATCH \ From 7ac770eaf69c86396ebc5ac077de22e3b7a04389 Mon Sep 17 00:00:00 2001 From: Elaine Laguerta Date: Thu, 2 Nov 2023 12:38:08 -0700 Subject: [PATCH 11/72] Try adding write-all permissions --- .github/workflows/fossa.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/fossa.yml b/.github/workflows/fossa.yml index 0b8aa79..335d507 100644 --- a/.github/workflows/fossa.yml +++ b/.github/workflows/fossa.yml @@ -8,6 +8,7 @@ on: jobs: fossa: + permissions: write-all runs-on: ubuntu-latest env: FOSSA_API_KEY: ${{secrets.FOSSA_API_KEY}} From 2b1f8191c43a57ee0de863575d47b6358c534cca Mon Sep 17 00:00:00 2001 From: Elaine Laguerta Date: Thu, 2 Nov 2023 12:44:54 -0700 Subject: [PATCH 12/72] Revert "Try adding write-all permissions" This reverts commit 7ac770eaf69c86396ebc5ac077de22e3b7a04389. --- .github/workflows/fossa.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/fossa.yml b/.github/workflows/fossa.yml index 335d507..0b8aa79 100644 --- a/.github/workflows/fossa.yml +++ b/.github/workflows/fossa.yml @@ -8,7 +8,6 @@ on: jobs: fossa: - permissions: write-all runs-on: ubuntu-latest env: FOSSA_API_KEY: ${{secrets.FOSSA_API_KEY}} From 566d8385f5e4449185044a4d08f6d54c377e3a9f Mon Sep 17 00:00:00 2001 From: Elaine Laguerta Date: Thu, 2 Nov 2023 12:52:21 -0700 Subject: [PATCH 13/72] Try using a PAT --- .github/workflows/fossa.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/fossa.yml b/.github/workflows/fossa.yml index 0b8aa79..ccbf7b6 100644 --- a/.github/workflows/fossa.yml +++ b/.github/workflows/fossa.yml @@ -36,7 +36,7 @@ jobs: curl -L \ -X PATCH \ -H "Accept: application/vnd.github+json" \ - -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \ + -H "Authorization: Bearer ${{ secrets.ELAGUERTA_PAT }}" \ -H "X-GitHub-Api-Version: 2022-11-28" \ https://api.github.com/orgs/${{ github.repository_owner }}/properties/values \ -d '{"repository_names":[${{ github.repository }}],"properties":[{"property_name":"zeroFossaTargets","value":"True"}]}' From f98fd24962732158a140b8a272a206f14d03bbe5 Mon Sep 17 00:00:00 2001 From: Elaine Laguerta Date: Thu, 2 Nov 2023 14:20:05 -0700 Subject: [PATCH 14/72] Specify a PAT with org-admin access for updating custom properties --- .github/workflows/fossa.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/fossa.yml b/.github/workflows/fossa.yml index ccbf7b6..78f1752 100644 --- a/.github/workflows/fossa.yml +++ b/.github/workflows/fossa.yml @@ -28,7 +28,7 @@ jobs: curl -L \ -X PATCH \ -H "Accept: application/vnd.github+json" \ - -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \ + -H "Authorization: Bearer ${{ secrets.ELAGUERTA_PAT }}" \ -H "X-GitHub-Api-Version: 2022-11-28" \ https://api.github.com/orgs/${{ github.repository_owner }}/properties/values \ -d '{"repository_names":[${{ github.repository }}],"properties":[{"property_name":"zeroFossaTargets","value":"null"}]}' From a94d81fdae248fdf84dbc1754f048ac40a3bce4f Mon Sep 17 00:00:00 2001 From: Elaine Laguerta Date: Thu, 2 Nov 2023 14:40:30 -0700 Subject: [PATCH 15/72] Fixup: Use environment variables to save context vars --- .github/workflows/fossa.yml | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/.github/workflows/fossa.yml b/.github/workflows/fossa.yml index 78f1752..2ffbed7 100644 --- a/.github/workflows/fossa.yml +++ b/.github/workflows/fossa.yml @@ -11,6 +11,9 @@ jobs: runs-on: ubuntu-latest env: FOSSA_API_KEY: ${{secrets.FOSSA_API_KEY}} + ORG: ${{ github.repository_owner }} + REPO: ${{ github.repository }} + ORG_ADMIN_PAT: ${{ secrets.ELAGUERTA_PAT }} strategy: fail-fast: false @@ -28,17 +31,17 @@ jobs: curl -L \ -X PATCH \ -H "Accept: application/vnd.github+json" \ - -H "Authorization: Bearer ${{ secrets.ELAGUERTA_PAT }}" \ + -H "Authorization: Bearer $ORG_ADMIN_PAT" \ -H "X-GitHub-Api-Version: 2022-11-28" \ - https://api.github.com/orgs/${{ github.repository_owner }}/properties/values \ - -d '{"repository_names":[${{ github.repository }}],"properties":[{"property_name":"zeroFossaTargets","value":"null"}]}' + https://api.github.com/orgs/$ORG/properties/values \ + -d '{"repository_names":[$REPO],"properties":[{"property_name":"hasFossaTargets","value":"True"}]}' else curl -L \ -X PATCH \ -H "Accept: application/vnd.github+json" \ - -H "Authorization: Bearer ${{ secrets.ELAGUERTA_PAT }}" \ + -H "Authorization: Bearer $ORG_ADMIN_PAT" \ -H "X-GitHub-Api-Version: 2022-11-28" \ - https://api.github.com/orgs/${{ github.repository_owner }}/properties/values \ - -d '{"repository_names":[${{ github.repository }}],"properties":[{"property_name":"zeroFossaTargets","value":"True"}]}' + https://api.github.com/orgs/$ORG/properties/values \ + -d '{"repository_names":[$REPO],"properties":[{"property_name":"hasFossaTargets","value":"False"}]}' printf -- "Fossa did not find any analysis targets.\n" fi From 899ebf1a2388e5cb21d31b349c1d40705efddf1c Mon Sep 17 00:00:00 2001 From: elaguerta-nr <148913307+elaguerta-nr@users.noreply.github.com> Date: Thu, 2 Nov 2023 14:48:06 -0700 Subject: [PATCH 16/72] Fixup: double quotes to expand env variables --- .github/workflows/fossa.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/fossa.yml b/.github/workflows/fossa.yml index 2ffbed7..9d5df60 100644 --- a/.github/workflows/fossa.yml +++ b/.github/workflows/fossa.yml @@ -34,7 +34,7 @@ jobs: -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":"True"}]}' + -d "{"repository_names":[$REPO],"properties":[{"property_name":"hasFossaTargets","value":"True"}]}" else curl -L \ -X PATCH \ @@ -42,6 +42,6 @@ jobs: -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":"False"}]}' + -d "{"repository_names":[$REPO],"properties":[{"property_name":"hasFossaTargets","value":"False"}]}" printf -- "Fossa did not find any analysis targets.\n" fi From 2f3e0e2b1c6f7ffdeaa8811272c1b39afe9cdf04 Mon Sep 17 00:00:00 2001 From: elaguerta-nr <148913307+elaguerta-nr@users.noreply.github.com> Date: Thu, 2 Nov 2023 14:51:29 -0700 Subject: [PATCH 17/72] debug: echo json data --- .github/workflows/fossa.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/fossa.yml b/.github/workflows/fossa.yml index 9d5df60..fe0b36e 100644 --- a/.github/workflows/fossa.yml +++ b/.github/workflows/fossa.yml @@ -35,6 +35,7 @@ jobs: -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":"True"}]}" + echo "{"repository_names":[$REPO],"properties":[{"property_name":"hasFossaTargets","value":"True"}]}" else curl -L \ -X PATCH \ From 741755148517a4722b99952e7a40d697a9f33775 Mon Sep 17 00:00:00 2001 From: elaguerta-nr <148913307+elaguerta-nr@users.noreply.github.com> Date: Thu, 2 Nov 2023 15:47:00 -0700 Subject: [PATCH 18/72] Fixup: remove owner from repo var --- .github/workflows/fossa.yml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/.github/workflows/fossa.yml b/.github/workflows/fossa.yml index fe0b36e..efa7243 100644 --- a/.github/workflows/fossa.yml +++ b/.github/workflows/fossa.yml @@ -34,8 +34,7 @@ jobs: -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":"True"}]}" - echo "{"repository_names":[$REPO],"properties":[{"property_name":"hasFossaTargets","value":"True"}]}" + -d '{"repository_names":["'"${REPO##*/}"'"],"properties":[{"property_name":"hasFossaTargets","value":"True"}]}' else curl -L \ -X PATCH \ @@ -43,6 +42,6 @@ jobs: -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":"False"}]}" + -d '{"repository_names":["'"${REPO##*/}"'"],"properties":[{"property_name":"hasFossaTargets","value":"False"}]}' printf -- "Fossa did not find any analysis targets.\n" fi From abe76546b225fdacf4defd67d5c39eff4b24fab6 Mon Sep 17 00:00:00 2001 From: elaguerta-nr <148913307+elaguerta-nr@users.noreply.github.com> Date: Thu, 2 Nov 2023 16:13:54 -0700 Subject: [PATCH 19/72] Consolidate curl call to update custom property --- .github/workflows/fossa.yml | 23 +++++++++-------------- 1 file changed, 9 insertions(+), 14 deletions(-) diff --git a/.github/workflows/fossa.yml b/.github/workflows/fossa.yml index efa7243..35ece9b 100644 --- a/.github/workflows/fossa.yml +++ b/.github/workflows/fossa.yml @@ -28,20 +28,15 @@ jobs: then printf -- "%s\n" "$output" fossa analyze - 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":"True"}]}' + export HAS_FOSSA_TARGETS="True" else - 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":"False"}]}' printf -- "Fossa did not find any analysis targets.\n" + export HAS_FOSSA_TARGETS="False" fi + 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":"'"${HAS_FOSSA_TARGETS}"'"}]}' From b310dbc1c0981674382bbabf71d5440a9bcfadcc Mon Sep 17 00:00:00 2001 From: Elaine Laguerta Date: Fri, 3 Nov 2023 14:52:40 -0700 Subject: [PATCH 20/72] Feat: check for errors from fossa list-targets --- .github/workflows/fossa.yml | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/.github/workflows/fossa.yml b/.github/workflows/fossa.yml index 35ece9b..7f32901 100644 --- a/.github/workflows/fossa.yml +++ b/.github/workflows/fossa.yml @@ -23,10 +23,13 @@ jobs: - name: Run fossa run: | curl -H 'Cache-Control: no-cache' https://raw.githubusercontent.com/fossas/fossa-cli/master/install-latest.sh | bash - output="$(fossa list-targets --format=text)" - if [[ -n $output ]] + list_targets_output = "$(fossa list-targets 2>&1)" + printf -- "%s\n" "$list_targets_output" + + if [[ echo $list_targets_output | grep 'Error' ]] then - printf -- "%s\n" "$output" + export HAS_FOSSA_TARGETS="Error" + elif [[ echo $list_targets_output | grep 'Found target' ]] fossa analyze export HAS_FOSSA_TARGETS="True" else From 781cd997882d8af3ea700b5fdbc846909251e221 Mon Sep 17 00:00:00 2001 From: Elaine Laguerta Date: Fri, 3 Nov 2023 15:09:11 -0700 Subject: [PATCH 21/72] fixup: extra spaces --- .github/workflows/fossa.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/fossa.yml b/.github/workflows/fossa.yml index 7f32901..b82fdcc 100644 --- a/.github/workflows/fossa.yml +++ b/.github/workflows/fossa.yml @@ -23,7 +23,7 @@ jobs: - name: Run fossa run: | curl -H 'Cache-Control: no-cache' https://raw.githubusercontent.com/fossas/fossa-cli/master/install-latest.sh | bash - list_targets_output = "$(fossa list-targets 2>&1)" + list_targets_output="$(fossa list-targets 2>&1)" printf -- "%s\n" "$list_targets_output" if [[ echo $list_targets_output | grep 'Error' ]] From 90b7456750b3b0c7caaee72d86048d13ce229e5f Mon Sep 17 00:00:00 2001 From: elaguerta-nr <148913307+elaguerta-nr@users.noreply.github.com> Date: Mon, 6 Nov 2023 17:20:27 -0800 Subject: [PATCH 22/72] Update fossa.yml --- .github/workflows/fossa.yml | 28 +++++++++++++++++++++------- 1 file changed, 21 insertions(+), 7 deletions(-) diff --git a/.github/workflows/fossa.yml b/.github/workflows/fossa.yml index b82fdcc..9461850 100644 --- a/.github/workflows/fossa.yml +++ b/.github/workflows/fossa.yml @@ -20,26 +20,40 @@ jobs: steps: - uses: actions/checkout@v3 - - name: Run fossa + - 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 list_targets_output="$(fossa list-targets 2>&1)" printf -- "%s\n" "$list_targets_output" - if [[ echo $list_targets_output | grep 'Error' ]] + list_targets_output="$(fossa list-targets 2>&1)" + printf -- "%s\n" "$list_targets_output" + + if [[ $(echo $list_targets_output | grep "Error" | wc -l) -gt 0 ]] + then + "HAS_FOSSA_TARGETS=Error" >> "$GITHUB_OUTPUT" + elif [[ $(echo $list_targets_output | grep "Found target" | wc -l) -gt 0 ]] then - export HAS_FOSSA_TARGETS="Error" - elif [[ echo $list_targets_output | grep 'Found target' ]] fossa analyze - export HAS_FOSSA_TARGETS="True" + "HAS_FOSSA_TARGETS=True" >> "$GITHUB_OUTPUT" else printf -- "Fossa did not find any analysis targets.\n" - export HAS_FOSSA_TARGETS="False" + "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":"'"${HAS_FOSSA_TARGETS}"'"}]}' + -d '{"repository_names":["'"${REPO##*/}"'"],"properties":[{"property_name":"hasFossaTargets","value":"'"${{ steps.fossa-list-targets.outputs.HAS_FOSSA_TARGETS }}"'"}]}' + - name: Fail if fossa list-targets had an error + if: ${{ steps.fossa-list-targets.outputs.HAS_FOSSA_TARGETS == 'Error'}} + run: exit 1 + - name: Run fossa analyze + if: ${{ steps.fossa-list-targets.outputs.HAS_FOSSA_TARGETS == 'True'}} + run: fossa analyze + From 3c32b3c6330af8b4a823294e9db68e9acaea9530 Mon Sep 17 00:00:00 2001 From: elaguerta-nr <148913307+elaguerta-nr@users.noreply.github.com> Date: Mon, 6 Nov 2023 17:48:37 -0800 Subject: [PATCH 23/72] Fixup: try running list-targets with set -e --- .github/workflows/fossa.yml | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/.github/workflows/fossa.yml b/.github/workflows/fossa.yml index 9461850..53f1fe3 100644 --- a/.github/workflows/fossa.yml +++ b/.github/workflows/fossa.yml @@ -24,10 +24,7 @@ jobs: name: Run fossa list-targets run: | curl -H 'Cache-Control: no-cache' https://raw.githubusercontent.com/fossas/fossa-cli/master/install-latest.sh | bash - list_targets_output="$(fossa list-targets 2>&1)" - printf -- "%s\n" "$list_targets_output" - - list_targets_output="$(fossa list-targets 2>&1)" + list_targets_output=$(set -e; fossa list-targets 2>&1) printf -- "%s\n" "$list_targets_output" if [[ $(echo $list_targets_output | grep "Error" | wc -l) -gt 0 ]] From 0a43319f1234331d8e2a9e80f0260a6d104a0a3d Mon Sep 17 00:00:00 2001 From: elaguerta-nr <148913307+elaguerta-nr@users.noreply.github.com> Date: Tue, 7 Nov 2023 10:17:52 -0800 Subject: [PATCH 24/72] Fixups: error handling and logging --- .github/workflows/fossa.yml | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/.github/workflows/fossa.yml b/.github/workflows/fossa.yml index 53f1fe3..0b6007a 100644 --- a/.github/workflows/fossa.yml +++ b/.github/workflows/fossa.yml @@ -24,19 +24,17 @@ jobs: name: Run fossa list-targets run: | curl -H 'Cache-Control: no-cache' https://raw.githubusercontent.com/fossas/fossa-cli/master/install-latest.sh | bash + echo "HAS_FOSSA_TARGETS=Error" >> "$GITHUB_OUTPUT" list_targets_output=$(set -e; fossa list-targets 2>&1) - printf -- "%s\n" "$list_targets_output" - if [[ $(echo $list_targets_output | grep "Error" | wc -l) -gt 0 ]] + if [[ $(echo $list_targets_output | grep "Found target" | wc -l) -gt 0 ]] then - "HAS_FOSSA_TARGETS=Error" >> "$GITHUB_OUTPUT" - elif [[ $(echo $list_targets_output | grep "Found target" | wc -l) -gt 0 ]] - then - fossa analyze - "HAS_FOSSA_TARGETS=True" >> "$GITHUB_OUTPUT" + echo "::notice::Fossa found analysis targets." + echo "::notice::$list_targets_output" + echo "HAS_FOSSA_TARGETS=True" >> "$GITHUB_OUTPUT" else - printf -- "Fossa did not find any analysis targets.\n" - "HAS_FOSSA_TARGETS=False" >> "$GITHUB_OUTPUT" + echo "::warning::Fossa did not find any analysis targets." + echo "HAS_FOSSA_TARGETS=False" >> "$GITHUB_OUTPUT" fi - name: Set hasFossaTargets custom property run: | @@ -47,9 +45,6 @@ jobs: -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 }}"'"}]}' - - name: Fail if fossa list-targets had an error - if: ${{ steps.fossa-list-targets.outputs.HAS_FOSSA_TARGETS == 'Error'}} - run: exit 1 - name: Run fossa analyze if: ${{ steps.fossa-list-targets.outputs.HAS_FOSSA_TARGETS == 'True'}} run: fossa analyze From 55b48959f2b999918ec197213f80d3afc98f53b7 Mon Sep 17 00:00:00 2001 From: elaguerta-nr <148913307+elaguerta-nr@users.noreply.github.com> Date: Tue, 7 Nov 2023 11:43:55 -0800 Subject: [PATCH 25/72] try removing set -e --- .github/workflows/fossa.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/fossa.yml b/.github/workflows/fossa.yml index 0b6007a..7eae529 100644 --- a/.github/workflows/fossa.yml +++ b/.github/workflows/fossa.yml @@ -25,7 +25,7 @@ jobs: run: | curl -H 'Cache-Control: no-cache' https://raw.githubusercontent.com/fossas/fossa-cli/master/install-latest.sh | bash echo "HAS_FOSSA_TARGETS=Error" >> "$GITHUB_OUTPUT" - list_targets_output=$(set -e; fossa list-targets 2>&1) + list_targets_output=$(fossa list-targets 2>&1) if [[ $(echo $list_targets_output | grep "Found target" | wc -l) -gt 0 ]] then From 31106797676c8e3ae8877bd7f5dc63f9ac681918 Mon Sep 17 00:00:00 2001 From: elaguerta-nr <148913307+elaguerta-nr@users.noreply.github.com> Date: Tue, 7 Nov 2023 11:54:19 -0800 Subject: [PATCH 26/72] Log list targets output --- .github/workflows/fossa.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/fossa.yml b/.github/workflows/fossa.yml index 7eae529..4387338 100644 --- a/.github/workflows/fossa.yml +++ b/.github/workflows/fossa.yml @@ -33,6 +33,7 @@ jobs: echo "::notice::$list_targets_output" echo "HAS_FOSSA_TARGETS=True" >> "$GITHUB_OUTPUT" else + echo "::notice::$list_targets_output" echo "::warning::Fossa did not find any analysis targets." echo "HAS_FOSSA_TARGETS=False" >> "$GITHUB_OUTPUT" fi From 0597c540f135a64c9a8101f0020dec50dfe658db Mon Sep 17 00:00:00 2001 From: elaguerta-nr <148913307+elaguerta-nr@users.noreply.github.com> Date: Tue, 7 Nov 2023 12:06:13 -0800 Subject: [PATCH 27/72] Check for "error" in list-targets --- .github/workflows/fossa.yml | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/.github/workflows/fossa.yml b/.github/workflows/fossa.yml index 4387338..39792e4 100644 --- a/.github/workflows/fossa.yml +++ b/.github/workflows/fossa.yml @@ -24,10 +24,13 @@ jobs: name: Run fossa list-targets run: | curl -H 'Cache-Control: no-cache' https://raw.githubusercontent.com/fossas/fossa-cli/master/install-latest.sh | bash - echo "HAS_FOSSA_TARGETS=Error" >> "$GITHUB_OUTPUT" list_targets_output=$(fossa list-targets 2>&1) - - if [[ $(echo $list_targets_output | grep "Found target" | wc -l) -gt 0 ]] + + if [[ $(echo $list_targets_output | grep "Error" | wc -l) -gt 0 ]] + then + echo "::error::Fossa list-targets ran with errors." + echo "HAS_FOSSA_TARGETS=Error" >> "$GITHUB_OUTPUT" + elif [[ $(echo $list_targets_output | grep "Found target" | wc -l) -gt 0 ]] then echo "::notice::Fossa found analysis targets." echo "::notice::$list_targets_output" From b98f4d82a7c42ae8066df93488389290ab27d24a Mon Sep 17 00:00:00 2001 From: elaguerta-nr <148913307+elaguerta-nr@users.noreply.github.com> Date: Tue, 7 Nov 2023 12:13:01 -0800 Subject: [PATCH 28/72] Add exit 1 condition if list-targets errored --- .github/workflows/fossa.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/fossa.yml b/.github/workflows/fossa.yml index 39792e4..f8217aa 100644 --- a/.github/workflows/fossa.yml +++ b/.github/workflows/fossa.yml @@ -52,4 +52,7 @@ jobs: - name: Run fossa analyze if: ${{ steps.fossa-list-targets.outputs.HAS_FOSSA_TARGETS == 'True'}} run: fossa analyze + - name: Exit + if: ${{ steps.fossa-list-targets.outputs.HAS_FOSSA_TARGETS == 'Error'}} + run: exit 1 From 99083647d6dd36d302d6b18d6c42c43c0f508a9d Mon Sep 17 00:00:00 2001 From: elaguerta-nr <148913307+elaguerta-nr@users.noreply.github.com> Date: Tue, 7 Nov 2023 12:36:31 -0800 Subject: [PATCH 29/72] Add logic for flagging on fossa analyze --- .github/workflows/fossa.yml | 30 ++++++++++++++++++++++++------ 1 file changed, 24 insertions(+), 6 deletions(-) diff --git a/.github/workflows/fossa.yml b/.github/workflows/fossa.yml index f8217aa..ebd5aa8 100644 --- a/.github/workflows/fossa.yml +++ b/.github/workflows/fossa.yml @@ -25,18 +25,17 @@ jobs: run: | curl -H 'Cache-Control: no-cache' https://raw.githubusercontent.com/fossas/fossa-cli/master/install-latest.sh | bash list_targets_output=$(fossa list-targets 2>&1) + echo "::notice::$list_targets_output" if [[ $(echo $list_targets_output | grep "Error" | wc -l) -gt 0 ]] then - echo "::error::Fossa list-targets ran with errors." + echo "::error::fossa list-targets ran with errors." echo "HAS_FOSSA_TARGETS=Error" >> "$GITHUB_OUTPUT" elif [[ $(echo $list_targets_output | grep "Found target" | wc -l) -gt 0 ]] then echo "::notice::Fossa found analysis targets." - echo "::notice::$list_targets_output" echo "HAS_FOSSA_TARGETS=True" >> "$GITHUB_OUTPUT" else - echo "::notice::$list_targets_output" echo "::warning::Fossa did not find any analysis targets." echo "HAS_FOSSA_TARGETS=False" >> "$GITHUB_OUTPUT" fi @@ -49,10 +48,29 @@ jobs: -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 }}"'"}]}' - - name: Run fossa analyze + - id: fossa-analyze + name: Run fossa analyze if: ${{ steps.fossa-list-targets.outputs.HAS_FOSSA_TARGETS == 'True'}} - run: fossa analyze + run: | + fossa_analyze_output=$(fossa analyze 2>&1) + echo "::notice::$fossa_analyze_output" + + if [[ $(echo $fossa_analyze_output | grep "Error" | wc -l) -gt 0 ]] + then + echo "::error::fossa analyze ran with errors." + echo "FOSSA_ANALYZE_RESULT=Error" >> "$GITHUB_OUTPUT" + else + echo "FOSSA_ANALYZE_RESULT=Success" >> "$GITHUB_OUTPUT" + - 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'}} + if: ${{ steps.fossa-list-targets.outputs.HAS_FOSSA_TARGETS == 'Error' || steps.fossa-analyze.outputs.FOSSA_ANALYZE_RESULT == 'Error' }} run: exit 1 From 6e741ed29c7f3e077fb098a1ed341aec9b3ef508 Mon Sep 17 00:00:00 2001 From: elaguerta-nr <148913307+elaguerta-nr@users.noreply.github.com> Date: Tue, 7 Nov 2023 13:07:55 -0800 Subject: [PATCH 30/72] Try adding a curl before running fossa analyze --- .github/workflows/fossa.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/fossa.yml b/.github/workflows/fossa.yml index ebd5aa8..75619de 100644 --- a/.github/workflows/fossa.yml +++ b/.github/workflows/fossa.yml @@ -52,6 +52,7 @@ jobs: name: Run fossa analyze if: ${{ steps.fossa-list-targets.outputs.HAS_FOSSA_TARGETS == 'True'}} run: | + curl -H 'Cache-Control: no-cache' https://raw.githubusercontent.com/fossas/fossa-cli/master/install-latest.sh | bash fossa_analyze_output=$(fossa analyze 2>&1) echo "::notice::$fossa_analyze_output" From 681f687b7feaa170d940a6124ee0da91d4bfa16a Mon Sep 17 00:00:00 2001 From: elaguerta-nr <148913307+elaguerta-nr@users.noreply.github.com> Date: Tue, 7 Nov 2023 13:22:23 -0800 Subject: [PATCH 31/72] Fixup: close if statement --- .github/workflows/fossa.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/fossa.yml b/.github/workflows/fossa.yml index 75619de..e9c37be 100644 --- a/.github/workflows/fossa.yml +++ b/.github/workflows/fossa.yml @@ -52,7 +52,6 @@ jobs: name: Run fossa analyze if: ${{ steps.fossa-list-targets.outputs.HAS_FOSSA_TARGETS == 'True'}} run: | - curl -H 'Cache-Control: no-cache' https://raw.githubusercontent.com/fossas/fossa-cli/master/install-latest.sh | bash fossa_analyze_output=$(fossa analyze 2>&1) echo "::notice::$fossa_analyze_output" @@ -62,6 +61,7 @@ jobs: echo "FOSSA_ANALYZE_RESULT=Error" >> "$GITHUB_OUTPUT" else echo "FOSSA_ANALYZE_RESULT=Success" >> "$GITHUB_OUTPUT" + fi - name: Set fossaAnalyzeResult custom property run: | curl -L \ From cd86fe768ed157894413acca9a611a7154688820 Mon Sep 17 00:00:00 2001 From: elaguerta-nr <148913307+elaguerta-nr@users.noreply.github.com> Date: Tue, 7 Nov 2023 14:17:15 -0800 Subject: [PATCH 32/72] Add policy flag to fossa analyze --- .github/workflows/fossa.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/fossa.yml b/.github/workflows/fossa.yml index e9c37be..90d5683 100644 --- a/.github/workflows/fossa.yml +++ b/.github/workflows/fossa.yml @@ -52,7 +52,7 @@ jobs: name: Run fossa analyze if: ${{ steps.fossa-list-targets.outputs.HAS_FOSSA_TARGETS == 'True'}} run: | - fossa_analyze_output=$(fossa analyze 2>&1) + fossa_analyze_output=$(fossa analyze --policy='New Relic Public Github' 2>&1) echo "::notice::$fossa_analyze_output" if [[ $(echo $fossa_analyze_output | grep "Error" | wc -l) -gt 0 ]] From bc1857e35af8048e69972d6b932e1594d41f8b9c Mon Sep 17 00:00:00 2001 From: elaguerta-nr <148913307+elaguerta-nr@users.noreply.github.com> Date: Mon, 13 Nov 2023 14:33:15 -0800 Subject: [PATCH 33/72] Update fossa.yml save list-targets std-out and std-err to two different temp files --- .github/workflows/fossa.yml | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/.github/workflows/fossa.yml b/.github/workflows/fossa.yml index 90d5683..4eeab45 100644 --- a/.github/workflows/fossa.yml +++ b/.github/workflows/fossa.yml @@ -24,16 +24,20 @@ jobs: name: Run fossa list-targets run: | curl -H 'Cache-Control: no-cache' https://raw.githubusercontent.com/fossas/fossa-cli/master/install-latest.sh | bash - list_targets_output=$(fossa list-targets 2>&1) - echo "::notice::$list_targets_output" + export LIST_TARGETS_OUT_FILE=${{ runner.temp }}/list-targets_out.txt + export LIST_TARGETS_ERR_FILE=${{ runner.temp }}/list-targets_err.txt - if [[ $(echo $list_targets_output | grep "Error" | wc -l) -gt 0 ]] + 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." - echo "HAS_FOSSA_TARGETS=Error" >> "$GITHUB_OUTPUT" - elif [[ $(echo $list_targets_output | grep "Found target" | wc -l) -gt 0 ]] + 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." From a1b85004076dc8cc90aae7431a11dc880cb36748 Mon Sep 17 00:00:00 2001 From: elaguerta-nr <148913307+elaguerta-nr@users.noreply.github.com> Date: Mon, 13 Nov 2023 14:41:56 -0800 Subject: [PATCH 34/72] Fixup: variable syntax --- .github/workflows/fossa.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/fossa.yml b/.github/workflows/fossa.yml index 4eeab45..dabd4b6 100644 --- a/.github/workflows/fossa.yml +++ b/.github/workflows/fossa.yml @@ -27,7 +27,7 @@ jobs: 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 From 179a0078c9616d08c95630586d1fb1c2a2aa77c9 Mon Sep 17 00:00:00 2001 From: elaguerta-nr <148913307+elaguerta-nr@users.noreply.github.com> Date: Mon, 13 Nov 2023 14:59:08 -0800 Subject: [PATCH 35/72] Fixup: missing closing quote --- .github/workflows/fossa.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/fossa.yml b/.github/workflows/fossa.yml index dabd4b6..721f2ef 100644 --- a/.github/workflows/fossa.yml +++ b/.github/workflows/fossa.yml @@ -33,7 +33,7 @@ jobs: then echo "::error::fossa list-targets ran with errors." cat $LIST_TARGETS_ERR_FILE - echo "HAS_FOSSA_TARGETS=Error" >> "$GITHUB_OUTPUT + echo "HAS_FOSSA_TARGETS=Error" >> "$GITHUB_OUTPUT" elif [[ $(cat $LIST_TARGETS_OUT_FILE | wc -l) -gt 0 ]] then echo "::notice::Fossa found analysis targets." From 547fc7951ce5194584beec5227e8a224d7dc0506 Mon Sep 17 00:00:00 2001 From: elaguerta-nr <148913307+elaguerta-nr@users.noreply.github.com> Date: Mon, 13 Nov 2023 15:10:04 -0800 Subject: [PATCH 36/72] Separate fossa analyze stdout and stderr into 2 tmp files --- .github/workflows/fossa.yml | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/.github/workflows/fossa.yml b/.github/workflows/fossa.yml index 721f2ef..ae9961d 100644 --- a/.github/workflows/fossa.yml +++ b/.github/workflows/fossa.yml @@ -56,14 +56,16 @@ jobs: name: Run fossa analyze if: ${{ steps.fossa-list-targets.outputs.HAS_FOSSA_TARGETS == 'True'}} run: | - fossa_analyze_output=$(fossa analyze --policy='New Relic Public Github' 2>&1) - echo "::notice::$fossa_analyze_output" - - if [[ $(echo $fossa_analyze_output | grep "Error" | wc -l) -gt 0 ]] + 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 From 841875e42f3b623f04d5fb6dd82a7b6be1df14e6 Mon Sep 17 00:00:00 2001 From: elaguerta-nr <148913307+elaguerta-nr@users.noreply.github.com> Date: Mon, 13 Nov 2023 15:30:14 -0800 Subject: [PATCH 37/72] Create fossa-scala.yml --- .github/workflows/fossa-scala.yml | 86 +++++++++++++++++++++++++++++++ 1 file changed, 86 insertions(+) create mode 100644 .github/workflows/fossa-scala.yml diff --git a/.github/workflows/fossa-scala.yml b/.github/workflows/fossa-scala.yml new file mode 100644 index 0000000..a063caf --- /dev/null +++ b/.github/workflows/fossa-scala.yml @@ -0,0 +1,86 @@ +c + +name: FOSSA CLI Analysis - Scala +on: + push: + branches: [ $default-branch ] + pull_request: + branches: [ $default-branch ] + workflow_dispatch: + +jobs: + fossa: + runs-on: ubuntu-latest + env: + FOSSA_API_KEY: ${{secrets.FOSSA_API_KEY}} + ORG: ${{ github.repository_owner }} + REPO: ${{ github.repository }} + ORG_ADMIN_PAT: ${{ secrets.ELAGUERTA_PAT }} + + strategy: + fail-fast: false + + steps: + - uses: actions/checkout@v3 + - name: Download sbt + run: curl -fL https://github.com/coursier/coursier/releases/latest/download/cs-x86_64-pc-linux.gz | gzip -d > cs && chmod +x cs && ./cs setup + - 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 + + 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 From 5bd625431c4918b36579fb3ef3bc8ddabfde29ec Mon Sep 17 00:00:00 2001 From: elaguerta-nr <148913307+elaguerta-nr@users.noreply.github.com> Date: Mon, 13 Nov 2023 15:51:23 -0800 Subject: [PATCH 38/72] Fixup: typo --- .github/workflows/fossa-scala.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/fossa-scala.yml b/.github/workflows/fossa-scala.yml index a063caf..48731b2 100644 --- a/.github/workflows/fossa-scala.yml +++ b/.github/workflows/fossa-scala.yml @@ -1,5 +1,3 @@ -c - name: FOSSA CLI Analysis - Scala on: push: From 643d5020f5f77f04b07e5bddd1238fea03864618 Mon Sep 17 00:00:00 2001 From: elaguerta-nr <148913307+elaguerta-nr@users.noreply.github.com> Date: Mon, 13 Nov 2023 16:00:46 -0800 Subject: [PATCH 39/72] Setup github action according to scala-sbt docs See https://www.scala-sbt.org/1.x/docs/GitHub-Actions-with-sbt.html --- .github/workflows/fossa-scala.yml | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/.github/workflows/fossa-scala.yml b/.github/workflows/fossa-scala.yml index 48731b2..1504989 100644 --- a/.github/workflows/fossa-scala.yml +++ b/.github/workflows/fossa-scala.yml @@ -19,9 +19,12 @@ jobs: fail-fast: false steps: - - uses: actions/checkout@v3 - - name: Download sbt - run: curl -fL https://github.com/coursier/coursier/releases/latest/download/cs-x86_64-pc-linux.gz | gzip -d > cs && chmod +x cs && ./cs setup + - uses: actions/checkout@v4 + - name: Setup JDK + uses: actions/setup-java@v3 + with: + distribution: temurin + java-version: 8 - id: fossa-list-targets name: Run fossa list-targets run: | From 3a734a64ec3d69665cfd8c7a70191524fe0caa25 Mon Sep 17 00:00:00 2001 From: Elaine Laguerta Date: Tue, 14 Nov 2023 09:28:55 -0800 Subject: [PATCH 40/72] Revert step to use JDK --- .github/workflows/fossa-scala.yml | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/.github/workflows/fossa-scala.yml b/.github/workflows/fossa-scala.yml index 1504989..2e401ce 100644 --- a/.github/workflows/fossa-scala.yml +++ b/.github/workflows/fossa-scala.yml @@ -18,15 +18,10 @@ jobs: strategy: fail-fast: false - steps: - - uses: actions/checkout@v4 - - name: Setup JDK - uses: actions/setup-java@v3 - with: - distribution: temurin - java-version: 8 + steps: + - uses: actions/checkout@v3 - id: fossa-list-targets - name: Run 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 @@ -82,6 +77,6 @@ jobs: -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 + - name: Exit if: ${{ steps.fossa-list-targets.outputs.HAS_FOSSA_TARGETS == 'Error' || steps.fossa-analyze.outputs.FOSSA_ANALYZE_RESULT == 'Error' }} run: exit 1 From 5d5d130b7258075811cc6781282aa720246734b2 Mon Sep 17 00:00:00 2001 From: Elaine Laguerta Date: Tue, 14 Nov 2023 09:34:44 -0800 Subject: [PATCH 41/72] Download newrelic.jar, for newrelic-java-examples --- .github/workflows/fossa-scala.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/workflows/fossa-scala.yml b/.github/workflows/fossa-scala.yml index 2e401ce..a1f6f60 100644 --- a/.github/workflows/fossa-scala.yml +++ b/.github/workflows/fossa-scala.yml @@ -20,6 +20,11 @@ jobs: steps: - uses: actions/checkout@v3 + - name: Download newrelic.jar + if: ${{ github.repository == 'newrelic-java-examples' }} + run: | + mkdir newrelic-java-agent/scala/segment-api-synchronous/libs + curl https://download.newrelic.com/newrelic/java-agent/newrelic-agent/current/newrelic.jar --output newrelic-java-agent/scala/segment-api-synchronous/libs/newrelic.jar - id: fossa-list-targets name: Run fossa list-targets run: | From a9664030a85c90c651664e289fe9c32f7bf9deda Mon Sep 17 00:00:00 2001 From: Elaine Laguerta Date: Tue, 14 Nov 2023 09:44:53 -0800 Subject: [PATCH 42/72] fixup: use owner/repo to identify github.repository --- .github/workflows/fossa-scala.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/fossa-scala.yml b/.github/workflows/fossa-scala.yml index a1f6f60..f7136e9 100644 --- a/.github/workflows/fossa-scala.yml +++ b/.github/workflows/fossa-scala.yml @@ -21,7 +21,7 @@ jobs: steps: - uses: actions/checkout@v3 - name: Download newrelic.jar - if: ${{ github.repository == 'newrelic-java-examples' }} + if: ${{ github.repository == 'newrelic-csec/newrelic-java-examples' }} run: | mkdir newrelic-java-agent/scala/segment-api-synchronous/libs curl https://download.newrelic.com/newrelic/java-agent/newrelic-agent/current/newrelic.jar --output newrelic-java-agent/scala/segment-api-synchronous/libs/newrelic.jar From 4530fa880605d02485cdb0d2ac72b4f4c5ef3c0d Mon Sep 17 00:00:00 2001 From: Elaine Laguerta Date: Tue, 14 Nov 2023 10:02:19 -0800 Subject: [PATCH 43/72] Add a fossa-gradle workflow --- .github/workflows/fossa-gradle.yml | 83 ++++++++++++++++++++++++++++++ 1 file changed, 83 insertions(+) create mode 100644 .github/workflows/fossa-gradle.yml diff --git a/.github/workflows/fossa-gradle.yml b/.github/workflows/fossa-gradle.yml new file mode 100644 index 0000000..ae9961d --- /dev/null +++ b/.github/workflows/fossa-gradle.yml @@ -0,0 +1,83 @@ +name: FOSSA CLI Analysis +on: + push: + branches: [ $default-branch ] + pull_request: + branches: [ $default-branch ] + workflow_dispatch: + +jobs: + fossa: + runs-on: ubuntu-latest + env: + FOSSA_API_KEY: ${{secrets.FOSSA_API_KEY}} + ORG: ${{ github.repository_owner }} + REPO: ${{ github.repository }} + ORG_ADMIN_PAT: ${{ secrets.ELAGUERTA_PAT }} + + strategy: + fail-fast: false + + steps: + - uses: actions/checkout@v3 + - 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 + + 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 + From a57d1d287e99618a02290044211426e3ea1f47a7 Mon Sep 17 00:00:00 2001 From: Elaine Laguerta Date: Tue, 14 Nov 2023 10:41:23 -0800 Subject: [PATCH 44/72] Reference java agent setup action --- .github/workflows/fossa-gradle.yml | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/.github/workflows/fossa-gradle.yml b/.github/workflows/fossa-gradle.yml index ae9961d..ef491b3 100644 --- a/.github/workflows/fossa-gradle.yml +++ b/.github/workflows/fossa-gradle.yml @@ -18,10 +18,12 @@ jobs: strategy: fail-fast: false - steps: + steps: - uses: actions/checkout@v3 + - name: Setup java agent environment + uses: newrelic/newrelic-java-agent/.github/actions/setup-environment - id: fossa-list-targets - name: Run 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 @@ -77,7 +79,7 @@ jobs: -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 + - name: Exit if: ${{ steps.fossa-list-targets.outputs.HAS_FOSSA_TARGETS == 'Error' || steps.fossa-analyze.outputs.FOSSA_ANALYZE_RESULT == 'Error' }} run: exit 1 From 7399846cd9e77ca44207bd29667d112e3012c68d Mon Sep 17 00:00:00 2001 From: Elaine Laguerta Date: Tue, 14 Nov 2023 11:08:39 -0800 Subject: [PATCH 45/72] Check out newrelic-java-agent and reference locally --- .github/workflows/fossa-gradle.yml | 127 +++++++++++++++-------------- 1 file changed, 67 insertions(+), 60 deletions(-) diff --git a/.github/workflows/fossa-gradle.yml b/.github/workflows/fossa-gradle.yml index ef491b3..22e0857 100644 --- a/.github/workflows/fossa-gradle.yml +++ b/.github/workflows/fossa-gradle.yml @@ -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 From be8d36d8f2e3587914a6ebd982493619b518081c Mon Sep 17 00:00:00 2001 From: Elaine Laguerta Date: Tue, 14 Nov 2023 11:10:57 -0800 Subject: [PATCH 46/72] fixup: comment out uses --- .github/workflows/fossa-gradle.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/fossa-gradle.yml b/.github/workflows/fossa-gradle.yml index 22e0857..8fe91df 100644 --- a/.github/workflows/fossa-gradle.yml +++ b/.github/workflows/fossa-gradle.yml @@ -27,7 +27,7 @@ jobs: repository: newrelic/newrelic-java-agent path: newrelic-java-agent - name: Setup java agent environment - uses: newrelic-java-agent/.github/actions/setup-environment + # uses: newrelic-java-agent/.github/actions/setup-environment run: ls # - id: fossa-list-targets # name: Run fossa list-targets From aa82e76d50c2964d1c5b0bbb8256cad598f3e39b Mon Sep 17 00:00:00 2001 From: Elaine Laguerta Date: Tue, 14 Nov 2023 11:15:59 -0800 Subject: [PATCH 47/72] Add path to setup-environment action --- .github/workflows/fossa-gradle.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/fossa-gradle.yml b/.github/workflows/fossa-gradle.yml index 8fe91df..83fc26f 100644 --- a/.github/workflows/fossa-gradle.yml +++ b/.github/workflows/fossa-gradle.yml @@ -27,8 +27,7 @@ jobs: repository: newrelic/newrelic-java-agent path: newrelic-java-agent - name: Setup java agent environment - # uses: newrelic-java-agent/.github/actions/setup-environment - run: ls + uses: .github/actions/setup-environment/action.yml # - id: fossa-list-targets # name: Run fossa list-targets # run: | From c31a0eeacd1051d1d50bda2d9406f2a42bbf7273 Mon Sep 17 00:00:00 2001 From: Elaine Laguerta Date: Tue, 14 Nov 2023 11:20:01 -0800 Subject: [PATCH 48/72] Fixup: specify path to folder containing yml --- .github/workflows/fossa-gradle.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/fossa-gradle.yml b/.github/workflows/fossa-gradle.yml index 83fc26f..7825342 100644 --- a/.github/workflows/fossa-gradle.yml +++ b/.github/workflows/fossa-gradle.yml @@ -27,7 +27,7 @@ jobs: repository: newrelic/newrelic-java-agent path: newrelic-java-agent - name: Setup java agent environment - uses: .github/actions/setup-environment/action.yml + uses: .github/actions/setup-environment # - id: fossa-list-targets # name: Run fossa list-targets # run: | From 550453d5cb06902e228918316292a1cfe398ee20 Mon Sep 17 00:00:00 2001 From: Elaine Laguerta Date: Tue, 14 Nov 2023 11:23:57 -0800 Subject: [PATCH 49/72] debug --- .github/workflows/fossa-gradle.yml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.github/workflows/fossa-gradle.yml b/.github/workflows/fossa-gradle.yml index 7825342..3fa061c 100644 --- a/.github/workflows/fossa-gradle.yml +++ b/.github/workflows/fossa-gradle.yml @@ -27,7 +27,11 @@ jobs: repository: newrelic/newrelic-java-agent path: newrelic-java-agent - name: Setup java agent environment - uses: .github/actions/setup-environment + run: | + echo "PWD $(pwd)" + echo "ls -a" + ls -a + # uses: .github/actions/setup-environment # - id: fossa-list-targets # name: Run fossa list-targets # run: | From f8336b48d9ace500ab7e02567677e3c5a29b6e3c Mon Sep 17 00:00:00 2001 From: Elaine Laguerta Date: Tue, 14 Nov 2023 11:27:16 -0800 Subject: [PATCH 50/72] prepend path to action with ./ --- .github/workflows/fossa-gradle.yml | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/.github/workflows/fossa-gradle.yml b/.github/workflows/fossa-gradle.yml index 3fa061c..042ed31 100644 --- a/.github/workflows/fossa-gradle.yml +++ b/.github/workflows/fossa-gradle.yml @@ -27,11 +27,7 @@ jobs: repository: newrelic/newrelic-java-agent path: newrelic-java-agent - name: Setup java agent environment - run: | - echo "PWD $(pwd)" - echo "ls -a" - ls -a - # uses: .github/actions/setup-environment + uses: ./.github/actions/setup-environment # - id: fossa-list-targets # name: Run fossa list-targets # run: | From 380fa2e143f3940b55918468079ede6d9acf980e Mon Sep 17 00:00:00 2001 From: Elaine Laguerta Date: Tue, 14 Nov 2023 11:29:41 -0800 Subject: [PATCH 51/72] Add fossa-list-targets --- .github/workflows/fossa-gradle.yml | 60 +++++++++++++++--------------- 1 file changed, 30 insertions(+), 30 deletions(-) diff --git a/.github/workflows/fossa-gradle.yml b/.github/workflows/fossa-gradle.yml index 042ed31..b30cac3 100644 --- a/.github/workflows/fossa-gradle.yml +++ b/.github/workflows/fossa-gradle.yml @@ -28,38 +28,38 @@ jobs: path: newrelic-java-agent - name: Setup java agent environment uses: ./.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 + - 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 }}"'"}]}' + 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'}} From 7e039c224615753278ff7f08994b92baef930354 Mon Sep 17 00:00:00 2001 From: Elaine Laguerta Date: Tue, 14 Nov 2023 11:39:34 -0800 Subject: [PATCH 52/72] Add fossa analyze --- .github/workflows/fossa-gradle.yml | 56 +++++++++++++++--------------- 1 file changed, 28 insertions(+), 28 deletions(-) diff --git a/.github/workflows/fossa-gradle.yml b/.github/workflows/fossa-gradle.yml index b30cac3..0fa5524 100644 --- a/.github/workflows/fossa-gradle.yml +++ b/.github/workflows/fossa-gradle.yml @@ -60,32 +60,32 @@ jobs: -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 + - 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 From 3a8b93eda3593401d41b4062a388cec55250ba0b Mon Sep 17 00:00:00 2001 From: Elaine Laguerta Date: Tue, 14 Nov 2023 13:53:36 -0800 Subject: [PATCH 53/72] prepend action path with newrelic-java-agent --- .github/workflows/fossa-gradle.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/fossa-gradle.yml b/.github/workflows/fossa-gradle.yml index 0fa5524..44ca77f 100644 --- a/.github/workflows/fossa-gradle.yml +++ b/.github/workflows/fossa-gradle.yml @@ -27,7 +27,7 @@ jobs: repository: newrelic/newrelic-java-agent path: newrelic-java-agent - name: Setup java agent environment - uses: ./.github/actions/setup-environment + uses: ./newrelic-java-agent/.github/actions/setup-environment - id: fossa-list-targets name: Run fossa list-targets run: | From 129d4891059cdb2035477b3971e4123041364ee4 Mon Sep 17 00:00:00 2001 From: Elaine Laguerta Date: Tue, 14 Nov 2023 14:25:03 -0800 Subject: [PATCH 54/72] Hard-code java agent setup --- .github/workflows/fossa-gradle.yml | 28 ++++++++++++++++++++++------ 1 file changed, 22 insertions(+), 6 deletions(-) diff --git a/.github/workflows/fossa-gradle.yml b/.github/workflows/fossa-gradle.yml index 44ca77f..d47bd10 100644 --- a/.github/workflows/fossa-gradle.yml +++ b/.github/workflows/fossa-gradle.yml @@ -21,13 +21,29 @@ jobs: steps: - name: Checkout this repo uses: actions/checkout@v4 - - name: Checkout newrelic/newrelic-java-agent - uses: actions/checkout@v4 + - name: Setup javas + uses: actions/setup-java@v3 + with: + distribution: 'temurin' + java-version: | + 21 + 17 + 11 + 8 + - name: Set gradle.properties + run: | + export GRADLE_PROPERTIES_PATH="./android/gradle.properties" + echo "jdk8=${JAVA_HOME_8_X64}" >> $GRADLE_PROPERTIES_PATH + echo "jdk11=${JAVA_HOME_11_X64}" >> $GRADLE_PROPERTIES_PATH + echo "jdk17=${JAVA_HOME_17_X64}" >> $GRADLE_PROPERTIES_PATH + echo "jdk21=${JAVA_HOME_21_X64}" >> $GRADLE_PROPERTIES_PATH + - name: Setup Gradle + uses: gradle/gradle-build-action@v2 with: - repository: newrelic/newrelic-java-agent - path: newrelic-java-agent - - name: Setup java agent environment - uses: ./newrelic-java-agent/.github/actions/setup-environment + cache-read-only: true + - name: Setup Gradle options + run: echo "GRADLE_OPTIONS=--console=plain --parallel -Porg.gradle.java.installations.auto-detect=false -Porg.gradle.java.installations.fromEnv=JAVA_HOME_8_X64,JAVA_HOME_11_X64,JAVA_HOME_17_X64,JAVA_HOME_21_X64" >> $GITHUB_ENV + - id: fossa-list-targets name: Run fossa list-targets run: | From 2a53dbd1f45c5a9542476872b1f584168a33f0c1 Mon Sep 17 00:00:00 2001 From: Elaine Laguerta Date: Tue, 14 Nov 2023 15:02:24 -0800 Subject: [PATCH 55/72] Add repository env variable to specify a setup build action --- .github/workflows/fossa-gradle.yml | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/.github/workflows/fossa-gradle.yml b/.github/workflows/fossa-gradle.yml index 0fa5524..cdf1a63 100644 --- a/.github/workflows/fossa-gradle.yml +++ b/.github/workflows/fossa-gradle.yml @@ -21,13 +21,8 @@ jobs: steps: - 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: ./.github/actions/setup-environment + - name: Run the specified Setup Build Action + uses: ${{ vars.SETUP_BUILD_ACTION_PATH }} - id: fossa-list-targets name: Run fossa list-targets run: | From 180b124cfec89b2d2e4a35b25982ba506e0d0128 Mon Sep 17 00:00:00 2001 From: Elaine Laguerta Date: Tue, 14 Nov 2023 15:32:08 -0800 Subject: [PATCH 56/72] Hard-code path to setup-environment action --- .github/workflows/fossa-gradle.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/fossa-gradle.yml b/.github/workflows/fossa-gradle.yml index cdf1a63..380eb17 100644 --- a/.github/workflows/fossa-gradle.yml +++ b/.github/workflows/fossa-gradle.yml @@ -22,7 +22,7 @@ jobs: - name: Checkout this repo uses: actions/checkout@v4 - name: Run the specified Setup Build Action - uses: ${{ vars.SETUP_BUILD_ACTION_PATH }} + uses: ./.github/actions/setup-environment - id: fossa-list-targets name: Run fossa list-targets run: | From 1c8f9dd7d214c4c636da77434d3748316f21cccc Mon Sep 17 00:00:00 2001 From: Elaine Laguerta Date: Wed, 15 Nov 2023 15:48:07 -0800 Subject: [PATCH 57/72] fixup: specify gradle.properties path to the top of the repo --- .github/workflows/fossa-gradle.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/fossa-gradle.yml b/.github/workflows/fossa-gradle.yml index d47bd10..db81562 100644 --- a/.github/workflows/fossa-gradle.yml +++ b/.github/workflows/fossa-gradle.yml @@ -32,7 +32,7 @@ jobs: 8 - name: Set gradle.properties run: | - export GRADLE_PROPERTIES_PATH="./android/gradle.properties" + export GRADLE_PROPERTIES_PATH="./gradle.properties" echo "jdk8=${JAVA_HOME_8_X64}" >> $GRADLE_PROPERTIES_PATH echo "jdk11=${JAVA_HOME_11_X64}" >> $GRADLE_PROPERTIES_PATH echo "jdk17=${JAVA_HOME_17_X64}" >> $GRADLE_PROPERTIES_PATH From 077ba77d46b76e8964a5e06a5abda7acda2cbfc3 Mon Sep 17 00:00:00 2001 From: Elaine Laguerta Date: Wed, 15 Nov 2023 16:16:48 -0800 Subject: [PATCH 58/72] add a fossa workflow with ruby bundler --- .github/workflows/fossa-ruby-bundler.yml | 84 ++++++++++++++++++++++++ 1 file changed, 84 insertions(+) create mode 100644 .github/workflows/fossa-ruby-bundler.yml diff --git a/.github/workflows/fossa-ruby-bundler.yml b/.github/workflows/fossa-ruby-bundler.yml new file mode 100644 index 0000000..45c2ed9 --- /dev/null +++ b/.github/workflows/fossa-ruby-bundler.yml @@ -0,0 +1,84 @@ +name: FOSSA CLI Analysis +on: + push: + branches: [ $default-branch ] + pull_request: + branches: [ $default-branch ] + workflow_dispatch: + +jobs: + fossa: + runs-on: ubuntu-latest + env: + FOSSA_API_KEY: ${{secrets.FOSSA_API_KEY}} + ORG: ${{ github.repository_owner }} + REPO: ${{ github.repository }} + ORG_ADMIN_PAT: ${{ secrets.ELAGUERTA_PAT }} + + strategy: + fail-fast: false + + steps: + - uses: actions/checkout@v3 + - uses: ruby/setup-ruby@v1 + - 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 + + 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 + From 9598c3f47db25c3aa2f84a23c1e8519f4482b852 Mon Sep 17 00:00:00 2001 From: Elaine Laguerta Date: Wed, 15 Nov 2023 16:25:51 -0800 Subject: [PATCH 59/72] specify ruby-version@3.2 --- .github/workflows/fossa-ruby-bundler.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/fossa-ruby-bundler.yml b/.github/workflows/fossa-ruby-bundler.yml index 45c2ed9..4c1c02a 100644 --- a/.github/workflows/fossa-ruby-bundler.yml +++ b/.github/workflows/fossa-ruby-bundler.yml @@ -21,6 +21,8 @@ jobs: steps: - uses: actions/checkout@v3 - uses: ruby/setup-ruby@v1 + with: + ruby-version: '3.2' - id: fossa-list-targets name: Run fossa list-targets run: | From b128dfcbb0cb48db54d91499ed03b31f6621ae8b Mon Sep 17 00:00:00 2001 From: Elaine Laguerta Date: Thu, 16 Nov 2023 13:59:44 -0800 Subject: [PATCH 60/72] Do not exit right away on failed fossa CLI commands --- .github/workflows/fossa.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/fossa.yml b/.github/workflows/fossa.yml index ae9961d..563a515 100644 --- a/.github/workflows/fossa.yml +++ b/.github/workflows/fossa.yml @@ -18,16 +18,16 @@ jobs: strategy: fail-fast: false - steps: + steps: - uses: actions/checkout@v3 - id: fossa-list-targets - name: Run 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 || true if [[ $(grep -i "error" $LIST_TARGETS_ERR_FILE | wc -l) -gt 0 ]] then @@ -58,7 +58,7 @@ jobs: 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 + fossa analyze --policy='New Relic Public Github' 1>$ANALYZE_OUT_FILE 2>$ANALZYE_ERR_FILE || true if [[ $(grep -i "error" $ANALYZE_ERR_FILE | wc -l) -gt 0 ]] then echo "::error::fossa analyze ran with errors." @@ -77,7 +77,7 @@ jobs: -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 + - name: Exit if: ${{ steps.fossa-list-targets.outputs.HAS_FOSSA_TARGETS == 'Error' || steps.fossa-analyze.outputs.FOSSA_ANALYZE_RESULT == 'Error' }} run: exit 1 From f1394e96a5dd84d97d5688f3029db8c593de0fe7 Mon Sep 17 00:00:00 2001 From: Elaine Laguerta Date: Thu, 16 Nov 2023 14:46:44 -0800 Subject: [PATCH 61/72] Fixup: typo --- .github/workflows/fossa.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/fossa.yml b/.github/workflows/fossa.yml index 563a515..8e87b0a 100644 --- a/.github/workflows/fossa.yml +++ b/.github/workflows/fossa.yml @@ -57,8 +57,8 @@ jobs: 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 || true + export ANALYZE_ERR_FILE=${{ runner.temp }}/analyze_err.txt + fossa analyze --policy='New Relic Public Github' 1>$ANALYZE_OUT_FILE 2>$ANALYZE_ERR_FILE || true if [[ $(grep -i "error" $ANALYZE_ERR_FILE | wc -l) -gt 0 ]] then echo "::error::fossa analyze ran with errors." From cf843f35cfc8df831deaa9f0443192ca7d1a1c4a Mon Sep 17 00:00:00 2001 From: Elaine Laguerta Date: Thu, 16 Nov 2023 15:01:02 -0800 Subject: [PATCH 62/72] Fixup: search for all caps ERROR in fossa analyze error logs --- .github/workflows/fossa.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/fossa.yml b/.github/workflows/fossa.yml index 8e87b0a..522601d 100644 --- a/.github/workflows/fossa.yml +++ b/.github/workflows/fossa.yml @@ -59,7 +59,7 @@ jobs: export ANALYZE_OUT_FILE=${{ runner.temp }}/analyze_out.txt export ANALYZE_ERR_FILE=${{ runner.temp }}/analyze_err.txt fossa analyze --policy='New Relic Public Github' 1>$ANALYZE_OUT_FILE 2>$ANALYZE_ERR_FILE || true - if [[ $(grep -i "error" $ANALYZE_ERR_FILE | wc -l) -gt 0 ]] + if [[ $(grep "ERROR" $ANALYZE_ERR_FILE | wc -l) -gt 0 ]] then echo "::error::fossa analyze ran with errors." cat $ANALYZE_ERR_FILE From efd5183f03811dfec7d311e79de2f46690100717 Mon Sep 17 00:00:00 2001 From: elaguerta-nr <148913307+elaguerta-nr@users.noreply.github.com> Date: Mon, 11 Mar 2024 11:25:47 -0700 Subject: [PATCH 63/72] Add schedule trigger to run every hh:30 --- .github/workflows/fossa.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/fossa.yml b/.github/workflows/fossa.yml index 522601d..2ae69f2 100644 --- a/.github/workflows/fossa.yml +++ b/.github/workflows/fossa.yml @@ -5,6 +5,8 @@ on: pull_request: branches: [ $default-branch ] workflow_dispatch: + schedule: + - cron: '30 * * * *' jobs: fossa: From 286d05a4fbd6ef3ba7ca0aa73ee77e3e5474375c Mon Sep 17 00:00:00 2001 From: elaguerta-nr <148913307+elaguerta-nr@users.noreply.github.com> Date: Mon, 11 Mar 2024 11:26:35 -0700 Subject: [PATCH 64/72] add schedule trigger to gradle --- .github/workflows/fossa-gradle.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/fossa-gradle.yml b/.github/workflows/fossa-gradle.yml index 380eb17..898a9ba 100644 --- a/.github/workflows/fossa-gradle.yml +++ b/.github/workflows/fossa-gradle.yml @@ -5,6 +5,8 @@ on: pull_request: branches: [ $default-branch ] workflow_dispatch: + schedule: + - cron: '30 * * * *' jobs: fossa: From 89216f8ccced4225607713b7bf9d8c64ed0edf0d Mon Sep 17 00:00:00 2001 From: elaguerta-nr <148913307+elaguerta-nr@users.noreply.github.com> Date: Mon, 11 Mar 2024 11:26:58 -0700 Subject: [PATCH 65/72] Add schedule trigger to ruby --- .github/workflows/fossa-ruby-bundler.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/fossa-ruby-bundler.yml b/.github/workflows/fossa-ruby-bundler.yml index 4c1c02a..66c9a11 100644 --- a/.github/workflows/fossa-ruby-bundler.yml +++ b/.github/workflows/fossa-ruby-bundler.yml @@ -5,6 +5,8 @@ on: pull_request: branches: [ $default-branch ] workflow_dispatch: + schedule: + - cron: '30 * * * *' jobs: fossa: From fdc409ad04a9f4b37fcce86d024f7061fd1539e1 Mon Sep 17 00:00:00 2001 From: elaguerta-nr <148913307+elaguerta-nr@users.noreply.github.com> Date: Mon, 11 Mar 2024 11:27:20 -0700 Subject: [PATCH 66/72] add schedule trigger to scala --- .github/workflows/fossa-scala.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/fossa-scala.yml b/.github/workflows/fossa-scala.yml index f7136e9..c1f2dc1 100644 --- a/.github/workflows/fossa-scala.yml +++ b/.github/workflows/fossa-scala.yml @@ -5,6 +5,8 @@ on: pull_request: branches: [ $default-branch ] workflow_dispatch: + schedule: + - cron: '30 * * * *' jobs: fossa: From 513ef0d11daec468b84f36c3d7b00c2e7b43b601 Mon Sep 17 00:00:00 2001 From: Elaine Laguerta Date: Mon, 18 Mar 2024 15:15:21 -0700 Subject: [PATCH 67/72] add elixir workflow --- .github/workflows/fossa-elixir.yml | 84 ++++++++++++++++++++++++++++++ 1 file changed, 84 insertions(+) create mode 100644 .github/workflows/fossa-elixir.yml diff --git a/.github/workflows/fossa-elixir.yml b/.github/workflows/fossa-elixir.yml new file mode 100644 index 0000000..6c6cd05 --- /dev/null +++ b/.github/workflows/fossa-elixir.yml @@ -0,0 +1,84 @@ +name: FOSSA CLI Analysis +on: + push: + branches: [ $default-branch ] + pull_request: + branches: [ $default-branch ] + workflow_dispatch: + +jobs: + fossa: + runs-on: ubuntu-latest + env: + FOSSA_API_KEY: ${{secrets.FOSSA_API_KEY}} + ORG: ${{ github.repository_owner }} + REPO: ${{ github.repository }} + ORG_ADMIN_PAT: ${{ secrets.ELAGUERTA_PAT }} + + strategy: + fail-fast: false + + steps: + - uses: actions/checkout@v3 + - uses: erlef/setup-beam@v1 + - 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 + + 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 + From 1db60d737c3800a5033d1b4fc5761e3e5c1f2394 Mon Sep 17 00:00:00 2001 From: Elaine Laguerta Date: Tue, 9 Apr 2024 15:01:21 -0700 Subject: [PATCH 68/72] add otp and elixir versions --- .github/workflows/fossa-elixir.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/fossa-elixir.yml b/.github/workflows/fossa-elixir.yml index 6c6cd05..5b49e98 100644 --- a/.github/workflows/fossa-elixir.yml +++ b/.github/workflows/fossa-elixir.yml @@ -21,6 +21,9 @@ jobs: steps: - uses: actions/checkout@v3 - uses: erlef/setup-beam@v1 + with: + otp-version: '26' + elixir: '1.15' - id: fossa-list-targets name: Run fossa list-targets run: | From f27b1d22a66cf8227b54319e4a040affeba88be5 Mon Sep 17 00:00:00 2001 From: Elaine Laguerta Date: Wed, 10 Apr 2024 14:47:23 -0700 Subject: [PATCH 69/72] Add separate fossa-caos workflow --- .github/workflows/fossa-caos.yml | 89 ++++++++++++++++++++++++++++++++ 1 file changed, 89 insertions(+) create mode 100644 .github/workflows/fossa-caos.yml diff --git a/.github/workflows/fossa-caos.yml b/.github/workflows/fossa-caos.yml new file mode 100644 index 0000000..cce4146 --- /dev/null +++ b/.github/workflows/fossa-caos.yml @@ -0,0 +1,89 @@ +name: FOSSA CLI Analysis +on: + push: + branches: [ $default-branch ] + pull_request: + branches: [ $default-branch ] + workflow_dispatch: + schedule: + - cron: '30 * * * *' + +jobs: + fossa: + runs-on: ubuntu-latest + env: + FOSSA_API_KEY: ${{secrets.FOSSA_API_KEY}} + ORG: ${{ github.repository_owner }} + REPO: ${{ github.repository }} + ORG_ADMIN_PAT: ${{ secrets.ELAGUERTA_PAT }} + + strategy: + fail-fast: false + + steps: + - uses: actions/checkout@v3 + - name: Give GitHub Actions access to private crates + uses: webfactory/ssh-agent@v0.8.0 + with: + ssh-private-key: ${{ secrets.CAOS_RUST_CRATE_FOSSA }} + - 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 || true + + 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 ANALYZE_ERR_FILE=${{ runner.temp }}/analyze_err.txt + fossa analyze --policy='New Relic Public Github' 1>$ANALYZE_OUT_FILE 2>$ANALYZE_ERR_FILE || true + if [[ $(grep "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 + From 4c15d159e0f0da1b88457f65c59db29984a50846 Mon Sep 17 00:00:00 2001 From: Elaine Laguerta Date: Fri, 10 May 2024 14:17:01 -0700 Subject: [PATCH 70/72] delete schedule trigger bc it doesn't work with repo rulesets --- .github/workflows/fossa-caos.yml | 2 -- .github/workflows/fossa-gradle.yml | 2 -- .github/workflows/fossa-ruby-bundler.yml | 2 -- .github/workflows/fossa-scala.yml | 2 -- .github/workflows/fossa.yml | 2 -- 5 files changed, 10 deletions(-) diff --git a/.github/workflows/fossa-caos.yml b/.github/workflows/fossa-caos.yml index cce4146..efcbdfe 100644 --- a/.github/workflows/fossa-caos.yml +++ b/.github/workflows/fossa-caos.yml @@ -5,8 +5,6 @@ on: pull_request: branches: [ $default-branch ] workflow_dispatch: - schedule: - - cron: '30 * * * *' jobs: fossa: diff --git a/.github/workflows/fossa-gradle.yml b/.github/workflows/fossa-gradle.yml index dfce98f..30ab58f 100644 --- a/.github/workflows/fossa-gradle.yml +++ b/.github/workflows/fossa-gradle.yml @@ -5,8 +5,6 @@ on: pull_request: branches: [ $default-branch ] workflow_dispatch: - schedule: - - cron: '30 * * * *' jobs: fossa: diff --git a/.github/workflows/fossa-ruby-bundler.yml b/.github/workflows/fossa-ruby-bundler.yml index 66c9a11..4c1c02a 100644 --- a/.github/workflows/fossa-ruby-bundler.yml +++ b/.github/workflows/fossa-ruby-bundler.yml @@ -5,8 +5,6 @@ on: pull_request: branches: [ $default-branch ] workflow_dispatch: - schedule: - - cron: '30 * * * *' jobs: fossa: diff --git a/.github/workflows/fossa-scala.yml b/.github/workflows/fossa-scala.yml index c1f2dc1..f7136e9 100644 --- a/.github/workflows/fossa-scala.yml +++ b/.github/workflows/fossa-scala.yml @@ -5,8 +5,6 @@ on: pull_request: branches: [ $default-branch ] workflow_dispatch: - schedule: - - cron: '30 * * * *' jobs: fossa: diff --git a/.github/workflows/fossa.yml b/.github/workflows/fossa.yml index 2ae69f2..522601d 100644 --- a/.github/workflows/fossa.yml +++ b/.github/workflows/fossa.yml @@ -5,8 +5,6 @@ on: pull_request: branches: [ $default-branch ] workflow_dispatch: - schedule: - - cron: '30 * * * *' jobs: fossa: From 1366e8da4db90850299cae6618d643183a5e4181 Mon Sep 17 00:00:00 2001 From: Elaine Laguerta Date: Mon, 13 May 2024 12:31:13 -0700 Subject: [PATCH 71/72] rename the default fossa workflow --- .github/workflows/{fossa.yml => fossa-default.yml} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename .github/workflows/{fossa.yml => fossa-default.yml} (100%) diff --git a/.github/workflows/fossa.yml b/.github/workflows/fossa-default.yml similarity index 100% rename from .github/workflows/fossa.yml rename to .github/workflows/fossa-default.yml From 864e76ac90dd315345bc14b7fbf61b067ef61329 Mon Sep 17 00:00:00 2001 From: Elaine Laguerta Date: Mon, 13 May 2024 13:30:18 -0700 Subject: [PATCH 72/72] bugfix: add '|| true' to CLI commands This prevents the workflow from terminating early if the CLI hits an error. --- .github/workflows/fossa-elixir.yml | 4 ++-- .github/workflows/fossa-gradle.yml | 4 ++-- .github/workflows/fossa-ruby-bundler.yml | 4 ++-- .github/workflows/fossa-scala.yml | 4 ++-- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/.github/workflows/fossa-elixir.yml b/.github/workflows/fossa-elixir.yml index 5b49e98..d72e58d 100644 --- a/.github/workflows/fossa-elixir.yml +++ b/.github/workflows/fossa-elixir.yml @@ -31,7 +31,7 @@ jobs: 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 || true if [[ $(grep -i "error" $LIST_TARGETS_ERR_FILE | wc -l) -gt 0 ]] then @@ -62,7 +62,7 @@ jobs: 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 + fossa analyze --policy='New Relic Public Github' 1>$ANALYZE_OUT_FILE 2>$ANALZYE_ERR_FILE || true if [[ $(grep -i "error" $ANALYZE_ERR_FILE | wc -l) -gt 0 ]] then echo "::error::fossa analyze ran with errors." diff --git a/.github/workflows/fossa-gradle.yml b/.github/workflows/fossa-gradle.yml index 30ab58f..e5eb3de 100644 --- a/.github/workflows/fossa-gradle.yml +++ b/.github/workflows/fossa-gradle.yml @@ -50,7 +50,7 @@ jobs: 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 || true if [[ $(grep -i "error" $LIST_TARGETS_ERR_FILE | wc -l) -gt 0 ]] then @@ -81,7 +81,7 @@ jobs: 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 + fossa analyze --policy='New Relic Public Github' 1>$ANALYZE_OUT_FILE 2>$ANALZYE_ERR_FILE || true if [[ $(grep -i "error" $ANALYZE_ERR_FILE | wc -l) -gt 0 ]] then echo "::error::fossa analyze ran with errors." diff --git a/.github/workflows/fossa-ruby-bundler.yml b/.github/workflows/fossa-ruby-bundler.yml index 4c1c02a..780b003 100644 --- a/.github/workflows/fossa-ruby-bundler.yml +++ b/.github/workflows/fossa-ruby-bundler.yml @@ -30,7 +30,7 @@ jobs: 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 || true if [[ $(grep -i "error" $LIST_TARGETS_ERR_FILE | wc -l) -gt 0 ]] then @@ -61,7 +61,7 @@ jobs: 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 + fossa analyze --policy='New Relic Public Github' 1>$ANALYZE_OUT_FILE 2>$ANALZYE_ERR_FILE || true if [[ $(grep -i "error" $ANALYZE_ERR_FILE | wc -l) -gt 0 ]] then echo "::error::fossa analyze ran with errors." diff --git a/.github/workflows/fossa-scala.yml b/.github/workflows/fossa-scala.yml index f7136e9..6651378 100644 --- a/.github/workflows/fossa-scala.yml +++ b/.github/workflows/fossa-scala.yml @@ -32,7 +32,7 @@ jobs: 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 || true if [[ $(grep -i "error" $LIST_TARGETS_ERR_FILE | wc -l) -gt 0 ]] then @@ -63,7 +63,7 @@ jobs: 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 + fossa analyze --policy='New Relic Public Github' 1>$ANALYZE_OUT_FILE 2>$ANALZYE_ERR_FILE || true if [[ $(grep -i "error" $ANALYZE_ERR_FILE | wc -l) -gt 0 ]] then echo "::error::fossa analyze ran with errors."