Skip to content

Commit

Permalink
build and push images in github
Browse files Browse the repository at this point in the history
Signed-off-by: Shi, Crane <crane.shi@emc.com>
  • Loading branch information
CraneShiEMC committed May 13, 2023
1 parent 29bc09d commit 401fe35
Showing 1 changed file with 87 additions and 86 deletions.
173 changes: 87 additions & 86 deletions .github/workflows/e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ name: e2e
on:
push:
branches: [ master ]
pull_request_review:
types: [submitted]
pull_request:
branches: [ master ]

env:
REGISTRY: 'ghcr.io/dell/csi-baremetal'
REGISTRY: 'craneshiemc'
go_version: '1.17.7'
golangci_version: '1.44.0'
helm_version: '3.7.1'
Expand All @@ -16,8 +16,6 @@ env:
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
Expand Down Expand Up @@ -182,101 +180,104 @@ jobs:

- name: Build docker images
run: |
docker login -u craneshiemc -p 52XiaoKeAi
make images REGISTRY=${{ env.REGISTRY }}
make DRIVE_MANAGER_TYPE=loopbackmgr image-drivemgr REGISTRY=${{ env.REGISTRY }}
make push REGISTRY=${{ env.REGISTRY }}
make DRIVE_MANAGER_TYPE=loopbackmgr push-drivemgr REGISTRY=${{ env.REGISTRY }}
- name: Build Operator docker image
run: |
cd ${{env.CSI_BAREMETAL_OPERATOR_DIR}}
docker login -u craneshiemc -p 52XiaoKeAi
make docker-build REGISTRY=${{ env.REGISTRY }}
make docker-push 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: 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/upload-artifact@v2.2.1
with:
name: e2e_artifacts_archive
path: reports.zip
# - 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: Upload report to artifacts
uses: actions/upload-artifact@v2.2.1
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!')
# - 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

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"
# - uses: montudor/action-zip@v1
# with:
# args: zip -qq -r reports.zip tests/e2e/reports
#
# - name: Upload report to artifacts
# uses: actions/upload-artifact@v2.2.1
# with:
# name: e2e_artifacts_archive
# path: reports.zip
#
# - name: Upload report to artifacts
# uses: actions/upload-artifact@v2.2.1
# 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!')

- 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 }}
# result_job:
# needs: e2e
# 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 }}

0 comments on commit 401fe35

Please sign in to comment.