Skip to content

Build Test

Build Test #39

Workflow file for this run

name: Build Test
# Builds and tests carl-storm on various platforms
# also deploys images to Dockerhub
on:
push:
schedule:
# run weekly
- cron: '0 10 * * 2'
# needed to trigger the workflow manually
workflow_dispatch:
pull_request:
env:
# GitHub runners currently have two cores
NR_JOBS: "2"
jobs:
indepthTests:
name: Build and Test
runs-on: ubuntu-latest
strategy:
matrix:
distro: ["debian-10", "debian-11", "ubuntu-20.04", "ubuntu-22.04"]
debugOrRelease: ["debug", "release"]
steps:
- name: Setup configuration
# this is strangely the best way to implement environment variables based on the value of another
# GITHUB_ENV is a magic variable pointing to a file; if a line with format {NAME}={VALUE}
# then the env variable with name NAME will be created/updated with VALUE
run: |
([[ ${{ matrix.debugOrRelease }} == "debug" ]] && echo "BUILD_TYPE=Debug" || echo "BUILD_TYPE=Release") >> $GITHUB_ENV
- name: Git clone
uses: actions/checkout@v3
- name: Build Carl-storm
run: docker build -t movesrwth/carl-storm:ci-${{ matrix.debugOrRelease }} . --build-arg BASE_IMAGE=movesrwth/storm-basesystem:${{ matrix.distro }} --build-arg build_type=${BUILD_TYPE} --build-arg no_threads=${NR_JOBS}
- name: Run Docker
run: docker run -d -it --name ci --privileged movesrwth/carl-storm:ci-${{ matrix.debugOrRelease }}
- name: Build tests
run: docker exec ci bash -c "cd /opt/carl/build; make -j ${NR_JOBS}"
- name: Run unit tests
run: docker exec ci bash -c "cd /opt/carl/build; ctest test --output-on-failure"
deploy:
name: Build, Test and Deploy
runs-on: ubuntu-latest
strategy:
matrix:
distro: ["latest"]
debugOrRelease: ["debug", "release"]
steps:
- name: Setup cmake arguments
# this is strangely the best way to implement environment variables based on the value of another
# GITHUB_ENV is a magic variable pointing to a file; if a line with format {NAME}={VALUE}
# then the env variable with name NAME will be created/updated with VALUE
run: |
([[ ${{ matrix.debugOrRelease }} == "debug" ]] && echo "BUILD_TYPE=Debug" || echo "BUILD_TYPE=Release") >> $GITHUB_ENV
- name: Login into docker
# Only login if using master on original repo (and not for pull requests or forks)
if: github.repository_owner == 'moves-rwth' && github.ref == 'refs/heads/master'
run: echo "${{ secrets.STORM_CI_DOCKER_PASSWORD }}" | docker login -u "${{ secrets.STORM_CI_DOCKER_USERNAME }}" --password-stdin
- name: Git clone
uses: actions/checkout@v3
- name: Build Carl-storm
run: docker build -t movesrwth/carl-storm:ci-${{ matrix.debugOrRelease }} . --build-arg BASE_IMAGE=movesrwth/storm-basesystem:${{ matrix.distro }} --build-arg build_type=${BUILD_TYPE} --build-arg no_threads=${NR_JOBS}
- name: Run Docker
run: docker run -d -it --name ci movesrwth/carl-storm:ci-${{ matrix.debugOrRelease }}
- name: Build tests
run: docker exec ci bash -c "cd /opt/carl/build; make -j ${NR_JOBS}"
- name: Run unit tests
run: docker exec ci bash -c "cd /opt/carl/build; ctest test --output-on-failure"
- name: Deploy carl
# Only deploy if using master on original repo (and not for pull requests or forks)
if: github.repository_owner == 'moves-rwth' && github.ref == 'refs/heads/master'
run: |
docker commit ci movesrwth/carl-storm:ci-${{ matrix.debugOrRelease }}
docker push movesrwth/carl-storm:ci-${{ matrix.debugOrRelease }}
notify:
name: Email notification
runs-on: ubuntu-latest
needs: [indepthTests, deploy]
# Only run in main repo and even if previous step failed
if: github.repository_owner == 'moves-rwth' && always()
steps:
- uses: technote-space/workflow-conclusion-action@v2
- uses: dawidd6/action-send-mail@v2
with:
server_address: ${{ secrets.STORM_CI_MAIL_SERVER }}
server_port: 587
username: ${{ secrets.STORM_CI_MAIL_USERNAME }}
password: ${{ secrets.STORM_CI_MAIL_PASSWORD }}
subject: "[You broke it] CI run failed for ${{ github.repository }}"
body:
"CI job of ${{ github.repository }} has failed for commit ${{ github.sha }}.\n\
The error type is: ${{ env.WORKFLOW_CONCLUSION }}.\n\n\
For more information, see https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}"
to: ${{ secrets.STORM_CI_MAIL_RECIPIENTS }}
from: Github Actions <[email protected]>
if: env.WORKFLOW_CONCLUSION != 'success' # notify only if failure