krill 0.9.0

Resource Public Key Infrastructure (RPKI) daemon
Documentation
# This workflow deploys Krill and various Relying Parties (such as Routinator)
# in a local Docker private network and verifies that, for example, ROAs
# published by Krill can be retrieved by the RPs.
#
# This test was originally designed to work on remote cloud VMs such as
# DigitalOcean or Amazon Web  Services as the GitHub Runner hosts were too
# small. However, the test now  works on GH Runners, but for historical reasons
# the test is still orchestrated by Terraform even though there is no longer any
# cloud deployment involved.
#
# Commit 9a88f9c is the last version of this workflow that was configured to
# use cloud deployment.
#
# The actual E2E test framework is not part of the Krill repository as it is
# quite big. The framework is at https://github.com/NLnetLabs/rpki-deploy in the
# terraform/krill-e2e-test subdirectory.

name: E2E Test

on:
  push:
    branches: 
      - main
    paths:
      - '**'
      - '!.github/workflows/ci.yml'
      - '!.github/workflows/e2e test cache rebuild.yml'
      - '!.github/workflows/pkg.yml'
      - '!Changelog.md'
      - '!doc/**'
      - '!LICENSE'
      - '!README.md'
      - '!tests/**'
      - 'tests/e2e/**'
      - '!test-resources/**'
  pull_request:
    branches: 
      - main
      - v0.8.1-bis

jobs:
  krill_e2e_test:
    name: deploy_and_test
    runs-on: ubuntu-18.04
    steps:
    - name: Checkout Krill
      uses: actions/checkout@v2
      with:
        path: krill
        fetch-depth: 1

    - name: Determine E2E test framework branch to use
      id: pick_e2e_branch
      shell: bash
      run: |
        if git ls-remote --exit-code --heads https://github.com/NLnetLabs/rpki-deploy ${GITHUB_HEAD_REF}; then
          # If the e2e test framework has been modified specifically for this branch and thus there exists a dedicated
          # corresponding branch in the framework repo, use that branch.
          echo "::set-output name=branch::${GITHUB_HEAD_REF}"

        elif git ls-remote --exit-code --heads https://github.com/NLnetLabs/rpki-deploy ${GITHUB_BASE_REF}; then
          # If the e2e test framework has been modified for the branch we are merging into it will have a corresponding
          # branch in the framework repo and we will need to run that version of the framework, not the main version.
          echo "::set-output name=branch::${GITHUB_BASE_REF}"

        else
          # Otherwise use the master branch version.
          echo "::set-output name=branch::main"
        fi

    - name: Checkout the E2E test framework
      uses: actions/checkout@v2
      with:
        repository: nlnetlabs/rpki-deploy
        path: rpki-deploy
        fetch-depth: 1
        ref: ${{ steps.pick_e2e_branch.outputs.branch }}

    - name: Checkout RTRLIB (v0.7.0 tag)
      uses: actions/checkout@v2
      with:
        repository: rtrlib/rtrlib
        ref: v0.7.0
        path: rtrlib

    - name: Print GITHUB_WORKSPACE contents
      run: ls -la ${GITHUB_WORKSPACE}

    - name: Install Python 3 venv package
      run: |
        set -x
        sudo apt-get update
        sudo apt-get install -y python3-venv

    - name: Install RTRLIB with NDEBUG
      working-directory: ./rtrlib
      run: |
        set -x
        cmake -D CMAKE_C_FLAGS='-DNDEBUG' -D CMAKE_BUILD_TYPE=Release -D RTRLIB_TRANSPORT_SSH=No .
        make
        sudo make install
        sudo ldconfig

    - name: Install Terraform
      uses: hashicorp/setup-terraform@v1.3.2
      with:
        terraform_version: "0.12.19"

    # Strictly speaking this is not required when testing locally, but currently
    # the test fails without it.
    - name: Install Terraform plugins
      run: |
        set -x
        mkdir -p $HOME/.terraform.d/plugins/
        cp ${GITHUB_WORKSPACE}/rpki-deploy/terraform/plugins/terraform-provider-dockermachine $HOME/.terraform.d/plugins/

    - name: Print application versions
      run: |
        set -x
        docker --version
        docker-compose --version
        python3 --version
        terraform --version

    # Don't lock the state file, otherwise if the user cancels the build via the
    # GitHub Actions UI the terraform destroy cleanup step will fail.
    - name: Deploy
      working-directory: ./rpki-deploy/terraform/krill-e2e-test/run_on_localhost
      timeout-minutes: 30
      run: |
        set -x
        terraform init
        terraform apply -lock=false -auto-approve -var "krill_build_path=${GITHUB_WORKSPACE}/krill"
      env:
        TF_VAR_run_tests: false

    - name: Run tests
      working-directory: ./rpki-deploy/terraform/krill-e2e-test/run_on_localhost
      run: |
        set -x
        terraform apply -auto-approve \
          -var "krill_build_path=${GITHUB_WORKSPACE}/krill" \
          -var "test_suite_path=${GITHUB_WORKSPACE}/krill/tests/e2e"
      env:
        TF_VAR_run_tests: true

    - name: Upload HTML test report
      uses: actions/upload-artifact@v1
      with:
        name: test-report
        path: /tmp/report.html

    - name: Dump diagnostics on failure
      if: failure()
      working-directory: ./rpki-deploy/terraform/krill-e2e-test/run_on_do
      run: |
        set -x
        terraform output docker_env_vars
        eval $(terraform output docker_env_vars)
        pushd ../lib/docker
        docker system info
        docker system events --since 60m --until 1s

    - name: Undeploy
      if: always()
      working-directory: ./rpki-deploy/terraform/krill-e2e-test/run_on_localhost
      run: terraform destroy -auto-approve -var "krill_build_path=${GITHUB_WORKSPACE}/krill"