Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 7430026

Browse files
QuLogicoscargustacaswell
committed
CI: Add CodeQL analysis
Co-authored-by: Oscar Gustafsson <[email protected]> Co-authored-by: Thomas A Caswell <[email protected]>
1 parent 312fdb7 commit 7430026

File tree

2 files changed

+67
-5
lines changed

2 files changed

+67
-5
lines changed

.github/workflows/codeql-analysis.yml

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
---
2+
name: "CodeQL"
3+
4+
on:
5+
push:
6+
branches: [main, v*.x]
7+
pull_request:
8+
# The branches below must be a subset of the branches above
9+
branches: [main]
10+
schedule:
11+
- cron: '45 19 * * 1'
12+
13+
jobs:
14+
analyze:
15+
name: Analyze
16+
runs-on: ubuntu-latest
17+
permissions:
18+
actions: read
19+
contents: read
20+
security-events: write
21+
22+
strategy:
23+
fail-fast: false
24+
matrix:
25+
language: ['cpp', 'javascript', 'python']
26+
27+
steps:
28+
- name: Checkout repository
29+
uses: actions/checkout@v3
30+
31+
- name: Set up Python
32+
uses: actions/setup-python@v4
33+
if: matrix.language != 'javascript'
34+
with:
35+
python-version: '3.x'
36+
- name: Install dependencies
37+
if: matrix.language != 'javascript'
38+
run: |
39+
python -m pip install --upgrade pip setuptools wheel
40+
# TODO: Use pip-tools instead when it supports build-system
41+
# dependencies so we don't need another copy here.
42+
# https://github.com/jazzband/pip-tools/pull/1681
43+
python -m pip install --upgrade \
44+
certifi contourpy cycler fonttools kiwisolver importlib_resources \
45+
numpy packaging pillow pyparsing python-dateutil setuptools-scm
46+
echo "CODEQL_PYTHON=$(which python)" >> $GITHUB_ENV
47+
48+
- name: Initialize CodeQL
49+
uses: github/codeql-action/init@v2
50+
with:
51+
languages: ${{ matrix.language }}
52+
setup-python-dependencies: false
53+
54+
- name: Build compiled code
55+
if: matrix.language == 'cpp'
56+
run: |
57+
mkdir ~/.cache/matplotlib
58+
$CODEQL_PYTHON setup.py build
59+
60+
- name: Perform CodeQL Analysis
61+
uses: github/codeql-action/analyze@v2

setupext.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,8 @@ def get_from_cache_or_download(url, sha):
7070
if cache_dir is not None: # Try to read from cache.
7171
try:
7272
data = (cache_dir / sha).read_bytes()
73-
except IOError:
74-
pass
73+
except IOError as e:
74+
print('Failed to read', sha, 'from cache_dir', cache_dir, e)
7575
else:
7676
if _get_hash(data) == sha:
7777
return BytesIO(data)
@@ -95,8 +95,8 @@ def get_from_cache_or_download(url, sha):
9595
cache_dir.mkdir(parents=True, exist_ok=True)
9696
with open(cache_dir / sha, "xb") as fout:
9797
fout.write(data)
98-
except IOError:
99-
pass
98+
except IOError as e:
99+
print('Failed to write cached', sha, 'to cache_dir', cache_dir, e)
100100

101101
return BytesIO(data)
102102

@@ -123,7 +123,8 @@ def get_and_extract_tarball(urls, sha, dirname):
123123
try:
124124
tar_contents = get_from_cache_or_download(url, sha)
125125
break
126-
except Exception:
126+
except Exception as e:
127+
print('Failed to get tarball from', url, e)
127128
pass
128129
else:
129130
raise IOError(

0 commit comments

Comments
 (0)