Skip to content

Merge pull request #342 from vrnetlab/test-ssh #68

Merge pull request #342 from vrnetlab/test-ssh

Merge pull request #342 from vrnetlab/test-ssh #68

Workflow file for this run

name: "Build and Test virtual routers"
on:
pull_request:
push:
branches:
- main
- master
env:
PNS: ci-${GITHUB_RUN_ID}
DOCKER_REGISTRY: ghcr.io/vrnetlab/vrnetlab
jobs:
test-vr-xcon-and-vr-bgp:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3
- name: Build vr-xcon
run: |
make vr-xcon
- name: Test vr-xcon
run: |
make vr-xcon-test
- name: Save vr-xcon logs
if: always()
run: |
make -C vr-xcon docker-test-save-logs
- name: Clean test vr-xcon containers
if: always()
run: make -C vr-xcon docker-test-clean
# vr-bgp depends on the vr-xcon container image, so let's build it right
# now on the same runner ...
- name: Build vr-bgp
run: |
make vr-bgp
- name: Test vr-bgp
run: |
make vr-bgp-test
- name: Save vr-bgp logs
if: always()
run: |
make -C vr-bgp docker-test-save-logs
- name: Clean test vr-bgp containers
if: always()
run: make -C vr-bgp docker-test-clean
test-topomachine:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3
- name: Build topomachine
run: |
make topology-machine
- name: Test topomachine
run: |
make topology-machine-test
- name: Save topomachine logs
if: always()
run: |
make -C topology-machine docker-test-save-logs
- name: Clean test topomachine containers
if: always()
run: make -C topology-machine docker-test-clean
test-vr:
runs-on: ["self-hosted"]
container:
image: vrnetlab/ci-builder
volumes:
- /data/gh-runner/vrnetlab-images:/vrnetlab-images
strategy:
fail-fast: false
matrix:
platform: ['csr', 'nxos', 'nxos9kv', 'routeros', 'sros', 'veos', 'vmx', 'vqfx', 'vrp', 'vsr1000', 'xrv', 'xrv9k']
steps:
- uses: actions/checkout@v3
- name: Fixup dubious ownership
run: git config --global --add safe.directory ${GITHUB_WORKSPACE}
- name: Use git to check if the source files (platform or shared) have changed
uses: dorny/paths-filter@v2
id: source_changes
with:
filters: |
platform:
- '${{ matrix.platform }}/**/*'
- 'common/*'
- name: Compute platform image hashes in bind-mounted volume
run: |
shasum -a 512 /vrnetlab-images/${{ matrix.platform }}/* > hash-${{ matrix.platform }}.txt || touch hash-${{ matrix.platform }}.txt
cat hash-${{ matrix.platform }}.txt
- name: Cache image hashes
id: cache-hash
uses: actions/cache@v3
with:
path: cache-hash-${{ matrix.platform }}.txt
key: hash-${{ matrix.platform }}
- name: Compare computed image hashes with cached hashes
id: image_changes
run: |
if diff hash-${{ matrix.platform }}.txt cache-hash-${{ matrix.platform}}.txt; then
echo platform=false >> ${GITHUB_OUTPUT};
echo "No image changes detected for ${{ matrix.platform }}";
else
echo platform=true >> ${GITHUB_OUTPUT};
echo "Image changes detected for ${{ matrix.platform }}";
fi
- name: Build ${{ matrix.platform }}
if: ${{ steps.source_changes.outputs.platform == 'true' || steps.image_changes.outputs.platform == 'true' }}
run: |
cp /vrnetlab-images/${{ matrix.platform }}/* ${{ matrix.platform }} || true
ls -al ${{ matrix.platform }}
make ${{ matrix.platform }}
- name: Test ${{ matrix.platform }}
if: ${{ steps.source_changes.outputs.platform == 'true' || steps.image_changes.outputs.platform == 'true' }}
run: |
make ${{ matrix.platform }}-test
- name: Save ${{ matrix.platform }} logs
if: ${{ always() && (steps.source_changes.outputs.platform == 'true' || steps.image_changes.outputs.platform == 'true') }}
run: |
make -C ${{ matrix.platform }} docker-test-save-logs
- uses: actions/upload-artifact@v3
if: ${{ always() && (steps.source_changes.outputs.platform == 'true' || steps.image_changes.outputs.platform == 'true') }}
with:
name: vr-logs
path: |
${{ matrix.platform }}/*.log
- name: Clean test ${{ matrix.platform }} containers
if: ${{ always() && (steps.source_changes.outputs.platform == 'true' || steps.image_changes.outputs.platform == 'true') }}
run: make -C ${{ matrix.platform }} docker-test-clean
- name: Persist image hashes
run: mv hash-${{ matrix.platform }}.txt cache-hash-${{ matrix.platform }}.txt