9
9
shell : bash
10
10
run : echo "This action should only run on getsentry repos" && exit 1
11
11
12
- - name : ' Pick a FOSSA API key'
12
+ - name : ' Pick a FOSSA API key and install FOSSA cli '
13
13
id : set_key
14
14
shell : bash
15
15
env :
@@ -27,50 +27,60 @@ runs:
27
27
# here in this file and gives us at least basic pass/fail.
28
28
#
29
29
# See also: https://docs.fossa.com/docs/api-reference#api-tokens
30
-
31
30
FALLBACK="9fc50c40b136c68873ad05aec573cf3e"
32
31
echo "key=${PREFERRED:-$FALLBACK}" >> "$GITHUB_OUTPUT"
32
+ # Install specific version of fossa-cli to guarantee stability of parsing fossa job outputs
33
+ curl -H 'Cache-Control: no-cache' https://raw.githubusercontent.com/fossas/fossa-cli/v3.7.5/install-latest.sh | bash
33
34
34
35
- name : ' Checkout Code'
35
36
uses : actions/checkout@v2
36
37
37
- - name : ' Run FOSSA Scan '
38
+ - name : ' Run `fossa analyze` '
38
39
id : analyze
39
40
continue-on-error : true
40
- uses : fossas/fossa-action@5913e730490ebf75ae47b59687b7e590289eed92
41
- with :
42
- api-key : ${{ steps.set_key.outputs.key }}
43
-
44
- - if : steps.analyze.outcome == 'failure'
45
- name : ' Send error to Sentry on FOSSA scan failure'
46
- shell : bash
47
41
env :
48
- SENTRY_URL : https://self-hosted.getsentry.net/
49
- SENTRY_ORG : self-hosted
50
- SENTRY_PROJECT : test
51
- SENTRY_DSN :
https://[email protected] /4
42
+ FOSSA_API_KEY : ${{ steps.set_key.outputs.key }}
43
+ shell : bash
52
44
run : |
53
- curl -sL https://sentry.io/get-cli/ | sh
54
- # Environment variables will automatically be sent, so we just want some minimal information
55
- sentry-cli send-event -m "FOSSA scan failure in $GITHUB_REPOSITORY" -e url:$GITHUB_SERVER_URL/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID
45
+ exec &> >(tee -a "analyze_logs.txt")
46
+ fossa analyze
56
47
57
- # We only want to run license compliance test if FOSSA scan succeeds. This is to unblock CI
48
+ # We only want to run license compliance test if `fossa test` succeeds. This is to unblock CI
58
49
# on FOSSA outages.
59
50
- if : steps.analyze.outcome == 'success'
60
- name : ' Run FOSSA Test '
51
+ name : ' Run `fossa test` '
61
52
id : test
62
- uses : fossas/fossa-action@5913e730490ebf75ae47b59687b7e590289eed92
63
- with :
64
- api-key : ${{ steps.set_key.outputs.key }}
65
- run-tests : true
53
+ continue-on-error : true
54
+ env :
55
+ FOSSA_API_KEY : ${{ steps.set_key.outputs.key }}
56
+ shell : bash
57
+ run : |
58
+ exec &> >(tee -a "test_logs.txt")
59
+ # Set timeout to 5 minutes (default of 60 minutes is waaaay too long to block CI)
60
+ fossa test --timeout 300
66
61
67
- - if : github.repository_owner == 'getsentry' && failure()
68
- name : ' Handle errors'
62
+ - if : steps.analyze.outcome == 'failure' || steps.test.outcome == ' failure'
63
+ name : ' Send error to Sentry on `fossa-cli` errors'
69
64
shell : bash
65
+ env :
66
+ SENTRY_DSN :
https://[email protected] /4505031352713216
70
67
run : |
71
- echo
72
- echo "π π π π π π π π π π π π π π π π π π π π π π π π "
73
- echo
74
- echo "Eep! It seems that this PR introduces a license violation. Did you add any libraries? Do they use the GPL or some weird license? Am I a confused bot? If you need a hand, cc: @getsentry/open-source in a comment. π"
75
- echo
76
- echo "π π π π π π π π π π π π π π π π π π π π π π π π "
68
+ if [[ ${{ steps.analyze.outcome }} == 'failure' ]]; then
69
+ curl -sL https://sentry.io/get-cli/ | sh
70
+ # Environment variables will automatically be sent, so we just want some minimal information
71
+ error_msg=$(cat analyze_logs.txt | grep -zoP '(?<=>>> Relevant errors\n\n Error\n\n ).*?(?=\n)' || echo 'unknown error message')
72
+ sentry-cli send-event -m "analyze: $error_msg" -t repo:$GITHUB_REPOSITORY -e url:$GITHUB_SERVER_URL/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID --logfile analyze_logs.txt
73
+ exit 0
74
+ fi
75
+ if grep -q "The scan has revealed issues. Number of issues found:" test_logs.txt; then
76
+ echo
77
+ echo "π π π π π π π π π π π π π π π π π π π π π π π π "
78
+ echo
79
+ echo "Eep! It seems that this PR introduces a license violation. Did you add any libraries? Do they use the GPL or some weird license? Am I a confused bot? If you need a hand, cc: @getsentry/open-source in a comment. π"
80
+ echo
81
+ echo "π π π π π π π π π π π π π π π π π π π π π π π π "
82
+ exit 1
83
+ fi
84
+ curl -sL https://sentry.io/get-cli/ | sh
85
+ error_msg=$(cat test_logs.txt | grep -zoP '(?<=>>> Relevant errors\n\n Error\n\n ).*?(?=\n)' || echo 'unknown error message')
86
+ sentry-cli send-event -m "test: $error_msg" -t repo:$GITHUB_REPOSITORY -e url:$GITHUB_SERVER_URL/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID --logfile test_logs.txt
0 commit comments