-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathaction.yml
More file actions
126 lines (116 loc) · 4.23 KB
/
Copy pathaction.yml
File metadata and controls
126 lines (116 loc) · 4.23 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
# SPDX-FileCopyrightText: 2026 Alexandru Girlea
#
# SPDX-License-Identifier: Apache-2.0
name: precommitEU compliance scan
description: Scan changed code for EU regulatory compliance violations, locally.
author: Alexandru Girlea
branding:
icon: shield
color: blue
inputs:
regulations:
description: Comma-separated regulation packs to scan against.
default: gdpr
paths:
description: Paths to scan. Empty scans files changed vs the merge target.
default: ""
fail-on-findings:
description: Fail the job when confirmed findings remain.
default: "true"
sarif:
description: Path to write the SARIF report to.
default: precommiteu.sarif
summary:
description: Path to write the Markdown summary to.
default: precommiteu-summary.md
version:
description: precommiteu version to install. Empty installs the latest.
default: ""
models-revision:
description: Model bundle revision on Hugging Face — tag, branch or commit.
default: main
llama-build:
description: llama.cpp release providing llama-server.
default: b10158
outputs:
sarif:
description: Path to the SARIF report.
value: ${{ inputs.sarif }}
summary:
description: Path to the Markdown summary.
value: ${{ inputs.summary }}
runs:
using: composite
steps:
- name: Resolve merge-target history
if: inputs.paths == ''
shell: bash
env:
TARGET: ${{ github.base_ref || github.event.repository.default_branch || 'main' }}
run: |
if [ "$(git rev-parse --is-shallow-repository)" = "true" ]; then
git fetch --unshallow --quiet || true
fi
git fetch --quiet origin "+refs/heads/${TARGET}:refs/remotes/origin/${TARGET}" || true
- name: Install llama-server
shell: bash
env:
BUILD: ${{ inputs.llama-build }}
run: |
curl -fsSL -o "$RUNNER_TEMP/llama.tar.gz" \
"https://github.com/ggml-org/llama.cpp/releases/download/${BUILD}/llama-${BUILD}-bin-ubuntu-x64.tar.gz"
mkdir -p "$RUNNER_TEMP/llama"
tar -xzf "$RUNNER_TEMP/llama.tar.gz" -C "$RUNNER_TEMP/llama"
dirname "$(find "$RUNNER_TEMP/llama" -name llama-server -type f | head -1)" >> "$GITHUB_PATH"
- name: Install precommiteu
shell: bash
env:
VERSION: ${{ inputs.version }}
run: |
python3 -m venv "$RUNNER_TEMP/precommiteu-venv"
"$RUNNER_TEMP/precommiteu-venv/bin/pip" install --quiet --upgrade pip
"$RUNNER_TEMP/precommiteu-venv/bin/pip" install --quiet \
"huggingface_hub[cli]" "precommiteu${VERSION:+==$VERSION}"
echo "$RUNNER_TEMP/precommiteu-venv/bin" >> "$GITHUB_PATH"
- name: Cache the model bundle
id: models
uses: actions/cache@v4
with:
path: ${{ runner.temp }}/precommiteu-models
key: precommiteu-models-${{ inputs.regulations }}-${{ inputs.models-revision }}
- name: Download the model bundle
if: steps.models.outputs.cache-hit != 'true'
shell: bash
env:
REGULATIONS: ${{ inputs.regulations }}
REVISION: ${{ inputs.models-revision }}
run: |
files=(base.gguf)
for r in ${REGULATIONS//,/ }; do
files+=("${r}/detector-adapter.gguf")
done
hf download AlexandruGirlea/precommiteu-models "${files[@]}" \
--revision "$REVISION" \
--local-dir "$RUNNER_TEMP/precommiteu-models"
- name: Scan
shell: bash
env:
PRECOMMITEU_MODELS_DIR: ${{ runner.temp }}/precommiteu-models
GIT_MERGE_TARGET_BRANCH: ${{ github.base_ref || github.event.repository.default_branch || 'main' }}
REGULATIONS: ${{ inputs.regulations }}
PATHS: ${{ inputs.paths }}
SARIF: ${{ inputs.sarif }}
SUMMARY: ${{ inputs.summary }}
FAIL_ON_FINDINGS: ${{ inputs.fail-on-findings }}
run: |
# --force: the action owns these paths and rewrites them each run.
args=(--regulations "$REGULATIONS" --sarif "$SARIF" --out "$SUMMARY" --force)
if [ "$FAIL_ON_FINDINGS" = "true" ]; then
args+=(--fail-on-findings)
fi
if [ -n "$PATHS" ]; then
# shellcheck disable=SC2086
precommiteu scan $PATHS "${args[@]}"
else
precommiteu scan --ci "${args[@]}"
fi