-
Notifications
You must be signed in to change notification settings - Fork 226
162 lines (148 loc) · 5.54 KB
/
codeql.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
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
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
name: "CodeQL Scanner"
on:
push:
branches:
- 'master'
- 'release/**'
- 'hotfix/**'
paths-ignore:
- '**/README.md'
- '**/LICENSE'
- '.github/**'
#pull_request:
# branches:
# - 'master'
# - 'release/**'
# - 'hotfix/**'
schedule:
- cron: '00 19 * * 5'
# This job take a lot of time, so if the number of worker
# processes from one branch or one PR exceeds 1, all previous
# running processes will be automatically canceled to avoid the accumulation
# of a large number of concurrent workers
concurrency:
group: codeql-${{ github.event.pull_request.number || github.ref_name }}
cancel-in-progress: true
env:
SOURCE_ROOT: "/build/core"
jobs:
analyze:
name: Analyze
runs-on: ${{ 'ubuntu-latest' }}
container:
image: ${{ matrix.image }}
options: --privileged
volumes:
- /usr/local/lib:/foovolume/android
- /usr/local/share:/foovolume/boost
- /usr/share:/foovolume/dotnet
- /opt:/foovolume/opt
- /opt/hostedtoolcache:/foovolume/tool
timeout-minutes: ${{ (matrix.language == 'swift' && 120) || 360 }}
permissions:
actions: read
contents: read
security-events: write
strategy:
fail-fast: false
matrix:
language: [ 'c-cpp' ]
image: ["ubuntu:20.04"]
# CodeQL supports [ 'c-cpp', 'csharp', 'go', 'java-kotlin', 'javascript-typescript', 'python', 'ruby', 'swift' ]
# Use only 'java-kotlin' to analyze code written in Java, Kotlin or both
# Use only 'javascript-typescript' to analyze code written in JavaScript, TypeScript or both
# Learn more about CodeQL language support at https://aka.ms/codeql-docs/language-support
steps:
- uses: actions/setup-node@v4
with:
node-version: 20
- name: make free space in container
run: |
rm -rf /foovolume/android/android
rm -rf /foovolume/dotnet/dotnet
rm -rf /foovolume/boost/boost
rm -rf /foovolume/opt/ghc
rm -rf /foovolume/tool/*
df -h
# Prepare container environment
# Install some deps
# Set cache restore keys
- name: Prepare environment
id: prepare
shell: bash
env:
TZ: Etc/UTC
run: |
pwd
ls -la
ln -snf /usr/share/zoneinfo/$TZ /etc/localtime
echo $TZ > /etc/timezone
apt-get update
apt-get install -y python3 python2 sudo curl jq git
apt-get install -y python || true
rm /usr/bin/python || true
ln -s /usr/bin/python2 /usr/bin/python
mkdir -p /build
git clone --depth 1 \
--single-branch \
--branch ${{ github.base_ref || github.ref_name }} https://github.com/ONLYOFFICE/core.git ${SOURCE_ROOT}
git clone --depth 1 \
--single-branch \
--branch ${{ github.base_ref || github.ref_name }} https://github.com/ONLYOFFICE/build_tools.git /build/build_tools
echo "party-key=$(curl -L -H "Accept: application/vnd.github+json" \
-H "X-GitHub-Api-Version: 2022-11-28" \
"https://api.github.com/repos/ONLYOFFICE/core/commits?per_page=1&path=/Common/3dParty&sha=${{ github.base_ref || github.ref_name }}" | \
jq -r '.[].sha')" >> "$GITHUB_OUTPUT"
echo "qt-key=$(cat /build/build_tools/tools/linux/automate.py | egrep -m1 -o "qt_source_([0-9])?.([0-9])?.([0-9])?")" >> "$GITHUB_OUTPUT"
# Restore 3dParty from cache if cache key is match
- uses: actions/cache/restore@v3
id: restore-3d
with:
path: /build/core/Common/3dParty
key: 3dParty-${{ steps.prepare.outputs.party-key }}
# Restore qt tool from cache if cache key is match
- uses: actions/cache/restore@v3
id: restore-qt
with:
path: /build/build_tools/tools/linux/qt_build
key: qt-${{ steps.prepare.outputs.qt-key }}
# NOTE:
# init codeql with custom source-root dir
# because sources code was checkout with git from cli
# NOT with checkout action
# Also. Init and scan with codeql only if all cache hit
# otherwise will no initialization, just build and cache depends
- name: Initialize CodeQL
if: >
steps.restore-3d.outputs.cache-hit == 'true'
&& steps.restore-qt.outputs.cache-hit == 'true'
uses: github/codeql-action/init@v3
with:
languages: ${{ matrix.language }}
source-root: ${{ env.SOURCE_ROOT }}
- name: build
shell: bash
run: |
cd /build/build_tools/tools/linux
python3 ./automate.py core
- name: Perform CodeQL Analysis
if: >
steps.restore-3d.outputs.cache-hit == 'true'
&& steps.restore-qt.outputs.cache-hit == 'true'
uses: github/codeql-action/analyze@v3
with:
category: "/language:${{matrix.language}}"
# Make new 3dParty cache if restore action do not restore any cache
- uses: actions/cache/save@v3
if: steps.restore-3d.outputs.cache-hit != 'true'
id: save-3d
with:
path: /build/core/Common/3dParty
key: 3dParty-${{ steps.prepare.outputs.party-key }}
# Make new qt tool cache if restore action do not restore any cache
- uses: actions/cache/save@v3
if: steps.restore-qt.outputs.cache-hit != 'true'
id: save-qt
with:
path: /build/build_tools/tools/linux/qt_build
key: qt-${{ steps.prepare.outputs.qt-key }}