Skip to content
Open
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
94 changes: 94 additions & 0 deletions .github/workflows/linux-compile.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
name: Linux compile

on:
pull_request:
branches: [main]
types: [opened, synchronize, reopened]
paths:
- 'core/**'
- 'cmake/**'
- 'CMakeLists.txt'
- '3rdparty/**'
- '.gitmodules'
- '.github/workflows/linux-compile.yml'

permissions:
contents: read
pull-requests: read

concurrency:
group: linux-compile-${{ github.event.pull_request.number }}
cancel-in-progress: true

env:
CONFIGURE: >-
-G Ninja -DCMAKE_BUILD_TYPE=Release -DBUILD_TESTING=ON
-DCMAKE_C_COMPILER=gcc -DCMAKE_CXX_COMPILER=g++

jobs:
linux-compile:
runs-on: ubuntu-latest
timeout-minutes: 40
steps:
- uses: actions/checkout@v7
with:
persist-credentials: false
- id: submodules
name: Key the submodules on their commits
run: |
echo "key=$(git ls-files -s | awk '$1 == "160000" { print $2, $4 }' | cat - .gitmodules | sha256sum | cut -c1-16)" >> "$GITHUB_OUTPUT"
- id: submodule-cache
uses: actions/cache/restore@v6
with:
path: ${{ runner.temp }}/submodule-gitdirs.tar
key: submodule-gitdirs-${{ runner.os }}-${{ steps.submodules.outputs.key }}
- name: Check out the submodules
run: |
if [ -f "$RUNNER_TEMP/submodule-gitdirs.tar" ]; then tar -xf "$RUNNER_TEMP/submodule-gitdirs.tar"; fi
git submodule update --init --recursive --depth 1 --jobs 8
- if: steps.submodule-cache.outputs.cache-hit != 'true'
run: tar -cf "$RUNNER_TEMP/submodule-gitdirs.tar" .git/modules
- if: steps.submodule-cache.outputs.cache-hit != 'true'
uses: actions/cache/save@v6
continue-on-error: true
with:
path: ${{ runner.temp }}/submodule-gitdirs.tar
key: submodule-gitdirs-${{ runner.os }}-${{ steps.submodules.outputs.key }}
- name: Install the build dependencies
run: |
sudo apt-get update
sudo apt-get install -y --no-install-recommends ninja-build libx11-dev libxext-dev libxrandr-dev libasound2-dev libpulse-dev mesa-vulkan-drivers
- name: Configure the Linux build
run: cmake -S . -B build $CONFIGURE
- name: Build the AGC library and its generated headers
run: cmake --build build --target libSceAgcDriver -- -j 4
- id: sources
name: List the changed library sources
env:
GH_TOKEN: ${{ github.token }}
PR_NUMBER: ${{ github.event.pull_request.number }}
run: |
set -euo pipefail
gh api --paginate "repos/$GITHUB_REPOSITORY/pulls/$PR_NUMBER/files" --jq '.[] | select(.status != "removed") | .filename' > "$RUNNER_TEMP/files.txt"
status=0
grep -Ei '^core/.*\.(c|cc|cpp|cxx)$' "$RUNNER_TEMP/files.txt" > "$RUNNER_TEMP/sources.txt" || status=$?
if [ "$status" -gt 1 ]; then exit "$status"; fi
echo "count=$(wc -l < "$RUNNER_TEMP/sources.txt")" >> "$GITHUB_OUTPUT"
cat "$RUNNER_TEMP/sources.txt"
- name: Check that the changed library sources compile
if: steps.sources.outputs.count != '0'
run: |
set +e
mapfile -t sources < "$RUNNER_TEMP/sources.txt"
output=$(python3 tools/check_compile.py --build build --jobs 4 "${sources[@]}" 2>&1)
status=$?
set -e
printf '%s\n' "$output"
if [ "$status" -eq 3 ]; then
echo "The changed sources are not part of the Linux build configuration"
exit 0
fi
exit "$status"
- name: Report that there is no changed library source to check
if: steps.sources.outputs.count == '0'
run: echo "No changed C or C++ source under core/; changed headers alone are not checked by this job"
2 changes: 1 addition & 1 deletion tools/check_compile.py
Original file line number Diff line number Diff line change
Expand Up @@ -712,7 +712,7 @@ def main(argv=None):
return 1
if not checked:
print(f"no translation unit to check in {args.build}", file=sys.stderr)
return 1
return 3
print(f"{checked} translation units compile")
return 0

Expand Down
4 changes: 2 additions & 2 deletions tools/tests/test_check_compile.py
Original file line number Diff line number Diff line change
Expand Up @@ -261,10 +261,10 @@ def test_windows_paths_and_quoted_defines_survive_the_syntax_check(self):
self.assertEqual(json.loads(seen.read_text(encoding="utf-8")),
["-fsyntax-only", *flags, str(source)])

def test_nothing_checked_is_a_failure(self):
def test_nothing_checked_is_a_distinct_result(self):
self.manifest([])
result = self.tool("orphan.cpp")
self.assertEqual(result.returncode, 1)
self.assertEqual(result.returncode, 3)
self.assertIn("orphan.cpp: no compile command in", result.stderr)
self.assertIn("no translation unit to check in", result.stderr)

Expand Down
Loading