|
| 1 | +name: Build and test the project |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - main |
| 7 | + paths-ignore: |
| 8 | + - ".devcontainer/Dockerfile" |
| 9 | + pull_request: |
| 10 | + branches: |
| 11 | + - main |
| 12 | + paths-ignore: |
| 13 | + - ".devcontainer/Dockerfile" |
| 14 | + workflow_dispatch: |
| 15 | + |
| 16 | +# IMPORTANT: make sure to use the 'runner user'when running jobs in a container! |
| 17 | +# Otherwise there will be 'dubious ownership' issues reported by Git. |
| 18 | +# Therefore, make sure to use the '--user 1001' option for the container. |
| 19 | +jobs: |
| 20 | + build-doc: |
| 21 | + runs-on: ubuntu-latest |
| 22 | + container: |
| 23 | + image: ghcr.io/${{ github.repository_owner }}/${{ github.event.repository.name }}:latest |
| 24 | + options: --user 1001 |
| 25 | + steps: |
| 26 | + - name: Checkout code |
| 27 | + uses: actions/checkout@v4 |
| 28 | + - name: Build documentation |
| 29 | + run: ./tools/build-docs.sh |
| 30 | + - name: Upload documentation |
| 31 | + uses: actions/upload-artifact@v4 |
| 32 | + with: |
| 33 | + name: documentation |
| 34 | + path: "build/html" |
| 35 | + retention-days: 1 |
| 36 | + |
| 37 | + build-app: |
| 38 | + runs-on: ubuntu-latest |
| 39 | + container: |
| 40 | + image: ghcr.io/${{ github.repository_owner }}/${{ github.event.repository.name }}:latest |
| 41 | + options: --user 1001 |
| 42 | + strategy: |
| 43 | + matrix: |
| 44 | + compiler: [gcc, clang] |
| 45 | + steps: |
| 46 | + - name: Checkout code |
| 47 | + uses: actions/checkout@v4 |
| 48 | + with: |
| 49 | + submodules: "true" |
| 50 | + - name: Run clang-format |
| 51 | + run: ./tools/clang-format.sh |
| 52 | + - name: Build application |
| 53 | + run: | |
| 54 | + export ENABLE_IWYU=1 |
| 55 | + export ENABLE_LWYU=1 |
| 56 | + export ENABLE_CLANG_TIDY=1 |
| 57 | + export ENABLE_CPPCHECK=1 |
| 58 | + ./tools/build-cmake-target.sh ${{ matrix.compiler }}-release cplusplus_training_project |
| 59 | + - name: Upload application |
| 60 | + uses: actions/upload-artifact@v4 |
| 61 | + with: |
| 62 | + name: application-${{ matrix.compiler }} |
| 63 | + path: "build/${{ matrix.compiler }}-release/bin/cplusplus_training_project" |
| 64 | + retention-days: 1 |
| 65 | + |
| 66 | + test-app: |
| 67 | + runs-on: ubuntu-latest |
| 68 | + container: |
| 69 | + image: ghcr.io/${{ github.repository_owner }}/${{ github.event.repository.name }}:latest |
| 70 | + options: --user 1001 |
| 71 | + strategy: |
| 72 | + matrix: |
| 73 | + compiler: [gcc, clang] |
| 74 | + steps: |
| 75 | + - name: Checkout code |
| 76 | + uses: actions/checkout@v4 |
| 77 | + with: |
| 78 | + submodules: "true" |
| 79 | + - name: Build tests |
| 80 | + run: ./tools/build-cmake-target.sh ${{ matrix.compiler }}-coverage calculate_test |
| 81 | + - name: Run tests |
| 82 | + run: ./tools/run-test.sh build/${{ matrix.compiler }}-coverage/bin/calculate_test build/${{ matrix.compiler }} |
| 83 | + - name: Upload test results |
| 84 | + uses: actions/upload-artifact@v4 |
| 85 | + with: |
| 86 | + name: test-results-${{ matrix.compiler }} |
| 87 | + path: "build/${{ matrix.compiler }}/*.xml" |
| 88 | + retention-days: 1 |
0 commit comments