diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md index 4962e86fa..cc78ed8c7 100644 --- a/.github/CONTRIBUTING.md +++ b/.github/CONTRIBUTING.md @@ -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 diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index dce907484..7a2d3a7c4 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -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' @@ -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' @@ -129,25 +123,6 @@ jobs: with: fetch-depth: 2 - - name: Read repo config - uses: pietrobolcato/action-read-yaml@1.1.0 - 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 @@ -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 diff --git a/scripts/build_codeql_language.py b/scripts/build_codeql_language.py index 5b3306c1e..8988aac01 100644 --- a/scripts/build_codeql_language.py +++ b/scripts/build_codeql_language.py @@ -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: @@ -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) diff --git a/scripts/get_codeql_languages.py b/scripts/get_codeql_languages.py index 32544d5a1..92af9f0fa 100644 --- a/scripts/get_codeql_languages.py +++ b/scripts/get_codeql_languages.py @@ -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",