Skip to content

test examples

test examples #78

Workflow file for this run

name: test examples
on:
pull_request:
push:
branches:
- main
schedule:
# Twice a month
- cron: '0 0 1,15 * *'
workflow_dispatch:
jobs:
# Collect all relative paths containing a 'snap/snapcraft.yaml'
collect_dirs:
runs-on: ubuntu-latest
outputs:
dirs: ${{ steps.dirs.outputs.dirs }}
steps:
- uses: actions/checkout@v3
- id: dirs
run: echo "dirs=$(find . -type f -name 'snapcraft.yaml' | sed -r 's|\/snap/[^/]+$||' |sort |uniq |jq --raw-input --slurp --compact-output 'split("\n")[:-1]')" >> $GITHUB_OUTPUT
# Run snapcraft for each example
run_tests:
needs: collect_dirs
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
dir: ${{ fromJson(needs.collect_dirs.outputs.dirs) }}
exclude:
- dir: "./github_action_private_source/snapcraft.yaml"
name: "Snap ${{ matrix.dir }}"
steps:
- uses: actions/checkout@v3
- uses: snapcore/action-build@v1
id: build-snap
with:
# Select the example we want to build
path: "${{ matrix.dir }}"
snapcraft-channel: ${{ contains(matrix.dir, 'core18') && '7.x/stable' || 'stable' }}
# Make sure the snap is installable
- run: sudo snap install --dangerous ${{ steps.build-snap.outputs.snap }}
# Do some testing with the snap
# - run: ros2-shared-memory.ros2-talker-listener --print
# @todo set unique artifact or snap names
- uses: actions/upload-artifact@v3
continue-on-error: true
with:
name: snaps
path: ${{ steps.build-snap.outputs.snap }}
retention-days: 7