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
33 changes: 20 additions & 13 deletions .github/workflows/c-cpp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,29 @@

on:
push:
branches: [ "main" ]
branches: ["**"]
pull_request:
branches: [ "main" ]

jobs:
build:
concurrency:
group: c-cpp-ci-${{ github.ref }}
cancel-in-progress: true

jobs:
linux-build:
name: Configure + Build (Linux)
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- name: configure
run: ./configure
- name: make
run: make
- name: make check
run: make check
- name: make distcheck
run: make distcheck
- name: Checkout repository
uses: actions/checkout@v4

- name: Configure (CMake)
run: cmake -S . -B build -D PYC_BUILD_EXPERIMENTAL=OFF

- name: Build
run: cmake --build build --config Release --parallel

- name: List built artifacts
run: |
echo "Built files:"
find build -maxdepth 3 -type f | sort
Comment on lines +14 to +30

Check warning

Code scanning / CodeQL

Workflow does not contain permissions Medium

Actions job or workflow does not limit the permissions of the GITHUB_TOKEN. Consider setting an explicit permissions block, using the following as a minimal starting point: {contents: read}

Copilot Autofix

AI 2 months ago

In general, the fix is to explicitly declare the minimal required GITHUB_TOKEN permissions in the workflow YAML using a permissions: block, either at the top level (applies to all jobs) or per job. Since this workflow only needs to read repository contents to check out and build, contents: read is sufficient.

The best fix here, without changing functionality, is to add a root-level permissions block near the top of .github/workflows/c-cpp.yml, for example immediately after the on: section (or before jobs:). This will apply to all jobs (currently just linux-build) and restrict the automatic GITHUB_TOKEN to read-only access to repository contents. No changes to steps, actions, or other configuration are necessary.

Concretely:

  • Edit .github/workflows/c-cpp.yml.

  • Insert:

    permissions:
      contents: read

    between the on: block and the concurrency: block (or equivalently between on: and jobs: if preferred), keeping indentation consistent.

  • No new imports, libraries, or additional GitHub Actions are required.

Suggested changeset 1
.github/workflows/c-cpp.yml

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/.github/workflows/c-cpp.yml b/.github/workflows/c-cpp.yml
--- a/.github/workflows/c-cpp.yml
+++ b/.github/workflows/c-cpp.yml
@@ -5,6 +5,9 @@
     branches: ["**"]
   pull_request:
 
+permissions:
+  contents: read
+
 concurrency:
   group: c-cpp-ci-${{ github.ref }}
   cancel-in-progress: true
EOF
@@ -5,6 +5,9 @@
branches: ["**"]
pull_request:

permissions:
contents: read

concurrency:
group: c-cpp-ci-${{ github.ref }}
cancel-in-progress: true
Copilot is powered by AI and may make mistakes. Always verify output.
30 changes: 17 additions & 13 deletions .github/workflows/cmake-multi-platform.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,31 +2,35 @@ name: CMake Multi-Platform

on:
push:
branches: [ main ]
branches: [main]
pull_request:
branches: [ main ]

concurrency:
group: cmake-matrix-${{ github.ref }}
cancel-in-progress: true

jobs:
build:
name: Build on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]

steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Checkout repository
uses: actions/checkout@v4

- name: Set up CMake
uses: lukka/get-cmake@v3
- name: Set up CMake
uses: jwlawson/actions-setup-cmake@v2

- name: Configure
run: cmake -S . -B build
- name: Configure
run: cmake -S . -B build -D PYC_BUILD_EXPERIMENTAL=OFF

- name: Build
run: cmake --build build
- name: Build
run: cmake --build build --config Release --parallel

- name: Run tests
if: always()
run: ctest --test-dir build
- name: Run tests (if present)
run: ctest --test-dir build -C Release --output-on-failure
continue-on-error: true
51 changes: 32 additions & 19 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,27 +1,40 @@
cmake_minimum_required(VERSION 3.10)
project(PyC_Core C CXX)

# Set the source directory
set(SRC_DIR "${CMAKE_SOURCE_DIR}/Core/C_Files")
set(HEADER_DIR "${CMAKE_SOURCE_DIR}/Core/Header")

# Gather all .c and .cpp files
file(GLOB SOURCES
"${SRC_DIR}/*.c"
"${SRC_DIR}/*.cpp"
set(CMAKE_C_STANDARD 11)
set(CMAKE_C_STANDARD_REQUIRED ON)
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

set(HEADER_DIR "${CMAKE_SOURCE_DIR}/Core/Header_Files")
include_directories(${HEADER_DIR})

# Build a stable core library that is currently portable and compiles in CI.
add_library(pyc_foundation STATIC
Core/C_Files/stack.c
Core/C_Files/symbol_table.c
)

# Add the executable
add_executable(PyC_Core ${SOURCES})
target_include_directories(pyc_foundation PUBLIC ${HEADER_DIR})

# Ensure the compiler can find your header files!
target_include_directories(PyC_Core PRIVATE ${HEADER_DIR})
option(PYC_BUILD_EXPERIMENTAL "Build experimental compiler sources" OFF)

# (Optional) Set C++ standard if needed
set_target_properties(PyC_Core PROPERTIES
CXX_STANDARD 11
CXX_STANDARD_REQUIRED YES
)
if(PYC_BUILD_EXPERIMENTAL)
message(STATUS "Building experimental PyC compiler sources")

add_executable(PyC_Core
Core/C_Files/Core.cpp
Core/C_Files/IR.c
Core/C_Files/api.c
Core/C_Files/backend.c
Core/C_Files/codegen.c
Core/C_Files/error_handler.c
Core/C_Files/frontend.c
Core/C_Files/ir_generator.c
Core/C_Files/lexer.c
Core/C_Files/main.c
Core/C_Files/parser.c
)

# (Optional) Link libraries here, e.g.:
# target_link_libraries(PyC_Core PRIVATE <library_name>)
target_include_directories(PyC_Core PRIVATE ${HEADER_DIR})
endif()
Loading