Repository navigation
ci: add Codecov, Snyk, SonarCloud and Codacy badges #25
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
4580a9c
a9275ff
183b3cd
6221a79
81ac9c5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,111 @@ | ||
| name: Snyk | ||
|
|
||
| # The third-party dependencies are the Rust maintainer tools' crates and the | ||
| # CI's pinned Python packages; the npm packages declare none. Each Python set | ||
| # is installed into its own virtual environment and tested through Snyk's pip | ||
| # support. It runs weekly and when a dependency file changes, which keeps it | ||
| # inside the free plan's monthly test allowance. | ||
| on: | ||
| schedule: | ||
| - cron: "23 4 * * 1" | ||
| workflow_dispatch: | ||
| push: | ||
| branches: [main] | ||
| paths: | ||
| - "tools/Cargo.lock" | ||
| - "tools/Cargo.toml" | ||
| - ".github/ci/requirements.txt" | ||
| - ".github/workflows/snyk.yml" | ||
| pull_request: | ||
| paths: | ||
| - "tools/Cargo.lock" | ||
| - "tools/Cargo.toml" | ||
| - ".github/ci/requirements.txt" | ||
| - ".github/workflows/snyk.yml" | ||
|
|
||
| permissions: | ||
| contents: read | ||
|
|
||
| concurrency: | ||
| group: ${{ github.workflow }}-${{ github.ref }} | ||
| cancel-in-progress: true | ||
|
|
||
| jobs: | ||
| test: | ||
| name: Snyk open source test | ||
| # Pull requests from forks, and Dependabot's (which get Dependabot secrets | ||
| # only), receive no SNYK_TOKEN; the weekly run on main scans their changes. | ||
| if: github.event_name != 'pull_request' || (github.event.pull_request.head.repo.full_name == github.repository && github.event.pull_request.user.login != 'dependabot[bot]') | ||
| runs-on: ubuntu-latest | ||
| timeout-minutes: 30 | ||
| env: | ||
| # One dependency set per line: pip:<requirements file>. | ||
| SNYK_TARGETS: | | ||
| pip:.github/ci/requirements.txt | ||
| steps: | ||
| - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 | ||
| with: | ||
| persist-credentials: false | ||
| - uses: actions/setup-python@6d4fd22b20465ccc0f7354476588e8df7c9ca0e0 # v7.1.0 | ||
| with: | ||
| python-version: "3.12" | ||
| - uses: snyk/actions/setup@9adf32b1121593767fc3c057af55b55db032dc04 # v1.0.0 | ||
| - name: Test each dependency set | ||
| env: | ||
| SNYK_TOKEN: ${{ secrets.SNYK_TOKEN }} | ||
| run: | | ||
| set -uo pipefail | ||
| # Without the token every set is still installed, so a broken pin | ||
| # shows up, but the job fails because nothing was scanned. | ||
| if [ -z "$SNYK_TOKEN" ]; then | ||
| echo "::error::The SNYK_TOKEN repository secret is not set, so nothing was scanned." | ||
| fi | ||
| status=0 | ||
| while IFS=: read -r kind target; do | ||
| [ -n "$kind" ] || continue | ||
| work=$(mktemp -d) | ||
| case "$kind" in | ||
| pip) cp "$target" "$work/requirements.txt" \ | ||
| || { echo "::error::Cannot read $target"; status=1; continue; } ;; | ||
| *) echo "::error::Unknown dependency set $kind:$target"; status=1; continue ;; | ||
| esac | ||
| python -m venv "$work/venv" | ||
| "$work/venv/bin/python" -m pip install --quiet --disable-pip-version-check --no-deps \ | ||
| --only-binary=:all: --requirement "$work/requirements.txt" || { status=1; continue; } | ||
| [ -z "$SNYK_TOKEN" ] || snyk test --file="$work/requirements.txt" --package-manager=pip \ | ||
| --command="$work/venv/bin/python" --project-name="$kind:$target" || status=1 | ||
| done <<< "$SNYK_TARGETS" | ||
| [ -n "$SNYK_TOKEN" ] || exit 1 | ||
| exit "$status" | ||
|
|
||
| rust: | ||
| name: Snyk Rust dependencies | ||
| # Pull requests from forks, and Dependabot's (which get Dependabot secrets | ||
| # only), receive no SNYK_TOKEN; the weekly run on main scans their changes. | ||
| if: github.event_name != 'pull_request' || (github.event.pull_request.head.repo.full_name == github.repository && github.event.pull_request.user.login != 'dependabot[bot]') | ||
| runs-on: ubuntu-latest | ||
| timeout-minutes: 15 | ||
| permissions: | ||
| contents: read | ||
| env: | ||
| # tools/Cargo.toml's rust-version. | ||
| RUSTUP_TOOLCHAIN: "1.85" | ||
| steps: | ||
| - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 | ||
| with: | ||
| persist-credentials: false | ||
| - uses: snyk/actions/setup@9adf32b1121593767fc3c057af55b55db032dc04 # v1.0.0 | ||
| # Snyk cannot read Cargo.lock directly, so the graph is described as a | ||
| # CycloneDX SBOM and tested with `snyk sbom test`. | ||
| - name: Install the SBOM generator | ||
| run: | | ||
| rustup toolchain install "$RUSTUP_TOOLCHAIN" --profile minimal | ||
| cargo install cargo-cyclonedx --locked --version 0.5.9 | ||
| - name: Test the Cargo graph | ||
| working-directory: tools | ||
| env: | ||
| SNYK_TOKEN: ${{ secrets.SNYK_TOKEN }} | ||
| run: | | ||
| cargo cyclonedx --format json --spec-version 1.5 --override-filename snyk-sbom | ||
| [ -n "$SNYK_TOKEN" ] || { echo "::error::The SNYK_TOKEN repository secret is not set, so nothing was scanned."; exit 1; } | ||
| snyk sbom test --experimental --file=snyk-sbom.json |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| # Codecov reports coverage for the README badge. Coverage gates no merge, so | ||
| # Codecov's own statuses are informational and it posts no comments. | ||
| coverage: | ||
| status: | ||
| project: | ||
| default: | ||
| informational: true | ||
| patch: | ||
| default: | ||
| informational: true | ||
| comment: false |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -31,8 +31,10 @@ | |
| /^(?:module\.)?exports\.([A-Za-z_$][\w$]*)\s*=/gm], | ||
| go: [/^func\s+(?:\([^)]*\)\s*)?([A-Z]\w*)/gm, /^type\s+([A-Z]\w*)/gm], | ||
| rs: [/^pub\s+(?:async\s+)?(?:fn|struct|enum|trait|type)\s+(\w+)/gm], | ||
| rb: [/^\s*(?:def|class|module)\s+([A-Za-z][\w.]*)/gm], | ||
| jvm: [/^\s*(?:public\s+)?(?:static\s+)?(?:final\s+)?(?:class|interface|enum|record)\s+(\w+)/gm], | ||
| // [ \t]* rather than \s*: \s also matches newlines, so a run of blank lines cost | ||
| // quadratic time. | ||
| rb: [/^[ \t]*(?:def|class|module)\s+([A-Za-z][\w.]*)/gm], | ||
| jvm: [/^[ \t]*(?:public\s+)?(?:static\s+)?(?:final\s+)?(?:class|interface|enum|record)\s+(\w+)/gm], | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🔴 HIGH RISK Suggestion: Refactor this declaration matcher to avoid chained optional groups and unbounded backtracking while preserving indented declaration detection. Add regression coverage for long adversarial non-matching input.
|
||
| }; | ||
| const LANG = { py: 'py', js: 'js', jsx: 'js', mjs: 'js', cjs: 'js', ts: 'js', tsx: 'js', go: 'go', rs: 'rs', | ||
| rb: 'rb', java: 'jvm', kt: 'jvm', swift: 'jvm', cs: 'jvm', php: 'jvm' }; | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🟡 MEDIUM RISK
Run the full test suite on Ubuntu as well, while separately collecting Node coverage, or explicitly add the omitted correctness checks so the coverage runner does not exercise a reduced suite.
TIPReact 👍 if this review is right, or reply with what's wrong and how it could be better to help improve the reviewer.