summaryrefslogtreecommitdiff
path: root/.github/workflows/ci.yml
blob: fc0fa78d558ce640829a1a77ce83a29ad9a6802f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
---
name: CI
on:
  push:
    branches: [main]
  pull_request:

env:
  COLLECTION_PATH: ansible_collections/vyos/blueprints

jobs:
  lint:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
        with:
          path: ${{ env.COLLECTION_PATH }}
      - uses: actions/setup-python@v5
        with:
          python-version: "3.12"
      - run: pip install ansible-core ansible-lint
      - name: Install dependencies
        run: ansible-galaxy collection install -r ${{ env.COLLECTION_PATH }}/tests/requirements.yml -p .
      - name: ansible-lint
        working-directory: ${{ env.COLLECTION_PATH }}
        env:
          ANSIBLE_COLLECTIONS_PATH: ${{ github.workspace }}
        run: ansible-lint
      - name: Role docs render
        env:
          ANSIBLE_COLLECTIONS_PATH: ${{ github.workspace }}
        run: |
          for r in $(ls ${{ env.COLLECTION_PATH }}/roles); do
            ansible-doc -t role vyos.blueprints.$r > /dev/null
          done

  render:
    # Tier 1: no device. Renders every role and diffs against golden commands.
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
        with:
          path: ${{ env.COLLECTION_PATH }}
      - uses: actions/setup-python@v5
        with:
          python-version: "3.12"
      - run: pip install ansible-core ansible-pylibssh
      - run: ansible-galaxy collection install -r ${{ env.COLLECTION_PATH }}/tests/requirements.yml -p .
      - name: Render tests
        env:
          ANSIBLE_COLLECTIONS_PATH: ${{ github.workspace }}
        run: ${{ env.COLLECTION_PATH }}/tests/render/run.sh

  molecule:
    # Tier 2: containerized VyOS. Needs repository variable VYOS_ISO_URL.
    needs: [lint, render]
    if: ${{ vars.VYOS_ISO_URL != '' }}
    runs-on: ubuntu-latest
    strategy:
      fail-fast: false
      matrix:
        scenario: [base, edge_nat, ha_vrrp, ospf_unnumbered, bgp_unnumbered, zone_firewall, vrf_firewall, bridge_firewall, ipsec_route_based, ipsec_policy_based, policy_ipsec_firewall, gre_tunnel, ipsec_route_based_bgp, ipsec_route_based_bgp_dual, ipsec_route_based_gcp, ha_walkthrough, ha_walkthrough_ospf, ha_walkthrough_bgp, inter_vrf, wan_load_balance, pppoe_ipv6, qos, isis_segment_routing, l3vpn_hub_and_spoke, l2tp_lns, dmvpn, management]
    steps:
      - uses: actions/checkout@v4
        with:
          path: ${{ env.COLLECTION_PATH }}
      - uses: actions/setup-python@v5
        with:
          python-version: "3.12"
      - run: pip install ansible-core ansible-pylibssh molecule
      - run: ansible-galaxy collection install -r ${{ env.COLLECTION_PATH }}/tests/requirements.yml -p .
      - name: Install containerlab and image tools
        run: |
          bash -c "$(curl -sL https://get.containerlab.dev)"
          sudo apt-get update && sudo apt-get install -y libarchive-tools squashfs-tools-ng
      - name: Build VyOS image
        run: ${{ env.COLLECTION_PATH }}/scripts/build-vyos-image.sh "${{ vars.VYOS_ISO_URL }}" vyos:blueprints-ci
      - name: molecule test
        working-directory: ${{ env.COLLECTION_PATH }}/extensions
        env:
          ANSIBLE_COLLECTIONS_PATH: ${{ github.workspace }}
          VYOS_IMAGE: vyos:blueprints-ci
        run: molecule test -s ${{ matrix.scenario }}