Skip to content

Commit

Permalink
switch back to explicit docker create/exec commands instead of 'conta…
Browse files Browse the repository at this point in the history
…iner' option

The container option doesn't support QEMU emulation and thus selecting a architecture
different from the runners/host's one crashed the container with a 'exec format error'.

Unfortunately this breaks running the workflows locally using nektos/act. I still have
to figure out why exactly.
  • Loading branch information
siggmo committed Sep 6, 2024
1 parent 0dbe410 commit 4671b9e
Showing 1 changed file with 44 additions and 17 deletions.
61 changes: 44 additions & 17 deletions .github/workflows/build_and_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,29 +17,52 @@ jobs:
build:
name: ${{ format('Ubuntu {0}, {1}', matrix.UBUNTU_VERSION, matrix.ARCH) }}
runs-on: ubuntu-latest
container:
image: 'unistuttgartdae/fans-ci:${{ matrix.UBUNTU_VERSION }}'
options: ${{ github.actor != 'nektos/act' && format('--platform=linux/{0}', matrix.ARCH) || '' }}
defaults:
run:
shell: "bash --login -eo pipefail {0}"
env:
FANS_DIR: /FANS
FANS_IMG: unistuttgartdae/fans-ci
FANS_CONTAINER: fans-ci
FANS_BUILD_DIR: build
strategy:
fail-fast: false
matrix:
ARCH: ${{ fromJson(github.actor != 'nektos/act' && '["amd64", "arm64"]' || '["host-arch"]') }}
ARCH: [amd64, arm64]
UBUNTU_VERSION: [noble, jammy, focal]
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up QEMU
uses: docker/setup-qemu-action@v3

- name: Create and start container
run: |
docker create \
--name ${{ env.FANS_CONTAINER }} \
--platform linux/${{ matrix.ARCH }} \
-i -t \
-u `id -u`:`id -g` \
-v /etc/localtime:/etc/localtime:ro \
-v /etc/timezone:/etc/timezone:ro \
-v ${{ github.workspace }}:${{ env.FANS_DIR }} \
-w ${{ env.FANS_DIR }} \
${{ env.FANS_IMG }}:${{ matrix.UBUNTU_VERSION }}
docker start ${{ env.FANS_CONTAINER }}
- name: Generate build directory
run: mkdir -p build
run: |
docker exec \
-w ${{ env.FANS_DIR }} \
${{ env.FANS_CONTAINER }} \
bash -c "mkdir -p ${{ env.FANS_BUILD_DIR }}"
- name: Configure
working-directory: build
run: |
cmake --version
cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_EXPORT_COMPILE_COMMANDS=ON ..
docker exec \
-w ${{ env.FANS_DIR }}/${{ env.FANS_BUILD_DIR }} \
${{ env.FANS_CONTAINER }} \
bash -c " \
cmake --version && \
cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_EXPORT_COMPILE_COMMANDS=ON .."
- uses: actions/upload-artifact@v4
if: failure()
Expand All @@ -58,15 +81,19 @@ jobs:
path: build/compile_commands.json

- name: Compile
working-directory: build
run: |
cmake --build . -j $(nproc) || cmake --build . -j1
docker exec \
-w ${{ env.FANS_DIR }}/${{ env.FANS_BUILD_DIR }} \
${{ env.FANS_CONTAINER }} \
cmake --build . -j $(nproc) || cmake --build . -j1
- name: Tests
env:
CTEST_OUTPUT_ON_FAILURE: 1
working-directory: build
run: ctest
run: |
docker exec \
-w ${{ env.FANS_DIR }}/${{ env.FANS_BUILD_DIR }} \
-e CTEST_OUTPUT_ON_FAILURE=1 \
${{ env.FANS_CONTAINER }} \
ctest
- uses: actions/upload-artifact@v4
if: failure()
Expand Down

0 comments on commit 4671b9e

Please sign in to comment.