diff --git a/.github/actions/build-and-push-docker/action.yml b/.github/actions/build-and-push-docker/action.yml new file mode 100644 index 000000000..78dc6a4fb --- /dev/null +++ b/.github/actions/build-and-push-docker/action.yml @@ -0,0 +1,45 @@ +name: build and push Docker image +description: build and push the wlan-testing Docker image + +inputs: + registry: + description: the registry to push to + required: true + registry_user: + description: the user to authenticate against the registry + required: true + registry_password: + description: the password to authenticate against the registry + required: true + +runs: + using: "composite" + steps: + - name: Checkout Testing repo + uses: actions/checkout@v2 + with: + path: wlan-testing + + - name: Checkout LANforge scripts + uses: actions/checkout@v2 + with: + path: wlan-lanforge-scripts + repository: Telecominfraproject/wlan-lanforge-scripts + + - name: import LANforge scripts + shell: bash + working-directory: wlan-testing + run: ./sync_repos.bash + + - name: docker login + shell: bash + run: docker login ${{ inputs.registry }} -u ${{ inputs.registry_user }} -p ${{ inputs.registry_password }} + + - name: build docker image + working-directory: wlan-testing + shell: bash + run: docker build -t ${{ inputs.registry }}/cloud-sdk-nightly:${{ github.run_id }} -f docker/Dockerfile . + + - name: push docker image + shell: bash + run: docker push ${{ inputs.registry }}/cloud-sdk-nightly:${{ github.run_id }} diff --git a/.github/actions/cleanup-docker/action.yml b/.github/actions/cleanup-docker/action.yml new file mode 100644 index 000000000..e66bdaf7d --- /dev/null +++ b/.github/actions/cleanup-docker/action.yml @@ -0,0 +1,17 @@ +name: build and push Docker image +description: build and push the wlan-testing Docker image + +inputs: + registry_user: + description: the user to authenticate against the registry + required: true + registry_password: + description: the password to authenticate against the registry + required: true + +runs: + using: "composite" + steps: + - name: cleanup Docker image + shell: bash + run: curl -u ${{ inputs.registry_user }}:${{ inputs.registry_password }} -X DELETE "https://tip.jfrog.io/artifactory/tip-wlan-cloud-docker-repo/cloud-sdk-nightly/${{ github.run_id }}" diff --git a/.github/workflows/advanced.yml b/.github/workflows/advanced.yml new file mode 100644 index 000000000..7121222b8 --- /dev/null +++ b/.github/workflows/advanced.yml @@ -0,0 +1,273 @@ +name: advanced testing + +env: + ALLURE_CLI_VERSION: 2.14.0 + +on: + workflow_dispatch: + schedule: + - cron: '30 20 * * *' + +defaults: + run: + shell: bash + +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: build and push Docker image + uses: ./.github/actions/build-and-push-docker + with: + registry: tip-tip-wlan-cloud-docker-repo.jfrog.io + registry_user: wlan-testing-cicd + registry_password: ${{ secrets.DOCKER_USER_PASSWORD }} + + test: + runs-on: ubuntu-latest + needs: [ build ] + env: + AWS_EKS_NAME: tip-wlan-main + AWS_DEFAULT_OUTPUT: json + AWS_DEFAULT_REGION: us-east-2 + AWS_ACCOUNT_ID: ${{ secrets.AWS_ACCOUNT_ID }} + AWS_ACCESS_KEY_ID: ${{ secrets.AWS_CLIENT_ID }} + AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_CLIENT_KEY }} + + strategy: + fail-fast: false + matrix: + testbed: + - advanced-01 + - advanced-02 + + steps: + - name: get EKS access credentials + run: aws eks update-kubeconfig --name ${{ env.AWS_EKS_NAME }} + + - name: install Allure CLI tool + run: | + wget https://repo.maven.apache.org/maven2/io/qameta/allure/allure-commandline/${{ env.ALLURE_CLI_VERSION }}/allure-commandline-${{ env.ALLURE_CLI_VERSION }}.tgz + tar -xzf allure-commandline-${{ env.ALLURE_CLI_VERSION }}.tgz + + - name: set job name + id: job + run: echo "::set-output name=name::advanced-ci-${{ github.run_number }}" + + - name: prepare namespace + id: namespace + run: | + NAMESPACE="testing-${{ github.run_number }}-${{ matrix.testbed }}" + kubectl create ns $NAMESPACE + kubectl config set-context --current --namespace=$NAMESPACE + echo "::set-output name=name::${NAMESPACE}" + + - name: create configuration.py secret + run: | + cat << EOF > configuration.py + ${{ secrets.LAB_CONFIGURATION }} + EOF + kubectl create secret generic configuration --from-file=configuration=./configuration.py + + - name: run tests + run: | + cat </dev/null 2>&1 + done + echo "tests completed" + echo "downloading allure results..." + kubectl cp $podname:/tmp/allure-results allure-results >/dev/null 2>&1 + echo "waiting for pod to exit" + kubectl logs -f $podname >/dev/null 2>&1 + exit $(kubectl get pod $podname --output="jsonpath={.status.containerStatuses[].state.terminated.exitCode}") + + - name: upload Allure results as artifact + if: ${{ always() }} + uses: actions/upload-artifact@v2 + with: + name: allure-results-${{ matrix.testbed }} + path: allure-results + + - name: cleanup + if: ${{ always() }} + run: | + kubectl delete ns "${{ steps.namespace.outputs.name }}" --wait=true + + report: + needs: [ test ] + if: always() + runs-on: ubuntu-latest + strategy: + fail-fast: false + max-parallel: 1 + matrix: + testbed: + - advanced-01 + - advanced-02 + steps: + - name: install Allure CLI tool + run: | + wget https://repo.maven.apache.org/maven2/io/qameta/allure/allure-commandline/${{ env.ALLURE_CLI_VERSION }}/allure-commandline-${{ env.ALLURE_CLI_VERSION }}.tgz + tar -xzf allure-commandline-${{ env.ALLURE_CLI_VERSION }}.tgz + + - uses: actions/download-artifact@v2 + with: + name: allure-results-${{ matrix.testbed }} + path: allure-results + + - name: checkout testing repo + uses: actions/checkout@v2 + with: + path: wlan-testing + + - name: get reports branch + uses: actions/checkout@v2 + continue-on-error: true + with: + ref: gh-pages + path: reports + + - name: copy history into results + run: | + if [ -e "reports/advanced/${{ matrix.testbed }}/latest" ] ; then + cp -r reports/advanced/${{ matrix.testbed }}/latest/history/ allure-results/history + fi + + - name: add report metadata + run: | + cat << EOF >> allure-results/environment.properties + Testbed=${{ matrix.testbed }} + Tests.CommitId=$(cd wlan-testing && git rev-parse --short HEAD) + CiRun.Id=${{ github.run_id }} + CiRun.Number=${{ github.run_number }} + CiRun.Url=https://github.com/${{github.repository}}/actions/runs/${{github.run_id}} + EOF + + - name: generate Allure report + run: allure-${{ env.ALLURE_CLI_VERSION }}/bin/allure generate allure-results + + - name: upload Allure report as artifact + uses: actions/upload-artifact@v2 + with: + name: allure-report-${{ matrix.testbed }} + path: allure-report + + # doing this to be able to aggregate multiple reports together later on + - name: copy results into report + run: | + mkdir -p allure-report/results + cp -r allure-results/* allure-report/results + + - name: copy new report + run: | + mkdir -p reports/advanced/${{ matrix.testbed }} + cp -Tr allure-report reports/advanced/${{ matrix.testbed }}/${{ github.run_number }} + + - name: update latest symlink + working-directory: reports/advanced/${{ matrix.testbed }} + run: ln -fns ${{ github.run_number }} latest + + - name: generate new index.html + run: python wlan-testing/.github/tools/generate_directory_index.py -r reports + + - name: commit reports update + working-directory: reports + run: | + git config --global user.name "github-actions[bot]" + git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com" + + git add . + git commit -m "Automated deployment: $(date -u)" + + - name: push + if: github.ref == 'refs/heads/master' + uses: ad-m/github-push-action@v0.6.0 + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + branch: gh-pages + directory: reports + + - name: upload to S3 + if: github.ref == 'refs/heads/master' + uses: ./wlan-testing/.github/actions/allure-report-to-s3 + with: + test_type: advanced + testbed: ${{ matrix.testbed }} + report_path: allure-report + s3_access_key_id: ${{ secrets.ALLURE_S3_ACCESS_KEY_ID }} + s3_access_key_secret: ${{ secrets.ALLURE_S3_ACCESS_KEY_SECRET }} + + cleanup: + needs: [ test ] + runs-on: ubuntu-latest + if: always() + steps: + - uses: actions/checkout@v2 + - name: cleanup Docker image + uses: ./.github/actions/cleanup-docker + with: + registry_user: wlan-testing-cicd + registry_password: ${{ secrets.DOCKER_USER_PASSWORD }} diff --git a/.github/workflows/interop.yml b/.github/workflows/interop.yml index 2f899defd..c8a038e38 100644 --- a/.github/workflows/interop.yml +++ b/.github/workflows/interop.yml @@ -184,12 +184,6 @@ jobs: kubectl logs -f $podname >/dev/null 2>&1 exit $(kubectl get pod $podname --output="jsonpath={.status.containerStatuses[].state.terminated.exitCode}") - - name: print logs - if: ${{ always() }} - run: | - podname=$(kubectl get pods --no-headers -o custom-columns=":metadata.name" -l job-name="${{ steps.job.outputs.name }}" | sed "s/pod\///") - kubectl logs $podname - - name: upload Allure results as artifact if: ${{ always() }} uses: actions/upload-artifact@v2