Skip to content

Commit

Permalink
Use trimja-action
Browse files Browse the repository at this point in the history
Use trimja ourselves to reduce the amount we need to build on pull
requests.  Unfortunately the Ninja file generated from CMake doesn't
have good dependencies for the tests.  The tests don't have a proper
dependency on the `trimja` executable, nor the test files that it reads.

For the moment we pass both `trimja` and `test` into `affected` so that
everything is always built.  However, we should look into improving
this.
  • Loading branch information
elliotgoodrich committed Oct 13, 2024
1 parent 5a8e007 commit 5405708
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 10 deletions.
26 changes: 17 additions & 9 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,25 +24,33 @@ jobs:
steps:
- uses: actions/checkout@v4
- uses: seanmiddleditch/gha-setup-ninja@master
- name: Set reusable strings
id: strings
shell: bash
run: |
echo "build-output-dir=${{ github.workspace }}/build" >> "$GITHUB_OUTPUT"
- name: Configure CMake
run: >
cmake -B ${{ steps.strings.outputs.build-output-dir }}
cmake -B output
-DCMAKE_CXX_COMPILER=${{ matrix.environment.cpp }}
-DCMAKE_C_COMPILER=${{ matrix.environment.c }}
${{ format('-D{0}={1}', matrix.environment.name == 'Windows' && 'CMAKE_CONFIGURATION_TYPES' || 'CMAKE_BUILD_TYPE', matrix.build_type) }}
${{ matrix.environment.name != 'Windows' && '-G Ninja' || ''}}
- uses: elliotgoodrich/trimja-action@v1
# Skip Windows (which doesn't yet use Ninja) and releases
if: matrix.environment.name != 'Windows' && !startsWith(github.ref, 'refs/tags/')
with:
version: '0.5.3'
path: output/build.ninja
build-configuration: ${{ matrix.build_type }}
# CTest does not have the right dependencies so we always build everything, we
# won't gain any time, but will verify that trimja can at least handle a Ninja
# file generated by CMake.
affected: |
test
trimja
- name: Build
run: cmake --build ${{ steps.strings.outputs.build-output-dir }} --config ${{ matrix.build_type }}
run: cmake --build output --config ${{ matrix.build_type }}
- name: Test
run: ctest --test-dir ${{ steps.strings.outputs.build-output-dir }} --build-config ${{ matrix.build_type }} --output-on-failure
run: ctest --test-dir output --build-config ${{ matrix.build_type }} --output-on-failure
- name: Install
if: startsWith(github.ref, 'refs/tags/') && matrix.build_type == 'Release'
run: cmake --build ${{ steps.strings.outputs.build-output-dir }} --config ${{ matrix.build_type }} --target package
run: cmake --build output --config ${{ matrix.build_type }} --target package
- name: Generate Changelog
run: git show -s --format='%b' > build/CHANGELOG.txt
if: startsWith(github.ref, 'refs/tags/') && matrix.build_type == 'Release'
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,3 +92,4 @@ files.
7. Run `ninja`
8. If the build is successful upload `.ninja_log` and `.ninja_deps` to the
cache

2 changes: 1 addition & 1 deletion src/trimutil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ struct BuildContext {
return ruleIt->second;
}();

// Collect inputs
// Collect all inputs
std::vector<std::string> ins;
for (const EvalString& path : r.in()) {
ins.push_back(evaluatePath(path));
Expand Down

0 comments on commit 5405708

Please sign in to comment.