diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml new file mode 100644 index 0000000..b6810f8 --- /dev/null +++ b/.github/workflows/codeql.yml @@ -0,0 +1,58 @@ +name: "CodeQL" + +on: + push: + branches: [ "main" ] + pull_request: + branches: [ "main" ] + +jobs: + analyze: + name: Analyze (${{ matrix.language }}) + runs-on: ${{ (matrix.language == 'swift' && 'macos-latest') || 'ubuntu-latest' }} + permissions: + # required for all workflows + security-events: write + + # required to fetch internal or private CodeQL packs + packages: read + + # only required for workflows in private repositories + actions: read + contents: read + + strategy: + fail-fast: false + matrix: + include: + - language: c-cpp + build-mode: manual + - language: python + build-mode: none + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Initialize CodeQL + uses: github/codeql-action/init@v3 + with: + languages: ${{ matrix.language }} + build-mode: ${{ matrix.build-mode }} + # If you wish to specify custom queries, you can do so here or in a config file. + # By default, queries listed here will override any specified in a config file. + # Prefix the list here with "+" to use these queries and those in the config file. + # For more details on CodeQL's query packs, refer to: https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs + queries: security-extended,security-and-quality + + - if: matrix.build-mode == 'manual' + shell: bash + run: | + sudo apt-get install libboost-all-dev libgtest-dev + g++ -std=c++20 -DBUILD_ONLY -o nob nob.cpp + ./nob + + - name: Perform CodeQL Analysis + uses: github/codeql-action/analyze@v3 + with: + category: "/language:${{matrix.language}}" diff --git a/nob.cpp b/nob.cpp index 02d3aed..9a5f53b 100644 --- a/nob.cpp +++ b/nob.cpp @@ -80,7 +80,9 @@ void build_and_run_gtest_file(std::string_view filename) { Cstr path = PATH(filename.data()); CMD("g++", CPPFLAGS, "-o", NOEXT(path), path, "-lgtest"); +#ifndef BUILD_ONLY // github.com/iglesias/coding-challenges/actions/runs/12532941559/job/34952138092#step:4:943 CMD(NOEXT(path)); +#endif } Pid build_gtest_file_async(std::string_view path) @@ -113,6 +115,7 @@ void work_out_leetcode() for (const Pid& pid : pids) pid_wait(pid); +#ifndef BUILD_ONLY // github.com/iglesias/coding-challenges/actions/runs/12532941559/job/34952138092#step:4:943 pids.clear(); for (const auto& entry : fs::directory_iterator("leetcode")) if (fs::is_regular_file(entry.path())) { @@ -121,6 +124,7 @@ void work_out_leetcode() if (filename.ends_with(".cpp")) pids.push_back(run_gtest_file_async("leetcode/" + filename)); } for (const Pid& pid : pids) pid_wait(pid); +#endif } void build_codeforces_cpp_files() {