Adding e2e workflows to test dind, kube mode and proxy (#2412)
This commit is contained in:
		
							parent
							
								
									08acb1b831
								
							
						
					
					
						commit
						44c3931d8e
					
				|  | @ -49,12 +49,11 @@ runs: | ||||||
|         cache-from: type=gha |         cache-from: type=gha | ||||||
|         cache-to: type=gha,mode=max |         cache-to: type=gha,mode=max | ||||||
| 
 | 
 | ||||||
|     - name: Create Kind cluster and load image |     - name: Create minikube cluster and load image | ||||||
|       shell: bash |       shell: bash | ||||||
|       run: | |       run: | | ||||||
|         PATH=$(go env GOPATH)/bin:$PATH |         minikube start | ||||||
|         kind create cluster --name arc-e2e |         minikube image load ${{inputs.docker-image-name}}:${{inputs.docker-image-tag}} | ||||||
|         kind load docker-image ${{inputs.docker-image-name}}:${{inputs.docker-image-tag}} --name arc-e2e |  | ||||||
| 
 | 
 | ||||||
|     - name: Get configure token |     - name: Get configure token | ||||||
|       id: config-token |       id: config-token | ||||||
|  |  | ||||||
|  | @ -27,6 +27,8 @@ env: | ||||||
| jobs: | jobs: | ||||||
|   default-setup: |   default-setup: | ||||||
|     runs-on: ubuntu-latest |     runs-on: ubuntu-latest | ||||||
|  |     env: | ||||||
|  |       WORKFLOW_FILE: "arc-test-workflow.yaml" | ||||||
|     steps: |     steps: | ||||||
|       - uses: actions/checkout@v3 |       - uses: actions/checkout@v3 | ||||||
| 
 | 
 | ||||||
|  | @ -109,9 +111,11 @@ jobs: | ||||||
|           kubectl get pod -n arc-systems |           kubectl get pod -n arc-systems | ||||||
| 
 | 
 | ||||||
|       - name: Test ARC scales pods up and down |       - name: Test ARC scales pods up and down | ||||||
|  |         id: test | ||||||
|         run: | |         run: | | ||||||
|           export GITHUB_TOKEN="${{ steps.setup.outputs.token }}" |           export GITHUB_TOKEN="${{ steps.setup.outputs.token }}" | ||||||
|           export ARC_NAME="${{ steps.install_arc.outputs.ARC_NAME }}" |           export ARC_NAME="${{ steps.install_arc.outputs.ARC_NAME }}" | ||||||
|  |           export WORKFLOW_FILE="${{env.WORKFLOW_FILE}}" | ||||||
|           go test ./test_e2e_arc -v |           go test ./test_e2e_arc -v | ||||||
| 
 | 
 | ||||||
|       - name: Uninstall gha-runner-scale-set |       - name: Uninstall gha-runner-scale-set | ||||||
|  | @ -125,8 +129,19 @@ jobs: | ||||||
|         run: | |         run: | | ||||||
|           kubectl logs deployment/arc-gha-runner-scale-set-controller -n arc-systems |           kubectl logs deployment/arc-gha-runner-scale-set-controller -n arc-systems | ||||||
| 
 | 
 | ||||||
|  |       - name: Job summary | ||||||
|  |         if: always() && steps.install_arc.outcome == 'success' | ||||||
|  |         run: | | ||||||
|  |           cat <<-EOF > $GITHUB_STEP_SUMMARY | ||||||
|  |           | **Outcome**    | ${{ steps.test.outcome }}  | | ||||||
|  |           |----------------|--------------------------------------------- | | ||||||
|  |           | **References** | [Test workflow runs](https://github.com/${{ steps.resolved_inputs.outputs.TARGET_ORG }}/${{steps.resolved_inputs.outputs.TARGET_REPO}}/actions/workflows/${{ env.WORKFLOW_FILE }}) | | ||||||
|  |           EOF | ||||||
|  | 
 | ||||||
|   single-namespace-setup: |   single-namespace-setup: | ||||||
|     runs-on: ubuntu-latest |     runs-on: ubuntu-latest | ||||||
|  |     env: | ||||||
|  |       WORKFLOW_FILE: "arc-test-workflow.yaml" | ||||||
|     steps: |     steps: | ||||||
|       - uses: actions/checkout@v3 |       - uses: actions/checkout@v3 | ||||||
| 
 | 
 | ||||||
|  | @ -211,9 +226,11 @@ jobs: | ||||||
|           kubectl get pod -n arc-systems |           kubectl get pod -n arc-systems | ||||||
| 
 | 
 | ||||||
|       - name: Test ARC scales pods up and down |       - name: Test ARC scales pods up and down | ||||||
|  |         id: test | ||||||
|         run: | |         run: | | ||||||
|           export GITHUB_TOKEN="${{ steps.setup.outputs.token }}" |           export GITHUB_TOKEN="${{ steps.setup.outputs.token }}" | ||||||
|           export ARC_NAME="${{ steps.install_arc.outputs.ARC_NAME }}" |           export ARC_NAME="${{ steps.install_arc.outputs.ARC_NAME }}" | ||||||
|  |           export WORKFLOW_FILE="${{env.WORKFLOW_FILE}}" | ||||||
|           go test ./test_e2e_arc -v |           go test ./test_e2e_arc -v | ||||||
| 
 | 
 | ||||||
|       - name: Uninstall gha-runner-scale-set |       - name: Uninstall gha-runner-scale-set | ||||||
|  | @ -226,3 +243,490 @@ jobs: | ||||||
|         if: always() && steps.install_arc_controller.outcome == 'success' |         if: always() && steps.install_arc_controller.outcome == 'success' | ||||||
|         run: | |         run: | | ||||||
|           kubectl logs deployment/arc-gha-runner-scale-set-controller -n arc-systems |           kubectl logs deployment/arc-gha-runner-scale-set-controller -n arc-systems | ||||||
|  | 
 | ||||||
|  |       - name: Job summary | ||||||
|  |         if: always() && steps.install_arc.outcome == 'success' | ||||||
|  |         run: | | ||||||
|  |           cat <<-EOF > $GITHUB_STEP_SUMMARY | ||||||
|  |           | **Outcome**    | ${{ steps.test.outcome }}  | | ||||||
|  |           |----------------|--------------------------------------------- | | ||||||
|  |           | **References** | [Test workflow runs](https://github.com/${{ steps.resolved_inputs.outputs.TARGET_ORG }}/${{steps.resolved_inputs.outputs.TARGET_REPO}}/actions/workflows/${{ env.WORKFLOW_FILE }}) | | ||||||
|  |           EOF | ||||||
|  | 
 | ||||||
|  |   dind-mode-setup: | ||||||
|  |     runs-on: ubuntu-latest | ||||||
|  |     env: | ||||||
|  |       WORKFLOW_FILE: arc-test-dind-workflow.yaml | ||||||
|  |     steps: | ||||||
|  |       - uses: actions/checkout@v3 | ||||||
|  | 
 | ||||||
|  |       - name: Resolve inputs | ||||||
|  |         id: resolved_inputs | ||||||
|  |         run: | | ||||||
|  |           TARGET_ORG="${{env.TARGET_ORG}}" | ||||||
|  |           TARGET_REPO="${{env.TARGET_REPO}}" | ||||||
|  |           if [ ! -z "${{inputs.target_org}}" ]; then | ||||||
|  |             TARGET_ORG="${{inputs.target_org}}" | ||||||
|  |           fi | ||||||
|  |           if [ ! -z "${{inputs.target_repo}}" ]; then | ||||||
|  |             TARGET_REPO="${{inputs.target_repo}}" | ||||||
|  |           fi | ||||||
|  |           echo "TARGET_ORG=$TARGET_ORG" >> $GITHUB_OUTPUT | ||||||
|  |           echo "TARGET_REPO=$TARGET_REPO" >> $GITHUB_OUTPUT | ||||||
|  | 
 | ||||||
|  |       - uses: ./.github/actions/setup-arc-e2e | ||||||
|  |         id: setup | ||||||
|  |         with: | ||||||
|  |           github-app-id: ${{secrets.ACTIONS_ACCESS_APP_ID}} | ||||||
|  |           github-app-pk: ${{secrets.ACTIONS_ACCESS_PK}} | ||||||
|  |           github-app-org: ${{steps.resolved_inputs.outputs.TARGET_ORG}} | ||||||
|  |           docker-image-name: ${{env.IMAGE_NAME}} | ||||||
|  |           docker-image-tag: ${{env.IMAGE_VERSION}} | ||||||
|  | 
 | ||||||
|  |       - name: Install gha-runner-scale-set-controller | ||||||
|  |         id: install_arc_controller | ||||||
|  |         run: | | ||||||
|  |           helm install arc \ | ||||||
|  |           --namespace "arc-systems" \ | ||||||
|  |           --create-namespace \ | ||||||
|  |           --set image.repository=${{ env.IMAGE_NAME }} \ | ||||||
|  |           --set image.tag=${{ env.IMAGE_VERSION }} \ | ||||||
|  |           ./charts/gha-runner-scale-set-controller \ | ||||||
|  |           --debug | ||||||
|  |           count=0 | ||||||
|  |           while true; do | ||||||
|  |             POD_NAME=$(kubectl get pods -n arc-systems -l app.kubernetes.io/name=gha-runner-scale-set-controller -o name) | ||||||
|  |             if [ -n "$POD_NAME" ]; then | ||||||
|  |               echo "Pod found: $POD_NAME" | ||||||
|  |               break | ||||||
|  |             fi | ||||||
|  |             if [ "$count" -ge 10 ]; then | ||||||
|  |               echo "Timeout waiting for controller pod with label app.kubernetes.io/name=gha-runner-scale-set-controller" | ||||||
|  |               exit 1 | ||||||
|  |             fi | ||||||
|  |             sleep 1 | ||||||
|  |           done | ||||||
|  |           kubectl wait --timeout=30s --for=condition=ready pod -n arc-systems -l app.kubernetes.io/name=gha-runner-scale-set-controller | ||||||
|  |           kubectl get pod -n arc-systems | ||||||
|  |           kubectl describe deployment arc-gha-runner-scale-set-controller -n arc-systems | ||||||
|  | 
 | ||||||
|  |       - name: Install gha-runner-scale-set | ||||||
|  |         id: install_arc | ||||||
|  |         run: | | ||||||
|  |           ARC_NAME=arc-runner-${{github.job}}-$(date +'%M-%S')-$(($RANDOM % 100 + 1)) | ||||||
|  |           helm install "$ARC_NAME" \ | ||||||
|  |           --namespace "arc-runners" \ | ||||||
|  |           --create-namespace \ | ||||||
|  |           --set githubConfigUrl="https://github.com/${{ steps.resolved_inputs.outputs.TARGET_ORG }}/${{steps.resolved_inputs.outputs.TARGET_REPO}}" \ | ||||||
|  |           --set githubConfigSecret.github_token="${{ steps.setup.outputs.token }}" \ | ||||||
|  |           --set containerMode.type="dind" \ | ||||||
|  |           ./charts/gha-runner-scale-set \ | ||||||
|  |           --debug | ||||||
|  |           echo "ARC_NAME=$ARC_NAME" >> $GITHUB_OUTPUT | ||||||
|  |           count=0 | ||||||
|  |           while true; do | ||||||
|  |             POD_NAME=$(kubectl get pods -n arc-systems -l auto-scaling-runner-set-name=$ARC_NAME -o name) | ||||||
|  |             if [ -n "$POD_NAME" ]; then | ||||||
|  |               echo "Pod found: $POD_NAME" | ||||||
|  |               break | ||||||
|  |             fi | ||||||
|  |             if [ "$count" -ge 10 ]; then | ||||||
|  |               echo "Timeout waiting for listener pod with label auto-scaling-runner-set-name=$ARC_NAME" | ||||||
|  |               exit 1 | ||||||
|  |             fi | ||||||
|  |             sleep 1 | ||||||
|  |           done | ||||||
|  |           kubectl wait --timeout=30s --for=condition=ready pod -n arc-systems -l auto-scaling-runner-set-name=$ARC_NAME | ||||||
|  |           kubectl get pod -n arc-systems | ||||||
|  | 
 | ||||||
|  |       - name: Test ARC scales pods up and down | ||||||
|  |         id: test | ||||||
|  |         run: | | ||||||
|  |           export GITHUB_TOKEN="${{ steps.setup.outputs.token }}" | ||||||
|  |           export ARC_NAME="${{ steps.install_arc.outputs.ARC_NAME }}" | ||||||
|  |           export WORKFLOW_FILE="${{env.WORKFLOW_FILE}}" | ||||||
|  |           go test ./test_e2e_arc -v | ||||||
|  | 
 | ||||||
|  |       - name: Uninstall gha-runner-scale-set | ||||||
|  |         if: always() && steps.install_arc.outcome == 'success' | ||||||
|  |         run: | | ||||||
|  |           helm uninstall ${{ steps.install_arc.outputs.ARC_NAME }} --namespace arc-runners | ||||||
|  |           kubectl wait --timeout=10s --for=delete AutoScalingRunnerSet -n demo -l app.kubernetes.io/instance=${{ steps.install_arc.outputs.ARC_NAME }} | ||||||
|  | 
 | ||||||
|  |       - name: Dump gha-runner-scale-set-controller logs | ||||||
|  |         if: always() && steps.install_arc_controller.outcome == 'success' | ||||||
|  |         run: | | ||||||
|  |           kubectl logs deployment/arc-gha-runner-scale-set-controller -n arc-systems | ||||||
|  | 
 | ||||||
|  |       - name: Job summary | ||||||
|  |         if: always() && steps.install_arc.outcome == 'success' | ||||||
|  |         run: | | ||||||
|  |           cat <<-EOF > $GITHUB_STEP_SUMMARY | ||||||
|  |           | **Outcome**    | ${{ steps.test.outcome }}  | | ||||||
|  |           |----------------|--------------------------------------------- | | ||||||
|  |           | **References** | [Test workflow runs](https://github.com/${{ steps.resolved_inputs.outputs.TARGET_ORG }}/${{steps.resolved_inputs.outputs.TARGET_REPO}}/actions/workflows/${{ env.WORKFLOW_FILE }}) | | ||||||
|  |           EOF | ||||||
|  | 
 | ||||||
|  |   kubernetes-mode-setup: | ||||||
|  |     runs-on: ubuntu-latest | ||||||
|  |     env: | ||||||
|  |       WORKFLOW_FILE: "arc-test-kubernetes-workflow.yaml" | ||||||
|  |     steps: | ||||||
|  |       - uses: actions/checkout@v3 | ||||||
|  | 
 | ||||||
|  |       - name: Resolve inputs | ||||||
|  |         id: resolved_inputs | ||||||
|  |         run: | | ||||||
|  |           TARGET_ORG="${{env.TARGET_ORG}}" | ||||||
|  |           TARGET_REPO="${{env.TARGET_REPO}}" | ||||||
|  |           if [ ! -z "${{inputs.target_org}}" ]; then | ||||||
|  |             TARGET_ORG="${{inputs.target_org}}" | ||||||
|  |           fi | ||||||
|  |           if [ ! -z "${{inputs.target_repo}}" ]; then | ||||||
|  |             TARGET_REPO="${{inputs.target_repo}}" | ||||||
|  |           fi | ||||||
|  |           echo "TARGET_ORG=$TARGET_ORG" >> $GITHUB_OUTPUT | ||||||
|  |           echo "TARGET_REPO=$TARGET_REPO" >> $GITHUB_OUTPUT | ||||||
|  | 
 | ||||||
|  |       - uses: ./.github/actions/setup-arc-e2e | ||||||
|  |         id: setup | ||||||
|  |         with: | ||||||
|  |           github-app-id: ${{secrets.ACTIONS_ACCESS_APP_ID}} | ||||||
|  |           github-app-pk: ${{secrets.ACTIONS_ACCESS_PK}} | ||||||
|  |           github-app-org: ${{steps.resolved_inputs.outputs.TARGET_ORG}} | ||||||
|  |           docker-image-name: ${{env.IMAGE_NAME}} | ||||||
|  |           docker-image-tag: ${{env.IMAGE_VERSION}} | ||||||
|  | 
 | ||||||
|  |       - name: Install gha-runner-scale-set-controller | ||||||
|  |         id: install_arc_controller | ||||||
|  |         run: | | ||||||
|  |           helm install arc \ | ||||||
|  |           --namespace "arc-systems" \ | ||||||
|  |           --create-namespace \ | ||||||
|  |           --set image.repository=${{ env.IMAGE_NAME }} \ | ||||||
|  |           --set image.tag=${{ env.IMAGE_VERSION }} \ | ||||||
|  |           ./charts/gha-runner-scale-set-controller \ | ||||||
|  |           --debug | ||||||
|  |           count=0 | ||||||
|  |           while true; do | ||||||
|  |             POD_NAME=$(kubectl get pods -n arc-systems -l app.kubernetes.io/name=gha-runner-scale-set-controller -o name) | ||||||
|  |             if [ -n "$POD_NAME" ]; then | ||||||
|  |               echo "Pod found: $POD_NAME" | ||||||
|  |               break | ||||||
|  |             fi | ||||||
|  |             if [ "$count" -ge 10 ]; then | ||||||
|  |               echo "Timeout waiting for controller pod with label app.kubernetes.io/name=gha-runner-scale-set-controller" | ||||||
|  |               exit 1 | ||||||
|  |             fi | ||||||
|  |             sleep 1 | ||||||
|  |           done | ||||||
|  |           kubectl wait --timeout=30s --for=condition=ready pod -n arc-systems -l app.kubernetes.io/name=gha-runner-scale-set-controller | ||||||
|  |           kubectl get pod -n arc-systems | ||||||
|  |           kubectl describe deployment arc-gha-runner-scale-set-controller -n arc-systems | ||||||
|  | 
 | ||||||
|  |       - name: Install gha-runner-scale-set | ||||||
|  |         id: install_arc | ||||||
|  |         run: | | ||||||
|  |           echo "Install openebs/dynamic-localpv-provisioner" | ||||||
|  |           helm repo add openebs https://openebs.github.io/charts | ||||||
|  |           helm repo update | ||||||
|  |           helm install openebs openebs/openebs -n openebs --create-namespace | ||||||
|  | 
 | ||||||
|  |           ARC_NAME=arc-runner-${{github.job}}-$(date +'%M-%S')-$(($RANDOM % 100 + 1)) | ||||||
|  |           helm install "$ARC_NAME" \ | ||||||
|  |           --namespace "arc-runners" \ | ||||||
|  |           --create-namespace \ | ||||||
|  |           --set githubConfigUrl="https://github.com/${{ steps.resolved_inputs.outputs.TARGET_ORG }}/${{steps.resolved_inputs.outputs.TARGET_REPO}}" \ | ||||||
|  |           --set githubConfigSecret.github_token="${{ steps.setup.outputs.token }}" \ | ||||||
|  |           --set containerMode.type="kubernetes" \ | ||||||
|  |           --set containerMode.kubernetesModeWorkVolumeClaim.storageClassName="openebs-hostpath" \ | ||||||
|  |           ./charts/gha-runner-scale-set \ | ||||||
|  |           --debug | ||||||
|  |           echo "ARC_NAME=$ARC_NAME" >> $GITHUB_OUTPUT | ||||||
|  |           count=0 | ||||||
|  |           while true; do | ||||||
|  |             POD_NAME=$(kubectl get pods -n arc-systems -l auto-scaling-runner-set-name=$ARC_NAME -o name) | ||||||
|  |             if [ -n "$POD_NAME" ]; then | ||||||
|  |               echo "Pod found: $POD_NAME" | ||||||
|  |               break | ||||||
|  |             fi | ||||||
|  |             if [ "$count" -ge 10 ]; then | ||||||
|  |               echo "Timeout waiting for listener pod with label auto-scaling-runner-set-name=$ARC_NAME" | ||||||
|  |               exit 1 | ||||||
|  |             fi | ||||||
|  |             sleep 1 | ||||||
|  |           done | ||||||
|  |           kubectl wait --timeout=30s --for=condition=ready pod -n arc-systems -l auto-scaling-runner-set-name=$ARC_NAME | ||||||
|  |           kubectl get pod -n arc-systems | ||||||
|  | 
 | ||||||
|  |       - name: Test ARC scales pods up and down | ||||||
|  |         id: test | ||||||
|  |         run: | | ||||||
|  |           export GITHUB_TOKEN="${{ steps.setup.outputs.token }}" | ||||||
|  |           export ARC_NAME="${{ steps.install_arc.outputs.ARC_NAME }}" | ||||||
|  |           export WORKFLOW_FILE="${{env.WORKFLOW_FILE}}" | ||||||
|  |           go test ./test_e2e_arc -v | ||||||
|  | 
 | ||||||
|  |       - name: Uninstall gha-runner-scale-set | ||||||
|  |         if: always() && steps.install_arc.outcome == 'success' | ||||||
|  |         run: | | ||||||
|  |           helm uninstall ${{ steps.install_arc.outputs.ARC_NAME }} --namespace arc-runners | ||||||
|  |           kubectl wait --timeout=10s --for=delete AutoScalingRunnerSet -n demo -l app.kubernetes.io/instance=${{ steps.install_arc.outputs.ARC_NAME }} | ||||||
|  | 
 | ||||||
|  |       - name: Dump gha-runner-scale-set-controller logs | ||||||
|  |         if: always() && steps.install_arc_controller.outcome == 'success' | ||||||
|  |         run: | | ||||||
|  |           kubectl logs deployment/arc-gha-runner-scale-set-controller -n arc-systems | ||||||
|  | 
 | ||||||
|  |       - name: Job summary | ||||||
|  |         if: always() && steps.install_arc.outcome == 'success' | ||||||
|  |         run: | | ||||||
|  |           cat <<-EOF > $GITHUB_STEP_SUMMARY | ||||||
|  |           | **Outcome**    | ${{ steps.test.outcome }}  | | ||||||
|  |           |----------------|--------------------------------------------- | | ||||||
|  |           | **References** | [Test workflow runs](https://github.com/${{ steps.resolved_inputs.outputs.TARGET_ORG }}/${{steps.resolved_inputs.outputs.TARGET_REPO}}/actions/workflows/${{ env.WORKFLOW_FILE }}) | | ||||||
|  |           EOF | ||||||
|  | 
 | ||||||
|  |   auth-proxy-setup: | ||||||
|  |     runs-on: ubuntu-latest | ||||||
|  |     env: | ||||||
|  |       WORKFLOW_FILE: "arc-test-workflow.yaml" | ||||||
|  |     steps: | ||||||
|  |       - uses: actions/checkout@v3 | ||||||
|  | 
 | ||||||
|  |       - name: Resolve inputs | ||||||
|  |         id: resolved_inputs | ||||||
|  |         run: | | ||||||
|  |           TARGET_ORG="${{env.TARGET_ORG}}" | ||||||
|  |           TARGET_REPO="${{env.TARGET_REPO}}" | ||||||
|  |           if [ ! -z "${{inputs.target_org}}" ]; then | ||||||
|  |             TARGET_ORG="${{inputs.target_org}}" | ||||||
|  |           fi | ||||||
|  |           if [ ! -z "${{inputs.target_repo}}" ]; then | ||||||
|  |             TARGET_REPO="${{inputs.target_repo}}" | ||||||
|  |           fi | ||||||
|  |           echo "TARGET_ORG=$TARGET_ORG" >> $GITHUB_OUTPUT | ||||||
|  |           echo "TARGET_REPO=$TARGET_REPO" >> $GITHUB_OUTPUT | ||||||
|  | 
 | ||||||
|  |       - uses: ./.github/actions/setup-arc-e2e | ||||||
|  |         id: setup | ||||||
|  |         with: | ||||||
|  |           github-app-id: ${{secrets.ACTIONS_ACCESS_APP_ID}} | ||||||
|  |           github-app-pk: ${{secrets.ACTIONS_ACCESS_PK}} | ||||||
|  |           github-app-org: ${{steps.resolved_inputs.outputs.TARGET_ORG}} | ||||||
|  |           docker-image-name: ${{env.IMAGE_NAME}} | ||||||
|  |           docker-image-tag: ${{env.IMAGE_VERSION}} | ||||||
|  | 
 | ||||||
|  |       - name: Install gha-runner-scale-set-controller | ||||||
|  |         id: install_arc_controller | ||||||
|  |         run: | | ||||||
|  |           helm install arc \ | ||||||
|  |           --namespace "arc-systems" \ | ||||||
|  |           --create-namespace \ | ||||||
|  |           --set image.repository=${{ env.IMAGE_NAME }} \ | ||||||
|  |           --set image.tag=${{ env.IMAGE_VERSION }} \ | ||||||
|  |           ./charts/gha-runner-scale-set-controller \ | ||||||
|  |           --debug | ||||||
|  |           count=0 | ||||||
|  |           while true; do | ||||||
|  |             POD_NAME=$(kubectl get pods -n arc-systems -l app.kubernetes.io/name=gha-runner-scale-set-controller -o name) | ||||||
|  |             if [ -n "$POD_NAME" ]; then | ||||||
|  |               echo "Pod found: $POD_NAME" | ||||||
|  |               break | ||||||
|  |             fi | ||||||
|  |             if [ "$count" -ge 10 ]; then | ||||||
|  |               echo "Timeout waiting for controller pod with label app.kubernetes.io/name=gha-runner-scale-set-controller" | ||||||
|  |               exit 1 | ||||||
|  |             fi | ||||||
|  |             sleep 1 | ||||||
|  |           done | ||||||
|  |           kubectl wait --timeout=30s --for=condition=ready pod -n arc-systems -l app.kubernetes.io/name=gha-runner-scale-set-controller | ||||||
|  |           kubectl get pod -n arc-systems | ||||||
|  |           kubectl describe deployment arc-gha-runner-scale-set-controller -n arc-systems | ||||||
|  | 
 | ||||||
|  |       - name: Install gha-runner-scale-set | ||||||
|  |         id: install_arc | ||||||
|  |         run: | | ||||||
|  |           docker run -d \ | ||||||
|  |             --name squid \ | ||||||
|  |             --publish 3128:3128 \ | ||||||
|  |             huangtingluo/squid-proxy:latest | ||||||
|  |           kubectl create namespace arc-runners | ||||||
|  |           kubectl create secret generic proxy-auth \ | ||||||
|  |             --namespace=arc-runners \ | ||||||
|  |             --from-literal=username=github \ | ||||||
|  |             --from-literal=password='actions' | ||||||
|  |           ARC_NAME=arc-runner-${{github.job}}-$(date +'%M-%S')-$(($RANDOM % 100 + 1)) | ||||||
|  |           helm install "$ARC_NAME" \ | ||||||
|  |           --namespace "arc-runners" \ | ||||||
|  |           --create-namespace \ | ||||||
|  |           --set githubConfigUrl="https://github.com/${{ steps.resolved_inputs.outputs.TARGET_ORG }}/${{steps.resolved_inputs.outputs.TARGET_REPO}}" \ | ||||||
|  |           --set githubConfigSecret.github_token="${{ steps.setup.outputs.token }}" \ | ||||||
|  |           --set proxy.https.url="http://host.minikube.internal:3128" \ | ||||||
|  |           --set proxy.https.credentialSecretRef="proxy-auth" \ | ||||||
|  |           --set "proxy.noProxy[0]=10.96.0.1:443" \ | ||||||
|  |           ./charts/gha-runner-scale-set \ | ||||||
|  |           --debug | ||||||
|  |           echo "ARC_NAME=$ARC_NAME" >> $GITHUB_OUTPUT | ||||||
|  |           count=0 | ||||||
|  |           while true; do | ||||||
|  |             POD_NAME=$(kubectl get pods -n arc-systems -l auto-scaling-runner-set-name=$ARC_NAME -o name) | ||||||
|  |             if [ -n "$POD_NAME" ]; then | ||||||
|  |               echo "Pod found: $POD_NAME" | ||||||
|  |               break | ||||||
|  |             fi | ||||||
|  |             if [ "$count" -ge 10 ]; then | ||||||
|  |               echo "Timeout waiting for listener pod with label auto-scaling-runner-set-name=$ARC_NAME" | ||||||
|  |               exit 1 | ||||||
|  |             fi | ||||||
|  |             sleep 1 | ||||||
|  |           done | ||||||
|  |           kubectl wait --timeout=30s --for=condition=ready pod -n arc-systems -l auto-scaling-runner-set-name=$ARC_NAME | ||||||
|  |           kubectl get pod -n arc-systems | ||||||
|  | 
 | ||||||
|  |       - name: Test ARC scales pods up and down | ||||||
|  |         id: test | ||||||
|  |         run: | | ||||||
|  |           export GITHUB_TOKEN="${{ steps.setup.outputs.token }}" | ||||||
|  |           export ARC_NAME="${{ steps.install_arc.outputs.ARC_NAME }}" | ||||||
|  |           export WORKFLOW_FILE="${{env.WORKFLOW_FILE}}" | ||||||
|  |           go test ./test_e2e_arc -v | ||||||
|  | 
 | ||||||
|  |       - name: Uninstall gha-runner-scale-set | ||||||
|  |         if: always() && steps.install_arc.outcome == 'success' | ||||||
|  |         run: | | ||||||
|  |           helm uninstall ${{ steps.install_arc.outputs.ARC_NAME }} --namespace arc-runners | ||||||
|  |           kubectl wait --timeout=10s --for=delete AutoScalingRunnerSet -n demo -l app.kubernetes.io/instance=${{ steps.install_arc.outputs.ARC_NAME }} | ||||||
|  | 
 | ||||||
|  |       - name: Dump gha-runner-scale-set-controller logs | ||||||
|  |         if: always() && steps.install_arc_controller.outcome == 'success' | ||||||
|  |         run: | | ||||||
|  |           kubectl logs deployment/arc-gha-runner-scale-set-controller -n arc-systems | ||||||
|  | 
 | ||||||
|  |       - name: Job summary | ||||||
|  |         if: always() && steps.install_arc.outcome == 'success' | ||||||
|  |         run: | | ||||||
|  |           cat <<-EOF > $GITHUB_STEP_SUMMARY | ||||||
|  |           | **Outcome**    | ${{ steps.test.outcome }}  | | ||||||
|  |           |----------------|--------------------------------------------- | | ||||||
|  |           | **References** | [Test workflow runs](https://github.com/${{ steps.resolved_inputs.outputs.TARGET_ORG }}/${{steps.resolved_inputs.outputs.TARGET_REPO}}/actions/workflows/${{ env.WORKFLOW_FILE }}) | | ||||||
|  |           EOF | ||||||
|  | 
 | ||||||
|  |   anonymous-proxy-setup: | ||||||
|  |     runs-on: ubuntu-latest | ||||||
|  |     env: | ||||||
|  |       WORKFLOW_FILE: "arc-test-workflow.yaml" | ||||||
|  |     steps: | ||||||
|  |       - uses: actions/checkout@v3 | ||||||
|  | 
 | ||||||
|  |       - name: Resolve inputs | ||||||
|  |         id: resolved_inputs | ||||||
|  |         run: | | ||||||
|  |           TARGET_ORG="${{env.TARGET_ORG}}" | ||||||
|  |           TARGET_REPO="${{env.TARGET_REPO}}" | ||||||
|  |           if [ ! -z "${{inputs.target_org}}" ]; then | ||||||
|  |             TARGET_ORG="${{inputs.target_org}}" | ||||||
|  |           fi | ||||||
|  |           if [ ! -z "${{inputs.target_repo}}" ]; then | ||||||
|  |             TARGET_REPO="${{inputs.target_repo}}" | ||||||
|  |           fi | ||||||
|  |           echo "TARGET_ORG=$TARGET_ORG" >> $GITHUB_OUTPUT | ||||||
|  |           echo "TARGET_REPO=$TARGET_REPO" >> $GITHUB_OUTPUT | ||||||
|  | 
 | ||||||
|  |       - uses: ./.github/actions/setup-arc-e2e | ||||||
|  |         id: setup | ||||||
|  |         with: | ||||||
|  |           github-app-id: ${{secrets.ACTIONS_ACCESS_APP_ID}} | ||||||
|  |           github-app-pk: ${{secrets.ACTIONS_ACCESS_PK}} | ||||||
|  |           github-app-org: ${{steps.resolved_inputs.outputs.TARGET_ORG}} | ||||||
|  |           docker-image-name: ${{env.IMAGE_NAME}} | ||||||
|  |           docker-image-tag: ${{env.IMAGE_VERSION}} | ||||||
|  | 
 | ||||||
|  |       - name: Install gha-runner-scale-set-controller | ||||||
|  |         id: install_arc_controller | ||||||
|  |         run: | | ||||||
|  |           helm install arc \ | ||||||
|  |           --namespace "arc-systems" \ | ||||||
|  |           --create-namespace \ | ||||||
|  |           --set image.repository=${{ env.IMAGE_NAME }} \ | ||||||
|  |           --set image.tag=${{ env.IMAGE_VERSION }} \ | ||||||
|  |           ./charts/gha-runner-scale-set-controller \ | ||||||
|  |           --debug | ||||||
|  |           count=0 | ||||||
|  |           while true; do | ||||||
|  |             POD_NAME=$(kubectl get pods -n arc-systems -l app.kubernetes.io/name=gha-runner-scale-set-controller -o name) | ||||||
|  |             if [ -n "$POD_NAME" ]; then | ||||||
|  |               echo "Pod found: $POD_NAME" | ||||||
|  |               break | ||||||
|  |             fi | ||||||
|  |             if [ "$count" -ge 10 ]; then | ||||||
|  |               echo "Timeout waiting for controller pod with label app.kubernetes.io/name=gha-runner-scale-set-controller" | ||||||
|  |               exit 1 | ||||||
|  |             fi | ||||||
|  |             sleep 1 | ||||||
|  |           done | ||||||
|  |           kubectl wait --timeout=30s --for=condition=ready pod -n arc-systems -l app.kubernetes.io/name=gha-runner-scale-set-controller | ||||||
|  |           kubectl get pod -n arc-systems | ||||||
|  |           kubectl describe deployment arc-gha-runner-scale-set-controller -n arc-systems | ||||||
|  | 
 | ||||||
|  |       - name: Install gha-runner-scale-set | ||||||
|  |         id: install_arc | ||||||
|  |         run: | | ||||||
|  |           docker run -d \ | ||||||
|  |             --name squid \ | ||||||
|  |             --publish 3128:3128 \ | ||||||
|  |             ubuntu/squid:latest | ||||||
|  |           ARC_NAME=arc-runner-${{github.job}}-$(date +'%M-%S')-$(($RANDOM % 100 + 1)) | ||||||
|  |           helm install "$ARC_NAME" \ | ||||||
|  |           --namespace "arc-runners" \ | ||||||
|  |           --create-namespace \ | ||||||
|  |           --set githubConfigUrl="https://github.com/${{ steps.resolved_inputs.outputs.TARGET_ORG }}/${{steps.resolved_inputs.outputs.TARGET_REPO}}" \ | ||||||
|  |           --set githubConfigSecret.github_token="${{ steps.setup.outputs.token }}" \ | ||||||
|  |           --set proxy.https.url="http://host.minikube.internal:3128" \ | ||||||
|  |           --set "proxy.noProxy[0]=10.96.0.1:443" \ | ||||||
|  |           ./charts/gha-runner-scale-set \ | ||||||
|  |           --debug | ||||||
|  |           echo "ARC_NAME=$ARC_NAME" >> $GITHUB_OUTPUT | ||||||
|  |           count=0 | ||||||
|  |           while true; do | ||||||
|  |             POD_NAME=$(kubectl get pods -n arc-systems -l auto-scaling-runner-set-name=$ARC_NAME -o name) | ||||||
|  |             if [ -n "$POD_NAME" ]; then | ||||||
|  |               echo "Pod found: $POD_NAME" | ||||||
|  |               break | ||||||
|  |             fi | ||||||
|  |             if [ "$count" -ge 10 ]; then | ||||||
|  |               echo "Timeout waiting for listener pod with label auto-scaling-runner-set-name=$ARC_NAME" | ||||||
|  |               exit 1 | ||||||
|  |             fi | ||||||
|  |             sleep 1 | ||||||
|  |           done | ||||||
|  |           kubectl wait --timeout=30s --for=condition=ready pod -n arc-systems -l auto-scaling-runner-set-name=$ARC_NAME | ||||||
|  |           kubectl get pod -n arc-systems | ||||||
|  | 
 | ||||||
|  |       - name: Test ARC scales pods up and down | ||||||
|  |         id: test | ||||||
|  |         run: | | ||||||
|  |           export GITHUB_TOKEN="${{ steps.setup.outputs.token }}" | ||||||
|  |           export ARC_NAME="${{ steps.install_arc.outputs.ARC_NAME }}" | ||||||
|  |           export WORKFLOW_FILE="${{ env.WORKFLOW_FILE }}" | ||||||
|  |           go test ./test_e2e_arc -v | ||||||
|  | 
 | ||||||
|  |       - name: Uninstall gha-runner-scale-set | ||||||
|  |         if: always() && steps.install_arc.outcome == 'success' | ||||||
|  |         run: | | ||||||
|  |           helm uninstall ${{ steps.install_arc.outputs.ARC_NAME }} --namespace arc-runners | ||||||
|  |           kubectl wait --timeout=10s --for=delete AutoScalingRunnerSet -n demo -l app.kubernetes.io/instance=${{ steps.install_arc.outputs.ARC_NAME }} | ||||||
|  | 
 | ||||||
|  |       - name: Dump gha-runner-scale-set-controller logs | ||||||
|  |         if: always() && steps.install_arc_controller.outcome == 'success' | ||||||
|  |         run: | | ||||||
|  |           kubectl logs deployment/arc-gha-runner-scale-set-controller -n arc-systems | ||||||
|  | 
 | ||||||
|  |       - name: Job summary | ||||||
|  |         if: always() && steps.install_arc.outcome == 'success' | ||||||
|  |         run: | | ||||||
|  |           cat <<-EOF > $GITHUB_STEP_SUMMARY | ||||||
|  |           | **Outcome**    | ${{ steps.test.outcome }}  | | ||||||
|  |           |----------------|--------------------------------------------- | | ||||||
|  |           | **References** | [Test workflow runs](https://github.com/${{ steps.resolved_inputs.outputs.TARGET_ORG }}/${{steps.resolved_inputs.outputs.TARGET_REPO}}/actions/workflows/${{ env.WORKFLOW_FILE }}) | | ||||||
|  |           EOF | ||||||
|  |  | ||||||
|  | @ -11,6 +11,7 @@ import ( | ||||||
| 	"testing" | 	"testing" | ||||||
| 	"time" | 	"time" | ||||||
| 
 | 
 | ||||||
|  | 	"github.com/stretchr/testify/require" | ||||||
| 	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | 	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||||||
| 	"k8s.io/client-go/kubernetes" | 	"k8s.io/client-go/kubernetes" | ||||||
| 	"k8s.io/client-go/tools/clientcmd" | 	"k8s.io/client-go/tools/clientcmd" | ||||||
|  | @ -93,16 +94,23 @@ func TestARCJobs(t *testing.T) { | ||||||
| 	t.Run("Get available pods during job run", func(t *testing.T) { | 	t.Run("Get available pods during job run", func(t *testing.T) { | ||||||
| 		c := http.Client{} | 		c := http.Client{} | ||||||
| 		targetArcName := os.Getenv("ARC_NAME") | 		targetArcName := os.Getenv("ARC_NAME") | ||||||
|  | 		require.NotEmpty(t, targetArcName, "ARC_NAME environment variable is required for this test to run. (e.g. arc-e2e-test)") | ||||||
|  | 
 | ||||||
|  | 		targetWorkflow := os.Getenv("WORKFLOW_FILE") | ||||||
|  | 		require.NotEmpty(t, targetWorkflow, "WORKFLOW_FILE environment variable is required for this test to run. (e.g. e2e_test.yml)") | ||||||
|  | 
 | ||||||
|  | 		ght := os.Getenv("GITHUB_TOKEN") | ||||||
|  | 		require.NotEmpty(t, ght, "GITHUB_TOKEN environment variable is required for this test to run.") | ||||||
|  | 
 | ||||||
| 		// We are triggering manually a workflow that already exists in the repo.
 | 		// We are triggering manually a workflow that already exists in the repo.
 | ||||||
| 		// This workflow is expected to spin up a number of runner pods matching the runners value set in podCountsByType.
 | 		// This workflow is expected to spin up a number of runner pods matching the runners value set in podCountsByType.
 | ||||||
| 		url := "https://api.github.com/repos/actions-runner-controller/arc_e2e_test_dummy/actions/workflows/arc-test-workflow.yaml/dispatches" | 		url := "https://api.github.com/repos/actions-runner-controller/arc_e2e_test_dummy/actions/workflows/" + targetWorkflow + "/dispatches" | ||||||
| 		jsonStr := []byte(fmt.Sprintf(`{"ref":"main", "inputs":{"arc_name":"%s"}}`, targetArcName)) | 		jsonStr := []byte(fmt.Sprintf(`{"ref":"main", "inputs":{"arc_name":"%s"}}`, targetArcName)) | ||||||
| 
 | 
 | ||||||
| 		req, err := http.NewRequest("POST", url, bytes.NewBuffer(jsonStr)) | 		req, err := http.NewRequest("POST", url, bytes.NewBuffer(jsonStr)) | ||||||
| 		if err != nil { | 		if err != nil { | ||||||
| 			t.Fatal(err) | 			t.Fatal(err) | ||||||
| 		} | 		} | ||||||
| 		ght := os.Getenv("GITHUB_TOKEN") |  | ||||||
| 		req.Header.Add("Accept", "application/vnd.github+json") | 		req.Header.Add("Accept", "application/vnd.github+json") | ||||||
| 		req.Header.Add("Authorization", fmt.Sprintf("Bearer %s", ght)) | 		req.Header.Add("Authorization", fmt.Sprintf("Bearer %s", ght)) | ||||||
| 		req.Header.Add("X-GitHub-Api-Version", "2022-11-28") | 		req.Header.Add("X-GitHub-Api-Version", "2022-11-28") | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue