Skip to content

Commit 532c048

Browse files
authored
use new inputs for the action instead of vendoring code
1 parent 68c703a commit 532c048

File tree

1 file changed

+7
-80
lines changed

1 file changed

+7
-80
lines changed

.github/workflows/enforce-license-compliance.yml

Lines changed: 7 additions & 80 deletions
Original file line numberDiff line numberDiff line change
@@ -22,86 +22,13 @@ jobs:
2222
- name: Checkout
2323
uses: actions/checkout@v4
2424

25+
# TODO: remove this when upstream is fixed
2526
- name: Disable Gradle configuration cache (see https://github.com/fossas/fossa-cli/issues/872)
2627
run: sed -i 's/^org.gradle.configuration-cache=.*/org.gradle.configuration-cache=false/' gradle.properties
2728

28-
- if: github.repository_owner != 'getsentry' && github.repository_owner != 'codecov'
29-
shell: bash
30-
run: echo "This action should only run on getsentry and codecov repos" && exit 1
31-
32-
- name: 'Pick a FOSSA API key and install FOSSA cli'
33-
id: set_key
34-
shell: bash
35-
env:
36-
PREFERRED: ${{ secrets.FOSSA_API_KEY }}
37-
run: |
38-
39-
# FOSSA has two kinds of API keys (aka tokens), a full-privilege key
40-
# and a low-privilege "push-only" key. The practical difference is that
41-
# the full key provides more feedback on `fossa test` failure. We have
42-
# a full key stored in org-wide GitHub Secrets, but a) we can't access
43-
# it in an action, only in a workflow (hence the input here) and b) it
44-
# isn't available even in a workflow when run in a PR from a fork. If
45-
# for any reason it's missing we fall back to a push-only key attached
46-
# to a low-privilege account, which is safe (enough) to expose publicly
47-
# here in this file and gives us at least basic pass/fail.
48-
#
49-
# See also: https://docs.fossa.com/docs/api-reference#api-tokens
50-
FALLBACK="9fc50c40b136c68873ad05aec573cf3e"
51-
echo "key=${PREFERRED:-$FALLBACK}" >> "$GITHUB_OUTPUT"
52-
# Install specific version of fossa-cli to guarantee stability of parsing fossa job outputs
53-
VERSION="v3.8.20"
54-
curl -H 'Cache-Control: no-cache' "https://raw.githubusercontent.com/fossas/fossa-cli/$VERSION/install-latest.sh" | bash -s -- "$VERSION"
55-
56-
- name: 'Run `fossa analyze`'
57-
id: analyze
58-
continue-on-error: true
59-
env:
60-
FOSSA_API_KEY: ${{ steps.set_key.outputs.key }}
61-
GITHUB_PR_SHA: ${{ github.event.pull_request.head.sha || github.sha }}
62-
GITHUB_PR_REF: ${{ github.event.pull_request.head.ref || github.ref }}
63-
shell: bash
64-
run: |
65-
exec &> >(tee -a "analyze_logs.txt")
66-
fossa analyze --branch "$GITHUB_PR_REF" --revision "$GITHUB_PR_SHA" --debug
67-
68-
# We only want to run license compliance test if `fossa test` succeeds. This is to unblock CI
69-
# on FOSSA outages.
70-
- if: steps.analyze.outcome == 'success'
71-
name: 'Run `fossa test`'
72-
id: test
73-
continue-on-error: true
74-
env:
75-
FOSSA_API_KEY: ${{ steps.set_key.outputs.key }}
76-
GITHUB_PR_SHA: ${{ github.event.pull_request.head.sha || github.sha }}
77-
shell: bash
78-
run: |
79-
exec &> >(tee -a "test_logs.txt")
80-
# Set timeout to 30 minutes
81-
fossa test --timeout 1800 --revision "$GITHUB_PR_SHA"
82-
83-
- if: steps.analyze.outcome == 'failure' || steps.test.outcome == 'failure'
84-
name: 'Send error to Sentry on `fossa-cli` errors'
85-
shell: bash
86-
env:
87-
SENTRY_DSN: https://decbca863c554db095624ede8a83310c@o1.ingest.sentry.io/4505031352713216
88-
run: |
89-
if [[ ${{ steps.analyze.outcome }} == 'failure' ]]; then
90-
curl -sL https://sentry.io/get-cli/ | sh
91-
# Environment variables will automatically be sent, so we just want some minimal information
92-
error_msg=$(cat analyze_logs.txt | grep -zoP '(?<=>>> Relevant errors\n\n Error\n\n ).*?(?=\n)' || echo 'unknown error message')
93-
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
94-
exit 0
95-
fi
96-
if grep -q "The scan has revealed issues. Number of issues found:" test_logs.txt; then
97-
echo
98-
echo "🛑 🛑 🛑 🛑 🛑 🛑 🛑 🛑 🛑 🛑 🛑 🛑 🛑 🛑 🛑 🛑 🛑 🛑 🛑 🛑 🛑 🛑 🛑 🛑 "
99-
echo
100-
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/dev-infra in a comment. 🙏"
101-
echo
102-
echo "🛑 🛑 🛑 🛑 🛑 🛑 🛑 🛑 🛑 🛑 🛑 🛑 🛑 🛑 🛑 🛑 🛑 🛑 🛑 🛑 🛑 🛑 🛑 🛑 "
103-
exit 1
104-
fi
105-
curl -sL https://sentry.io/get-cli/ | sh
106-
error_msg=$(cat test_logs.txt | grep -zoP '(?<=>>> Relevant errors\n\n Error\n\n ).*?(?=\n)' || echo 'unknown error message')
107-
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
29+
- name: 'Enforce License Compliance'
30+
uses: getsentry/action-enforce-license-compliance@main
31+
with:
32+
skip_checkout: 'true'
33+
fossa_test_timeout_seconds: 900
34+
fossa_api_key: ${{ secrets.FOSSA_API_KEY }}

0 commit comments

Comments
 (0)