diff --git a/.github/workflows/check-pr.yml b/.github/workflows/check-pr.yml deleted file mode 100644 index 7dfb9dec..00000000 --- a/.github/workflows/check-pr.yml +++ /dev/null @@ -1,95 +0,0 @@ -name: check-pr -on: - pull_request_target: - branches: - - 'master' - paths-ignore: - - 'docs/**' - types: - - 'opened' - - 'synchronize' - - 'reopened' - - 'labeled' -jobs: - check-running-allowed: - runs-on: ubuntu-latest - outputs: - result: ${{ steps.check-ownership-membership.outputs.result }} - steps: - - id: check-ownership-membership - uses: actions/github-script@v6 - with: - github-token: ${{ secrets.GH_PERSONAL_ACCESS_TOKEN }} - script: | - // This is used primarily in forks. Repository owner - // should be allowed to run anything. - const userLogin = context.payload.pull_request.user.login; - - // How to interpret membership status code: - // https://docs.github.com/en/rest/orgs/members?apiVersion=2022-11-28#check-organization-membership-for-a-user - const isOrgMember = async function () { - try { - const response = await github.rest.orgs.checkMembershipForUser({ - org: context.payload.organization.login, - username: userLogin, - }); - return response.status == 204; - } catch (error) { - if (error.status && error.status == 404) { - return false; - } - throw error; - } - } - - if (context.payload.repository.owner.login == userLogin) { - return true; - } - - if (await isOrgMember()) { - return true; - } - - const labels = context.payload.pull_request.labels; - const okToTestLabel = labels.find( - label => label.name == 'ok-to-test' - ); - return okToTestLabel !== undefined; - - name: comment-if-waiting-on-ok - if: steps.check-ownership-membership.outputs.result == 'false' && - github.event.action == 'opened' - uses: actions/github-script@v6 - with: - script: | - github.rest.issues.createComment({ - issue_number: context.issue.number, - owner: context.repo.owner, - repo: context.repo.repo, - body: 'Hi! Thank you for contributing!\nThe tests on this PR will run after a maintainer adds an `ok-to-test` label to this PR manually. Thank you for your patience!' - }); - - name: cleanup-test-label - uses: actions/github-script@v6 - with: - script: | - const { owner, repo } = context.repo; - const prNumber = context.payload.pull_request.number; - const labelToRemove = 'ok-to-test'; - try { - const result = await github.rest.issues.removeLabel({ - owner, - repo, - issue_number: prNumber, - name: labelToRemove - }); - } catch(e) { - // ignore the 404 error that arises - // when the label did not exist for the - // organization member - console.log(e); - } - run-tests: - needs: - - check-running-allowed - if: needs.check-running-allowed.outputs.result == 'true' - uses: ./.github/workflows/run-tests.yml - secrets: inherit diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml index dd847b36..e73c6f6d 100644 --- a/.github/workflows/run-tests.yml +++ b/.github/workflows/run-tests.yml @@ -4,58 +4,17 @@ name: run-tests on: - workflow_call: - workflow_dispatch: + pull_request jobs: - start-runner: - runs-on: ubuntu-latest - outputs: - runner-label: ${{ steps.start-yc-runner.outputs.label }} - instance-id: ${{ steps.start-yc-runner.outputs.instance-id }} - steps: - - name: start-yc-runner - id: start-yc-runner - uses: yc-actions/yc-github-runner@v1 - with: - mode: start - yc-sa-json-credentials: ${{ secrets.CI_RUNNER_CREATOR_KEY }} - github-token: ${{ secrets.GH_PERSONAL_ACCESS_TOKEN }} - folder-id: b1gmgbhccra2qca8v5g6 - image-id: fd80o2eikcn22b229tsa - cores: 16 - disk-type: network-ssd-nonreplicated - disk-size: 465GB - memory: 32GB - core-fraction: 100 - subnet-id: e9bu12i8ocv6q8kl83ru - user: yc-admin - ssh-public-key: ${{ secrets.CI_RUNNER_DEBUG_SHH_PUBLIC_KEY }} - smart-checkout: - needs: - - start-runner - runs-on: ${{ needs.start-runner.outputs.runner-label }} - steps: - - name: checkout-when-fork-source - uses: actions/checkout@v3 - if: github.event.pull_request.head.sha != '' - with: - ref: ${{ github.event.pull_request.head.sha }} - - name: checkout-when-this-repo-source - uses: actions/checkout@v3 - if: github.event.pull_request.head.sha == '' lint: concurrency: group: lint-golangci-${{ github.head_ref || github.ref_name }} cancel-in-progress: true - needs: - - start-runner - - smart-checkout - runs-on: ${{ needs.start-runner.outputs.runner-label }} + runs-on: ubuntu-latest steps: - - name: set-env-vars - run: | - echo "HOME=/actions-runner" >> $GITHUB_ENV + - name: checkout + uses: actions/checkout@v3 - name: setup-go uses: actions/setup-go@v3 with: @@ -68,14 +27,10 @@ jobs: concurrency: group: lint-autoformat-${{ github.head_ref || github.ref_name }} cancel-in-progress: true - needs: - - start-runner - - smart-checkout - runs-on: ${{ needs.start-runner.outputs.runner-label }} + runs-on: ubuntu-latest steps: - - name: set-env-vars - run: | - echo "HOME=/actions-runner" >> $GITHUB_ENV + - name: checkout + uses: actions/checkout@v3 - name: setup-go uses: actions/setup-go@v3 with: @@ -88,173 +43,149 @@ jobs: run: bash ./.github/scripts/format-all-go-code.sh "$PWD" - name: Check repository diff run: bash ./.github/scripts/check-work-copy-equals-to-committed.sh "auto-format broken" - run-unit-tests: - concurrency: - group: run-unit-tests-${{ github.head_ref || github.ref_name }} - cancel-in-progress: true - needs: - - start-runner - - smart-checkout - - lint - - code-format-check - runs-on: ${{ needs.start-runner.outputs.runner-label }} - outputs: - result: ${{ steps.run-unit-tests.outputs.result }} - steps: - - name: set-env-vars - run: | - echo "HOME=/actions-runner" >> $GITHUB_ENV - - name: setup-go - uses: actions/setup-go@v3 - with: - go-version: '1.20' - - name: setup-medium-test-class-binaries - run: | - # This installs kube-apiserver and etcd binaries for `medium` - # class tests. Refer to the writing tests docs for more info. - make envtest - KUBEBUILDER_ASSETS=$(./bin/setup-envtest use 1.26 -p path) - echo "KUBEBUILDER_ASSETS=$KUBEBUILDER_ASSETS" >> $GITHUB_ENV - - name: setup-gotestsum - run: | - go install gotest.tools/gotestsum@v1.12.0 - - name: run-unit-tests - id: run-unit-tests - run: | - gotestsum --format pkgname --jsonfile log.json -- -v -timeout 900s -p 1 ./internal/... -ginkgo.vv -coverprofile cover.out - - name: convert-to-human-readable - run: jq -r '.Output| gsub("[\\n]"; "")' log.json 2>/dev/null 1>log.txt || true - - name: artifact-upload-step - uses: actions/upload-artifact@v4 - id: artifact-upload-step - if: always() - with: - name: unit-tests-log - path: log.txt - if-no-files-found: error - - name: echo-tests-log-url - run: echo 'Unit tests log URL is ${{ steps.artifact-upload-step.outputs.artifact-url }}' - run-e2e-tests: - concurrency: - group: run-e2e-tests-${{ github.head_ref || github.ref_name }} - cancel-in-progress: true - needs: - - start-runner - - smart-checkout - - lint - - code-format-check - - run-unit-tests - runs-on: ${{ needs.start-runner.outputs.runner-label }} - outputs: - result: ${{ steps.run-e2e-tests.outputs.result }} - steps: - - name: set-env-vars - run: | - echo "HOME=/actions-runner" >> $GITHUB_ENV - - name: setup-go - uses: actions/setup-go@v3 - with: - go-version: '1.20' - - name: install-dependencies - run: | - sudo apt-get update - sudo apt-get install -y build-essential + # run-unit-tests: + # concurrency: + # group: run-unit-tests-${{ github.head_ref || github.ref_name }} + # cancel-in-progress: true + # needs: + # - lint + # - code-format-check + # runs-on: ubuntu-latest + # outputs: + # result: ${{ steps.run-unit-tests.outputs.result }} + # steps: + # - name: checkout + # uses: actions/checkout@v3 + # - name: setup-go + # uses: actions/setup-go@v3 + # with: + # go-version: '1.20' + # - name: setup-medium-test-class-binaries + # run: | + # # This installs kube-apiserver and etcd binaries for `medium` + # # class tests. Refer to the writing tests docs for more info. + # make envtest + # KUBEBUILDER_ASSETS=$(./bin/setup-envtest use 1.26 -p path) + # echo "KUBEBUILDER_ASSETS=$KUBEBUILDER_ASSETS" >> $GITHUB_ENV + # - name: setup-gotestsum + # run: | + # go install gotest.tools/gotestsum@v1.12.0 + # - name: run-unit-tests + # id: run-unit-tests + # run: | + # gotestsum --format pkgname --jsonfile log.json -- -v -timeout 900s -p 1 ./internal/... -ginkgo.vv -coverprofile cover.out + # - name: convert-to-human-readable + # run: jq -r '.Output| gsub("[\\n]"; "")' log.json 2>/dev/null 1>log.txt || true + # - name: artifact-upload-step + # uses: actions/upload-artifact@v4 + # id: artifact-upload-step + # if: always() + # with: + # name: unit-tests-log + # path: log.txt + # if-no-files-found: error + # - name: echo-tests-log-url + # run: echo 'Unit tests log URL is ${{ steps.artifact-upload-step.outputs.artifact-url }}' + # run-e2e-tests: + # concurrency: + # group: run-e2e-tests-${{ github.head_ref || github.ref_name }} + # cancel-in-progress: true + # needs: + # - lint + # - code-format-check + # - run-unit-tests + # runs-on: ubuntu-latest + # outputs: + # result: ${{ steps.run-e2e-tests.outputs.result }} + # steps: + # - name: checkout + # uses: actions/checkout@v3 + # - name: setup-go + # uses: actions/setup-go@v3 + # with: + # go-version: '1.20' + # - name: install-dependencies + # run: | + # sudo apt-get update + # sudo apt-get install -y build-essential - go install sigs.k8s.io/kind@v0.17.0 + # go install sigs.k8s.io/kind@v0.17.0 - curl -LO https://dl.k8s.io/release/v1.25.3/bin/linux/amd64/kubectl - chmod +x ./kubectl + # curl -LO https://dl.k8s.io/release/v1.25.3/bin/linux/amd64/kubectl + # chmod +x ./kubectl - HELM_PKG="helm-v3.13.3-linux-amd64.tar.gz" - curl -LO https://get.helm.sh/"${HELM_PKG}" - tar -zxvf "${HELM_PKG}" - mv ./linux-amd64/helm . + # HELM_PKG="helm-v3.13.3-linux-amd64.tar.gz" + # curl -LO https://get.helm.sh/"${HELM_PKG}" + # tar -zxvf "${HELM_PKG}" + # mv ./linux-amd64/helm . - curl -sSL https://storage.yandexcloud.net/yandexcloud-ydb/install.sh | bash + # curl -sSL https://storage.yandexcloud.net/yandexcloud-ydb/install.sh | bash - echo "$(pwd)" >> $GITHUB_PATH - echo "$HOME/ydb/bin" >> $GITHUB_PATH - echo "$HOME/go/bin" >> $GITHUB_PATH - - name: configure-system - run: | - sudo sysctl fs.inotify.max_user_instances=1280 - sudo sysctl fs.inotify.max_user_watches=655360 - - name: check-dependencies - run: | - gcc --version - go version - kind version - kubectl version --client=true - helm version - - name: setup-k8s-cluster - run: | - kind delete cluster - kind create cluster \ - --image=kindest/node:v1.25.3@sha256:cd248d1438192f7814fbca8fede13cfe5b9918746dfa12583976158a834fd5c5 \ - --config=./e2e/kind-cluster-config.yaml - kubectl wait --timeout=5m --for=condition=ready node -l worker=true - - name: build-operator-image - uses: docker/build-push-action@v3 - with: - context: . - push: false - # Get commit short sha within Github action workflow - # Just a random string name, we aren't uploading anyway - tags: kind/ydb-operator:current - - name: load-and-deploy-operator - run: | - kind load docker-image kind/ydb-operator:current - - name: pull-and-load-kube-webhook-certgen-image - uses: nick-fields/retry@v3 - with: - timeout_minutes: 5 - retry_wait_seconds: 20 - max_attempts: 3 - command: | - docker pull k8s.gcr.io/ingress-nginx/kube-webhook-certgen:v1.0 - kind load docker-image k8s.gcr.io/ingress-nginx/kube-webhook-certgen:v1.0 - - name: pull-and-load-ydb-image - run: | - # TODO would be cool to parse YDB image from manifests to avoid duplicating information - docker pull cr.yandex/crptqonuodf51kdj7a7d/ydb:23.3.17 - kind load docker-image cr.yandex/crptqonuodf51kdj7a7d/ydb:23.3.17 - - name: setup-gotestsum - run: | - go install gotest.tools/gotestsum@v1.12.0 - - name: run-e2e-tests - id: run-e2e-tests - run: | - gotestsum --format pkgname --jsonfile log.json -- -v -timeout 3600s -p 1 ./e2e/... -ginkgo.vv - - name: convert-to-human-readable - run: jq -r '.Output| gsub("[\\n]"; "")' log.json 2>/dev/null 1>log.txt || true - - name: artifact-upload-step - uses: actions/upload-artifact@v4 - id: artifact-upload-step - if: always() - with: - name: e2e-tests-log - path: log.txt - if-no-files-found: error - - name: echo-tests-log-url - run: echo 'Unit tests log URL is ${{ steps.artifact-upload-step.outputs.artifact-url }}' - - name: teardown-k8s-cluster - run: | - kind delete cluster - stop-runner: - needs: - - start-runner - - lint - - code-format-check - - run-unit-tests - - run-e2e-tests - runs-on: ubuntu-latest - if: always() - steps: - - name: stop-yc-runner - uses: yc-actions/yc-github-runner@v1 - with: - mode: stop - yc-sa-json-credentials: ${{ secrets.CI_RUNNER_CREATOR_KEY }} - github-token: ${{ secrets.GH_PERSONAL_ACCESS_TOKEN }} - label: ${{ needs.start-runner.outputs.runner-label }} - instance-id: ${{ needs.start-runner.outputs.instance-id }} + # echo "$(pwd)" >> $GITHUB_PATH + # echo "$HOME/ydb/bin" >> $GITHUB_PATH + # echo "$HOME/go/bin" >> $GITHUB_PATH + # - name: configure-system + # run: | + # sudo sysctl fs.inotify.max_user_instances=1280 + # sudo sysctl fs.inotify.max_user_watches=655360 + # - name: check-dependencies + # run: | + # gcc --version + # go version + # kind version + # kubectl version --client=true + # helm version + # - name: setup-k8s-cluster + # run: | + # kind delete cluster + # kind create cluster \ + # --image=kindest/node:v1.25.3@sha256:cd248d1438192f7814fbca8fede13cfe5b9918746dfa12583976158a834fd5c5 \ + # --config=./e2e/kind-cluster-config.yaml + # kubectl wait --timeout=5m --for=condition=ready node -l worker=true + # - name: build-operator-image + # uses: docker/build-push-action@v3 + # with: + # context: . + # push: false + # # Get commit short sha within Github action workflow + # # Just a random string name, we aren't uploading anyway + # tags: kind/ydb-operator:current + # - name: load-and-deploy-operator + # run: | + # kind load docker-image kind/ydb-operator:current + # - name: pull-and-load-kube-webhook-certgen-image + # uses: nick-fields/retry@v3 + # with: + # timeout_minutes: 5 + # retry_wait_seconds: 20 + # max_attempts: 3 + # command: | + # docker pull k8s.gcr.io/ingress-nginx/kube-webhook-certgen:v1.0 + # kind load docker-image k8s.gcr.io/ingress-nginx/kube-webhook-certgen:v1.0 + # - name: pull-and-load-ydb-image + # run: | + # # TODO would be cool to parse YDB image from manifests to avoid duplicating information + # docker pull cr.yandex/crptqonuodf51kdj7a7d/ydb:23.3.17 + # kind load docker-image cr.yandex/crptqonuodf51kdj7a7d/ydb:23.3.17 + # - name: setup-gotestsum + # run: | + # go install gotest.tools/gotestsum@v1.12.0 + # - name: run-e2e-tests + # id: run-e2e-tests + # run: | + # gotestsum --format pkgname --jsonfile log.json -- -v -timeout 3600s -p 1 ./e2e/... -ginkgo.vv + # - name: convert-to-human-readable + # run: jq -r '.Output| gsub("[\\n]"; "")' log.json 2>/dev/null 1>log.txt || true + # - name: artifact-upload-step + # uses: actions/upload-artifact@v4 + # id: artifact-upload-step + # if: always() + # with: + # name: e2e-tests-log + # path: log.txt + # if-no-files-found: error + # - name: echo-tests-log-url + # run: echo 'Unit tests log URL is ${{ steps.artifact-upload-step.outputs.artifact-url }}' + # - name: teardown-k8s-cluster + # run: | + # kind delete cluster