Skip to content

Commit bc387f1

Browse files
authored
Fix workflows and add new ones (#318)
* Fix workflows and add new ones * Fix CodeQL flagged code
1 parent f63822f commit bc387f1

13 files changed

+104
-13
lines changed

.github/codeql/codeql-config.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
name: "My CodeQL config"
2+
3+
queries:
4+
- uses: security-and-quality
5+
6+
paths-ignore:
7+
- docs

.github/dependabot.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
version: 2
2+
updates:
3+
# Set update schedule for GitHub Actions
4+
- package-ecosystem: "github-actions"
5+
directory: "/"
6+
schedule:
7+
# Check for updates to GitHub Actions every weekday
8+
interval: "weekly"
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
# For most projects, this workflow file will not need changing; you simply need
2+
# to commit it to your repository.
3+
#
4+
# You may wish to alter this file to override the set of languages analyzed,
5+
# or to provide custom queries or build logic.
6+
name: "CodeQL"
7+
8+
on:
9+
push:
10+
branches: [main]
11+
pull_request:
12+
# The branches below must be a subset of the branches above
13+
branches: [main]
14+
schedule:
15+
- cron: '0 8 * * 3'
16+
17+
permissions:
18+
security-events:
19+
write
20+
21+
jobs:
22+
analyze:
23+
name: Analyze
24+
runs-on: ubuntu-20.04
25+
26+
strategy:
27+
fail-fast: false
28+
matrix:
29+
# Override automatic language detection by changing the below list
30+
# Supported options are ['csharp', 'cpp', 'go', 'java', 'javascript', 'python']
31+
language: ['python']
32+
# Learn more...
33+
# https://docs.github.com/en/github/finding-security-vulnerabilities-and-errors-in-your-code/configuring-code-scanning#overriding-automatic-language-detection
34+
35+
steps:
36+
- name: Checkout repository
37+
uses: actions/checkout@v3
38+
with:
39+
# We must fetch at least the immediate parents so that if this is
40+
# a pull request then we can checkout the head.
41+
fetch-depth: 2
42+
43+
# Initializes the CodeQL tools for scanning.
44+
- name: Initialize CodeQL
45+
uses: github/codeql-action/init@v2
46+
with:
47+
languages: ${{ matrix.language }}
48+
config-file: ./.github/codeql/codeql-config.yml
49+
50+
# If you wish to specify custom queries, you can do so here or in a config file.
51+
# By default, queries listed here will override any specified in a config file.
52+
# Prefix the list here with "+" to use these queries and those in the config file.
53+
# queries: ./path/to/local/query, your-org/your-repo/queries@main
54+
55+
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
56+
# If this step fails, then you should remove it and run the build manually (see below)
57+
- name: Autobuild
58+
uses: github/codeql-action/autobuild@v2
59+
60+
# ℹ️ Command-line programs to run using the OS shell.
61+
# 📚 https://git.io/JvXDl
62+
63+
# ✏️ If the Autobuild fails above, remove it and uncomment the following three lines
64+
# and modify them (or add more) to build your code if your project
65+
# uses a compiled language
66+
67+
#- run: |
68+
# make bootstrap
69+
# make release
70+
71+
- name: Perform CodeQL Analysis
72+
uses: github/codeql-action/analyze@v2

.github/workflows/fix-license-header.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name: Fix License Headers
22

33
on:
4-
pull_request:
4+
pull_request_target:
55

66
permissions:
77
contents: write

.github/workflows/tests.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ jobs:
1818
fail-fast: false
1919
matrix:
2020
os: [ubuntu-latest, windows-latest, macos-latest]
21-
python_version: ["3.7", "3.10"]
21+
python-version: ["3.7", "3.10"]
2222
include:
2323
- os: windows-latest
2424
python-version: "3.9"
@@ -40,7 +40,7 @@ jobs:
4040
args="-vv -raXs --cov jupyterlab_server --cov-branch --cov-report term-missing:skip-covered --durations 10 --color=yes --cov-fail-under 65"
4141
python -m pytest $args || python -m pytest $args --lf
4242
- name: Run the tests on pypy and windows
43-
if: ${{ startsWith(matrix.python_version, 'pypy') || startsWith(matrix.os, 'windows') }}
43+
if: ${{ startsWith(matrix.python-version, 'pypy') || startsWith(matrix.os, 'windows') }}
4444
run: |
4545
python -m pytest -vv -raXs || python -m pytest -vv -raXs --lf
4646
- name: Upload coverage

jupyterlab_server/__init__.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
"LabHandler",
1818
"LabServerApp",
1919
"LicensesApp",
20-
"SETTINGS_EXTENSION",
2120
"slugify",
2221
"translator",
2322
"WORKSPACE_EXTENSION",

jupyterlab_server/licenses_handler.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,8 @@ def report(self, report_format, bundles_pattern, full_text):
8585
"text/markdown",
8686
)
8787

88+
raise ValueError(f"Unsupported report format {report_format}.")
89+
8890
def report_json(self, bundles):
8991
"""create a JSON report
9092
TODO: SPDX

jupyterlab_server/process.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ def __init__(self, cmd, logger=None, cwd=None, kill_event=None, env=None, quiet=
8989
if kill_event and kill_event.is_set():
9090
raise ValueError("Process aborted")
9191

92-
self.logger = logger = logger or self.get_log()
92+
self.logger = logger or self.get_log()
9393
self._last_line = ""
9494
if not quiet:
9595
self.logger.info(f"> {list2cmdline(cmd)}")

jupyterlab_server/settings_utils.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,6 @@ def _path(root_dir, schema_name, make_dirs=False, extension=".json"):
239239
parent directory for the calculated path if it does not exist.
240240
"""
241241

242-
parent_dir = root_dir
243242
notfound_error = "Settings not found (%s)"
244243
write_error = "Failed writing settings (%s): %s"
245244

jupyterlab_server/test_utils.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,6 @@ def maybe_patch_ioloop():
108108
"""a windows 3.8+ patch for the asyncio loop"""
109109
if sys.platform.startswith("win") and tornado.version_info < (6, 1):
110110
if sys.version_info >= (3, 8):
111-
import asyncio
112111

113112
try:
114113
from asyncio import (
@@ -119,10 +118,12 @@ def maybe_patch_ioloop():
119118
pass
120119
# not affected
121120
else:
122-
if type(asyncio.get_event_loop_policy()) is WindowsProactorEventLoopPolicy:
121+
from asyncio import get_event_loop_policy, set_event_loop_policy
122+
123+
if type(get_event_loop_policy()) is WindowsProactorEventLoopPolicy:
123124
# WindowsProactorEventLoopPolicy is not compatible with tornado 6
124125
# fallback to the pre-3.8 default of Selector
125-
asyncio.set_event_loop_policy(WindowsSelectorEventLoopPolicy())
126+
set_event_loop_policy(WindowsSelectorEventLoopPolicy())
126127

127128

128129
def expected_http_error(error, expected_code, expected_message=None):
@@ -148,6 +149,8 @@ def expected_http_error(error, expected_code, expected_message=None):
148149
return False
149150
return True
150151

152+
return False
153+
151154

152155
@contextmanager
153156
def assert_http_error(status, msg=None):

0 commit comments

Comments
 (0)