From 952f62dd827b466a599acf4b3486b72af87a69f6 Mon Sep 17 00:00:00 2001 From: Christopher Haar Date: Mon, 31 Jul 2023 13:33:36 +0200 Subject: [PATCH] feat(e2e): run uptest every pr in this repo Signed-off-by: Christopher Haar --- .../workflows/e2e-template-validation.yaml | 86 +++++++++++++++++++ .gitignore | 2 + hack/prepare.sh | 4 +- 3 files changed, 91 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/e2e-template-validation.yaml diff --git a/.github/workflows/e2e-template-validation.yaml b/.github/workflows/e2e-template-validation.yaml new file mode 100644 index 0000000..b6d0002 --- /dev/null +++ b/.github/workflows/e2e-template-validation.yaml @@ -0,0 +1,86 @@ +name: Run Template Validation + +jobs: + uptest: + if: ${{ github.event.issue.pull_request }} + runs-on: [e2-standard-8, linux] + + steps: + - name: Setup QEMU + uses: docker/setup-qemu-action@2b82ce82d56a2a04d2637cd93a637ae1b359c0a7 # v2 + with: + platforms: all + + - name: Checkout + uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3 + with: + submodules: true + + - name: Setup Go + uses: actions/setup-go@6edd4406fa81c3da01a34fa6f6343087c207a568 # v3 + with: + go-version: ${{ inputs.go-version }} + + - name: Checkout PR + id: checkout-pr + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + gh pr checkout ${{ github.event.issue.number }} + git submodule update --init --recursive + OUTPUT=$(git log -1 --format='%H') + echo "commit-sha=$OUTPUT" >> $GITHUB_OUTPUT + + - name: Find the Go Build Cache + if: ${{ inputs.package-type == 'provider' }} + id: go + run: echo "cache=$(make go.cachedir)" >> $GITHUB_OUTPUT + + - name: Cache the Go Build Cache + if: ${{ inputs.package-type == 'provider' }} + uses: actions/cache@88522ab9f39a2ea568f7027eddc7d8d8bc9d59c8 # v3 + with: + path: ${{ steps.go.outputs.cache }} + key: ${{ runner.os }}-build-uptest-${{ hashFiles('**/go.sum') }} + restore-keys: ${{ runner.os }}-build-uptest- + + - name: Cache Go Dependencies + if: ${{ inputs.package-type == 'provider' }} + uses: actions/cache@88522ab9f39a2ea568f7027eddc7d8d8bc9d59c8 # v3 + with: + path: .work/pkg + key: ${{ runner.os }}-pkg-${{ hashFiles('**/go.sum') }} + restore-keys: ${{ runner.os }}-pkg- + + - name: Vendor Dependencies + if: ${{ inputs.package-type == 'provider' }} + run: make vendor vendor.check + + - name: Run Uptest + id: run-uptest + env: + UPTEST_CLOUD_CREDENTIALS: '{"upjet": "provider-template"}' + UPTEST_EXAMPLE_LIST: "examples/null/resource.yaml" + UPTEST_TEST_DIR: ./_output/controlplane-dump + UPTEST_DATASOURCE_PATH: .work/uptest-datasource.yaml + run: | + mkdir -p .work && echo "${{ secrets.UPTEST_DATASOURCE }}" > .work/uptest-datasource.yaml + make e2e + + - name: Collect Cluster Dump + if: always() + run: | + make controlplane.dump + + - name: Upload Cluster Dump + if: always() + uses: actions/upload-artifact@0b7f8abb1508181956e8e162db84b466c27e18ce # v3 + with: + name: controlplane-dump + path: ./_output/controlplane-dump + + - name: Cleanup + if: always() + run: | + eval $(make --no-print-directory build.vars) + ${KUBECTL} delete managed --all || true diff --git a/.gitignore b/.gitignore index a6d3db0..63a330c 100644 --- a/.gitignore +++ b/.gitignore @@ -9,3 +9,5 @@ cover.out # ignore IDE folders .vscode/ .idea/ + +kubeconfig diff --git a/hack/prepare.sh b/hack/prepare.sh index d365a1d..e4c94e9 100755 --- a/hack/prepare.sh +++ b/hack/prepare.sh @@ -37,4 +37,6 @@ git mv "cluster/images/upjet-provider-template" "cluster/images/provider-${PROVI # generate: open /Users/hasanturken/Workspace/crossplane-contrib/upjet-provider-template/apis/null/v1alpha1/zz_generated.deepcopy.go: no such file or directory rm -rf apis/null # remove the sample directory which was a configuration in the template -rm -rf config/null \ No newline at end of file +rm -rf config/null +# remove the validation ci step which was a configuration in the template for validation with uptest +rm -rf .github/workflows/e2e-template-validation.yaml