Skip to content

e2e

e2e #1093

Workflow file for this run

name: e2e
on:
push:
branches: [ master ]
pull_request_review:
types: [submitted]
env:
REGISTRY: 'ghcr.io/dell/csi-baremetal'
go_version: '1.21.12'
golangci_version: '1.55.2'
helm_version: '3.7.1'
kubectl_version: 'v1.25.3'
kind_config: 'small-kind.yaml'
kind_wait: '30s'
jobs:
e2e:
# we need to start validation on master push or on /ci comment in PR only
if: github.event_name == 'push' || github.event.review.state == 'approved'
runs-on: ubuntu-20.04
steps:
- name: Get operator branch
uses: actions/github-script@v5
id: operator_branch
env:
COMMENT_BODY: ${{ github.event.comment.body }}
KEY: "operator_branch="
with:
result-encoding: string
script: |
const { COMMENT_BODY, KEY } = process.env
var branch = `${COMMENT_BODY}`.split(String.fromCharCode(0x0A))[1]
var key = `${KEY}`
if (branch){
if (branch.search(key) !== -1){
return branch.split(key)[1]
} else {
return 'keyword'
}
}
return ''
- name: Get PR SHA
# Since the issue comment event runs against the main branch
# we need to figure out a way to checkout the correct revision
# if we want to work with the changes from a pull request.
if: github.event.issue.pull_request_review
id: sha
uses: actions/github-script@v4
with:
result-encoding: string
script: |
const { owner, repo, number } = context.issue;
const pr = await github.pulls.get({
owner,
repo,
pull_number: number,
});
return pr.data.head.sha
# Set ref if triggered from comment
- name: Check out code
if: github.event.issue.pull_request_review
uses: actions/checkout@v2
with:
ref: '${{ steps.sha.outputs.result }}'
# Set ref if event is merge to master
- name: Check out code
if: github.event.issue.pull_request == false
uses: actions/checkout@v2
- name: Checkout csi-baremetal-operator repo
id: checkout_branch
uses: actions/checkout@v2
env:
OPERATOR_BRANCH: ${{ steps.operator_branch.outputs.result }}
with:
repository: dell/csi-baremetal-operator
ref: ${{ env.OPERATOR_BRANCH }}
path: ./csi-baremetal-operator
continue-on-error: true
- name: Create answer body
if: github.event.issue.pull_request && startsWith(github.event.comment.body, '/ci')
uses: actions/github-script@v5
id: set-answer
env:
OPERATOR_BRANCH: ${{ steps.operator_branch.outputs.result }}
CHECKOUT_BRANCH_OUTCOME: ${{ steps.checkout_branch.outcome }}
with:
result-encoding: string
script: |
const { OPERATOR_BRANCH, CHECKOUT_BRANCH_OUTCOME } = process.env
if (`${OPERATOR_BRANCH}` === 'keyword'){
return "Keyword error"
} else if (`${CHECKOUT_BRANCH_OUTCOME}` === 'failure'){
return "Branch doesn't exist"
}
return "Start CI"
- name: Send CI details
# don't send on push to master
if: github.event.issue.pull_request && startsWith(github.event.comment.body, '/ci')
uses: actions-ecosystem/action-create-comment@v1
env:
OPERATOR_BRANCH: ${{ steps.operator_branch.outputs.result }}
ANSWER: ${{ steps.set-answer.outputs.result }}
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
body: |
@${{ github.actor }} ${{ env.ANSWER }}.
Operator branch: ${{ env.OPERATOR_BRANCH }}
Go Version: ${{ env.go_version }}
GoLangCI Version: ${{ env.golangci_version }}
Helm Version: ${{ env.helm_version }}
Kubectl Version: ${{ env.kubectl_version }}
- name: Check on failures
if: steps.checkout_branch.outcome != 'success'
run: exit 1
- name: Set environment variables
run: |
echo "CSI_BAREMETAL_DIR=$RUNNER_WORKSPACE/csi-baremetal/" >> $GITHUB_ENV
echo "CSI_BAREMETAL_OPERATOR_DIR=$RUNNER_WORKSPACE/csi-baremetal/csi-baremetal-operator" >> $GITHUB_ENV
- name: Set CSI_VERSION
run: |
cd ${{ env.CSI_BAREMETAL_DIR }}
echo "CSI_VERSION=`make version`" >> $GITHUB_ENV
- name: Set CSI_OPERATOR_VERSION
run: |
cd ${{ env.CSI_BAREMETAL_OPERATOR_DIR }}
echo "CSI_OPERATOR_VERSION=`make version`" >> $GITHUB_ENV
- name: Send tested versions
# don't send on push to master
if: github.event.issue.pull_request && startsWith(github.event.comment.body, '/ci')
uses: actions-ecosystem/action-create-comment@v1
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
body: |
Versions using in CI
CSI Version: ${{ env.CSI_VERSION }}
OPERATOR Version: ${{ env.CSI_OPERATOR_VERSION }}
- name: LVM2 install
run: sudo apt-get install -y lvm2
- name: Prepare Golang
uses: actions/setup-go@v2
with:
go-version: ${{ env.go_version }}
- name: Install helm
uses: azure/setup-helm@v1
with:
version: ${{ env.helm_version }}
- name: Kubectl install
uses: azure/setup-kubectl@v1
with:
version: ${{ env.kubectl_version }}
- name: Get dependencies
run: make dependency
#TODO: Generate CRD - #618
- name: Build binary
run: |
make build
make DRIVE_MANAGER_TYPE=loopbackmgr build-drivemgr
#TODO: Install and compile proto - #613
- name: Download health-probe
run: make download-grpc-health-probe
- name: Build docker images
run: |
make images REGISTRY=${{ env.REGISTRY }}
make DRIVE_MANAGER_TYPE=loopbackmgr image-drivemgr REGISTRY=${{ env.REGISTRY }}
- name: Build Operator docker image
run: |
cd ${{env.CSI_BAREMETAL_OPERATOR_DIR}}
make docker-build REGISTRY=${{ env.REGISTRY }}
- name: Kind preparation
run: |
cd ${{env.CSI_BAREMETAL_DIR}}
make kind-build
make kind-create-cluster KIND_CONFIG=${{env.kind_config}} KIND_WAIT=${{env.kind_wait}}
kubectl cluster-info --context kind-kind
kubectl get pods -o wide --all-namespaces
echo "current-context:" $(kubectl config current-context)
echo "environment-kubeconfig:" ${KUBECONFIG}
- name: Sidecars preparing
run: |
make deps-docker-pull
make deps-docker-tag
- name: Retag CSI images and load them to kind
run: |
docker images
make kind-tag-images TAG=$CSI_VERSION REGISTRY=${{ env.REGISTRY }}
make kind-load-images TAG=$CSI_VERSION REGISTRY=${{ env.REGISTRY }}
make kind-tag-operator-image OPERATOR_VERSION=$CSI_OPERATOR_VERSION REGISTRY=${{ env.REGISTRY }}
make kind-load-operator-image OPERATOR_VERSION=$CSI_OPERATOR_VERSION
- name: Make test
continue-on-error: true
id: tests
run: make test-short-ci CSI_VERSION=$CSI_VERSION OPERATOR_VERSION=$CSI_OPERATOR_VERSION CHARTS_DIR=${{env.CSI_BAREMETAL_OPERATOR_DIR}}/charts
- name: Publish Unit Test Results
if: github.event.issue.pull_request && startsWith(github.event.comment.body, '/ci')
uses: EnricoMi/publish-unit-test-result-action@v1
with:
check_name: "E2E Test Results"
commit: '${{ steps.sha.outputs.result }}'
files: tests/e2e/reports/report.xml
hide_comments: off
check_run_annotations: all tests
comment_mode: create new
- uses: montudor/action-zip@v1
with:
args: zip -qq -r reports.zip tests/e2e/reports
- name: Upload report to artifacts
uses: actions/[email protected]
with:
name: e2e_artifacts_archive
path: reports.zip
- name: Upload report to artifacts
uses: actions/[email protected]
with:
name: e2e_artifacts_log
path: tests/log.txt
- name: Fail if test fails
if: steps.tests.outcome != 'success'
uses: actions/github-script@v3
with:
script: |
core.setFailed('E2E Tests failed!')
result_job:
needs: e2e
# answer must be posted on PR with /ci comment only
if: always() && github.event_name == 'issue_comment' && startsWith(github.event.comment.body, '/ci')
runs-on: ubuntu-20.04
steps:
- name: Create answer body
uses: actions/github-script@v5
id: set-answer
env:
TEST_RESULT: ${{ needs.e2e.result }}
with:
result-encoding: string
script: |
const { TEST_RESULT } = process.env
if (`${TEST_RESULT}` === 'failure' ){
return "CI tests failed"
} else if (`${TEST_RESULT}` === 'success'){
return "CI tests passed"
}
return "CI tests canceled"
- name: answer
uses: actions-ecosystem/action-create-comment@v1
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
body: |
@${{ github.actor }}, ${{ steps.set-answer.outputs.result }} Run: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}