diff --git a/.github/workflows/build-containerlab.yml b/.github/workflows/build-containerlab.yml new file mode 100644 index 000000000..98aa20e6d --- /dev/null +++ b/.github/workflows/build-containerlab.yml @@ -0,0 +1,40 @@ +name: build-clab + +"on": + workflow_call: + inputs: + go_ver: + required: true + type: string + +jobs: + build-clab: + runs-on: ubuntu-22.04 + steps: + - uses: actions/checkout@v4 + - uses: WillAbides/setup-go-faster@v1.13.0 + with: + go-version: ${{ inputs.go_ver }} + + - name: Cache go modules + uses: actions/cache@v3 + with: + # In order: + # * Module download cache + # * Build cache (Linux) + path: | + ~/go/pkg/mod + ~/.cache/go-build + key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} + restore-keys: | + ${{ runner.os }}-go- + + - name: Build containerlab + run: make build-with-podman-debug BINARY=containerlab + # store clab binary as artifact + - name: Upload containerlab binary + uses: actions/upload-artifact@v4 + with: + name: containerlab + path: containerlab + compression-level: 0 diff --git a/.github/workflows/cicd.yml b/.github/workflows/cicd.yml index 90a1ec7e0..6d840fdd1 100644 --- a/.github/workflows/cicd.yml +++ b/.github/workflows/cicd.yml @@ -11,11 +11,11 @@ on: workflow_dispatch: env: - GOVER: 1.20.2 + GO_VER: "1.20.2" CGO_ENABLED: 0 MKDOCS_INS_VER: 9.1.4-insiders-4.32.4-hellt GORELEASER_VER: v1.11.4 - PODMAN_VER: v4.4.2 + PY_VER: "3.10" jobs: file-changes: @@ -23,6 +23,9 @@ jobs: outputs: code: ${{ steps.filter.outputs.code }} docs: ${{ steps.filter.outputs.docs }} + # exporting env vars to be used in invoked workflows + py_ver: ${{ env.PY_VER }} + go_ver: ${{ env.GO_VER }} steps: - uses: actions/checkout@v4 - uses: dorny/paths-filter@v2 @@ -57,6 +60,13 @@ jobs: - '.github/workflows/cicd.yml' build-containerlab: + needs: file-changes + if: needs.file-changes.outputs.code == 'true' || startsWith(github.ref, 'refs/tags/v') + uses: ./.github/workflows/build-containerlab.yml + with: + go_ver: ${{ needs.file-changes.outputs.go_ver }} + + staticcheck: runs-on: ubuntu-22.04 needs: file-changes if: needs.file-changes.outputs.code == 'true' || startsWith(github.ref, 'refs/tags/v') @@ -64,7 +74,7 @@ jobs: - uses: actions/checkout@v4 - uses: WillAbides/setup-go-faster@v1.13.0 with: - go-version: ${{ env.GOVER }} + go-version: ${{ env.GO_VER }} - name: Cache go modules uses: actions/cache@v3 @@ -79,24 +89,6 @@ jobs: restore-keys: | ${{ runner.os }}-go- - - name: Build containerlab - run: make build-with-podman-debug BINARY=containerlab - # store clab binary as artifact - - uses: actions/upload-artifact@v3 - with: - name: containerlab - path: containerlab - - staticcheck: - runs-on: ubuntu-22.04 - needs: file-changes - if: needs.file-changes.outputs.code == 'true' || startsWith(github.ref, 'refs/tags/v') - steps: - - uses: actions/checkout@v4 - - uses: WillAbides/setup-go-faster@v1.13.0 - with: - go-version: ${{ env.GOVER }} - - name: Staticcheck run: | go install honnef.co/go/tools/cmd/staticcheck@latest @@ -110,7 +102,7 @@ jobs: - uses: actions/checkout@v4 - uses: WillAbides/setup-go-faster@v1.13.0 with: - go-version: ${{ env.GOVER }} + go-version: ${{ env.GO_VER }} - name: Cache go modules uses: actions/cache@v3 @@ -129,69 +121,23 @@ jobs: # upload coverage report from unit tests, as they are then # merged with e2e tests coverage - - uses: actions/upload-artifact@v3 + - name: Upload coverage + uses: actions/upload-artifact@v4 if: always() with: - name: coverage + name: coverage-unit-test path: /tmp/clab-tests/coverage/* retention-days: 7 smoke-tests: - runs-on: ubuntu-22.04 - strategy: - matrix: - runtime: - - "docker" - - "podman" + uses: ./.github/workflows/smoke-tests.yml + with: + py_ver: ${{ needs.file-changes.outputs.py_ver }} needs: + - file-changes - unit-test - staticcheck - build-containerlab - steps: - - name: Checkout - uses: actions/checkout@v4 - with: - fetch-depth: 0 - - uses: actions/download-artifact@v3 - with: - name: containerlab - - name: Move containerlab to usr/bin - run: sudo mv ./containerlab /usr/bin/containerlab && sudo chmod a+x /usr/bin/containerlab - - name: Setup Podman - if: matrix.runtime == 'podman' - run: | - sudo apt purge -y podman - echo 'deb http://download.opensuse.org/repositories/devel:/kubic:/libcontainers:/unstable/xUbuntu_22.04/ /' | sudo tee /etc/apt/sources.list.d/devel:kubic:libcontainers:unstable.list - curl -fsSL https://download.opensuse.org/repositories/devel:kubic:libcontainers:unstable/xUbuntu_22.04/Release.key | gpg --dearmor | sudo tee /etc/apt/trusted.gpg.d/devel_kubic_libcontainers_unstable.gpg > /dev/null - sudo apt update - sudo apt install -y podman - sudo systemctl start podman - - uses: actions/setup-python@v5 - with: - python-version: "3.8" - cache: pip - cache-dependency-path: "tests/requirements.txt" - - name: Install robotframework - run: | - pip install -r tests/requirements.txt - - name: Run smoke tests - run: | - bash ./tests/rf-run.sh ${{ matrix.runtime }} ./tests/01-smoke - # upload test reports as a zip file - - uses: actions/upload-artifact@v3 - if: always() - with: - name: 01-smoke-log - path: ./tests/out/*.html - - # upload coverage report from unit tests, as they are then - # merged with e2e tests coverage - - uses: actions/upload-artifact@v3 - if: always() - with: - name: coverage - path: /tmp/clab-tests/coverage/* - retention-days: 7 ext-container-tests: runs-on: ubuntu-22.04 @@ -208,14 +154,14 @@ jobs: uses: actions/checkout@v4 with: fetch-depth: 0 - - uses: actions/download-artifact@v3 + - uses: actions/download-artifact@v4 with: name: containerlab - name: Move containerlab to usr/bin run: sudo mv ./containerlab /usr/bin/containerlab && sudo chmod a+x /usr/bin/containerlab - uses: actions/setup-python@v5 with: - python-version: "3.8" + python-version: ${{ env.PY_VER }} cache: pip cache-dependency-path: "tests/requirements.txt" - name: Install robotframework @@ -231,18 +177,20 @@ jobs: run: | bash ./tests/rf-run.sh ${{ matrix.runtime }} ./tests/06-ext-container # upload test reports as a zip file - - uses: actions/upload-artifact@v3 + - name: Upload test reports + uses: actions/upload-artifact@v4 if: always() with: - name: 06-ext-container-log + name: 06-ext-container-log-${{ matrix.runtime }} path: ./tests/out/*.html # upload coverage report from unit tests, as they are then # merged with e2e tests coverage - - uses: actions/upload-artifact@v3 + - name: upload coverage reports + uses: actions/upload-artifact@v4 if: always() with: - name: coverage + name: coverage-ext-container-test-${{ matrix.runtime }} path: /tmp/clab-tests/coverage/* retention-days: 7 @@ -261,14 +209,14 @@ jobs: uses: actions/checkout@v4 with: fetch-depth: 0 - - uses: actions/download-artifact@v3 + - uses: actions/download-artifact@v4 with: name: containerlab - name: Move containerlab to usr/bin run: sudo mv ./containerlab /usr/bin/containerlab && sudo chmod a+x /usr/bin/containerlab - uses: actions/setup-python@v5 with: - python-version: "3.8" + python-version: ${{ env.PY_VER }} cache: pip cache-dependency-path: "tests/requirements.txt" - name: Install robotframework @@ -286,81 +234,31 @@ jobs: run: | bash ./tests/rf-run.sh ${{ matrix.runtime }} ./tests/03-basic-ceos # upload test reports as a zip file - - uses: actions/upload-artifact@v3 + - uses: actions/upload-artifact@v4 if: always() with: - name: 03-basic-ceos-log + name: 03-basic-ceos-log-${{ matrix.runtime }} path: ./tests/out/*.html # upload coverage report from unit tests, as they are then # merged with e2e tests coverage - - uses: actions/upload-artifact@v3 + - name: Upload coverage + uses: actions/upload-artifact@v4 if: always() with: - name: coverage + name: coverage-ceos-tests-${{ matrix.runtime }} path: /tmp/clab-tests/coverage/* retention-days: 7 srlinux-basic-tests: - runs-on: ubuntu-22.04 - strategy: - matrix: - runtime: - - "docker" - - "podman" + uses: ./.github/workflows/srlinux-tests.yml + with: + py_ver: ${{ needs.file-changes.outputs.py_ver }} needs: + - file-changes - unit-test - staticcheck - build-containerlab - steps: - - name: Checkout - uses: actions/checkout@v4 - with: - fetch-depth: 0 - - uses: actions/download-artifact@v3 - with: - name: containerlab - - name: Move containerlab to usr/bin - run: sudo mv ./containerlab /usr/bin/containerlab && sudo chmod a+x /usr/bin/containerlab - - - name: Setup Podman - if: matrix.runtime == 'podman' - # check http://download.opensuse.org/repositories/devel:/kubic:/libcontainers:/unstable/xUbuntu_22.04/amd64/ - # for available podman releases - run: | - sudo apt purge -y podman - echo 'deb http://download.opensuse.org/repositories/devel:/kubic:/libcontainers:/unstable/xUbuntu_22.04/ /' | sudo tee /etc/apt/sources.list.d/devel:kubic:libcontainers:unstable.list - curl -fsSL https://download.opensuse.org/repositories/devel:kubic:libcontainers:unstable/xUbuntu_22.04/Release.key | gpg --dearmor | sudo tee /etc/apt/trusted.gpg.d/devel_kubic_libcontainers_unstable.gpg > /dev/null - sudo apt update - sudo apt install -y podman - sudo systemctl start podman - - - uses: actions/setup-python@v5 - with: - python-version: "3.8" - cache: pip - cache-dependency-path: "tests/requirements.txt" - - name: Install robotframework - run: | - pip install -r tests/requirements.txt - - name: Run srlinux tests - run: | - bash ./tests/rf-run.sh ${{ matrix.runtime }} ./tests/02-basic-srl - # upload test reports as a zip file - - uses: actions/upload-artifact@v3 - if: always() - with: - name: 02-basic-srl-log - path: ./tests/out/*.html - - # upload coverage report from unit tests, as they are then - # merged with e2e tests coverage - - uses: actions/upload-artifact@v3 - if: always() - with: - name: coverage - path: /tmp/clab-tests/coverage/* - retention-days: 7 ixiac-one-basic-tests: runs-on: ubuntu-22.04 @@ -377,14 +275,14 @@ jobs: uses: actions/checkout@v4 with: fetch-depth: 0 - - uses: actions/download-artifact@v3 + - uses: actions/download-artifact@v4 with: name: containerlab - name: Move containerlab to usr/bin run: sudo mv ./containerlab /usr/bin/containerlab && sudo chmod a+x /usr/bin/containerlab - uses: actions/setup-python@v5 with: - python-version: "3.8" + python-version: ${{ env.PY_VER }} cache: pip cache-dependency-path: "tests/requirements.txt" - name: Install robotframework @@ -394,27 +292,31 @@ jobs: run: | bash ./tests/rf-run.sh ${{ matrix.runtime }} ./tests/04-basic-ixiacone # upload test reports as a zip file - - uses: actions/upload-artifact@v3 + - uses: actions/upload-artifact@v4 if: always() with: - name: 04-basic-ixiacone-log + name: 04-basic-ixiacone-log-${{ matrix.runtime }} path: ./tests/out/*.html # upload coverage report from unit tests, as they are then # merged with e2e tests coverage - - uses: actions/upload-artifact@v3 + - name: Upload coverage + uses: actions/upload-artifact@v4 if: always() with: - name: coverage + name: coverage-ixiac-one-tests-${{ matrix.runtime }} path: /tmp/clab-tests/coverage/* retention-days: 7 vxlan-tests: uses: ./.github/workflows/vxlan-tests.yml needs: + - file-changes - unit-test - staticcheck - build-containerlab + with: + py_ver: ${{ needs.file-changes.outputs.py_ver }} # a job that downloads coverage artifact and uses codecov to upload it coverage: @@ -432,15 +334,21 @@ jobs: uses: actions/checkout@v4 with: fetch-depth: 0 + - uses: WillAbides/setup-go-faster@v1.13.0 with: - go-version: ${{ env.GOVER }} - - uses: actions/download-artifact@v3 + go-version: ${{ env.GO_VER }} + + - uses: actions/download-artifact@v4 with: - name: coverage + pattern: coverage* path: /tmp/clab-tests/coverage - - name: convert Go's binary coverage to text coverage + merge-multiple: true + - run: ls -R /tmp/clab-tests/coverage + + - name: Convert Go's binary coverage to text coverage run: make convert-coverage + - name: Upload coverage to codecov uses: codecov/codecov-action@v3 @@ -498,7 +406,7 @@ jobs: - name: Set up Go uses: WillAbides/setup-go-faster@v1.13.0 with: - go-version: ${{ env.GOVER }} + go-version: ${{ env.GO_VER }} - name: Cache go modules uses: actions/cache@v3 diff --git a/.github/workflows/install-podman.sh b/.github/workflows/install-podman.sh new file mode 100755 index 000000000..d96e23062 --- /dev/null +++ b/.github/workflows/install-podman.sh @@ -0,0 +1,14 @@ +sudo apt purge -y podman +sudo mkdir -p /etc/apt/keyrings +curl -fsSL "https://download.opensuse.org/repositories/devel:kubic:libcontainers:unstable/xUbuntu_$(lsb_release -rs)/Release.key" \ + | gpg --dearmor \ + | sudo tee /etc/apt/keyrings/devel_kubic_libcontainers_unstable.gpg > /dev/null + +echo \ +"deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/devel_kubic_libcontainers_unstable.gpg]\ + https://download.opensuse.org/repositories/devel:kubic:libcontainers:unstable/xUbuntu_$(lsb_release -rs)/ /" \ + | sudo tee /etc/apt/sources.list.d/devel:kubic:libcontainers:unstable.list > /dev/null + +sudo apt-get update -qq +sudo apt-get -qq -y install podman +sudo systemctl start podman \ No newline at end of file diff --git a/.github/workflows/smoke-tests.yml b/.github/workflows/smoke-tests.yml new file mode 100644 index 000000000..2c3408cc6 --- /dev/null +++ b/.github/workflows/smoke-tests.yml @@ -0,0 +1,68 @@ +name: smoke-tests + +"on": + workflow_call: + inputs: + py_ver: + required: true + type: string + +jobs: + smoke-tests: + runs-on: ubuntu-22.04 + timeout-minutes: 5 + strategy: + matrix: + runtime: + - "docker" + - "podman" + # allow podman job to fail, since it started to fail on github actions + continue-on-error: ${{ matrix.runtime == 'podman' }} + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - uses: actions/download-artifact@v4 + with: + name: containerlab + + - name: Move containerlab to usr/bin + run: sudo mv ./containerlab /usr/bin/containerlab && sudo chmod a+x /usr/bin/containerlab + + - name: Setup Podman + if: matrix.runtime == 'podman' + run: sudo bash ./.github/workflows/install-podman.sh + + - uses: actions/setup-python@v5 + with: + python-version: ${{ inputs.py_ver }} + cache: pip + cache-dependency-path: "tests/requirements.txt" + + - name: Install robotframework + run: | + pip install -r tests/requirements.txt + + - name: Run smoke tests + run: | + bash ./tests/rf-run.sh ${{ matrix.runtime }} ./tests/01-smoke + + # upload test reports as a zip file + - name: Upload test report + uses: actions/upload-artifact@v4 + if: always() + with: + name: 01-smoke-log-${{ matrix.runtime }} + path: ./tests/out/*.html + + # upload coverage report from unit tests, as they are then + # merged with e2e tests coverage + - name: Upload coverage + uses: actions/upload-artifact@v4 + if: always() + with: + name: coverage-smoke-tests-${{ matrix.runtime }} + path: /tmp/clab-tests/coverage/* + retention-days: 7 diff --git a/.github/workflows/srlinux-tests.yml b/.github/workflows/srlinux-tests.yml new file mode 100644 index 000000000..d77fb7995 --- /dev/null +++ b/.github/workflows/srlinux-tests.yml @@ -0,0 +1,69 @@ +name: srlinux-tests + +"on": + workflow_call: + inputs: + py_ver: + required: true + type: string + +jobs: + srlinux-tests: + runs-on: ubuntu-22.04 + strategy: + matrix: + runtime: + - "docker" + - "podman" + # allow podman job to fail, since it started to fail on github actions + continue-on-error: ${{ matrix.runtime == 'podman' }} + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - uses: actions/download-artifact@v4 + with: + name: containerlab + + - name: Move containerlab to usr/bin + run: sudo mv ./containerlab /usr/bin/containerlab && sudo chmod a+x /usr/bin/containerlab + + - name: Setup Podman + if: matrix.runtime == 'podman' + # check http://download.opensuse.org/repositories/devel:/kubic:/libcontainers:/unstable/xUbuntu_22.04/amd64/ + # for available podman releases + run: sudo bash ./.github/workflows/install-podman.sh + + - uses: actions/setup-python@v5 + with: + python-version: ${{ inputs.py_ver }} + cache: pip + cache-dependency-path: "tests/requirements.txt" + + - name: Install robotframework + run: | + pip install -r tests/requirements.txt + + - name: Run srlinux tests + run: | + bash ./tests/rf-run.sh ${{ matrix.runtime }} ./tests/02-basic-srl + + # upload test reports as a zip file + - name: Upload test logs + uses: actions/upload-artifact@v4 + if: always() + with: + name: 02-basic-srl-log-${{ matrix.runtime }} + path: ./tests/out/*.html + + # upload coverage report from unit tests, as they are then + # merged with e2e tests coverage + - name: Upload coverage + uses: actions/upload-artifact@v4 + if: always() + with: + name: coverage-srlinux-tests-${{ matrix.runtime }} + path: /tmp/clab-tests/coverage/* + retention-days: 7 diff --git a/.github/workflows/vxlan-tests.yml b/.github/workflows/vxlan-tests.yml index 43c991f19..a592caa9d 100644 --- a/.github/workflows/vxlan-tests.yml +++ b/.github/workflows/vxlan-tests.yml @@ -2,6 +2,10 @@ name: vxlan-test "on": workflow_call: + inputs: + py_ver: + required: true + type: string jobs: vxlan-tests: @@ -20,7 +24,7 @@ jobs: with: fetch-depth: 0 - - uses: actions/download-artifact@v3 + - uses: actions/download-artifact@v4 with: name: containerlab @@ -29,7 +33,7 @@ jobs: - uses: actions/setup-python@v5 with: - python-version: "3.10" + python-version: ${{ inputs.py_ver }} cache: pip cache-dependency-path: "tests/requirements.txt" @@ -48,18 +52,22 @@ jobs: run: | bash ./tests/rf-run.sh ${{ matrix.runtime }} ./tests/08-vxlan/${{ matrix.test-suite }} + - name: Sanitize test-suite name + run: echo "TEST_SUITE=$(echo ${{ matrix.test-suite }} | tr -d '*')" >> $GITHUB_ENV + # upload test reports as a zip file - - uses: actions/upload-artifact@v3 + - uses: actions/upload-artifact@v4 if: always() with: - name: 08-${{ matrix.runtime }}-vxlan-log + name: 08-vxlan-log-${{ env.TEST_SUITE }}-${{ matrix.runtime }} path: ./tests/out/*.html # upload coverage report from unit tests, as they are then # merged with e2e tests coverage - - uses: actions/upload-artifact@v3 + - name: Upload coverage report + uses: actions/upload-artifact@v4 if: always() with: - name: coverage + name: coverage-vxlan-tests-${{ env.TEST_SUITE }}-${{ matrix.runtime }} path: /tmp/clab-tests/coverage/* retention-days: 7