-
Notifications
You must be signed in to change notification settings - Fork 0
94 lines (84 loc) · 3.66 KB
/
Copy pathvalidate.yml
File metadata and controls
94 lines (84 loc) · 3.66 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
name: Validate ci-fleet prototype
on:
pull_request:
push:
branches: [main]
workflow_dispatch:
permissions:
contents: read
concurrency:
group: validate-${{ github.ref }}
cancel-in-progress: true
jobs:
validate:
name: Build without registering a runner
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- name: Check out repository
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
with:
persist-credentials: false
fetch-depth: 0
- name: Scan every proposed commit for secrets
env:
EVENT_NAME: ${{ github.event_name }}
BASE_SHA: ${{ github.event.pull_request.base.sha || github.event.before }}
HEAD_SHA: ${{ github.event.pull_request.head.sha || github.sha }}
run: |
scanner=scripts/scan_committed_secrets.py
if [[ "$EVENT_NAME" == pull_request ]] && git cat-file -e "$BASE_SHA:$scanner" 2>/dev/null; then
git show "$BASE_SHA:$scanner" >"$RUNNER_TEMP/trusted-secret-scanner.py"
scanner="$RUNNER_TEMP/trusted-secret-scanner.py"
fi
if [[ -z "$BASE_SHA" || "$BASE_SHA" =~ ^0+$ ]]; then
mapfile -t commits < <(git rev-list --reverse "$HEAD_SHA")
else
mapfile -t commits < <(git rev-list --reverse "$BASE_SHA..$HEAD_SHA")
fi
if [[ ! " ${commits[*]} " == *" $HEAD_SHA "* ]]; then
commits+=("$HEAD_SHA")
fi
for commit in "${commits[@]}"; do
python3 "$scanner" --repository "$GITHUB_WORKSPACE" --commit "$commit"
done
- name: Install static analysis tools
run: sudo apt-get update && sudo apt-get install -y shellcheck
- name: Check shell scripts
run: shellcheck scripts/*.sh examples/project/scripts/ci/*.sh templates/config-repository/scripts/*.sh
- name: Check documentation links
run: python3 scripts/check_doc_links.py
- name: Build and inspect inert prototype
run: scripts/validate.sh
- name: Validate public configuration template
run: |
cmp -s scripts/scan_committed_secrets.py templates/config-repository/scripts/scan_committed_secrets.py
python3 templates/config-repository/scripts/test_policy.py
python3 templates/config-repository/scripts/scan_committed_secrets.py
templates/config-repository/scripts/validate.sh
templates/config-repository/scripts/validate.sh --config templates/config-repository/examples/multi-host/fleet.json
temporary_directory="$(mktemp -d)"
if templates/config-repository/scripts/init.sh \
--organization test-company \
--project test-app \
--output "${temporary_directory}/missing-engine.json"; then
echo 'initializer accepted a missing engine revision' >&2
exit 1
fi
test ! -e "${temporary_directory}/missing-engine.json"
if templates/config-repository/scripts/init.sh \
--organization test-company \
--project test-app \
--registry BAD \
--engine-ref "$(git rev-parse HEAD)" \
--output "${temporary_directory}/invalid.json"; then
echo 'initializer accepted an invalid registry' >&2
exit 1
fi
test ! -e "${temporary_directory}/invalid.json"
templates/config-repository/scripts/init.sh \
--organization test-company \
--project test-app \
--engine-ref "$(git rev-parse HEAD)" \
--output "${temporary_directory}/fleet.json"
test "$(stat -c '%a' "${temporary_directory}/fleet.json")" = 644