From 949c644423dd673108ad22249cd3c71476e9c53d Mon Sep 17 00:00:00 2001 From: Nick Le Large Date: Fri, 25 Oct 2024 09:26:21 +0000 Subject: [PATCH 01/23] Add test stage to Dockerfile --- .github/workflows/build-and-push-docker.yaml | 4 +++- Dockerfile | 21 +++++++++++++++++++- 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build-and-push-docker.yaml b/.github/workflows/build-and-push-docker.yaml index 06f9fbb9..e21c355c 100644 --- a/.github/workflows/build-and-push-docker.yaml +++ b/.github/workflows/build-and-push-docker.yaml @@ -33,9 +33,11 @@ jobs: cat version >> $GITHUB_ENV - name: Build and push Docker image - uses: docker/build-push-action@v5 + uses: docker/build-push-action@v6 with: push: true tags: | ghcr.io/kit-mrt/arbitration_graphs:latest ghcr.io/kit-mrt/arbitration_graphs:${{ env.VERSION }} + target: install + diff --git a/Dockerfile b/Dockerfile index 83420625..495044b8 100644 --- a/Dockerfile +++ b/Dockerfile @@ -42,6 +42,24 @@ USER blinky WORKDIR /home/blinky/ +FROM base AS unit_test + +COPY CMakeLists.txt /tmp/arbitration_graphs/ +COPY cmake /tmp/arbitration_graphs/cmake +COPY include /tmp/arbitration_graphs/include +COPY test /tmp/arbitration_graphs/test +COPY version /tmp/arbitration_graphs/version + +# Prepare build directory +RUN mkdir /tmp/arbitration_graphs/build && \ + cd /tmp/arbitration_graphs/build && \ + cmake -DBUILD_TESTS=true .. && \ + cmake --build . -j9 + +# Run unit tests +CMD ["cmake", "--build", "/tmp/arbitration_graphs/build", "--target", "test"] + + FROM base AS install @@ -60,4 +78,5 @@ RUN mkdir /tmp/arbitration_graphs/build && \ cmake .. && \ cmake --build . && \ cmake --install . && \ - rm -rf /tmp/arbitration_graphs \ No newline at end of file + rm -rf /tmp/arbitration_graphs + From 20cc048c91a5a468910b65ce8ea907a2183e9bc0 Mon Sep 17 00:00:00 2001 From: Nick Le Large Date: Fri, 25 Oct 2024 09:49:53 +0000 Subject: [PATCH 02/23] Add unit test workflow --- .github/workflows/run-unit-tests.yaml | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 .github/workflows/run-unit-tests.yaml diff --git a/.github/workflows/run-unit-tests.yaml b/.github/workflows/run-unit-tests.yaml new file mode 100644 index 00000000..752211ae --- /dev/null +++ b/.github/workflows/run-unit-tests.yaml @@ -0,0 +1,22 @@ +name: Run unit tests + +on: + push: + branches: + - github_actions # todo: set to main branch before merge + +jobs: + build-and-run-unit-tests: + runs-on: ubuntu-latest + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Build Docker image for library unit tests + run: | + docker build --target unittest --tag arbitration_graphs_test . + + - name: Run library unit tests in Docker container + run: | + docker run --rm arbitration_graphs_test From 4958b1f4245026ad76f079ba40e5605aa5a63989 Mon Sep 17 00:00:00 2001 From: Nick Le Large Date: Wed, 6 Nov 2024 08:38:22 +0100 Subject: [PATCH 03/23] Use WORKDIR to simplify Dockerfile --- Dockerfile | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/Dockerfile b/Dockerfile index 495044b8..4ca9d0c4 100644 --- a/Dockerfile +++ b/Dockerfile @@ -50,14 +50,13 @@ COPY include /tmp/arbitration_graphs/include COPY test /tmp/arbitration_graphs/test COPY version /tmp/arbitration_graphs/version -# Prepare build directory -RUN mkdir /tmp/arbitration_graphs/build && \ - cd /tmp/arbitration_graphs/build && \ - cmake -DBUILD_TESTS=true .. && \ +WORKDIR /tmp/arbitration_graphs/build + +RUN cmake -DBUILD_TESTS=true .. && \ cmake --build . -j9 # Run unit tests -CMD ["cmake", "--build", "/tmp/arbitration_graphs/build", "--target", "test"] +CMD ["cmake", "--build", ".", "--target", "test"] @@ -73,9 +72,9 @@ COPY gui /tmp/arbitration_graphs/gui COPY include /tmp/arbitration_graphs/include COPY test /tmp/arbitration_graphs/test -RUN mkdir /tmp/arbitration_graphs/build && \ - cd /tmp/arbitration_graphs/build && \ - cmake .. && \ +WORKDIR /tmp/arbitration_graphs/build + +RUN cmake .. && \ cmake --build . && \ cmake --install . && \ rm -rf /tmp/arbitration_graphs From bb3c19158c161d3dedcc081f966e00eafec8eb6f Mon Sep 17 00:00:00 2001 From: Nick Le Large Date: Wed, 6 Nov 2024 08:38:33 +0100 Subject: [PATCH 04/23] Add unittest stage to demo/Dockerfile --- demo/Dockerfile | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/demo/Dockerfile b/demo/Dockerfile index 1fc477ee..2f9e68ba 100644 --- a/demo/Dockerfile +++ b/demo/Dockerfile @@ -30,6 +30,25 @@ WORKDIR /home/blinky/demo CMD [ "/bin/bash" ] + +FROM tutorial AS unit_test + +COPY --chown=blinky:blinky cmake /home/blinky/demo/cmake +COPY --chown=blinky:blinky include /home/blinky/demo/include +COPY --chown=blinky:blinky src /home/blinky/demo/src +COPY --chown=blinky:blinky test /home/blinky/demo/test +COPY --chown=blinky:blinky CMakeLists.txt /home/blinky/demo/CMakeLists.txt + +WORKDIR /home/blinky/demo/build + +RUN cmake -DBUILD_TESTS=true .. && \ + cmake --build . -j8 + +# Run unit tests +CMD ["cmake", "--build", ".", "--target", "test"] + + + FROM tutorial AS demo COPY --chown=blinky:blinky cmake /home/blinky/demo/cmake From fd8ee1d7dbe27a0c8a2f50f9afbb301191bc3444 Mon Sep 17 00:00:00 2001 From: Nick Le Large Date: Wed, 6 Nov 2024 08:42:05 +0100 Subject: [PATCH 05/23] Extend unit test workflow by demo unit tests --- .github/workflows/run-unit-tests.yaml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/.github/workflows/run-unit-tests.yaml b/.github/workflows/run-unit-tests.yaml index 752211ae..65ca9a16 100644 --- a/.github/workflows/run-unit-tests.yaml +++ b/.github/workflows/run-unit-tests.yaml @@ -20,3 +20,11 @@ jobs: - name: Run library unit tests in Docker container run: | docker run --rm arbitration_graphs_test + + - name: Build Docker image for demo unit tests + run: | + docker build --file demo/Dockerfile --target unittest --tag arbitration_graphs_demo_test demo + + - name: Run unit tests in Docker container + run: | + docker run --rm arbitration_graphs_demo_test From ad82353be324454ad0ad003382e35abf6ab76b51 Mon Sep 17 00:00:00 2001 From: Nick Le Large Date: Wed, 6 Nov 2024 08:48:23 +0100 Subject: [PATCH 06/23] Add version tag to devel image as well --- docker-compose.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker-compose.yaml b/docker-compose.yaml index 26bfbcf3..197e3414 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -9,6 +9,6 @@ services: target: devel extends: service: arbitration_graphs - image: arbitration_graphs_devel + image: arbitration_graphs_devel:$VERSION volumes: - .:/home/blinky/arbitration_graphs From 10976643863f19895a8bb3e6faabe6ebe5e97495 Mon Sep 17 00:00:00 2001 From: Nick Le Large Date: Wed, 6 Nov 2024 08:55:31 +0100 Subject: [PATCH 07/23] Switch to docker-compose for GitHub actions --- .github/workflows/run-unit-tests.yaml | 11 ++--------- demo/docker-compose.yaml | 9 +++++++++ docker-compose.yaml | 10 ++++++++++ 3 files changed, 21 insertions(+), 9 deletions(-) diff --git a/.github/workflows/run-unit-tests.yaml b/.github/workflows/run-unit-tests.yaml index 65ca9a16..7a3de6c6 100644 --- a/.github/workflows/run-unit-tests.yaml +++ b/.github/workflows/run-unit-tests.yaml @@ -15,16 +15,9 @@ jobs: - name: Build Docker image for library unit tests run: | - docker build --target unittest --tag arbitration_graphs_test . - - - name: Run library unit tests in Docker container - run: | - docker run --rm arbitration_graphs_test + docker compose run --rm --build arbitration_graphs_test - name: Build Docker image for demo unit tests run: | - docker build --file demo/Dockerfile --target unittest --tag arbitration_graphs_demo_test demo + docker compose -f demo/docker-compose.yaml run --rm --build demo_test - - name: Run unit tests in Docker container - run: | - docker run --rm arbitration_graphs_demo_test diff --git a/demo/docker-compose.yaml b/demo/docker-compose.yaml index fea43e6e..63e4ebb4 100644 --- a/demo/docker-compose.yaml +++ b/demo/docker-compose.yaml @@ -1,4 +1,13 @@ services: + demo_test: + image: ghcr.io/kit-mrt/arbitration_graphs_pacman_demo_test:$VERSION + build: + context: . + args: + - VERSION=$VERSION + target: unit_test + env_file: .env + tutorial: image: ghcr.io/kit-mrt/arbitration_graphs_pacman_tutorial:$VERSION build: diff --git a/docker-compose.yaml b/docker-compose.yaml index 197e3414..ad5f3f57 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -3,6 +3,7 @@ services: image: ghcr.io/kit-mrt/arbitration_graphs:$VERSION build: . env_file: .env + arbitration_graphs_devel: build: context: . @@ -12,3 +13,12 @@ services: image: arbitration_graphs_devel:$VERSION volumes: - .:/home/blinky/arbitration_graphs + + arbitration_graphs_test: + build: + context: . + target: unit_test + extends: + service: arbitration_graphs + image: arbitration_graphs_test:$VERSION + From 9c41d0d5bb8ddfd8a495c949fbd908c4dc8be241 Mon Sep 17 00:00:00 2001 From: Nick Le Large Date: Thu, 7 Nov 2024 12:00:22 +0100 Subject: [PATCH 08/23] Fix unit test failure caused by changes on main After rebasing, the gui now also needs to be copied into the testing container. --- Dockerfile | 1 + 1 file changed, 1 insertion(+) diff --git a/Dockerfile b/Dockerfile index 4ca9d0c4..ac2e53a6 100644 --- a/Dockerfile +++ b/Dockerfile @@ -46,6 +46,7 @@ FROM base AS unit_test COPY CMakeLists.txt /tmp/arbitration_graphs/ COPY cmake /tmp/arbitration_graphs/cmake +COPY gui /tmp/arbitration_graphs/gui COPY include /tmp/arbitration_graphs/include COPY test /tmp/arbitration_graphs/test COPY version /tmp/arbitration_graphs/version From f135a9a916bd5bf20b760f3272f3a332246d542f Mon Sep 17 00:00:00 2001 From: Nick Le Large Date: Thu, 7 Nov 2024 12:02:20 +0100 Subject: [PATCH 09/23] Run unit test workflow on pushes to any branch --- .github/workflows/run-unit-tests.yaml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/run-unit-tests.yaml b/.github/workflows/run-unit-tests.yaml index 7a3de6c6..7e3dc097 100644 --- a/.github/workflows/run-unit-tests.yaml +++ b/.github/workflows/run-unit-tests.yaml @@ -2,8 +2,6 @@ name: Run unit tests on: push: - branches: - - github_actions # todo: set to main branch before merge jobs: build-and-run-unit-tests: From b7b0184f4d646cab31f2fe9c9228270627a06937 Mon Sep 17 00:00:00 2001 From: Nick Le Large Date: Thu, 7 Nov 2024 12:15:27 +0100 Subject: [PATCH 10/23] Add workflow action to build and release pacman demo image --- .github/workflows/build-and-push-docker.yaml | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build-and-push-docker.yaml b/.github/workflows/build-and-push-docker.yaml index e21c355c..6f719934 100644 --- a/.github/workflows/build-and-push-docker.yaml +++ b/.github/workflows/build-and-push-docker.yaml @@ -1,4 +1,4 @@ -name: Build and Push Docker Image +name: Build and Push Docker Images on: push: @@ -41,3 +41,16 @@ jobs: ghcr.io/kit-mrt/arbitration_graphs:${{ env.VERSION }} target: install + - name: Build and push Docker image + uses: docker/build-push-action@v6 + with: + build-args: | + VERSION=${{ env.VERSION }} + context: demo + file: demo/Dockerfile + push: true + tags: | + ghcr.io/kit-mrt/arbitration_graphs_pacman_demo:latest + ghcr.io/kit-mrt/arbitration_graphs_pacman_demo:${{ env.VERSION }} + target: demo + From 04998e5f5e7a7eee1b453c1b0710839dbb9b0a9c Mon Sep 17 00:00:00 2001 From: Nick Le Large Date: Thu, 7 Nov 2024 12:39:41 +0100 Subject: [PATCH 11/23] Add workflow action to build and push tutorial docker image --- .github/workflows/build-and-push-docker.yaml | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build-and-push-docker.yaml b/.github/workflows/build-and-push-docker.yaml index 6f719934..6cf27166 100644 --- a/.github/workflows/build-and-push-docker.yaml +++ b/.github/workflows/build-and-push-docker.yaml @@ -32,7 +32,7 @@ jobs: run: | cat version >> $GITHUB_ENV - - name: Build and push Docker image + - name: Build and push core library Docker image uses: docker/build-push-action@v6 with: push: true @@ -41,7 +41,7 @@ jobs: ghcr.io/kit-mrt/arbitration_graphs:${{ env.VERSION }} target: install - - name: Build and push Docker image + - name: Build and push Pacman demo Docker image uses: docker/build-push-action@v6 with: build-args: | @@ -54,3 +54,16 @@ jobs: ghcr.io/kit-mrt/arbitration_graphs_pacman_demo:${{ env.VERSION }} target: demo + - name: Build and push Pacman tutorial Docker image + uses: docker/build-push-action@v6 + with: + build-args: | + VERSION=${{ env.VERSION }} + context: demo + file: demo/Dockerfile + push: true + tags: | + ghcr.io/kit-mrt/arbitration_graphs_pacman_tutorial:latest + ghcr.io/kit-mrt/arbitration_graphs_pacman_tutorial:${{ env.VERSION }} + target: tutorial + From a419619928b79ffb67b827e2ba09793f843024a3 Mon Sep 17 00:00:00 2001 From: Nick Le Large Date: Thu, 7 Nov 2024 12:48:29 +0100 Subject: [PATCH 12/23] Switch back to pure docker builds to keep docker compose files clean --- .github/workflows/run-unit-tests.yaml | 34 +++++++++++++++++++++++---- demo/docker-compose.yaml | 9 ------- docker-compose.yaml | 8 ------- 3 files changed, 29 insertions(+), 22 deletions(-) diff --git a/.github/workflows/run-unit-tests.yaml b/.github/workflows/run-unit-tests.yaml index 7e3dc097..7932a8bd 100644 --- a/.github/workflows/run-unit-tests.yaml +++ b/.github/workflows/run-unit-tests.yaml @@ -8,14 +8,38 @@ jobs: runs-on: ubuntu-latest steps: - - name: Checkout repository + - name: Check out the repository uses: actions/checkout@v4 - - name: Build Docker image for library unit tests + - name: Read version from file run: | - docker compose run --rm --build arbitration_graphs_test + cat version >> $GITHUB_ENV - - name: Build Docker image for demo unit tests + - name: Build core library unit test Docker image + uses: docker/build-push-action@v6 + with: + push: false + tags: | + ghcr.io/kit-mrt/arbitration_graphs_tests:${{ env.VERSION }} + target: unit_test + + - name: Run library unit tests run: | - docker compose -f demo/docker-compose.yaml run --rm --build demo_test + docker run --rm ghcr.io/kit-mrt/arbitration_graphs_tests:${{ env.VERSION }} + + - name: Build Pacman demo unit test Docker image + uses: docker/build-push-action@v6 + with: + build-args: | + VERSION=${{ env.VERSION }} + context: demo + file: demo/Dockerfile + push: false + tags: | + ghcr.io/kit-mrt/arbitration_graphs_pacman_demo_tests:latest + ghcr.io/kit-mrt/arbitration_graphs_pacman_demo_tests:${{ env.VERSION }} + target: unit_test + - name: Run demo unit tests + run: | + docker run --rm ghcr.io/kit-mrt/arbitration_graphs_pacman_demo_tests:${{ env.VERSION }} diff --git a/demo/docker-compose.yaml b/demo/docker-compose.yaml index 63e4ebb4..fea43e6e 100644 --- a/demo/docker-compose.yaml +++ b/demo/docker-compose.yaml @@ -1,13 +1,4 @@ services: - demo_test: - image: ghcr.io/kit-mrt/arbitration_graphs_pacman_demo_test:$VERSION - build: - context: . - args: - - VERSION=$VERSION - target: unit_test - env_file: .env - tutorial: image: ghcr.io/kit-mrt/arbitration_graphs_pacman_tutorial:$VERSION build: diff --git a/docker-compose.yaml b/docker-compose.yaml index ad5f3f57..ffccf7fd 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -14,11 +14,3 @@ services: volumes: - .:/home/blinky/arbitration_graphs - arbitration_graphs_test: - build: - context: . - target: unit_test - extends: - service: arbitration_graphs - image: arbitration_graphs_test:$VERSION - From 97b75e4fc860b8f5704dc659ecd631015f497a1f Mon Sep 17 00:00:00 2001 From: Nick Le Large Date: Mon, 11 Nov 2024 13:03:11 +0100 Subject: [PATCH 13/23] Remove build instruction from docker compose files We now provide pre-built images so this is no longer necessary and only clutters up the compose file. --- demo/docker-compose.yaml | 10 ---------- docker-compose.yaml | 1 - 2 files changed, 11 deletions(-) diff --git a/demo/docker-compose.yaml b/demo/docker-compose.yaml index fea43e6e..f18bde66 100644 --- a/demo/docker-compose.yaml +++ b/demo/docker-compose.yaml @@ -1,11 +1,6 @@ services: tutorial: image: ghcr.io/kit-mrt/arbitration_graphs_pacman_tutorial:$VERSION - build: - context: . - args: - - VERSION=$VERSION - target: tutorial env_file: .env ports: - "8080:8080" @@ -22,11 +17,6 @@ services: demo: image: ghcr.io/kit-mrt/arbitration_graphs_pacman_demo:$VERSION - build: - context: . - args: - - VERSION=$VERSION - target: demo env_file: .env ports: - "8080:8080" diff --git a/docker-compose.yaml b/docker-compose.yaml index ffccf7fd..480c7684 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -1,7 +1,6 @@ services: arbitration_graphs: image: ghcr.io/kit-mrt/arbitration_graphs:$VERSION - build: . env_file: .env arbitration_graphs_devel: From 0e6327b9f7c2a4e8fb70ad9fbc4eb957234e9b9a Mon Sep 17 00:00:00 2001 From: Nick Le Large Date: Mon, 11 Nov 2024 13:06:16 +0100 Subject: [PATCH 14/23] Add workflow to create a new version and release on merge to main --- .../bump-version-and-create-release.yaml | 98 +++++++++++++++++++ 1 file changed, 98 insertions(+) create mode 100644 .github/workflows/bump-version-and-create-release.yaml diff --git a/.github/workflows/bump-version-and-create-release.yaml b/.github/workflows/bump-version-and-create-release.yaml new file mode 100644 index 00000000..9790a38c --- /dev/null +++ b/.github/workflows/bump-version-and-create-release.yaml @@ -0,0 +1,98 @@ +name: Bump version and create release +on: + pull_request: + types: + - closed + branches: + - main + +jobs: + compute-version: + if: github.event.pull_request.merged == true + runs-on: ubuntu-latest + permissions: + contents: write + outputs: + new_tag: ${{ steps.bump_version.outputs.new_tag }} + steps: + - name: Check out the repository + uses: actions/checkout@v4 + + - name: Read version from file + run: | + # Read the version from the version file, only store the number (without the 'v') + INITIAL_VERSION=$(source version && echo ${VERSION#v}) + echo "Current version: $INITIAL_VERSION" + echo "INITIAL_VERSION=${INITIAL_VERSION}" >> $GITHUB_ENV + + - name: Bump version + id: bump_version + uses: anothrNick/github-tag-action@v1 + env: + DEFAULT_BUMP: minor + DRY_RUN: true + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + INITIAL_VERSION: ${{ env.INITIAL_VERSION }} + WITH_V: true + + + update-version-file: + needs: compute-version + runs-on: ubuntu-latest + permissions: + contents: write + steps: + - name: Check out the repository + uses: actions/checkout@v4 + with: + ssh-key: ${{ secrets.DEPLOY_KEY }} + + - name: Update version file with new version + run: | + echo "New version: ${{ needs.compute-version.outputs.new_tag }}" + echo "VERSION=${{ needs.compute-version.outputs.new_tag }}" > version + git config --local user.name "github-actions[bot]" + git config --local user.email "github-actions[bot]@users.noreply.github.com" + git add version + git commit -m "chore: update version file to ${{ needs.compute-version.outputs.new_tag }}" + git push + + - name: Push new tag + run: | + git tag ${{ needs.compute-version.outputs.new_tag }} + git push origin ${{ needs.compute-version.outputs.new_tag }} + + + create-release: + needs: [compute-version, update-version-file] + runs-on: ubuntu-latest + permissions: + contents: write + steps: + - name: Check out the repository and pull the new tag + uses: actions/checkout@v4 + with: + fetch-depth: 0 + ref: ${{ needs.compute-version.outputs.new_tag }} + + - name: Build release packages + uses: docker/build-push-action@v6 + with: + context: . + push: false + tags: | + release_builder + target: release + + - name: Copy release packages + run: | + mkdir -p /tmp/artifacts/ + docker run --rm -v /tmp/artifacts:/tmp/artifacts release_builder cp -r /release /tmp/artifacts/ + + - name: Create Release + uses: ncipollo/release-action@v1 + with: + artifacts: "/tmp/artifacts/release/*" + tag: ${{ needs.compute-version.outputs.new_tag }} + body: ${{ github.event.pull_request.body }} + From cb002dc38496996780b9c1655c96bc220415a1dc Mon Sep 17 00:00:00 2001 From: Nick Le Large Date: Tue, 12 Nov 2024 10:57:39 +0100 Subject: [PATCH 15/23] Update installation section of README --- README.md | 37 ++++++++++++++++++++++++------------- 1 file changed, 24 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index 0c89b9ee..f1c92ac6 100644 --- a/README.md +++ b/README.md @@ -71,11 +71,31 @@ We will shortly add a [tutorial](https://github.com/KIT-MRT/arbitration_graphs/p ## Installation -From easy to advanced: +### Prerequisites -### Using Docker image +First make sure all dependencies are installed: +- [glog](https://github.com/google/glog) +- [Googletest](https://github.com/google/googletest) (optional, if you want to build unit tests) +- [yaml-cpp](https://github.com/jbeder/yaml-cpp) +- [util_caching](https://github.com/KIT-MRT/util_caching) +- [Crow](https://crowcpp.org) (optional, needed for GUI only) + +See also the [`Dockerfile`](./Dockerfile) for how to install these packages under Debian or Ubuntu. + +### Installation using Debian package (recommended) + +We provide a Debian package for easy installation on Debian-based distributions. +Download the latest `.deb` packages for the [core library](https://github.com/KIT-MRT/arbitration_graphs/releases/latest/download/libarbitration-graphs-core-dev.deb) +and optionally for [the gui](https://github.com/KIT-MRT/arbitration_graphs/releases/latest/download/libarbitration-graphs-gui-dev.deb) install them with `dpkg`: + +```bash +sudo dpkg -i libarbitration-graphs-core-dev.deb +sudo dpkg -i libarbitration-graphs-gui-dev.deb +``` + +### Using Docker image with pre-installed library -We provide a Docker image with the library already installed globally. +We provide a Docker image with the library and all dependencies already installed globally. ```bash docker pull ghcr.io/kit-mrt/arbitration_graphs @@ -91,16 +111,7 @@ find_package(arbitration_graphs REQUIRED) ### Building from source using CMake -First make sure all dependencies are installed: -- [glog](https://github.com/google/glog) -- [Googletest](https://github.com/google/googletest) (optional, if you want to build unit tests) -- [yaml-cpp](https://github.com/jbeder/yaml-cpp) -- [util_caching](https://github.com/KIT-MRT/util_caching) -- [Crow](https://crowcpp.org) (optional, needed for GUI only) - -See also the [`Dockerfile`](./Dockerfile) for how to install these packages under Debian or Ubuntu. - -Now, clone the repository: +Clone the repository: ```bash git clone https://github.com/KIT-MRT/arbitration_graphs.git From f8b2d51f0ae53a80439dabc2c8496a2524a3393a Mon Sep 17 00:00:00 2001 From: Nick Le Large Date: Tue, 12 Nov 2024 13:39:49 +0100 Subject: [PATCH 16/23] Copy additional files required by unit test pipeline into docker image --- Dockerfile | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Dockerfile b/Dockerfile index ac2e53a6..566d06c6 100644 --- a/Dockerfile +++ b/Dockerfile @@ -45,6 +45,8 @@ WORKDIR /home/blinky/ FROM base AS unit_test COPY CMakeLists.txt /tmp/arbitration_graphs/ +COPY LICENSE /tmp/arbitration_graphs/ +COPY README.md /tmp/arbitration_graphs/ COPY cmake /tmp/arbitration_graphs/cmake COPY gui /tmp/arbitration_graphs/gui COPY include /tmp/arbitration_graphs/include From 89d60661a44d0cf1130c34d0fc8e406cfc9e9a30 Mon Sep 17 00:00:00 2001 From: Nick Le Large Date: Thu, 14 Nov 2024 11:50:12 +0100 Subject: [PATCH 17/23] Add docker stage to build release package --- Dockerfile | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 566d06c6..8b686dce 100644 --- a/Dockerfile +++ b/Dockerfile @@ -42,6 +42,7 @@ USER blinky WORKDIR /home/blinky/ + FROM base AS unit_test COPY CMakeLists.txt /tmp/arbitration_graphs/ @@ -63,9 +64,28 @@ CMD ["cmake", "--build", ".", "--target", "test"] +FROM base AS release + +COPY CMakeLists.txt /tmp/arbitration_graphs/ +COPY LICENSE /tmp/arbitration_graphs/ +COPY README.md /tmp/arbitration_graphs/ +COPY version /tmp/arbitration_graphs/ +COPY cmake /tmp/arbitration_graphs/cmake +COPY gui /tmp/arbitration_graphs/gui +COPY include /tmp/arbitration_graphs/include + +WORKDIR /tmp/arbitration_graphs/build + +RUN cmake .. && \ + cmake --build . && \ + cmake --build . --target package && \ + mv packages /release && \ + rm -rf /tmp/arbitration_graphs + + + FROM base AS install -# Install arbitration_graphs COPY CMakeLists.txt /tmp/arbitration_graphs/ COPY LICENSE /tmp/arbitration_graphs/ COPY README.md /tmp/arbitration_graphs/ From 274f4ca1a02f5390385700ae7d027ffd2afafe5c Mon Sep 17 00:00:00 2001 From: Nick Le Large Date: Thu, 14 Nov 2024 12:14:25 +0100 Subject: [PATCH 18/23] Add some comments to structure the main Dockerfile --- Dockerfile | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/Dockerfile b/Dockerfile index 8b686dce..f12af2ab 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,3 +1,8 @@ +# ========== +# Base image +# ========== + + FROM ubuntu:22.04 AS base ARG DEBIAN_FRONTEND=noninteractive @@ -33,6 +38,10 @@ RUN dpkg -i /tmp/debfiles/*.deb && \ rm -rf /tmp/debfiles +# =========== +# Development +# =========== + FROM base AS devel @@ -42,6 +51,9 @@ USER blinky WORKDIR /home/blinky/ +# ========== +# Unit tests +# ========== FROM base AS unit_test @@ -63,6 +75,9 @@ RUN cmake -DBUILD_TESTS=true .. && \ CMD ["cmake", "--build", ".", "--target", "test"] +# ======= +# Release +# ======= FROM base AS release @@ -83,6 +98,9 @@ RUN cmake .. && \ rm -rf /tmp/arbitration_graphs +# ======= +# Install +# ======= FROM base AS install From dca4f8a89cad6ec38ef6d87d81cf8bf0555d0eb1 Mon Sep 17 00:00:00 2001 From: Nick Le Large Date: Thu, 14 Nov 2024 12:14:48 +0100 Subject: [PATCH 19/23] Add Docker stages to test release packages Fix gui release test --- Dockerfile | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/Dockerfile b/Dockerfile index f12af2ab..58d12da9 100644 --- a/Dockerfile +++ b/Dockerfile @@ -98,6 +98,54 @@ RUN cmake .. && \ rm -rf /tmp/arbitration_graphs +# ============= +# Release tests +# ============= + +FROM base AS release_test_core + +ARG RELEASE_DOWNLOAD_URL=https://github.com/KIT-MRT/arbitration_graphs/releases/latest/download/ + +# This downloads the latest arbitration_graph debian release and adds it to the docker image +# This "bloats" the image. But otherwise, we'd have to installing wget and ca-certificates +# temporarily to download and install the package in one docker layer… +ADD ${RELEASE_DOWNLOAD_URL}/libarbitration-graphs-core-dev.deb /tmp/debfiles/ + +# Install arbitration_graphs core library from release debian package +RUN dpkg -i /tmp/debfiles/*.deb && \ + rm -rf /tmp/debfiles + +COPY test /tmp/arbitration_graphs_test +WORKDIR /tmp/arbitration_graphs_test/build + +RUN cmake .. && \ + cmake --build . -j9 + +CMD ["cmake", "--build", ".", "--target", "test"] + +FROM base AS release_test_gui + +ARG RELEASE_DOWNLOAD_URL=https://github.com/KIT-MRT/arbitration_graphs/releases/latest/download/ + +# This downloads the latest arbitration_graph debian release and adds it to the docker image +# This "bloats" the image. But otherwise, we'd have to installing wget and ca-certificates +# temporarily to download and install the package in one docker layer… +ADD ${RELEASE_DOWNLOAD_URL}/libarbitration-graphs-core-dev.deb /tmp/debfiles/ +ADD ${RELEASE_DOWNLOAD_URL}/libarbitration-graphs-gui-dev.deb /tmp/debfiles/ + +# Install arbitration_graphs gui from release debian package +RUN dpkg -i /tmp/debfiles/*.deb && \ + rm -rf /tmp/debfiles + +COPY gui/test /tmp/arbitration_graphs_test +WORKDIR /tmp/arbitration_graphs_test/build + +RUN cmake .. && \ + cmake --build . -j9 + +CMD ["cmake", "--build", ".", "--target", "test"] + + # ======= # Install # ======= From 369d007e7b9351a421e7839e2812411a47a2dd61 Mon Sep 17 00:00:00 2001 From: Nick Le Large Date: Thu, 14 Nov 2024 12:25:46 +0100 Subject: [PATCH 20/23] Add workflow to run tests against released version --- .../bump-version-and-create-release.yaml | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/.github/workflows/bump-version-and-create-release.yaml b/.github/workflows/bump-version-and-create-release.yaml index 9790a38c..ec3acb6b 100644 --- a/.github/workflows/bump-version-and-create-release.yaml +++ b/.github/workflows/bump-version-and-create-release.yaml @@ -96,3 +96,32 @@ jobs: tag: ${{ needs.compute-version.outputs.new_tag }} body: ${{ github.event.pull_request.body }} + build-and-run-release-tests: + needs: [compute-version, create-release] + runs-on: ubuntu-latest + steps: + - name: Build release core test Docker image + uses: docker/build-push-action@v6 + with: + build-args: | + RELEASE_DOWNLOAD_URL=https://github.com/KIT-MRT/arbitration_graphs/releases/download/${{ needs.compute-version.outputs.new_tag }} + push: false + tags: release_tester_core + target: release_test_core + + - name: Run core unit tests with/against released version + run: | + docker run --rm release_tester_core + + - name: Build release gui test Docker image + uses: docker/build-push-action@v6 + with: + build-args: | + RELEASE_DOWNLOAD_URL=https://github.com/KIT-MRT/arbitration_graphs/releases/download/${{ needs.compute-version.outputs.new_tag }} + push: false + tags: release_tester_gui + target: release_test_gui + + - name: Run gui unit tests with/against released version + run: | + docker run --rm release_tester_gui From 3b93de67196f154028c865639e5911950eca96dd Mon Sep 17 00:00:00 2001 From: Nick Le Large Date: Thu, 14 Nov 2024 12:29:55 +0100 Subject: [PATCH 21/23] Move building of docker images into release workflow --- .github/workflows/build-and-push-docker.yaml | 69 ------------------- ...reate-release-and-push-docker-images.yaml} | 58 ++++++++++++++++ 2 files changed, 58 insertions(+), 69 deletions(-) delete mode 100644 .github/workflows/build-and-push-docker.yaml rename .github/workflows/{bump-version-and-create-release.yaml => bump-version-and-create-release-and-push-docker-images.yaml} (68%) diff --git a/.github/workflows/build-and-push-docker.yaml b/.github/workflows/build-and-push-docker.yaml deleted file mode 100644 index 6cf27166..00000000 --- a/.github/workflows/build-and-push-docker.yaml +++ /dev/null @@ -1,69 +0,0 @@ -name: Build and Push Docker Images - -on: - push: - branches: - - main - -jobs: - build-and-push-image: - runs-on: ubuntu-latest - - steps: - - name: Check out the repository - uses: actions/checkout@v4 - - - name: Set up QEMU - uses: docker/setup-qemu-action@v3 - with: - platforms: 'linux/amd64,linux/arm64,linux/arm/v7' - - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v3 - - - name: Log in to the Container registry - uses: docker/login-action@v3 - with: - registry: ghcr.io - username: ${{ github.actor }} - password: ${{ secrets.GITHUB_TOKEN }} - - - name: Read version from file - run: | - cat version >> $GITHUB_ENV - - - name: Build and push core library Docker image - uses: docker/build-push-action@v6 - with: - push: true - tags: | - ghcr.io/kit-mrt/arbitration_graphs:latest - ghcr.io/kit-mrt/arbitration_graphs:${{ env.VERSION }} - target: install - - - name: Build and push Pacman demo Docker image - uses: docker/build-push-action@v6 - with: - build-args: | - VERSION=${{ env.VERSION }} - context: demo - file: demo/Dockerfile - push: true - tags: | - ghcr.io/kit-mrt/arbitration_graphs_pacman_demo:latest - ghcr.io/kit-mrt/arbitration_graphs_pacman_demo:${{ env.VERSION }} - target: demo - - - name: Build and push Pacman tutorial Docker image - uses: docker/build-push-action@v6 - with: - build-args: | - VERSION=${{ env.VERSION }} - context: demo - file: demo/Dockerfile - push: true - tags: | - ghcr.io/kit-mrt/arbitration_graphs_pacman_tutorial:latest - ghcr.io/kit-mrt/arbitration_graphs_pacman_tutorial:${{ env.VERSION }} - target: tutorial - diff --git a/.github/workflows/bump-version-and-create-release.yaml b/.github/workflows/bump-version-and-create-release-and-push-docker-images.yaml similarity index 68% rename from .github/workflows/bump-version-and-create-release.yaml rename to .github/workflows/bump-version-and-create-release-and-push-docker-images.yaml index ec3acb6b..eb294e10 100644 --- a/.github/workflows/bump-version-and-create-release.yaml +++ b/.github/workflows/bump-version-and-create-release-and-push-docker-images.yaml @@ -125,3 +125,61 @@ jobs: - name: Run gui unit tests with/against released version run: | docker run --rm release_tester_gui + + build-and-push-images: + needs: [compute-version, build-and-run-release-tests] + runs-on: ubuntu-latest + steps: + - name: Check out the repository + uses: actions/checkout@v4 + + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + with: + platforms: 'linux/amd64,linux/arm64,linux/arm/v7' + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Log in to the Container registry + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Build and push core library Docker image + uses: docker/build-push-action@v6 + with: + push: true + tags: | + ghcr.io/kit-mrt/arbitration_graphs:latest + ghcr.io/kit-mrt/arbitration_graphs:${{ needs.compute-version.outputs.new_tag }} + target: install + + - name: Build and push Pacman demo Docker image + uses: docker/build-push-action@v6 + with: + build-args: | + VERSION=${{ env.VERSION }} + context: demo + file: demo/Dockerfile + push: true + tags: | + ghcr.io/kit-mrt/arbitration_graphs_pacman_demo:latest + ghcr.io/kit-mrt/arbitration_graphs_pacman_demo:${{ needs.compute-version.outputs.new_tag }} + target: demo + + - name: Build and push Pacman tutorial Docker image + uses: docker/build-push-action@v6 + with: + build-args: | + VERSION=${{ env.VERSION }} + context: demo + file: demo/Dockerfile + push: true + tags: | + ghcr.io/kit-mrt/arbitration_graphs_pacman_tutorial:latest + ghcr.io/kit-mrt/arbitration_graphs_pacman_tutorial:${{ needs.compute-version.outputs.new_tag }} + target: tutorial + From 5ffeaf7e22ff2c0f25746f1bcc66b50e3bf9a62b Mon Sep 17 00:00:00 2001 From: Nick Le Large Date: Thu, 14 Nov 2024 12:45:29 +0100 Subject: [PATCH 22/23] Fix docker build stage --- ...p-version-and-create-release-and-push-docker-images.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/bump-version-and-create-release-and-push-docker-images.yaml b/.github/workflows/bump-version-and-create-release-and-push-docker-images.yaml index eb294e10..861d335c 100644 --- a/.github/workflows/bump-version-and-create-release-and-push-docker-images.yaml +++ b/.github/workflows/bump-version-and-create-release-and-push-docker-images.yaml @@ -1,4 +1,4 @@ -name: Bump version and create release +name: Bump version, create and test release, and push Docker images on: pull_request: types: @@ -161,7 +161,7 @@ jobs: uses: docker/build-push-action@v6 with: build-args: | - VERSION=${{ env.VERSION }} + VERSION=${{ needs.compute-version.outputs.new_tag }} context: demo file: demo/Dockerfile push: true @@ -174,7 +174,7 @@ jobs: uses: docker/build-push-action@v6 with: build-args: | - VERSION=${{ env.VERSION }} + VERSION=${{ needs.compute-version.outputs.new_tag }} context: demo file: demo/Dockerfile push: true From 3d38df2ded9d76af9ae6717c5ce451f4e355b5fd Mon Sep 17 00:00:00 2001 From: Nick Le Large Date: Thu, 14 Nov 2024 13:46:09 +0100 Subject: [PATCH 23/23] Build arbitration graphs base image using current repo state The ghcr version of the image might not represent the current state of the library and possibly does not even exist for the version of a dev branch. --- .github/workflows/run-unit-tests.yaml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/.github/workflows/run-unit-tests.yaml b/.github/workflows/run-unit-tests.yaml index 7932a8bd..a3850bb7 100644 --- a/.github/workflows/run-unit-tests.yaml +++ b/.github/workflows/run-unit-tests.yaml @@ -15,6 +15,14 @@ jobs: run: | cat version >> $GITHUB_ENV + - name: Build and core library Docker image using current repo state + uses: docker/build-push-action@v6 + with: + push: false + tags: | + ghcr.io/kit-mrt/arbitration_graphs:${{ env.VERSION }} + target: install + - name: Build core library unit test Docker image uses: docker/build-push-action@v6 with: