This repository has been archived by the owner on Jan 29, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 44
98 lines (90 loc) · 3.16 KB
/
static-analysis.yaml
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
name: Static Analysis
on:
workflow_call:
inputs:
runsOn:
required: false
type: string
default: 'ubuntu-latest'
scanDir:
required: false
type: string
default: '.'
ignoreDir:
required: false
type: string
default: ''
workingDir:
required: false
default: '.'
type: string
goVersion:
required: false
type: string
default: 1.21.5
hadolintVersion:
required: false
type: string
default: v2.12.0
goLangCIVersion:
required: false
type: string
default: v1.55.2
goImportsVersion:
required: false
type: string
default: v0.16.0
permissions:
contents: read
jobs:
shellcheck:
name: Shellcheck
runs-on: ${{ inputs.runsOn }}
steps:
- uses: actions/checkout@v3
- run: |
wget -q https://github.com/koalaman/shellcheck/releases/download/stable/shellcheck-stable.linux.x86_64.tar.xz
tar -xvf shellcheck-stable.linux.x86_64.tar.xz
shellcheck-stable/shellcheck -V; find . -name '*.sh' -print -exec sha256sum {} \;; find . -type f \( -name "*.sh" \) -print -exec shellcheck-stable/shellcheck -a -s bash -S warning -f gcc {} \;;
shell: bash
hadolint:
name: Hadolint
runs-on: ${{ inputs.runsOn }}
steps:
- uses: actions/checkout@v3
- run: wget -q https://github.com/hadolint/hadolint/releases/download/${{ inputs.hadolintVersion }}/hadolint-Linux-x86_64 -O hadolint; chmod +x hadolint ; find ${{ inputs.scanDir }} -type f \( -name "Dockerfile*" \) -print0 | xargs -n 1 -0 ./hadolint ;
job-process-input:
name: Process workflow input parameters
runs-on: ${{ inputs.runsOn }}
outputs:
modules: ${{ steps.get-modules.outputs.value }}
steps:
- id: get-modules
run: |
echo ${{ inputs.workingDir }} | echo "value=[\"$(sed -r 's/,/","/g')\"]" >> $GITHUB_OUTPUT
gofmt-imports:
name: Gofmt & imports
needs: job-process-input
runs-on: ${{ inputs.runsOn }}
strategy:
matrix:
modulename: ${{ fromJson(needs.job-process-input.outputs.modules) }}
steps:
- uses: actions/checkout@v3
- uses: actions/setup-go@v3
with:
go-version: "${{ inputs.goVersion }}"
- run: go install golang.org/x/tools/cmd/goimports@${{ inputs.goImportsVersion }}; test -z $(goimports -l ${{ matrix.modulename }}) && test -z $(gofmt -l ${{ matrix.modulename }})
golangci-run:
name: Golang CI
runs-on: ${{ inputs.runsOn }}
strategy:
matrix:
workingdir: [extender, telemetry-aware-scheduling, gpu-aware-scheduling]
steps:
- uses: actions/checkout@v3
- uses: actions/setup-go@v3
with:
go-version: "${{ inputs.goVersion }}"
- name: Running golang CI for ${{matrix.workingdir}}
run: curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin ${{ inputs.goLangCIVersion }} && golangci-lint --version && cd ./${{ matrix.workingdir }} && golangci-lint run --timeout=5m -v --color='always' && cd ..