From 20a4fec643f1130c3b8233c2376196c521f75ac7 Mon Sep 17 00:00:00 2001 From: infiniteregrets Date: Mon, 11 Sep 2023 00:14:04 -0400 Subject: [PATCH 1/6] A reusable workflow for running e2e tests --- .github/workflows/ci.yaml | 101 +----------------------- .github/workflows/reusable_e2e.yaml | 114 ++++++++++++++++++++++++++++ 2 files changed, 118 insertions(+), 97 deletions(-) create mode 100644 .github/workflows/reusable_e2e.yaml diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index a0aaa783..3ad14a27 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -35,31 +35,6 @@ jobs: config: "markdownlint-config.json" args: "README.md" - build: - runs-on: ubuntu-latest - steps: - - name: Remove unnecessary files - run: | - sudo rm -rf /usr/share/dotnet - sudo rm -rf "$AGENT_TOOLSDIRECTORY" - - uses: actions/checkout@v3 - - name: Setup Java - uses: actions/setup-java@v3 - with: - distribution: zulu - java-version: 17 - - name: Build Plugin - env: - CI_BUILD_PLUGIN: true - run: | - chmod +x ./gradlew - ./gradlew buildPlugin - - name: Upload build folder - uses: actions/upload-artifact@v3 - with: - name: mirrord-build - path: build/ - lint: runs-on: ubuntu-latest steps: @@ -73,75 +48,9 @@ jobs: run: ./gradlew ktlintCheck e2e: - needs: [ build ] - runs-on: ubuntu-latest - env: - CI_BUILD_PLUGIN: "true" - steps: - - name: Public IP - id: ip - uses: haythem/public-ip@v1.3 - - name: Print Public IP - run: | - echo ${{ steps.ip.outputs.ipv4 }} - echo ${{ steps.ip.outputs.ipv6 }} - - name: Remove unnecessary files - run: | - sudo rm -rf /usr/share/dotnet - sudo rm -rf "$AGENT_TOOLSDIRECTORY" - - uses: actions/checkout@v3 - - name: Setup Java - uses: actions/setup-java@v3 - with: - distribution: zulu - java-version: 17 - - uses: actions/setup-python@v4 - with: - python-version: 3.11 - - uses: abatilo/actions-poetry@v2 - - run: poetry --version - - name: get mirrord latest - run: | - curl -fsSL https://raw.githubusercontent.com/metalbear-co/mirrord/main/scripts/install.sh | bash - - name: Start minikube - uses: medyagh/setup-minikube@master - with: - container-runtime: docker - - run: | - minikube image load /tmp/test.tar - kubectl apply -f sample/kubernetes/app.yaml - echo "POD_TO_SELECT=$(kubectl get pods -o=name | head -n 1)" >> "$GITHUB_ENV" - kubectl wait --for=condition=ready --timeout=30s $(kubectl get pods -o=name | head -n 1) - KUBE_SERVICE=$(minikube service list --output=json | jq -r '.[] | select(.Name == "py-serv") | .URLs[0]') - echo "$KUBE_SERVICE" - echo "KUBE_SERVICE=$KUBE_SERVICE" >> "$GITHUB_ENV" - - name: Setup FFmpeg - uses: FedericoCarboni/setup-ffmpeg@v2 - with: - token: ${{ secrets.GITHUB_TOKEN }} - - name: Download build folder - uses: actions/download-artifact@v3 - with: - name: mirrord-build - path: build/ - - name: Run intellij e2e in headless state - uses: coactions/setup-xvfb@v1 - env: - POD_TO_SELECT: ${{ env.POD_TO_SELECT }} - KUBE_SERVICE: ${{ env.KUBE_SERVICE }} - with: - run: ./gradlew test - - name: Move video - if: ${{ failure() }} - run: | - mv video build/reports - - name: Save fails report - if: ${{ failure() }} - uses: actions/upload-artifact@v3 - with: - name: mirrord-plugin-fail-report - path: | - build/reports + uses: ./github/workflows/reusable_e2e.yaml + with: + mirrord_release_branch: false ci-success: name: ci @@ -150,7 +59,6 @@ jobs: needs: [ towncrier_check, - build, e2e, lint_markdown, ] @@ -160,8 +68,7 @@ jobs: # We have to do it in the shell since if it's in the if condition # then skipping is considered success by branch protection rules env: - CI_SUCCESS: ${{ (needs.towncrier_check.result == 'success') && - (needs.build.result == 'success' || needs.build.result == 'skipped') && + CI_SUCCESS: ${{ (needs.towncrier_check.result == 'success') && (needs.e2e.result == 'success' || needs.e2e.result == 'skipped') && (needs.lint_markdown.result == 'success' || needs.lint_markdown.result == 'skipped') }} run: echo $CI_SUCCESS && if [ "$CI_SUCCESS" == "true" ]; then echo "SUCCESS" && exit 0; else echo "Failure" && exit 1; fi diff --git a/.github/workflows/reusable_e2e.yaml b/.github/workflows/reusable_e2e.yaml new file mode 100644 index 00000000..7e829ae0 --- /dev/null +++ b/.github/workflows/reusable_e2e.yaml @@ -0,0 +1,114 @@ +name: Run IDE e2e on release +on: + workflow_call: + inputs: + mirrord_release_branch: + required: false + type: boolean + default: true + +jobs: + intellij-e2e: + runs-on: ubuntu-latest + env: + CI_BUILD_PLUGIN: "true" + steps: + - name: Public IP + id: ip + uses: haythem/public-ip@v1.3 + - name: Print Public IP + run: | + echo ${{ steps.ip.outputs.ipv4 }} + echo ${{ steps.ip.outputs.ipv6 }} + + - name: Remove unnecessary files + run: | + sudo rm -rf /usr/share/dotnet + sudo rm -rf "$AGENT_TOOLSDIRECTORY" + + - name: checkout repository + if: ${{ !github.event.inputs.mirrord_release_branch }} + uses: actions/checkout@v3 + + - name: checkout into mirrord-intellij if mirrord_release_branch + if: ${{ github.event.inputs.mirrord_release_branch }} + uses: actions/checkout@v3 + with: + repository: "metalbear-co/mirrord-intellij" + + - name: checkout into the last released tag if mirrord_release_branch + if: ${{ github.event.inputs.mirrord_release_branch }} + run: | + git fetch --all --tags + git checkout tags/$(grep 'pluginVersion =' gradle.properties | cut -d '=' -f 2 | xargs) + + - name: Setup Java + uses: actions/setup-java@v3 + with: + distribution: zulu + java-version: 17 + + - uses: actions/setup-python@v4 + with: + python-version: 3.11 + - uses: abatilo/actions-poetry@v2 + + - name: download mirrord binary + if: ${{ github.event.inputs.mirrord_release_branch }} + uses: actions/download-artifact@v3 + with: + name: mirrord-artifacts + - name: add downloaded mirrord to path + if: ${{ github.event.inputs.mirrord_release_branch }} + run: | + chmod u+x mirrord + echo "${GITHUB_WORKSPACE}" >> "$GITHUB_PATH" + + - name: get the latest mirrord binary + if: ${{ !github.event.inputs.mirrord_release_branch }} + run: | + curl -fsSL https://raw.githubusercontent.com/metalbear-co/mirrord/main/scripts/install.sh | bash + + - name: Start minikube + uses: medyagh/setup-minikube@master + with: + container-runtime: docker + - run: | + minikube image load /tmp/test.tar + kubectl apply -f sample/kubernetes/app.yaml + echo "POD_TO_SELECT=$(kubectl get pods -o=name | head -n 1)" >> "$GITHUB_ENV" + kubectl wait --for=condition=ready --timeout=30s $(kubectl get pods -o=name | head -n 1) + KUBE_SERVICE=$(minikube service list --output=json | jq -r '.[] | select(.Name == "py-serv") | .URLs[0]') + echo "$KUBE_SERVICE" + echo "KUBE_SERVICE=$KUBE_SERVICE" >> "$GITHUB_ENV" + + - name: Setup FFmpeg + uses: FedericoCarboni/setup-ffmpeg@v2 + with: + token: ${{ secrets.GITHUB_TOKEN }} + + - name: build plugin + if : ${{ github.event.inputs.mirrord_release_branch }} + run: | + ./gradlew buildPlugin + + - name: Run intellij e2e in headless state + uses: coactions/setup-xvfb@v1 + env: + POD_TO_SELECT: ${{ env.POD_TO_SELECT }} + KUBE_SERVICE: ${{ env.KUBE_SERVICE }} + with: + run: | + ./gradlew test + + - name: Save the failure video + if: ${{ failure() }} + run: | + mv video build/reports + - name: Save fails report + if: ${{ failure() }} + uses: actions/upload-artifact@v3 + with: + name: mirrord-plugin-fail-report + path: | + build/reports \ No newline at end of file From bbf91673b93c22e537b9bcf6989cb90e886f88d0 Mon Sep 17 00:00:00 2001 From: infiniteregrets Date: Mon, 11 Sep 2023 00:15:47 -0400 Subject: [PATCH 2/6] changelog --- changelog.d/+reusable-e2e.internal.md | 1 + 1 file changed, 1 insertion(+) create mode 100644 changelog.d/+reusable-e2e.internal.md diff --git a/changelog.d/+reusable-e2e.internal.md b/changelog.d/+reusable-e2e.internal.md new file mode 100644 index 00000000..e870bf9d --- /dev/null +++ b/changelog.d/+reusable-e2e.internal.md @@ -0,0 +1 @@ +Create a reusable worflow for running e2e tests such that we maintain e2e in one place and can run tests on mirrord's release branch From bb18f5f80264c27c6189453326d55551171a9f89 Mon Sep 17 00:00:00 2001 From: infiniteregrets Date: Mon, 11 Sep 2023 00:17:45 -0400 Subject: [PATCH 3/6] .. --- .github/workflows/ci.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 3ad14a27..3683c81f 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -48,7 +48,7 @@ jobs: run: ./gradlew ktlintCheck e2e: - uses: ./github/workflows/reusable_e2e.yaml + uses: ./.github/workflows/reusable_e2e.yaml with: mirrord_release_branch: false From 505ad0b89914bd1fd16ae48c5e37949572c01005 Mon Sep 17 00:00:00 2001 From: infiniteregrets Date: Mon, 11 Sep 2023 00:25:03 -0400 Subject: [PATCH 4/6] fix --- .github/workflows/reusable_e2e.yaml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.github/workflows/reusable_e2e.yaml b/.github/workflows/reusable_e2e.yaml index 7e829ae0..5b04a80c 100644 --- a/.github/workflows/reusable_e2e.yaml +++ b/.github/workflows/reusable_e2e.yaml @@ -73,8 +73,7 @@ jobs: uses: medyagh/setup-minikube@master with: container-runtime: docker - - run: | - minikube image load /tmp/test.tar + - run: | kubectl apply -f sample/kubernetes/app.yaml echo "POD_TO_SELECT=$(kubectl get pods -o=name | head -n 1)" >> "$GITHUB_ENV" kubectl wait --for=condition=ready --timeout=30s $(kubectl get pods -o=name | head -n 1) @@ -88,7 +87,6 @@ jobs: token: ${{ secrets.GITHUB_TOKEN }} - name: build plugin - if : ${{ github.event.inputs.mirrord_release_branch }} run: | ./gradlew buildPlugin From b349c96308fed3acdd2fdcfdf2e333806cf49b9d Mon Sep 17 00:00:00 2001 From: infiniteregrets Date: Mon, 11 Sep 2023 00:50:29 -0400 Subject: [PATCH 5/6] comments --- .github/workflows/reusable_e2e.yaml | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/.github/workflows/reusable_e2e.yaml b/.github/workflows/reusable_e2e.yaml index 5b04a80c..2522ae0f 100644 --- a/.github/workflows/reusable_e2e.yaml +++ b/.github/workflows/reusable_e2e.yaml @@ -1,4 +1,12 @@ -name: Run IDE e2e on release +# This is a reusable workflow that can be run based on `mirrord_release_branch` boolean input +# in the `mirrord` or `mirrord-intellij` repository and hence is maintained in a single place. +# The difference in the workflow when `mirrord_release_branch` is set is as follows: +# - we checkout into the latest released tag of `mirrord-intellij` from the perspective of binary +# that has to be released on `mirrord` side. if not set, we checkout into the current branch. +# - we rely on downloading the mirrord binary from `mirrord-artifacts` using `actions/download-artifact` +# and adding it to the path. if not set, the latest version is downloaded. + +name: reusable_e2e on: workflow_call: inputs: @@ -73,7 +81,7 @@ jobs: uses: medyagh/setup-minikube@master with: container-runtime: docker - - run: | + - run: | kubectl apply -f sample/kubernetes/app.yaml echo "POD_TO_SELECT=$(kubectl get pods -o=name | head -n 1)" >> "$GITHUB_ENV" kubectl wait --for=condition=ready --timeout=30s $(kubectl get pods -o=name | head -n 1) @@ -96,7 +104,7 @@ jobs: POD_TO_SELECT: ${{ env.POD_TO_SELECT }} KUBE_SERVICE: ${{ env.KUBE_SERVICE }} with: - run: | + run: | ./gradlew test - name: Save the failure video @@ -109,4 +117,4 @@ jobs: with: name: mirrord-plugin-fail-report path: | - build/reports \ No newline at end of file + build/reports From b426d2d09844ecddde7c2112d2ee5d162e5c1433 Mon Sep 17 00:00:00 2001 From: infiniteregrets Date: Mon, 11 Sep 2023 11:44:02 -0400 Subject: [PATCH 6/6] more-docs --- .github/workflows/ci.yaml | 2 -- .github/workflows/reusable_e2e.yaml | 6 +++++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 3683c81f..a6d4aafc 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -49,8 +49,6 @@ jobs: e2e: uses: ./.github/workflows/reusable_e2e.yaml - with: - mirrord_release_branch: false ci-success: name: ci diff --git a/.github/workflows/reusable_e2e.yaml b/.github/workflows/reusable_e2e.yaml index 2522ae0f..23d2d1cc 100644 --- a/.github/workflows/reusable_e2e.yaml +++ b/.github/workflows/reusable_e2e.yaml @@ -13,7 +13,7 @@ on: mirrord_release_branch: required: false type: boolean - default: true + default: false jobs: intellij-e2e: @@ -38,6 +38,8 @@ jobs: if: ${{ !github.event.inputs.mirrord_release_branch }} uses: actions/checkout@v3 + # mirrord_release_branch boolean when set, means we are on a release branch + # and hence we need to checkout into the last released tag of mirrord-intellij - name: checkout into mirrord-intellij if mirrord_release_branch if: ${{ github.event.inputs.mirrord_release_branch }} uses: actions/checkout@v3 @@ -61,6 +63,8 @@ jobs: python-version: 3.11 - uses: abatilo/actions-poetry@v2 + # we are on a release branch, so we need to download the mirrord binary from + # mirrord-artifacts and add it to the path - name: download mirrord binary if: ${{ github.event.inputs.mirrord_release_branch }} uses: actions/download-artifact@v3