Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ To run the tests locally, **you will need the following dependencies**:
- **Python 3.9+**: our build system is constructed with Python given that
testing is built with glotter, a Python testing library that leverages docker.
- **Poetry**: our build system is managed and versioned using Poetry. Make sure
to use version **2.1.1** or later. If you are using an older version, please
to use version **2.1.3** or later. If you are using an older version, please
update to the latest.

With all three installed, the remaining dependencies can be installed using
Expand Down
27 changes: 1 addition & 26 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,7 @@ on:
branches: [ main ]
paths:
- '.github/workflows/codeql-analysis.yml'
- 'repo-config.yml'
- 'scripts/*.py'
- 'pyproject.toml'
- 'poetry.lock'
- 'archive/c/c/*.c'
- 'archive/c/c/testinfo.yml'
- 'archive/c/c-plus-plus/*.cpp'
Expand All @@ -45,10 +42,7 @@ on:
- 'main'
paths:
- '.github/workflows/codeql-analysis.yml'
- 'repo-config.yml'
- 'scripts/*.py'
- 'pyproject.toml'
- 'poetry.lock'
- 'archive/c/c/*.c'
- 'archive/c/c/testinfo.yml'
- 'archive/c/c-plus-plus/*.cpp'
Expand Down Expand Up @@ -129,25 +123,6 @@ jobs:
with:
fetch-depth: 2

- name: Read repo config
uses: pietrobolcato/[email protected]
id: repo-config
with:
config: repo-config.yml

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "${{ steps.repo-config.outputs['python-version'] }}"

- name: Run Poetry Image
uses: abatilo/actions-poetry@v3
with:
poetry-version: "${{ steps.repo-config.outputs['poetry-version'] }}"

- name: Install Dependencies
run: poetry install

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v3
Expand All @@ -170,7 +145,7 @@ jobs:

- name: Manual build
if: ${{ matrix.build-mode == 'manual' }}
run: poetry run python scripts/build_codeql_language.py ${{ matrix.language }} ${{ matrix.paths }}
run: python scripts/build_codeql_language.py ${{ matrix.language }} ${{ matrix.paths }}

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v3
20 changes: 11 additions & 9 deletions scripts/build_codeql_language.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,23 @@
import argparse
import re
import shlex
import subprocess
from dataclasses import dataclass
from pathlib import Path
from typing import Dict, List

from glotter.source import Source

TEST_INFO_DIR: Dict[str, str] = {
"c": "c",
"cpp": "c-plus-plus",
"java": "java",
"kotlin": "kotlin",
"swift": "swift",
}

BUILD_PATTERN = re.compile(r"""^\s+build:\s*['"]([^'"]+)""", re.M)
SOURCE_NAME_PATTERN = re.compile(r"\{\{\s*source\.name\s*\}\}")
SOURCE_EXTENSION_PATTERN = re.compile(r"\{\{\s*source\.extension\s*\}\}")


@dataclass
class TestInfoStruct:
Expand Down Expand Up @@ -42,13 +46,11 @@ def get_test_info_struct(language: str) -> TestInfoStruct:


def get_build_command(testinfo_struct: TestInfoStruct, path: Path) -> List[str]:
source = Source(
name=path.name,
language=testinfo_struct.language,
path=str(path),
test_info_string=testinfo_struct.test_info_str,
)
build: str = source.test_info.container_info.build
match_str = BUILD_PATTERN.search(testinfo_struct.test_info_str)
assert match_str

build = SOURCE_NAME_PATTERN.sub(path.stem, match_str.group(1))
build = SOURCE_EXTENSION_PATTERN.sub(path.suffix, build)
return shlex.split(build)


Expand Down
1 change: 1 addition & 0 deletions scripts/get_codeql_languages.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ class LanguageInfo:
"archive/p/python/*.py": LanguageInfo(language="python"),
"archive/r/ruby/*.rb": LanguageInfo(language="ruby"),
"archive/t/typescript/*.ts": LanguageInfo(language="typescript"),
"archive/s/swift/*.swift": LanguageInfo(language="swift", build_mode="manual", os=MACOS),
}
ALL_CODEQL_LANGUAGES_FILES = {
".github/workflows/codeql-analysis.yml",
Expand Down