Skip to content

Commit 2ddbff1

Browse files
chore: update global workflows (#106)
Co-authored-by: ReenigneArcher <[email protected]>
1 parent 77b1b55 commit 2ddbff1

File tree

4 files changed

+83
-37
lines changed

4 files changed

+83
-37
lines changed

.github/workflows/codeql.yml

+46-17
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,21 @@
11
---
2-
# This action is centrally managed in https://github.com/<organization>/.github/
2+
# This workflow is centrally managed in https://github.com/<organization>/.github/
33
# Don't make changes to this file in this repo as they will be overwritten with changes made to the same file in
44
# the above-mentioned repo.
55

66
# This workflow will analyze all supported languages in the repository using CodeQL Analysis.
77

88
name: "CodeQL"
9+
permissions:
10+
contents: read
911

1012
on:
1113
push:
12-
branches: ["master"]
14+
branches:
15+
- master
1316
pull_request:
14-
branches: ["master"]
17+
branches:
18+
- master
1519
schedule:
1620
- cron: '00 12 * * 0' # every Sunday at 12:00 UTC
1721

@@ -22,14 +26,17 @@ concurrency:
2226
jobs:
2327
languages:
2428
name: Get language matrix
25-
runs-on: ubuntu-latest
2629
outputs:
2730
matrix: ${{ steps.lang.outputs.result }}
2831
continue: ${{ steps.continue.outputs.result }}
32+
runs-on: ubuntu-latest
2933
steps:
34+
- name: Checkout repository
35+
uses: actions/checkout@v4
36+
3037
- name: Get repo languages
31-
uses: actions/github-script@v7
3238
id: lang
39+
uses: actions/github-script@v7
3340
with:
3441
script: |
3542
// CodeQL supports ['cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby', 'swift']
@@ -54,6 +61,22 @@ jobs:
5461
// Track languages we've already added to avoid duplicates
5562
const addedLanguages = new Set()
5663
64+
// Check if workflow files exist to determine if we should add actions language
65+
const fs = require('fs');
66+
const hasYmlFiles = fs.existsSync('.github/workflows') &&
67+
fs.readdirSync('.github/workflows').some(file => file.endsWith('.yml') || file.endsWith('.yaml'));
68+
69+
// Add actions language if workflow files exist
70+
if (hasYmlFiles) {
71+
console.log('Found GitHub Actions workflow files. Adding actions to the matrix.');
72+
matrix['include'].push({
73+
"category": "/language:actions",
74+
"language": "actions",
75+
"name": "actions",
76+
"os": "ubuntu-latest"
77+
});
78+
}
79+
5780
for (let [key, value] of Object.entries(response.data)) {
5881
// remap language
5982
if (remap_languages[key.toLowerCase()]) {
@@ -78,11 +101,18 @@ jobs:
78101
// set name for matrix
79102
let name = osList.length === 1 ? normalizedKey : `${normalizedKey}, ${os}`
80103
104+
// set category for matrix
105+
let category = `/language:${normalizedKey}`
106+
if (normalizedKey === 'cpp') {
107+
category = `/language:cpp-${os.split('-')[0]}`
108+
}
109+
81110
// add to matrix
82111
matrix['include'].push({
112+
"category": category,
83113
"language": normalizedKey,
84-
"os": os,
85-
"name": name
114+
"name": name,
115+
"os": os
86116
})
87117
}
88118
}
@@ -94,8 +124,8 @@ jobs:
94124
return matrix
95125
96126
- name: Continue
97-
uses: actions/github-script@v7
98127
id: continue
128+
uses: actions/github-script@v7
99129
with:
100130
script: |
101131
// if matrix['include'] is an empty list return false, otherwise true
@@ -109,24 +139,22 @@ jobs:
109139
110140
analyze:
111141
name: Analyze (${{ matrix.name }})
112-
if: ${{ needs.languages.outputs.continue == 'true' }}
142+
if: needs.languages.outputs.continue == 'true'
113143
defaults:
114144
run:
115145
shell: ${{ matrix.os == 'windows-latest' && 'msys2 {0}' || 'bash' }}
116146
env:
117147
GITHUB_CODEQL_BUILD: true
118-
needs: [languages]
119-
runs-on: ${{ matrix.os || 'ubuntu-latest' }}
120-
timeout-minutes: ${{ (matrix.language == 'swift' && 120) || 360 }}
148+
needs: languages
121149
permissions:
122150
actions: read
123151
contents: read
124152
security-events: write
125-
153+
runs-on: ${{ matrix.os || 'ubuntu-latest' }}
126154
strategy:
127155
fail-fast: false
128156
matrix: ${{ fromJson(needs.languages.outputs.matrix) }}
129-
157+
timeout-minutes: ${{ (matrix.language == 'swift' && 120) || 360 }}
130158
steps:
131159
- name: Maximize build space
132160
if: >-
@@ -174,8 +202,7 @@ jobs:
174202
- third-party
175203
176204
# Pre autobuild
177-
# create a file named .codeql-prebuild-${{ matrix.language }}.sh in the root of your repository
178-
# create a file named .codeql-build-${{ matrix.language }}.sh in the root of your repository
205+
# create a file named .codeql-prebuild-${{ matrix.language }}-${{ runner.os }}.sh in the root of your repository
179206
- name: Prebuild
180207
id: prebuild
181208
run: |
@@ -194,7 +221,7 @@ jobs:
194221
- name: Perform CodeQL Analysis
195222
uses: github/codeql-action/analyze@v3
196223
with:
197-
category: "/language:${{matrix.language}}"
224+
category: "${{ matrix.category }}"
198225
output: sarif-results
199226
upload: failure-only
200227

@@ -211,11 +238,13 @@ jobs:
211238
- name: Upload SARIF
212239
uses: github/codeql-action/upload-sarif@v3
213240
with:
241+
category: "${{ matrix.category }}"
214242
sarif_file: sarif-results/${{ matrix.language }}.sarif
215243

216244
- name: Upload loc as a Build Artifact
217245
uses: actions/upload-artifact@v4
218246
with:
219247
name: sarif-results-${{ matrix.language }}-${{ runner.os }}
220248
path: sarif-results
249+
if-no-files-found: error
221250
retention-days: 1

.github/workflows/common-lint.yml

+12-6
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,22 @@
11
---
2-
# This action is centrally managed in https://github.com/<organization>/.github/
2+
# This workflow is centrally managed in https://github.com/<organization>/.github/
33
# Don't make changes to this file in this repo as they will be overwritten with changes made to the same file in
44
# the above-mentioned repo.
55

66
# Common linting.
77

88
name: common lint
9+
permissions:
10+
contents: read
911

1012
on:
1113
pull_request:
12-
branches: [master]
13-
types: [opened, synchronize, reopened]
14+
branches:
15+
- master
16+
types:
17+
- opened
18+
- synchronize
19+
- reopened
1420

1521
concurrency:
1622
group: "${{ github.workflow }}-${{ github.ref }}"
@@ -77,9 +83,10 @@ jobs:
7783
7884
- name: C++ - Clang format lint
7985
if: always() && steps.cpp_files.outputs.found_files
80-
uses: DoozyX/clang-format-lint-action@v0.18
86+
uses: DoozyX/clang-format-lint-action@v0.20
8187
with:
8288
source: ${{ steps.cpp_files.outputs.found_files }}
89+
clangFormatVersion: '20'
8390
extensions: 'c,cpp,h,hpp,m,mm'
8491
style: file
8592
inplace: false
@@ -263,5 +270,4 @@ jobs:
263270

264271
- name: YAML - log
265272
if: always() && steps.yamllint.outcome == 'failure'
266-
run: |
267-
cat "${{ steps.yamllint.outputs.logfile }}" >> $GITHUB_STEP_SUMMARY
273+
run: cat "${{ steps.yamllint.outputs.logfile }}" >> $GITHUB_STEP_SUMMARY

.github/workflows/issues.yml

+8-3
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,22 @@
11
---
2-
# This action is centrally managed in https://github.com/<organization>/.github/
2+
# This workflow is centrally managed in https://github.com/<organization>/.github/
33
# Don't make changes to this file in this repo as they will be overwritten with changes made to the same file in
44
# the above-mentioned repo.
55

66
# Label and un-label actions using `../label-actions.yml`.
77

88
name: Issues
9+
permissions: {}
910

1011
on:
1112
issues:
12-
types: [labeled, unlabeled]
13+
types:
14+
- labeled
15+
- unlabeled
1316
discussion:
14-
types: [labeled, unlabeled]
17+
types:
18+
- labeled
19+
- unlabeled
1520

1621
jobs:
1722
label:

.github/workflows/update-pages.yml

+17-11
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,19 @@
11
---
22
name: Update
3+
permissions:
4+
contents: read
35

46
on:
57
pull_request:
6-
branches: [master]
7-
types: [opened, synchronize, reopened]
8+
branches:
9+
- master
10+
types:
11+
- opened
12+
- synchronize
13+
- reopened
814
push:
9-
branches: [master]
15+
branches:
16+
- master
1017
schedule:
1118
- cron: '0 * * * *' # every hour
1219
workflow_dispatch:
@@ -46,8 +53,7 @@ jobs:
4653
python -m pip install -r requirements.txt
4754
4855
- name: Install npm dependencies
49-
run: |
50-
npm install
56+
run: npm install
5157

5258
- name: Get current date
5359
id: date
@@ -89,8 +95,7 @@ jobs:
8995
./notebook/dashboard.ipynb
9096
9197
- name: Cat log
92-
run: |
93-
cat ./logs/updater.log
98+
run: cat ./logs/updater.log
9499

95100
- name: Check notebook for tracebacks
96101
run: |
@@ -100,26 +105,27 @@ jobs:
100105
grep -i -E 'Traceback \(most recent call last\):' ./gh-pages/index.html && exit 1 || true
101106
102107
- name: Archive gh-pages
103-
if: ${{ github.event_name == 'pull_request' || github.event_name == 'workflow_dispatch' }}
108+
if: github.event_name == 'pull_request' || github.event_name == 'workflow_dispatch'
104109
shell: bash
105110
run: |
106111
7z \
107112
"-xr!*.git*" \
108113
a "./gh-pages.zip" "./gh-pages"
109114
110115
- name: Upload Artifacts
111-
if: ${{ github.event_name == 'pull_request' || github.event_name == 'workflow_dispatch' }}
116+
if: github.event_name == 'pull_request' || github.event_name == 'workflow_dispatch'
112117
uses: actions/upload-artifact@v4
113118
with:
114119
name: gh-pages
115-
if-no-files-found: error # 'warn' or 'ignore' are also available, defaults to `warn`
120+
if-no-files-found: error
116121
path: |
117122
${{ github.workspace }}/gh-pages.zip
118123
119124
- name: Deploy to gh-pages
120125
if: >-
121126
(github.event_name == 'push' && github.ref == 'refs/heads/master') ||
122-
(github.event_name == 'schedule' || github.event_name == 'workflow_dispatch')
127+
github.event_name == 'schedule' ||
128+
github.event_name == 'workflow_dispatch'
123129
uses: actions-js/[email protected]
124130
with:
125131
github_token: ${{ secrets.GH_BOT_TOKEN }}

0 commit comments

Comments
 (0)