Skip to content

Commit

Permalink
e2e can be run on main branch
Browse files Browse the repository at this point in the history
  • Loading branch information
cyclinder committed Oct 18, 2023
1 parent 06bae59 commit 3045839
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 45 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/call-image-build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ jobs:
push: false
provenance: false
platforms: linux/amd64
type: docker,dest=/tmp/image.tar
outputs: type=docker,dest=/tmp/image.tar
github-token: ${{ secrets.GITHUB_TOKEN }}
tags: |
${{ env.ONLINE_REGISTER }}/${{ github.repository }}:${{ inputs.tag }}
Expand All @@ -107,5 +107,5 @@ jobs:
uses: actions/upload-artifact@v3.1.3
with:
name: image-e2e-tar
path: /tmp/images.tar
path: /tmp/image.tar
retention-days: 1
77 changes: 36 additions & 41 deletions .github/workflows/e2e.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: pull-request-e2e
name: e2e

env:
ONLINE_REGISTER: ghcr.io
Expand All @@ -10,25 +10,49 @@ on:
- opened
- synchronize
- reopened
push:
branches:
- main

jobs:
call-build-pr:
get_ref:
runs-on: ubuntu-latest
outputs:
tag: ${{ steps.get_ref.outputs.tag }}
steps:
- name: Get Ref
id: get_ref
run: |
if ${{ github.event_name == 'push' }} ; then
echo "trigger by push"
echo ::set-output name=tag::${{ github.sha }}
elif ${{ github.event_name == 'pull_request_target' }} ; then
echo "trigger by pull_request_target"
echo ::set-output name=tag::${{ github.event.pull_request.head.sha }}
else
echo "unexpected event: ${{ github.event_name }} "
exit 1
fi
call-build-image:
uses: ./.github/workflows/call-image-build.yaml
needs: [get_ref]
with:
ref: ${{ github.ref }}
tag: ${{ github.event.pull_request.head.sha }}
tag: ${{ needs.get_ref.outputs.tag }}
push: false
ci: true
secrets: inherit

call_e2e:
runs-on: ubuntu-latest
needs: [call-build-pr]
needs: [get_ref,call-build-image]
steps:
- name: Checkout Code
uses: actions/checkout@v3
with:
persist-credentials: false
fetch-depth: "0"
ref: ${{ github.ref }}

- name: Setup Golang
Expand All @@ -52,50 +76,21 @@ jobs:

- name: Load Image to docker
run: |
docker load -i .tmp/images.tar
docker load -i .tmp/image.tar
docker images
# https://github.com/actions/setup-python
- name: Set up Python
uses: actions/setup-python@v4.7.0
with:
python-version: 3.8
architecture: x64

# https://github.com/helm/chart-testing-action
# Pre-requisites: A GitHub repo containing a directory with your Helm charts (e.g: charts)
- name: Set up chart-testing
uses: helm/chart-testing-action@v2.4.0
with:
# CT version
version: v3.9.0

- name: Run chart-testing (list-changed)
id: list-changed
run: |
# https://github.com/helm/chart-testing-action/issues/25
# if the default branch is not master , the CLI exits with error
changed=$( ct list-changed --target-branch ${{ github.ref }} )
if [[ -n "$changed" ]]; then
echo "::set-output name=changed::true"
fi
# version checking, YAML schema validation on 'Chart.yaml', YAML linting on 'Chart.yaml'
# and 'values.yaml', and maintainer validation
- name: Run chart-testing (lint)
run: ct lint --debug --target-branch=${{ github.ref }} --check-version-increment=false

# https://github.com/helm/kind-action
- name: Create Kind cluster
if: steps.list-changed.outputs.changed == 'true'
uses: helm/kind-action@v1.8.0
with:
wait: 120s

# It automatically detects charts changed
- name: Run chart-testing (install)
if: steps.list-changed.outputs.changed == 'true'
run: |
kind load docker-image ${{ env.ONLINE_REGISTER }}/${{ github.repository }}:${{ github.event.pull_request.head.sha }}
ct install --debug --target-branch ${{ github.ref }} --namespace kube-system \
--helm-extra-args "--timeout 400s --cilium.image.tag=${{ github.event.pull_request.head.sha }}"
kind load docker-image ${{ env.ONLINE_REGISTER }}/${{ github.repository }}:${{ needs.get_ref.outputs.tag }} --name chart-testing
helm upgrade --install cilium-chaining -n kube-system charts/cilium-chaining \
--set cilium.image.tag=${{ needs.get_ref.outputs.tag }}
sleep 20
kubectl get po -n kube-system -o wide
kubectl describe po -n kube-system -l app.kubernetes.io/name=cilium-chaining
kubectl wait --for=condition=ready -l app.kubernetes.io/name=cilium-chaining --timeout=300s pod -n kube-system
2 changes: 1 addition & 1 deletion charts/cilium-chaining/templates/daemonset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ spec:
{{- end }}
containers:
- command:
- /bin/init.sh
- ./init.sh
env:
- name: NODENAME
valueFrom:
Expand Down
2 changes: 1 addition & 1 deletion manifests/cilium-chaining.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ spec:
- linux
containers:
- command:
- /bin/init.sh
- ./init.sh
env:
- name: NODENAME
valueFrom:
Expand Down

0 comments on commit 3045839

Please sign in to comment.